ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_kill.c
Revision: 3347
Committed: Sun Apr 20 14:03:06 2014 UTC (9 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 8149 byte(s)
Log Message:
- Moved files:
  s_user.c -> user.c
  s_misc.c -> misc.c
  s_serv.c -> server.c

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     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19     * 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     /* mo_kill()
44 michael 3096 * parv[0] = command
45 adx 30 * parv[1] = kill victim
46     * parv[2] = kill path
47     */
48 michael 2820 static int
49 michael 3156 mo_kill(struct Client *source_p, int parc, char *parv[])
50 adx 30 {
51 michael 3179 char buf[IRCD_BUFSIZE] = "";
52 michael 1794 char def_reason[] = CONF_NOREASON;
53 michael 3201 struct Client *target_p = NULL;
54     char *reason = NULL;
55 adx 30
56 michael 3201 if (EmptyString(parv[1]))
57 adx 30 {
58 michael 3109 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "KILL");
59 michael 2820 return 0;
60 adx 30 }
61    
62 michael 3201 reason = parv[2]; /* Either defined or NULL (parc >= 2!!) */
63    
64 adx 30 if (!EmptyString(reason))
65     {
66     if (strlen(reason) > (size_t)KILLLEN)
67     reason[KILLLEN] = '\0';
68     }
69     else
70     reason = def_reason;
71    
72 michael 3201 if ((target_p = hash_find_client(parv[1])) == NULL)
73 adx 30 {
74 michael 1136 /*
75     * If the user has recently changed nick, automatically
76 adx 30 * rewrite the KILL for this new nickname--this keeps
77     * servers in synch when nick change and kill collide
78     */
79 michael 3201 if ((target_p = whowas_get_history(parv[1],
80 michael 1451 (time_t)ConfigFileEntry.kill_chase_time_limit))
81     == NULL)
82 adx 30 {
83 michael 3201 sendto_one_numeric(source_p, &me, ERR_NOSUCHNICK, parv[1]);
84 michael 2820 return 0;
85 adx 30 }
86    
87 michael 3110 sendto_one_notice(source_p, &me, ":KILL changed from %s to %s",
88 michael 3201 parv[1], target_p->name);
89 adx 30 }
90    
91 michael 2801 if (!MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_KILL_REMOTE))
92 adx 30 {
93 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "kill:remote");
94 michael 2820 return 0;
95 adx 30 }
96    
97 michael 2801 if (MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_KILL))
98     {
99 michael 3109 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "kill");
100 michael 2820 return 0;
101 michael 2801 }
102    
103 michael 2012 if (IsServer(target_p) || IsMe(target_p))
104 adx 30 {
105 michael 3109 sendto_one_numeric(source_p, &me, ERR_CANTKILLSERVER);
106 michael 2820 return 0;
107 adx 30 }
108    
109     if (MyConnect(target_p))
110 michael 2820 sendto_one(target_p, ":%s!%s@%s KILL %s :%s",
111 adx 30 source_p->name, source_p->username, source_p->host,
112     target_p->name, reason);
113    
114 michael 1136 /*
115     * Do not change the format of this message. There's no point in changing messages
116     * that have been around for ever, for no reason..
117     */
118 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
119 michael 2820 "Received KILL message for %s!%s@%s[%s/%s]. From %s Path: %s (%s)",
120 michael 2037 target_p->name, target_p->username, target_p->host,
121     target_p->servptr->name,
122 michael 3201 target_p->servptr->id,
123 michael 2037 source_p->name, me.name, reason);
124 adx 30
125 michael 1247 ilog(LOG_TYPE_KILL, "KILL From %s For %s Path %s (%s)",
126 adx 30 source_p->name, target_p->name, me.name, reason);
127    
128     /*
129 michael 1136 * And pass on the message to other servers. Note, that if KILL
130     * was changed, the message has to be sent to all links, also
131     * back.
132     * Suicide kills are NOT passed on --SRB
133     */
134 adx 30 if (!MyConnect(target_p))
135     {
136 michael 3179 sendto_server(source_p, NOCAPS, NOCAPS, ":%s KILL %s :%s!%s!%s!%s (%s)",
137     source_p->id, target_p->id, me.name, source_p->host,
138     source_p->username, source_p->name, reason);
139 michael 3201
140 michael 3179 /*
141     * Set FLAGS_KILLED. This prevents exit_one_client from sending
142     * the unnecessary QUIT for this. (This flag should never be
143     * set in any other place)
144     */
145 michael 1219 AddFlag(target_p, FLAGS_KILLED);
146 adx 30 }
147    
148 michael 1136 snprintf(buf, sizeof(buf), "Killed (%s (%s))", source_p->name, reason);
149 michael 3171 exit_client(target_p, buf);
150 michael 2820 return 0;
151 adx 30 }
152    
153     /* ms_kill()
154 michael 3096 * parv[0] = command
155 adx 30 * parv[1] = kill victim
156     * parv[2] = kill path and reason
157     */
158 michael 2820 static int
159 michael 3156 ms_kill(struct Client *source_p, int parc, char *parv[])
160 adx 30 {
161 michael 3179 char buf[IRCD_BUFSIZE] = "";
162 michael 1794 char def_reason[] = CONF_NOREASON;
163 michael 3200 struct Client *target_p = NULL;
164     char *reason = NULL;
165 adx 30
166 michael 3201 if (parc < 3 || EmptyString(parv[2]))
167 adx 30 {
168 michael 3109 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "KILL");
169 michael 2820 return 0;
170 adx 30 }
171    
172 michael 3201 if ((target_p = hash_find_id(parv[1])) == NULL)
173     return 0;
174    
175 michael 3200 if ((reason = strchr(parv[2], ' ')))
176     *reason++ = '\0';
177     else
178 adx 30 reason = def_reason;
179    
180     if (IsServer(target_p) || IsMe(target_p))
181     {
182 michael 3109 sendto_one_numeric(source_p, &me, ERR_CANTKILLSERVER);
183 michael 2820 return 0;
184 adx 30 }
185    
186     if (MyConnect(target_p))
187     {
188     if (IsServer(source_p))
189     {
190     /* dont send clients kills from a hidden server */
191 michael 1219 if ((IsHidden(source_p) || ConfigServerHide.hide_servers) && !HasUMode(target_p, UMODE_OPER))
192 adx 30 sendto_one(target_p, ":%s KILL %s :%s",
193 michael 1451 me.name, target_p->name, reason);
194 adx 30 else
195 michael 1451 sendto_one(target_p, ":%s KILL %s :%s",
196     source_p->name, target_p->name, reason);
197 adx 30 }
198     else
199     sendto_one(target_p, ":%s!%s@%s KILL %s :%s",
200 michael 1451 source_p->name, source_p->username, source_p->host,
201     target_p->name, reason);
202 adx 30 }
203    
204 michael 1451 /*
205     * Be warned, this message must be From %s, or it confuses clients
206     * so dont change it to From: or the case or anything! -- fl -- db
207     */
208     /*
209     * path must contain at least 2 !'s, or bitchx falsely declares it
210 adx 30 * local --fl
211     */
212 michael 1219 if (HasUMode(source_p, UMODE_OPER)) /* send it normally */
213 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
214 michael 2037 "Received KILL message for %s!%s@%s[%s/%s]. From %s Path: %s!%s!%s!%s %s",
215     target_p->name, target_p->username, target_p->host,
216     target_p->servptr->name,
217 michael 3201 target_p->servptr->id, source_p->name,
218 michael 2037 source_p->servptr->name, source_p->host, source_p->username,
219     source_p->name, reason);
220 adx 30 else
221 michael 1618 sendto_realops_flags(UMODE_SKILL, L_ALL, SEND_NOTICE,
222 michael 2037 "Received KILL message for %s!%s@%s[%s/%s]. From %s %s",
223     target_p->name, target_p->username, target_p->host,
224     target_p->servptr->name,
225 michael 3201 target_p->servptr->id,
226 michael 2037 source_p->name, reason);
227 adx 30
228 michael 1247 ilog(LOG_TYPE_KILL, "KILL From %s For %s Path %s %s",
229 adx 30 source_p->name, target_p->name, source_p->name, reason);
230    
231 michael 3179 sendto_server(source_p, NOCAPS, NOCAPS, ":%s KILL %s :%s %s",
232 michael 3200 source_p->id, target_p->id, parv[2], reason);
233 michael 1219 AddFlag(target_p, FLAGS_KILLED);
234 adx 30
235     /* reason comes supplied with its own ()'s */
236     if (IsServer(source_p) && (IsHidden(source_p) || ConfigServerHide.hide_servers))
237 michael 1136 snprintf(buf, sizeof(buf), "Killed (%s %s)", me.name, reason);
238 adx 30 else
239 michael 1136 snprintf(buf, sizeof(buf), "Killed (%s %s)", source_p->name, reason);
240 adx 30
241 michael 3171 exit_client(target_p, buf);
242 michael 2820 return 0;
243 adx 30 }
244    
245    
246 michael 2820 static struct Message kill_msgtab =
247     {
248 michael 1230 "KILL", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
249 michael 2820 { m_unregistered, m_not_oper, ms_kill, m_ignore, mo_kill, m_ignore }
250 michael 1230 };
251    
252     static void
253     module_init(void)
254     {
255     mod_add_cmd(&kill_msgtab);
256     }
257    
258     static void
259     module_exit(void)
260     {
261     mod_del_cmd(&kill_msgtab);
262     }
263    
264 michael 2820 struct module module_entry =
265     {
266 michael 1230 .node = { NULL, NULL, NULL },
267     .name = NULL,
268     .version = "$Revision$",
269     .handle = NULL,
270     .modinit = module_init,
271     .modexit = module_exit,
272     .flags = MODULE_FLAG_CORE
273     };

Properties

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