1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1999 Bahamut development team. |
5 |
* Copyright (c) 2013-2014 ircd-hybrid development team |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License as published by |
9 |
* the Free Software Foundation; either version 2 of the License, or |
10 |
* (at your option) any later version. |
11 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with this program; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
* USA |
21 |
*/ |
22 |
|
23 |
/*! \file m_svskill.c |
24 |
* \brief Includes required functions for processing the SVSKILL command. |
25 |
* \version $Id$ |
26 |
*/ |
27 |
|
28 |
#include "stdinc.h" |
29 |
#include "client.h" |
30 |
#include "ircd.h" |
31 |
#include "s_serv.h" |
32 |
#include "send.h" |
33 |
#include "channel_mode.h" |
34 |
#include "parse.h" |
35 |
#include "modules.h" |
36 |
#include "irc_string.h" |
37 |
#include "s_user.h" |
38 |
#include "conf.h" |
39 |
|
40 |
|
41 |
/*! \brief SVSKILL command handler (called by services) |
42 |
* |
43 |
* \param client_p Pointer to allocated Client struct with physical connection |
44 |
* to this server, i.e. with an open socket connected. |
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] = sender prefix |
52 |
* - parv[1] = nickname |
53 |
* - parv[2] = TS |
54 |
* - parv[3] = kill message |
55 |
*/ |
56 |
static int |
57 |
ms_svskill(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) |
58 |
{ |
59 |
struct Client *target_p = NULL; |
60 |
const char *comment = NULL; |
61 |
char reason[KICKLEN + 1] = "SVSKilled: "; |
62 |
time_t ts = 0; |
63 |
|
64 |
if (!HasFlag(source_p, FLAGS_SERVICE)) |
65 |
return 0; |
66 |
|
67 |
if (EmptyString(parv[1])) |
68 |
return 0; |
69 |
|
70 |
if (parc > 3) |
71 |
{ |
72 |
comment = parv[3] ? parv[3] : source_p->name; |
73 |
ts = atol(parv[2]); |
74 |
} |
75 |
else |
76 |
comment = (parc > 2 && parv[2]) ? parv[2] : source_p->name; |
77 |
|
78 |
if ((target_p = find_person(client_p, parv[1])) == NULL) |
79 |
return 0; |
80 |
|
81 |
if (ts && (ts != target_p->tsinfo)) |
82 |
return 0; |
83 |
|
84 |
if (MyConnect(target_p)) |
85 |
{ |
86 |
strlcpy(reason + 11, comment, sizeof(reason) - 11); |
87 |
exit_client(target_p, target_p, reason); |
88 |
return 0; |
89 |
} |
90 |
|
91 |
if (target_p->from == client_p) |
92 |
{ |
93 |
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
94 |
"Received wrong-direction SVSKILL " |
95 |
"for %s (behind %s) from %s", |
96 |
target_p->name, client_p->name, |
97 |
get_client_name(source_p, HIDE_IP)); |
98 |
return 0; |
99 |
} |
100 |
|
101 |
if (ts == 0) |
102 |
sendto_one(target_p, ":%s SVSKILL %s :%s", |
103 |
ID_or_name(source_p, target_p->from), |
104 |
ID_or_name(target_p, target_p->from), comment); |
105 |
else |
106 |
sendto_one(target_p, ":%s SVSKILL %s %lu :%s", |
107 |
ID_or_name(source_p, target_p->from), |
108 |
ID_or_name(target_p, target_p->from), ts, comment); |
109 |
return 0; |
110 |
} |
111 |
|
112 |
static struct Message svskill_msgtab = |
113 |
{ |
114 |
"SVSKILL", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
115 |
{ m_ignore, m_ignore, ms_svskill, m_ignore, m_ignore, m_ignore } |
116 |
}; |
117 |
|
118 |
static void |
119 |
module_init(void) |
120 |
{ |
121 |
mod_add_cmd(&svskill_msgtab); |
122 |
} |
123 |
|
124 |
static void |
125 |
module_exit(void) |
126 |
{ |
127 |
mod_del_cmd(&svskill_msgtab); |
128 |
} |
129 |
|
130 |
struct module module_entry = |
131 |
{ |
132 |
.node = { NULL, NULL, NULL }, |
133 |
.name = NULL, |
134 |
.version = "$Revision$", |
135 |
.handle = NULL, |
136 |
.modinit = module_init, |
137 |
.modexit = module_exit, |
138 |
.flags = 0 |
139 |
}; |