ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_svsnick.c
Revision: 3138
Committed: Tue Mar 11 19:07:25 2014 UTC (10 years, 1 month ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/trunk/modules/m_svsnick.c
File size: 4318 byte(s)
Log Message:
- m_svsnick.c: applied "Do not self collide clients who svsnick to themselves" patch by adam

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1999 Bahamut development team.
5 * Copyright (c) 2011-2014 ircd-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
29 #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 /*! \brief SVSNICK command handler (called by services)
46 *
47 * \param client_p Pointer to allocated Client struct with physical connection
48 * to this server, i.e. with an open socket connected.
49 * \param source_p Pointer to allocated Client struct from which the message
50 * originally comes from. This can be a local or remote client.
51 * \param parc Integer holding the number of supplied arguments.
52 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
53 * pointers.
54 * \note Valid arguments for this command are:
55 * - parv[0] = command
56 * - parv[1] = old nickname
57 * - parv[2] = new nickname
58 * - parv[3] = timestamp
59 */
60 static int
61 ms_svsnick(struct Client *client_p, struct Client *source_p,
62 int parc, char *parv[])
63 {
64 struct Client *target_p = NULL, *exists_p = NULL;
65
66 if (!HasFlag(source_p, FLAGS_SERVICE) || !valid_nickname(parv[2], 1))
67 return 0;
68
69 if (hunt_server(client_p, source_p, ":%s SVSNICK %s %s :%s",
70 1, parc, parv) != HUNTED_ISME)
71 return 0;
72
73 if ((target_p = find_person(client_p, parv[1])) == NULL)
74 return 0;
75
76 assert(MyClient(target_p));
77
78 if ((exists_p = hash_find_client(parv[2])))
79 {
80 if (target_p == exists_p)
81 {
82 if (!strcmp(target_p->name, parv[2]))
83 return 0;
84 }
85 else if (IsUnknown(exists_p))
86 exit_client(exists_p, &me, "SVSNICK Override");
87 else
88 {
89 exit_client(target_p, &me, "SVSNICK Collide");
90 return 0;
91 }
92 }
93
94 target_p->tsinfo = atoi(parv[3]);
95 clear_ban_cache_client(target_p);
96 watch_check_hash(target_p, RPL_LOGOFF);
97
98 if (HasUMode(target_p, UMODE_REGISTERED))
99 {
100 unsigned int oldmodes = target_p->umodes;
101 char modebuf[IRCD_BUFSIZE] = { '\0' };
102
103 DelUMode(target_p, UMODE_REGISTERED);
104 send_umode(target_p, target_p, oldmodes, 0xffffffff, modebuf);
105 }
106
107 sendto_common_channels_local(target_p, 1, 0, ":%s!%s@%s NICK :%s",
108 target_p->name, target_p->username,
109 target_p->host, parv[2]);
110
111 whowas_add_history(target_p, 1);
112
113 sendto_server(NULL, NOCAPS, NOCAPS, ":%s NICK %s :%lu",
114 ID(target_p), parv[2], (unsigned long)target_p->tsinfo);
115 hash_del_client(target_p);
116 strlcpy(target_p->name, parv[2], sizeof(target_p->name));
117 hash_add_client(target_p);
118
119 watch_check_hash(target_p, RPL_LOGON);
120
121 fd_note(&target_p->localClient->fd, "Nick: %s", parv[2]);
122 return 0;
123 }
124
125 static struct Message svsnick_msgtab =
126 {
127 "SVSNICK", 0, 0, 4, MAXPARA, MFLG_SLOW, 0,
128 {m_ignore, m_ignore, ms_svsnick, m_ignore, m_ignore, m_ignore}
129 };
130
131 static void
132 module_init(void)
133 {
134 mod_add_cmd(&svsnick_msgtab);
135 }
136
137 static void
138 module_exit(void)
139 {
140 mod_del_cmd(&svsnick_msgtab);
141 }
142
143 struct module module_entry =
144 {
145 .node = { NULL, NULL, NULL },
146 .name = NULL,
147 .version = "$Revision$",
148 .handle = NULL,
149 .modinit = module_init,
150 .modexit = module_exit,
151 .flags = 0
152 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision