1 |
michael |
1165 |
/* |
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 SVSMODE command. |
25 |
|
|
* \version $Id$ |
26 |
|
|
*/ |
27 |
|
|
|
28 |
|
|
#include "stdinc.h" |
29 |
|
|
#include "handlers.h" |
30 |
|
|
#include "client.h" |
31 |
|
|
#include "ircd.h" |
32 |
|
|
#include "channel_mode.h" |
33 |
|
|
#include "numeric.h" |
34 |
|
|
#include "s_conf.h" |
35 |
|
|
#include "s_serv.h" |
36 |
|
|
#include "send.h" |
37 |
|
|
#include "msg.h" |
38 |
|
|
#include "parse.h" |
39 |
|
|
#include "modules.h" |
40 |
|
|
#include "irc_string.h" |
41 |
|
|
#include "s_user.h" |
42 |
|
|
#include "hash.h" |
43 |
|
|
#include "watch.h" |
44 |
|
|
#include "whowas.h" |
45 |
|
|
|
46 |
|
|
static void ms_svsnick(struct Client *, struct Client *, int, char *[]); |
47 |
|
|
|
48 |
|
|
struct Message svsnick_msgtab = { |
49 |
|
|
"SVSNICK", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0, |
50 |
|
|
{m_ignore, m_ignore, ms_svsnick, m_ignore, m_ignore, m_ignore} |
51 |
|
|
}; |
52 |
|
|
|
53 |
|
|
const char *_version = "$Revision$"; |
54 |
|
|
|
55 |
|
|
void |
56 |
|
|
_modinit(void) |
57 |
|
|
{ |
58 |
|
|
mod_add_cmd(&svsnick_msgtab); |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
void |
62 |
|
|
_moddeinit(void) |
63 |
|
|
{ |
64 |
|
|
mod_del_cmd(&svsnick_msgtab); |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
|
68 |
|
|
/*! \brief SVSNICK command handler (called by servers or services) |
69 |
|
|
* |
70 |
|
|
* \param client_p Pointer to allocated Client struct with physical connection |
71 |
|
|
* to this server, i.e. with an open socket connected. |
72 |
|
|
* \param source_p Pointer to allocated Client struct from which the message |
73 |
|
|
* originally comes from. This can be a local or remote client. |
74 |
|
|
* \param parc Integer holding the number of supplied arguments. |
75 |
|
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
76 |
|
|
* pointers. |
77 |
|
|
* \note Valid arguments for this command are: |
78 |
|
|
* - parv[0] = sender prefix |
79 |
|
|
* - parv[1] = old nickname |
80 |
|
|
* - parv[2] = new nickname |
81 |
|
|
* - parv[3] = timestamp |
82 |
|
|
*/ |
83 |
|
|
static void |
84 |
|
|
ms_svsnick(struct Client *client_p, struct Client *source_p, |
85 |
|
|
int parc, char *parv[]) |
86 |
|
|
{ |
87 |
|
|
struct Client *target_p = NULL, *exists_p = NULL; |
88 |
|
|
|
89 |
|
|
if (!IsService(source_p) || (parc < 4) || !valid_nickname(parv[2], 1)) |
90 |
|
|
return; |
91 |
|
|
|
92 |
|
|
if (hunt_server(client_p, source_p, ":%s SVSNICK %s %s :%s", |
93 |
|
|
1, parc, parv) != HUNTED_ISME) |
94 |
|
|
return; |
95 |
|
|
|
96 |
|
|
if ((target_p = find_person(client_p, parv[1])) == NULL) |
97 |
|
|
return; |
98 |
|
|
|
99 |
|
|
assert(MyClient(target_p)); |
100 |
|
|
|
101 |
michael |
1169 |
if ((exists_p = hash_find_client(parv[2]))) |
102 |
michael |
1165 |
{ |
103 |
|
|
if (IsUnknown(exists_p)) |
104 |
|
|
exit_client(exists_p, &me, "SVSNICK Override"); |
105 |
|
|
else |
106 |
|
|
{ |
107 |
|
|
exit_client(target_p, &me, "SVSNICK Collide"); |
108 |
|
|
return; |
109 |
|
|
} |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
target_p->tsinfo = atoi(parv[3]); |
113 |
|
|
clear_ban_cache_client(target_p); |
114 |
|
|
watch_check_hash(target_p, RPL_LOGOFF); |
115 |
|
|
|
116 |
|
|
if (HasUMode(target_p, UMODE_REGISTERED)) |
117 |
|
|
{ |
118 |
|
|
unsigned int oldmodes = target_p->umodes; |
119 |
|
|
char modebuf[IRCD_BUFSIZE] = { '\0' }; |
120 |
|
|
|
121 |
|
|
DelUMode(target_p, UMODE_REGISTERED); |
122 |
|
|
send_umode(target_p, target_p, oldmodes, 0xffffffff, modebuf); |
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
sendto_common_channels_local(target_p, 1, ":%s!%s@%s NICK :%s", |
126 |
|
|
target_p->name, target_p->username, |
127 |
|
|
target_p->host, parv[2]); |
128 |
|
|
|
129 |
|
|
add_history(target_p, 1); |
130 |
|
|
|
131 |
|
|
sendto_server(NULL, NULL, CAP_TS6, NOCAPS, |
132 |
|
|
":%s NICK %s :%lu", |
133 |
|
|
ID(target_p), parv[2], (unsigned long)target_p->tsinfo); |
134 |
|
|
sendto_server(NULL, NULL, NOCAPS, CAP_TS6, |
135 |
|
|
":%s NICK %s :%lu", |
136 |
|
|
target_p->name, parv[2], (unsigned long)source_p->tsinfo); |
137 |
|
|
|
138 |
|
|
hash_del_client(target_p); |
139 |
|
|
strlcpy(target_p->name, parv[2], sizeof(target_p->name)); |
140 |
|
|
hash_add_client(target_p); |
141 |
|
|
|
142 |
|
|
watch_check_hash(target_p, RPL_LOGON); |
143 |
|
|
|
144 |
|
|
fd_note(&target_p->localClient->fd, "Nick: %s", parv[2]); |
145 |
|
|
} |