ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_kill.c
Revision: 4703
Committed: Sun Oct 5 16:19:05 2014 UTC (9 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 8994 byte(s)
Log Message:
- m_kill.c:ms_kill(): replaced HasUMode(source_p, UMODE_OPER) with just IsClient(source_p)

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18 michael 4565 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2820 /*! \file m_kill.c
23     * \brief Includes required functions for processing the KILL command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28 michael 1011 #include "list.h"
29 adx 30 #include "client.h"
30 michael 2820 #include "hash.h"
31 adx 30 #include "ircd.h"
32     #include "numeric.h"
33 michael 1309 #include "log.h"
34 michael 3347 #include "server.h"
35 michael 1309 #include "conf.h"
36 adx 30 #include "send.h"
37     #include "whowas.h"
38     #include "irc_string.h"
39     #include "parse.h"
40     #include "modules.h"
41    
42    
43 michael 4600 /*! \brief KILL command handler
44     *
45     * \param source_p Pointer to allocated Client struct from which the message
46     * originally comes from. This can be a local or remote client.
47     * \param parc Integer holding the number of supplied arguments.
48     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
49     * pointers.
50     * \note Valid arguments for this command are:
51     * - parv[0] = command
52     * - parv[1] = kill victim
53     * - parv[2] = reason
54 adx 30 */
55 michael 2820 static int
56 michael 3156 mo_kill(struct Client *source_p, int parc, char *parv[])
57 adx 30 {
58 michael 3179 char buf[IRCD_BUFSIZE] = "";
59 michael 1794 char def_reason[] = CONF_NOREASON;
60 michael 3201 struct Client *target_p = NULL;
61     char *reason = NULL;
62 adx 30
63 michael 3201 if (EmptyString(parv[1]))
64 adx 30 {
65 michael 3109 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "KILL");
66 michael 2820 return 0;
67 adx 30 }
68    
69 michael 3201 reason = parv[2]; /* Either defined or NULL (parc >= 2!!) */
70    
71 adx 30 if (!EmptyString(reason))
72     {
73     if (strlen(reason) > (size_t)KILLLEN)
74     reason[KILLLEN] = '\0';
75     }
76     else
77     reason = def_reason;
78    
79 michael 3201 if ((target_p = hash_find_client(parv[1])) == NULL)
80 adx 30 {
81 michael 1136 /*
82     * If the user has recently changed nick, automatically
83 adx 30 * rewrite the KILL for this new nickname--this keeps
84     * servers in synch when nick change and kill collide
85     */
86 michael 3201 if ((target_p = whowas_get_history(parv[1],
87 michael 4340 (time_t)ConfigGeneral.kill_chase_time_limit))
88 michael 1451 == NULL)
89 adx 30 {
90 michael 3201 sendto_one_numeric(source_p, &me, ERR_NOSUCHNICK, parv[1]);
91 michael 2820 return 0;
92 adx 30 }
93    
94 michael 3110 sendto_one_notice(source_p, &me, ":KILL changed from %s to %s",
95 michael 3201 parv[1], target_p->name);
96 adx 30 }
97    
98 michael 2801 if (!MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_KILL_REMOTE))
99 adx 30 {
100 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "kill:remote");
101 michael 2820 return 0;
102 adx 30 }
103    
104 michael 2801 if (MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_KILL))
105     {
106 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "kill");
107 michael 2820 return 0;
108 michael 2801 }
109    
110 michael 2012 if (IsServer(target_p) || IsMe(target_p))
111 adx 30 {
112 michael 3109 sendto_one_numeric(source_p, &me, ERR_CANTKILLSERVER);
113 michael 2820 return 0;
114 adx 30 }
115    
116     if (MyConnect(target_p))
117 michael 2820 sendto_one(target_p, ":%s!%s@%s KILL %s :%s",
118 adx 30 source_p->name, source_p->username, source_p->host,
119     target_p->name, reason);
120    
121 michael 1136 /*
122     * Do not change the format of this message. There's no point in changing messages
123     * that have been around for ever, for no reason..
124     */
125 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
126 michael 2820 "Received KILL message for %s!%s@%s[%s/%s]. From %s Path: %s (%s)",
127 michael 2037 target_p->name, target_p->username, target_p->host,
128     target_p->servptr->name,
129 michael 3201 target_p->servptr->id,
130 michael 2037 source_p->name, me.name, reason);
131 adx 30
132 michael 1247 ilog(LOG_TYPE_KILL, "KILL From %s For %s Path %s (%s)",
133 adx 30 source_p->name, target_p->name, me.name, reason);
134    
135     /*
136 michael 1136 * And pass on the message to other servers. Note, that if KILL
137     * was changed, the message has to be sent to all links, also
138     * back.
139     * Suicide kills are NOT passed on --SRB
140     */
141 adx 30 if (!MyConnect(target_p))
142     {
143 michael 3179 sendto_server(source_p, NOCAPS, NOCAPS, ":%s KILL %s :%s!%s!%s!%s (%s)",
144     source_p->id, target_p->id, me.name, source_p->host,
145     source_p->username, source_p->name, reason);
146 michael 3201
147 michael 3179 /*
148 michael 4600 * Set FLAGS_KILLED. This prevents exit_client() from sending
149 michael 3179 * the unnecessary QUIT for this. (This flag should never be
150     * set in any other place)
151     */
152 michael 1219 AddFlag(target_p, FLAGS_KILLED);
153 adx 30 }
154    
155 michael 1136 snprintf(buf, sizeof(buf), "Killed (%s (%s))", source_p->name, reason);
156 michael 3171 exit_client(target_p, buf);
157 michael 2820 return 0;
158 adx 30 }
159    
160 michael 4600 /*! \brief KILL command handler
161     *
162     * \param source_p Pointer to allocated Client struct from which the message
163     * originally comes from. This can be a local or remote client.
164     * \param parc Integer holding the number of supplied arguments.
165     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
166     * pointers.
167     * \note Valid arguments for this command are:
168     * - parv[0] = command
169     * - parv[1] = kill victim
170     * - parv[2] = kill path and reason
171 adx 30 */
172 michael 2820 static int
173 michael 3156 ms_kill(struct Client *source_p, int parc, char *parv[])
174 adx 30 {
175 michael 3179 char buf[IRCD_BUFSIZE] = "";
176 michael 1794 char def_reason[] = CONF_NOREASON;
177 michael 3200 struct Client *target_p = NULL;
178     char *reason = NULL;
179 adx 30
180 michael 3201 if (parc < 3 || EmptyString(parv[2]))
181 adx 30 {
182 michael 3109 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "KILL");
183 michael 2820 return 0;
184 adx 30 }
185    
186 michael 3431 if ((target_p = find_person(source_p, parv[1])) == NULL)
187 michael 3201 return 0;
188    
189 michael 3200 if ((reason = strchr(parv[2], ' ')))
190     *reason++ = '\0';
191     else
192 adx 30 reason = def_reason;
193    
194     if (IsServer(target_p) || IsMe(target_p))
195     {
196 michael 3109 sendto_one_numeric(source_p, &me, ERR_CANTKILLSERVER);
197 michael 2820 return 0;
198 adx 30 }
199    
200     if (MyConnect(target_p))
201     {
202     if (IsServer(source_p))
203     {
204 michael 4298 /* Don't send clients kills from a hidden server */
205 michael 1219 if ((IsHidden(source_p) || ConfigServerHide.hide_servers) && !HasUMode(target_p, UMODE_OPER))
206 adx 30 sendto_one(target_p, ":%s KILL %s :%s",
207 michael 1451 me.name, target_p->name, reason);
208 adx 30 else
209 michael 1451 sendto_one(target_p, ":%s KILL %s :%s",
210     source_p->name, target_p->name, reason);
211 adx 30 }
212     else
213     sendto_one(target_p, ":%s!%s@%s KILL %s :%s",
214 michael 1451 source_p->name, source_p->username, source_p->host,
215     target_p->name, reason);
216 adx 30 }
217    
218 michael 1451 /*
219     * Be warned, this message must be From %s, or it confuses clients
220 michael 4298 * so don't change it to From: or the case or anything! -- fl -- db
221 michael 1451 */
222     /*
223 michael 4298 * Path must contain at least 2 !'s, or bitchx falsely declares it
224 adx 30 * local --fl
225     */
226 michael 4703 if (IsClient(source_p)) /* Send it normally */
227 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
228 michael 2037 "Received KILL message for %s!%s@%s[%s/%s]. From %s Path: %s!%s!%s!%s %s",
229     target_p->name, target_p->username, target_p->host,
230     target_p->servptr->name,
231 michael 3201 target_p->servptr->id, source_p->name,
232 michael 2037 source_p->servptr->name, source_p->host, source_p->username,
233     source_p->name, reason);
234 adx 30 else
235 michael 1618 sendto_realops_flags(UMODE_SKILL, L_ALL, SEND_NOTICE,
236 michael 2037 "Received KILL message for %s!%s@%s[%s/%s]. From %s %s",
237     target_p->name, target_p->username, target_p->host,
238     target_p->servptr->name,
239 michael 3201 target_p->servptr->id,
240 michael 2037 source_p->name, reason);
241 adx 30
242 michael 1247 ilog(LOG_TYPE_KILL, "KILL From %s For %s Path %s %s",
243 adx 30 source_p->name, target_p->name, source_p->name, reason);
244    
245 michael 3179 sendto_server(source_p, NOCAPS, NOCAPS, ":%s KILL %s :%s %s",
246 michael 3200 source_p->id, target_p->id, parv[2], reason);
247 michael 1219 AddFlag(target_p, FLAGS_KILLED);
248 adx 30
249 michael 4298 /* Reason comes supplied with its own ()'s */
250 adx 30 if (IsServer(source_p) && (IsHidden(source_p) || ConfigServerHide.hide_servers))
251 michael 1136 snprintf(buf, sizeof(buf), "Killed (%s %s)", me.name, reason);
252 adx 30 else
253 michael 1136 snprintf(buf, sizeof(buf), "Killed (%s %s)", source_p->name, reason);
254 adx 30
255 michael 3171 exit_client(target_p, buf);
256 michael 2820 return 0;
257 adx 30 }
258    
259    
260 michael 2820 static struct Message kill_msgtab =
261     {
262 michael 4545 "KILL", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
263 michael 2820 { m_unregistered, m_not_oper, ms_kill, m_ignore, mo_kill, m_ignore }
264 michael 1230 };
265    
266     static void
267     module_init(void)
268     {
269     mod_add_cmd(&kill_msgtab);
270     }
271    
272     static void
273     module_exit(void)
274     {
275     mod_del_cmd(&kill_msgtab);
276     }
277    
278 michael 2820 struct module module_entry =
279     {
280 michael 1230 .node = { NULL, NULL, NULL },
281     .name = NULL,
282     .version = "$Revision$",
283     .handle = NULL,
284     .modinit = module_init,
285     .modexit = module_exit,
286     .flags = MODULE_FLAG_CORE
287     };

Properties

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