~ubuntu-branches/ubuntu/trusty/charybdis/trusty-proposed

« back to all changes in this revision

Viewing changes to modules/m_user.c

  • Committer: Package Import Robot
  • Author(s): Antoine Beaupré
  • Date: 2011-11-10 23:07:37 UTC
  • Revision ID: package-import@ubuntu.com-20111110230737-kqo6qsglp5oh02hr
Tags: upstream-3.3.0
Import upstream version 3.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  ircd-ratbox: A slightly useful ircd.
 
3
 *  m_user.c: Sends username information.
 
4
 *
 
5
 *  Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
 
6
 *  Copyright (C) 1996-2002 Hybrid Development Team
 
7
 *  Copyright (C) 2002-2005 ircd-ratbox development team
 
8
 *
 
9
 *  This program is free software; you can redistribute it and/or modify
 
10
 *  it under the terms of the GNU General Public License as published by
 
11
 *  the Free Software Foundation; either version 2 of the License, or
 
12
 *  (at your option) any later version.
 
13
 *
 
14
 *  This program is distributed in the hope that it will be useful,
 
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 *  GNU General Public License for more details.
 
18
 *
 
19
 *  You should have received a copy of the GNU General Public License
 
20
 *  along with this program; if not, write to the Free Software
 
21
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 
22
 *  USA
 
23
 *
 
24
 *  $Id: m_user.c 3416 2007-04-15 20:18:54Z jilles $
 
25
 */
 
26
 
 
27
#include "stdinc.h"
 
28
#include "client.h"
 
29
#include "match.h"
 
30
#include "ircd.h"
 
31
#include "numeric.h"
 
32
#include "s_user.h"
 
33
#include "send.h"
 
34
#include "s_conf.h"
 
35
#include "msg.h"
 
36
#include "parse.h"
 
37
#include "modules.h"
 
38
#include "blacklist.h"
 
39
 
 
40
static int mr_user(struct Client *, struct Client *, int, const char **);
 
41
 
 
42
struct Message user_msgtab = {
 
43
        "USER", 0, 0, 0, MFLG_SLOW,
 
44
        {{mr_user, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
 
45
};
 
46
 
 
47
mapi_clist_av1 user_clist[] = { &user_msgtab, NULL };
 
48
DECLARE_MODULE_AV1(user, NULL, NULL, user_clist, NULL, NULL, "$Revision: 3416 $");
 
49
 
 
50
static int do_local_user(struct Client *client_p, struct Client *source_p,
 
51
                         const char *username, const char *realname);
 
52
 
 
53
/* mr_user()
 
54
 *      parv[1] = username (login name, account)
 
55
 *      parv[2] = client host name (ignored)
 
56
 *      parv[3] = server host name (ignored)
 
57
 *      parv[4] = users gecos
 
58
 */
 
59
static int
 
60
mr_user(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 
61
{
 
62
        static char buf[BUFSIZE];
 
63
        char *p;
 
64
 
 
65
        if (strlen(client_p->id) == 3)
 
66
        {
 
67
                exit_client(client_p, client_p, client_p, "Mixing client and server protocol");
 
68
                return 0;
 
69
        }
 
70
 
 
71
        if((p = strchr(parv[1], '@')))
 
72
                *p = '\0';
 
73
 
 
74
        rb_snprintf(buf, sizeof(buf), "%s %s", parv[2], parv[3]);
 
75
        rb_free(source_p->localClient->fullcaps);
 
76
        source_p->localClient->fullcaps = rb_strdup(buf);
 
77
 
 
78
        do_local_user(client_p, source_p, parv[1], parv[4]);
 
79
        return 0;
 
80
}
 
81
 
 
82
static int
 
83
do_local_user(struct Client *client_p, struct Client *source_p,
 
84
              const char *username, const char *realname)
 
85
{
 
86
        struct User *user;
 
87
 
 
88
        s_assert(NULL != source_p);
 
89
        s_assert(source_p->username != username);
 
90
 
 
91
        user = make_user(source_p);
 
92
 
 
93
        if (!(source_p->flags & FLAGS_SENTUSER))
 
94
        {
 
95
                lookup_blacklists(source_p);
 
96
                source_p->flags |= FLAGS_SENTUSER;
 
97
        }
 
98
 
 
99
        rb_strlcpy(source_p->info, realname, sizeof(source_p->info));
 
100
 
 
101
        if(!IsGotId(source_p))
 
102
        {
 
103
                /* This is in this location for a reason..If there is no identd
 
104
                 * and ping cookies are enabled..we need to have a copy of this
 
105
                 */
 
106
                rb_strlcpy(source_p->username, username, sizeof(source_p->username));
 
107
        }
 
108
 
 
109
        if(source_p->name[0])
 
110
        {
 
111
                /* NICK already received, now I have USER... */
 
112
                return register_local_user(client_p, source_p, username);
 
113
        }
 
114
 
 
115
        return 0;
 
116
}