ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/core/m_kill.c
Revision: 4299
Committed: Sun Jul 20 13:51:28 2014 UTC (9 years, 8 months ago) by michael
Content type: text/x-csrc
File size: 8160 byte(s)
Log Message:
- Fixed typos all over the place

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2014 ircd-hybrid development team
5 *
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 /*! \file m_kill.c
23 * \brief Includes required functions for processing the KILL command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "ircd.h"
32 #include "numeric.h"
33 #include "log.h"
34 #include "server.h"
35 #include "conf.h"
36 #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 * parv[0] = command
45 * parv[1] = kill victim
46 * parv[2] = kill path
47 */
48 static int
49 mo_kill(struct Client *source_p, int parc, char *parv[])
50 {
51 char buf[IRCD_BUFSIZE] = "";
52 char def_reason[] = CONF_NOREASON;
53 struct Client *target_p = NULL;
54 char *reason = NULL;
55
56 if (EmptyString(parv[1]))
57 {
58 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "KILL");
59 return 0;
60 }
61
62 reason = parv[2]; /* Either defined or NULL (parc >= 2!!) */
63
64 if (!EmptyString(reason))
65 {
66 if (strlen(reason) > (size_t)KILLLEN)
67 reason[KILLLEN] = '\0';
68 }
69 else
70 reason = def_reason;
71
72 if ((target_p = hash_find_client(parv[1])) == NULL)
73 {
74 /*
75 * If the user has recently changed nick, automatically
76 * rewrite the KILL for this new nickname--this keeps
77 * servers in synch when nick change and kill collide
78 */
79 if ((target_p = whowas_get_history(parv[1],
80 (time_t)ConfigFileEntry.kill_chase_time_limit))
81 == NULL)
82 {
83 sendto_one_numeric(source_p, &me, ERR_NOSUCHNICK, parv[1]);
84 return 0;
85 }
86
87 sendto_one_notice(source_p, &me, ":KILL changed from %s to %s",
88 parv[1], target_p->name);
89 }
90
91 if (!MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_KILL_REMOTE))
92 {
93 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "kill:remote");
94 return 0;
95 }
96
97 if (MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_KILL))
98 {
99 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "kill");
100 return 0;
101 }
102
103 if (IsServer(target_p) || IsMe(target_p))
104 {
105 sendto_one_numeric(source_p, &me, ERR_CANTKILLSERVER);
106 return 0;
107 }
108
109 if (MyConnect(target_p))
110 sendto_one(target_p, ":%s!%s@%s KILL %s :%s",
111 source_p->name, source_p->username, source_p->host,
112 target_p->name, reason);
113
114 /*
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 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
119 "Received KILL message for %s!%s@%s[%s/%s]. From %s Path: %s (%s)",
120 target_p->name, target_p->username, target_p->host,
121 target_p->servptr->name,
122 target_p->servptr->id,
123 source_p->name, me.name, reason);
124
125 ilog(LOG_TYPE_KILL, "KILL From %s For %s Path %s (%s)",
126 source_p->name, target_p->name, me.name, reason);
127
128 /*
129 * 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 if (!MyConnect(target_p))
135 {
136 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
140 /*
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 AddFlag(target_p, FLAGS_KILLED);
146 }
147
148 snprintf(buf, sizeof(buf), "Killed (%s (%s))", source_p->name, reason);
149 exit_client(target_p, buf);
150 return 0;
151 }
152
153 /* ms_kill()
154 * parv[0] = command
155 * parv[1] = kill victim
156 * parv[2] = kill path and reason
157 */
158 static int
159 ms_kill(struct Client *source_p, int parc, char *parv[])
160 {
161 char buf[IRCD_BUFSIZE] = "";
162 char def_reason[] = CONF_NOREASON;
163 struct Client *target_p = NULL;
164 char *reason = NULL;
165
166 if (parc < 3 || EmptyString(parv[2]))
167 {
168 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "KILL");
169 return 0;
170 }
171
172 if ((target_p = find_person(source_p, parv[1])) == NULL)
173 return 0;
174
175 if ((reason = strchr(parv[2], ' ')))
176 *reason++ = '\0';
177 else
178 reason = def_reason;
179
180 if (IsServer(target_p) || IsMe(target_p))
181 {
182 sendto_one_numeric(source_p, &me, ERR_CANTKILLSERVER);
183 return 0;
184 }
185
186 if (MyConnect(target_p))
187 {
188 if (IsServer(source_p))
189 {
190 /* Don't send clients kills from a hidden server */
191 if ((IsHidden(source_p) || ConfigServerHide.hide_servers) && !HasUMode(target_p, UMODE_OPER))
192 sendto_one(target_p, ":%s KILL %s :%s",
193 me.name, target_p->name, reason);
194 else
195 sendto_one(target_p, ":%s KILL %s :%s",
196 source_p->name, target_p->name, reason);
197 }
198 else
199 sendto_one(target_p, ":%s!%s@%s KILL %s :%s",
200 source_p->name, source_p->username, source_p->host,
201 target_p->name, reason);
202 }
203
204 /*
205 * Be warned, this message must be From %s, or it confuses clients
206 * so don't 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 * local --fl
211 */
212 if (HasUMode(source_p, UMODE_OPER)) /* send it normally */
213 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
214 "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 target_p->servptr->id, source_p->name,
218 source_p->servptr->name, source_p->host, source_p->username,
219 source_p->name, reason);
220 else
221 sendto_realops_flags(UMODE_SKILL, L_ALL, SEND_NOTICE,
222 "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 target_p->servptr->id,
226 source_p->name, reason);
227
228 ilog(LOG_TYPE_KILL, "KILL From %s For %s Path %s %s",
229 source_p->name, target_p->name, source_p->name, reason);
230
231 sendto_server(source_p, NOCAPS, NOCAPS, ":%s KILL %s :%s %s",
232 source_p->id, target_p->id, parv[2], reason);
233 AddFlag(target_p, FLAGS_KILLED);
234
235 /* Reason comes supplied with its own ()'s */
236 if (IsServer(source_p) && (IsHidden(source_p) || ConfigServerHide.hide_servers))
237 snprintf(buf, sizeof(buf), "Killed (%s %s)", me.name, reason);
238 else
239 snprintf(buf, sizeof(buf), "Killed (%s %s)", source_p->name, reason);
240
241 exit_client(target_p, buf);
242 return 0;
243 }
244
245
246 static struct Message kill_msgtab =
247 {
248 "KILL", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
249 { m_unregistered, m_not_oper, ms_kill, m_ignore, mo_kill, m_ignore }
250 };
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 struct module module_entry =
265 {
266 .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