00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdinc.h"
00026 #include "handlers.h"
00027 #include "client.h"
00028 #include "hash.h"
00029 #include "ircd.h"
00030 #include "numeric.h"
00031 #include "s_log.h"
00032 #include "s_serv.h"
00033 #include "s_conf.h"
00034 #include "send.h"
00035 #include "whowas.h"
00036 #include "irc_string.h"
00037 #include "sprintf_irc.h"
00038 #include "msg.h"
00039 #include "parse.h"
00040 #include "modules.h"
00041
00042
00043 static char buf[IRCD_BUFSIZE];
00044
00045 static void ms_kill(struct Client *, struct Client *, int, char *[]);
00046 static void mo_kill(struct Client *, struct Client *, int, char *[]);
00047 static void relay_kill(struct Client *, struct Client *, struct Client *,
00048 const char *, const char *);
00049
00050 struct Message kill_msgtab = {
00051 "KILL", 0, 0, 2, 0, MFLG_SLOW, 0,
00052 {m_unregistered, m_not_oper, ms_kill, m_ignore, mo_kill, m_ignore}
00053 };
00054
00055 #ifndef STATIC_MODULES
00056 void
00057 _modinit(void)
00058 {
00059 mod_add_cmd(&kill_msgtab);
00060 }
00061
00062 void
00063 _moddeinit(void)
00064 {
00065 mod_del_cmd(&kill_msgtab);
00066 }
00067
00068 const char *_version = "$Revision: 33 $";
00069 #endif
00070
00071
00072
00073
00074
00075
00076 static void
00077 mo_kill(struct Client *client_p, struct Client *source_p,
00078 int parc, char *parv[])
00079 {
00080 struct Client *target_p;
00081 const char *inpath = client_p->name;
00082 char *user;
00083 char *reason;
00084 char def_reason[] = "No reason";
00085
00086 user = parv[1];
00087 reason = parv[2];
00088
00089 if (*user == '\0')
00090 {
00091 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
00092 me.name, source_p->name, "KILL");
00093 return;
00094 }
00095
00096 if (IsDigit(*user))
00097 return;
00098
00099 if (!IsOperK(source_p) && !IsOperGlobalKill(source_p))
00100 {
00101 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
00102 me.name, source_p->name);
00103 return;
00104 }
00105
00106 if (!EmptyString(reason))
00107 {
00108 if (strlen(reason) > (size_t)KILLLEN)
00109 reason[KILLLEN] = '\0';
00110 }
00111 else
00112 reason = def_reason;
00113
00114 if ((target_p = find_client(user)) == NULL)
00115 {
00116
00117
00118
00119
00120 if ((target_p = get_history(user,
00121 (time_t)ConfigFileEntry.kill_chase_time_limit))
00122 == NULL)
00123 {
00124 sendto_one(source_p, form_str(ERR_NOSUCHNICK),
00125 me.name, source_p->name, user);
00126 return;
00127 }
00128
00129 sendto_one(source_p, ":%s NOTICE %s :KILL changed from %s to %s",
00130 me.name, source_p->name, user, target_p->name);
00131 }
00132
00133 if (IsServer(target_p) || IsMe(target_p))
00134 {
00135 sendto_one(source_p, form_str(ERR_CANTKILLSERVER),
00136 me.name, source_p->name);
00137 return;
00138 }
00139
00140 if (!MyConnect(target_p) && (!IsOperGlobalKill(source_p)))
00141 {
00142 sendto_one(source_p, ":%s NOTICE %s :Nick %s isnt on your server",
00143 me.name, source_p->name, target_p->name);
00144 return;
00145 }
00146
00147 if (MyConnect(target_p))
00148 sendto_one(target_p, ":%s!%s@%s KILL %s :%s",
00149 source_p->name, source_p->username, source_p->host,
00150 target_p->name, reason);
00151
00152
00153
00154 sendto_realops_flags(UMODE_ALL, L_ALL,
00155 "Received KILL message for %s. From %s Path: %s (%s)",
00156 target_p->name, source_p->name, me.name, reason);
00157
00158 ilog(L_INFO, "KILL From %s For %s Path %s (%s)",
00159 source_p->name, target_p->name, me.name, reason);
00160 log_oper_action(LOG_KILL_TYPE, source_p, "%s %s\n",
00161 me.name, reason);
00162
00163
00164
00165
00166
00167
00168
00169 if (!MyConnect(target_p))
00170 {
00171 relay_kill(client_p, source_p, target_p, inpath, reason);
00172
00173
00174
00175
00176
00177 SetKilled(target_p);
00178 }
00179
00180 ircsprintf(buf, "Killed (%s (%s))", source_p->name, reason);
00181 exit_client(target_p, source_p, buf);
00182 }
00183
00184
00185
00186
00187
00188
00189 static void
00190 ms_kill(struct Client *client_p, struct Client *source_p,
00191 int parc, char *parv[])
00192 {
00193 struct Client *target_p;
00194 char *user;
00195 char *reason;
00196 const char *path;
00197 char def_reason[] = "No reason";
00198
00199 if (*parv[1] == '\0')
00200 {
00201 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
00202 me.name, source_p->name, "KILL");
00203 return;
00204 }
00205
00206 user = parv[1];
00207
00208 if (EmptyString(parv[2]))
00209 {
00210 reason = def_reason;
00211
00212
00213 path = source_p->name;
00214 }
00215 else
00216 {
00217 reason = strchr(parv[2], ' ');
00218
00219 if (reason != NULL)
00220 *reason++ = '\0';
00221 else
00222 reason = def_reason;
00223
00224 path = parv[2];
00225 }
00226
00227 if ((target_p = find_person(client_p, user)) == NULL)
00228 {
00229
00230
00231
00232
00233 if(IsDigit(*user))
00234 return;
00235 if((target_p = get_history(user,
00236 (time_t)ConfigFileEntry.kill_chase_time_limit))
00237 == NULL)
00238 {
00239 sendto_one(source_p, form_str(ERR_NOSUCHNICK),
00240 me.name, source_p->name, user);
00241 return;
00242 }
00243 sendto_one(source_p,":%s NOTICE %s :KILL changed from %s to %s",
00244 me.name, source_p->name, user, target_p->name);
00245 }
00246
00247 if (IsServer(target_p) || IsMe(target_p))
00248 {
00249 sendto_one(source_p, form_str(ERR_CANTKILLSERVER),
00250 me.name, source_p->name);
00251 return;
00252 }
00253
00254 if (MyConnect(target_p))
00255 {
00256 if (IsServer(source_p))
00257 {
00258
00259 if ((IsHidden(source_p) || ConfigServerHide.hide_servers) && !IsOper(target_p))
00260 sendto_one(target_p, ":%s KILL %s :%s",
00261 me.name, target_p->name, reason);
00262 else
00263 sendto_one(target_p, ":%s KILL %s :%s",
00264 source_p->name, target_p->name, reason);
00265 }
00266 else
00267 sendto_one(target_p, ":%s!%s@%s KILL %s :%s",
00268 source_p->name, source_p->username, source_p->host,
00269 target_p->name, reason);
00270 }
00271
00272
00273
00274
00275
00276
00277 if (IsOper(source_p))
00278 {
00279 sendto_realops_flags(UMODE_ALL, L_ALL,
00280 "Received KILL message for %s. From %s Path: %s!%s!%s!%s %s",
00281 target_p->name, source_p->name, source_p->servptr->name,
00282 source_p->host, source_p->username, source_p->name, reason);
00283 }
00284 else
00285 {
00286 sendto_realops_flags(UMODE_SKILL, L_ALL,
00287 "Received KILL message for %s. From %s %s",
00288 target_p->name, source_p->name, reason);
00289 }
00290
00291 ilog(L_INFO,"KILL From %s For %s Path %s %s",
00292 source_p->name, target_p->name, source_p->name, reason);
00293
00294 relay_kill(client_p, source_p, target_p, path, reason);
00295 SetKilled(target_p);
00296
00297
00298 if (IsServer(source_p) && (IsHidden(source_p) || ConfigServerHide.hide_servers))
00299 ircsprintf(buf, "Killed (%s %s)", me.name, reason);
00300 else
00301 ircsprintf(buf, "Killed (%s %s)", source_p->name, reason);
00302
00303 exit_client(target_p, source_p, buf);
00304 }
00305
00306 static void
00307 relay_kill(struct Client *one, struct Client *source_p,
00308 struct Client *target_p, const char *inpath, const char *reason)
00309 {
00310 dlink_node *ptr;
00311 struct Client *client_p;
00312 int introduce_killed_client;
00313 const char *from, *to;
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329 if (IsServer(source_p))
00330 introduce_killed_client = 0;
00331 else
00332 introduce_killed_client = 1;
00333
00334 DLINK_FOREACH(ptr, serv_list.head)
00335 {
00336 client_p = ptr->data;
00337
00338 if (client_p == NULL || client_p == one)
00339 continue;
00340
00341 if (!introduce_killed_client)
00342 {
00343 if (ServerInfo.hub && IsCapable(client_p, CAP_LL))
00344 {
00345 if ((client_p->localClient->serverMask &
00346 target_p->lazyLinkClientExists) == 0)
00347 {
00348
00349 continue;
00350 }
00351 }
00352 }
00353
00354
00355 else if (strcmp(target_p->servptr->name, client_p->name))
00356 client_burst_if_needed(client_p, target_p);
00357
00358
00359 client_burst_if_needed(client_p, source_p);
00360
00361
00362 from = ID_or_name(source_p, client_p);
00363 to = ID_or_name(target_p, client_p);
00364
00365 if (MyClient(source_p))
00366 {
00367 sendto_one(client_p, ":%s KILL %s :%s!%s!%s!%s (%s)",
00368 from, to,
00369 me.name, source_p->host, source_p->username,
00370 source_p->name, reason);
00371 }
00372 else
00373 {
00374 sendto_one(client_p, ":%s KILL %s :%s %s",
00375 from, to, inpath, reason);
00376 }
00377 }
00378 }
00379