1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* |
4 |
* Copyright (C) 1999 by the Bahamut Development Team. |
5 |
* Copyright (C) 2011 by the Hybrid Development Team. |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License as published by |
9 |
* the Free Software Foundation; either version 2 of the License, or |
10 |
* (at your option) any later version. |
11 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with this program; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
* USA |
21 |
*/ |
22 |
|
23 |
/*! \file m_svsnick.c |
24 |
* \brief Includes required functions for processing the SVSNICK command. |
25 |
* \version $Id$ |
26 |
*/ |
27 |
|
28 |
#include "stdinc.h" |
29 |
#include "client.h" |
30 |
#include "ircd.h" |
31 |
#include "channel_mode.h" |
32 |
#include "numeric.h" |
33 |
#include "s_serv.h" |
34 |
#include "send.h" |
35 |
#include "parse.h" |
36 |
#include "modules.h" |
37 |
#include "irc_string.h" |
38 |
#include "s_user.h" |
39 |
#include "hash.h" |
40 |
#include "watch.h" |
41 |
#include "whowas.h" |
42 |
|
43 |
|
44 |
/*! \brief SVSNICK command handler (called by services) |
45 |
* |
46 |
* \param client_p Pointer to allocated Client struct with physical connection |
47 |
* to this server, i.e. with an open socket connected. |
48 |
* \param source_p Pointer to allocated Client struct from which the message |
49 |
* originally comes from. This can be a local or remote client. |
50 |
* \param parc Integer holding the number of supplied arguments. |
51 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
52 |
* pointers. |
53 |
* \note Valid arguments for this command are: |
54 |
* - parv[0] = sender prefix |
55 |
* - parv[1] = old nickname |
56 |
* - parv[2] = new nickname |
57 |
* - parv[3] = timestamp |
58 |
*/ |
59 |
static void |
60 |
ms_svsnick(struct Client *client_p, struct Client *source_p, |
61 |
int parc, char *parv[]) |
62 |
{ |
63 |
struct Client *target_p = NULL, *exists_p = NULL; |
64 |
|
65 |
if (!HasFlag(source_p, FLAGS_SERVICE) || !valid_nickname(parv[2], 1)) |
66 |
return; |
67 |
|
68 |
if (hunt_server(client_p, source_p, ":%s SVSNICK %s %s :%s", |
69 |
1, parc, parv) != HUNTED_ISME) |
70 |
return; |
71 |
|
72 |
if ((target_p = find_person(client_p, parv[1])) == NULL) |
73 |
return; |
74 |
|
75 |
assert(MyClient(target_p)); |
76 |
|
77 |
if ((exists_p = hash_find_client(parv[2]))) |
78 |
{ |
79 |
if (IsUnknown(exists_p)) |
80 |
exit_client(exists_p, &me, "SVSNICK Override"); |
81 |
else |
82 |
{ |
83 |
exit_client(target_p, &me, "SVSNICK Collide"); |
84 |
return; |
85 |
} |
86 |
} |
87 |
|
88 |
target_p->tsinfo = atoi(parv[3]); |
89 |
clear_ban_cache_client(target_p); |
90 |
watch_check_hash(target_p, RPL_LOGOFF); |
91 |
|
92 |
if (HasUMode(target_p, UMODE_REGISTERED)) |
93 |
{ |
94 |
unsigned int oldmodes = target_p->umodes; |
95 |
char modebuf[IRCD_BUFSIZE] = { '\0' }; |
96 |
|
97 |
DelUMode(target_p, UMODE_REGISTERED); |
98 |
send_umode(target_p, target_p, oldmodes, 0xffffffff, modebuf); |
99 |
} |
100 |
|
101 |
sendto_common_channels_local(target_p, 1, ":%s!%s@%s NICK :%s", |
102 |
target_p->name, target_p->username, |
103 |
target_p->host, parv[2]); |
104 |
|
105 |
add_history(target_p, 1); |
106 |
|
107 |
sendto_server(NULL, NULL, CAP_TS6, NOCAPS, |
108 |
":%s NICK %s :%lu", |
109 |
ID(target_p), parv[2], (unsigned long)target_p->tsinfo); |
110 |
sendto_server(NULL, NULL, NOCAPS, CAP_TS6, |
111 |
":%s NICK %s :%lu", |
112 |
target_p->name, parv[2], (unsigned long)source_p->tsinfo); |
113 |
|
114 |
hash_del_client(target_p); |
115 |
strlcpy(target_p->name, parv[2], sizeof(target_p->name)); |
116 |
hash_add_client(target_p); |
117 |
|
118 |
watch_check_hash(target_p, RPL_LOGON); |
119 |
|
120 |
fd_note(&target_p->localClient->fd, "Nick: %s", parv[2]); |
121 |
} |
122 |
|
123 |
static struct Message svsnick_msgtab = { |
124 |
"SVSNICK", 0, 0, 4, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0, |
125 |
{m_ignore, m_ignore, ms_svsnick, m_ignore, m_ignore, m_ignore} |
126 |
}; |
127 |
|
128 |
static void |
129 |
module_init(void) |
130 |
{ |
131 |
mod_add_cmd(&svsnick_msgtab); |
132 |
} |
133 |
|
134 |
static void |
135 |
module_exit(void) |
136 |
{ |
137 |
mod_del_cmd(&svsnick_msgtab); |
138 |
} |
139 |
|
140 |
struct module module_entry = { |
141 |
.node = { NULL, NULL, NULL }, |
142 |
.name = NULL, |
143 |
.version = "$Revision$", |
144 |
.handle = NULL, |
145 |
.modinit = module_init, |
146 |
.modexit = module_exit, |
147 |
.flags = 0 |
148 |
}; |