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
00026 #include "stdinc.h"
00027 #include "handlers.h"
00028 #include "client.h"
00029 #include "common.h"
00030 #include "hash.h"
00031 #include "ircd.h"
00032 #include "numeric.h"
00033 #include "s_log.h"
00034 #include "s_serv.h"
00035 #include "s_conf.h"
00036 #include "send.h"
00037 #include "whowas.h"
00038 #include "irc_string.h"
00039 #include "sprintf_irc.h"
00040 #include "msg.h"
00041 #include "parse.h"
00042 #include "channel_mode.h"
00043 #include "modules.h"
00044
00045 static void mo_killhost(struct Client *, struct Client *, int, char *[]);
00046 static void kh_relay_kill(struct Client *, struct Client *, struct Client *,
00047 const char *, const char *);
00048
00049 struct Message killhost_msgtab = {
00050 "KILLHOST", 0, 0, 2, 0, MFLG_SLOW, 0,
00051 { m_unregistered, m_ignore, m_ignore, m_ignore, mo_killhost, m_ignore }
00052 };
00053
00054 #ifndef STATIC_MODULES
00055 void
00056 _modinit(void)
00057 {
00058 mod_add_cmd(&killhost_msgtab);
00059 }
00060
00061 void
00062 _moddeinit(void)
00063 {
00064 mod_del_cmd(&killhost_msgtab);
00065 }
00066
00067 const char *_version = "$Revision: 620 $";
00068 #endif
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 static void
00079 mo_killhost(struct Client *client_p, struct Client *source_p,
00080 int parc, char *parv[])
00081 {
00082 dlink_node *ptr = NULL, *ptr_next = NULL;
00083 struct Client *target_p = NULL;
00084 const char *inpath = client_p->name;
00085 char *reason = NULL;
00086 char bufhost[IRCD_BUFSIZE];
00087 char nick[NICKLEN + 1];
00088 char user[USERLEN + 1];
00089 char host[HOSTLEN + 1];
00090 char def_reason[] = "No reason";
00091 unsigned int count = 0;
00092 struct split_nuh_item nuh;
00093
00094 if (!(IsOperK(source_p) || IsOperGlobalKill(source_p)))
00095 {
00096 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
00097 me.name, source_p->name);
00098 return;
00099 }
00100
00101 nuh.nuhmask = parv[1];
00102 nuh.nickptr = nick;
00103 nuh.userptr = user;
00104 nuh.hostptr = host;
00105
00106 nuh.nicksize = sizeof(nick);
00107 nuh.usersize = sizeof(user);
00108 nuh.hostsize = sizeof(host);
00109
00110 split_nuh(&nuh);
00111
00112 if (!valid_wild_card(source_p, YES, 3, nick, user, host))
00113 return;
00114
00115 if (!EmptyString(parv[2]))
00116 {
00117 reason = parv[2];
00118 if (strlen(reason) > (size_t)KILLLEN)
00119 reason[KILLLEN] = '\0';
00120 }
00121 else
00122 reason = def_reason;
00123
00124 DLINK_FOREACH_SAFE(ptr, ptr_next, global_client_list.head)
00125 {
00126 target_p = ptr->data;
00127
00128 if (!IsClient(target_p) || (source_p == target_p))
00129 continue;
00130
00131 if (!MyConnect(target_p) && !IsOperGlobalKill(source_p))
00132 continue;
00133
00134 if (match(nick, target_p->name) &&
00135 match(user, target_p->username) &&
00136 match(host, target_p->host))
00137 {
00138 if (MyConnect(target_p))
00139 sendto_one(target_p, ":%s!%s@%s KILL %s :%s",
00140 source_p->name, source_p->username, source_p->host,
00141 target_p->name, reason);
00142
00143 sendto_realops_flags(UMODE_ALL, L_ALL,
00144 "Received KILL message for %s. From %s Path: %s (%s)",
00145 target_p->name, source_p->name, me.name, reason);
00146
00147 ilog(L_INFO,"KILL From %s For %s Path %s (%s)",
00148 source_p->name, target_p->name, me.name, reason);
00149
00150 if (!MyConnect(target_p))
00151 {
00152 kh_relay_kill(client_p, source_p, target_p, inpath, reason);
00153 SetKilled(target_p);
00154 }
00155
00156 if (!count++)
00157 ircsprintf(bufhost, "Killed (%s (%s))", source_p->name, reason);
00158
00159 exit_client(target_p, source_p, bufhost);
00160 }
00161 }
00162
00163 if (count > 0)
00164 sendto_wallops_flags(UMODE_OPERWALL, source_p, "OPERWALL - KILLHOST %s %s",
00165 host, reason);
00166
00167 sendto_one(source_p,":%s NOTICE %s :%u clients killed",
00168 me.name, source_p->name, count);
00169 }
00170
00171 static void
00172 kh_relay_kill(struct Client *one, struct Client *source_p, struct Client *target_p,
00173 const char *inpath, const char *reason)
00174 {
00175 dlink_node *ptr;
00176 struct Client *client_p;
00177 int introduce_killed_client;
00178 char *user;
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 if(IsServer(source_p))
00195 introduce_killed_client = 0;
00196 else
00197 introduce_killed_client = 1;
00198
00199 DLINK_FOREACH(ptr, serv_list.head)
00200 {
00201 client_p = ptr->data;
00202
00203 if (client_p == one)
00204 continue;
00205
00206 if (!introduce_killed_client)
00207 {
00208 if (ServerInfo.hub && IsCapable(client_p, CAP_LL) )
00209 {
00210 if (((client_p->localClient->serverMask &
00211 target_p->lazyLinkClientExists) == 0))
00212 {
00213
00214 continue;
00215 }
00216 }
00217 }
00218
00219
00220 else if (strcmp(target_p->servptr->name,client_p->name))
00221 client_burst_if_needed(client_p, target_p);
00222
00223
00224 client_burst_if_needed(client_p, source_p);
00225
00226
00227 if (IsCapable(client_p, CAP_TS6))
00228 user = ID(target_p);
00229 else
00230 user = target_p->name;
00231
00232 if (MyClient(source_p))
00233 {
00234 sendto_one(client_p, ":%s KILL %s :%s!%s!%s!%s (%s)",
00235 source_p->name, user,
00236 me.name, source_p->host, source_p->username,
00237 source_p->name, reason);
00238 }
00239 else
00240 {
00241 sendto_one(client_p, ":%s KILL %s :%s %s",
00242 source_p->name, user,
00243 inpath, reason);
00244 }
00245 }
00246 }