1 |
michael |
1165 |
/* |
2 |
michael |
2820 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
michael |
1165 |
* |
4 |
michael |
2820 |
* Copyright (c) 1999 Bahamut development team. |
5 |
|
|
* Copyright (c) 2011-2014 ircd-hybrid development team |
6 |
michael |
1165 |
* |
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 |
michael |
1221 |
* \brief Includes required functions for processing the SVSNICK command. |
25 |
michael |
1165 |
* \version $Id$ |
26 |
|
|
*/ |
27 |
|
|
|
28 |
michael |
2820 |
|
29 |
michael |
1165 |
#include "stdinc.h" |
30 |
|
|
#include "client.h" |
31 |
|
|
#include "ircd.h" |
32 |
|
|
#include "channel_mode.h" |
33 |
|
|
#include "numeric.h" |
34 |
|
|
#include "s_serv.h" |
35 |
|
|
#include "send.h" |
36 |
|
|
#include "parse.h" |
37 |
|
|
#include "modules.h" |
38 |
|
|
#include "irc_string.h" |
39 |
|
|
#include "s_user.h" |
40 |
|
|
#include "hash.h" |
41 |
|
|
#include "watch.h" |
42 |
|
|
#include "whowas.h" |
43 |
|
|
|
44 |
|
|
|
45 |
michael |
1221 |
/*! \brief SVSNICK command handler (called by services) |
46 |
michael |
1165 |
* |
47 |
|
|
* \param source_p Pointer to allocated Client struct from which the message |
48 |
|
|
* originally comes from. This can be a local or remote client. |
49 |
|
|
* \param parc Integer holding the number of supplied arguments. |
50 |
|
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
51 |
|
|
* pointers. |
52 |
|
|
* \note Valid arguments for this command are: |
53 |
michael |
3096 |
* - parv[0] = command |
54 |
michael |
1165 |
* - parv[1] = old nickname |
55 |
|
|
* - parv[2] = new nickname |
56 |
|
|
* - parv[3] = timestamp |
57 |
|
|
*/ |
58 |
michael |
2820 |
static int |
59 |
michael |
3156 |
ms_svsnick(struct Client *source_p, int parc, char *parv[]) |
60 |
michael |
1165 |
{ |
61 |
|
|
struct Client *target_p = NULL, *exists_p = NULL; |
62 |
|
|
|
63 |
michael |
1221 |
if (!HasFlag(source_p, FLAGS_SERVICE) || !valid_nickname(parv[2], 1)) |
64 |
michael |
2820 |
return 0; |
65 |
michael |
1165 |
|
66 |
michael |
3156 |
if (hunt_server(source_p, ":%s SVSNICK %s %s :%s", |
67 |
michael |
1165 |
1, parc, parv) != HUNTED_ISME) |
68 |
michael |
2820 |
return 0; |
69 |
michael |
1165 |
|
70 |
michael |
3156 |
if ((target_p = find_person(source_p, parv[1])) == NULL) |
71 |
michael |
2820 |
return 0; |
72 |
michael |
1165 |
|
73 |
|
|
assert(MyClient(target_p)); |
74 |
|
|
|
75 |
michael |
1169 |
if ((exists_p = hash_find_client(parv[2]))) |
76 |
michael |
1165 |
{ |
77 |
michael |
3138 |
if (target_p == exists_p) |
78 |
|
|
{ |
79 |
|
|
if (!strcmp(target_p->name, parv[2])) |
80 |
|
|
return 0; |
81 |
|
|
} |
82 |
|
|
else if (IsUnknown(exists_p)) |
83 |
michael |
3171 |
exit_client(exists_p, "SVSNICK Override"); |
84 |
michael |
1165 |
else |
85 |
|
|
{ |
86 |
michael |
3171 |
exit_client(target_p, "SVSNICK Collide"); |
87 |
michael |
2820 |
return 0; |
88 |
michael |
1165 |
} |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
target_p->tsinfo = atoi(parv[3]); |
92 |
|
|
clear_ban_cache_client(target_p); |
93 |
|
|
watch_check_hash(target_p, RPL_LOGOFF); |
94 |
|
|
|
95 |
|
|
if (HasUMode(target_p, UMODE_REGISTERED)) |
96 |
|
|
{ |
97 |
|
|
unsigned int oldmodes = target_p->umodes; |
98 |
|
|
char modebuf[IRCD_BUFSIZE] = { '\0' }; |
99 |
|
|
|
100 |
|
|
DelUMode(target_p, UMODE_REGISTERED); |
101 |
|
|
send_umode(target_p, target_p, oldmodes, 0xffffffff, modebuf); |
102 |
|
|
} |
103 |
|
|
|
104 |
michael |
1734 |
sendto_common_channels_local(target_p, 1, 0, ":%s!%s@%s NICK :%s", |
105 |
michael |
1165 |
target_p->name, target_p->username, |
106 |
|
|
target_p->host, parv[2]); |
107 |
|
|
|
108 |
michael |
2300 |
whowas_add_history(target_p, 1); |
109 |
michael |
1165 |
|
110 |
michael |
3135 |
sendto_server(NULL, NOCAPS, NOCAPS, ":%s NICK %s :%lu", |
111 |
michael |
1165 |
ID(target_p), parv[2], (unsigned long)target_p->tsinfo); |
112 |
|
|
hash_del_client(target_p); |
113 |
|
|
strlcpy(target_p->name, parv[2], sizeof(target_p->name)); |
114 |
|
|
hash_add_client(target_p); |
115 |
|
|
|
116 |
|
|
watch_check_hash(target_p, RPL_LOGON); |
117 |
|
|
|
118 |
|
|
fd_note(&target_p->localClient->fd, "Nick: %s", parv[2]); |
119 |
michael |
2820 |
return 0; |
120 |
michael |
1165 |
} |
121 |
michael |
1230 |
|
122 |
michael |
2820 |
static struct Message svsnick_msgtab = |
123 |
|
|
{ |
124 |
michael |
1569 |
"SVSNICK", 0, 0, 4, MAXPARA, MFLG_SLOW, 0, |
125 |
michael |
1230 |
{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 |
michael |
2820 |
struct module module_entry = |
141 |
|
|
{ |
142 |
michael |
1230 |
.node = { NULL, NULL, NULL }, |
143 |
|
|
.name = NULL, |
144 |
|
|
.version = "$Revision$", |
145 |
|
|
.handle = NULL, |
146 |
|
|
.modinit = module_init, |
147 |
|
|
.modexit = module_exit, |
148 |
|
|
.flags = 0 |
149 |
|
|
}; |