| 1 |
michael |
2602 |
/* |
| 2 |
michael |
2820 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
michael |
2602 |
* |
| 4 |
michael |
2820 |
* Copyright (c) 1999 Bahamut development team. |
| 5 |
|
|
* Copyright (c) 2013-2014 ircd-hybrid development team |
| 6 |
michael |
2602 |
* |
| 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 |
michael |
2605 |
* \version $Id$ |
| 26 |
michael |
2602 |
*/ |
| 27 |
|
|
|
| 28 |
|
|
#include "stdinc.h" |
| 29 |
|
|
#include "client.h" |
| 30 |
|
|
#include "ircd.h" |
| 31 |
|
|
#include "s_serv.h" |
| 32 |
|
|
#include "send.h" |
| 33 |
|
|
#include "parse.h" |
| 34 |
|
|
#include "modules.h" |
| 35 |
|
|
#include "irc_string.h" |
| 36 |
|
|
#include "conf.h" |
| 37 |
|
|
|
| 38 |
|
|
|
| 39 |
|
|
/*! \brief SVSKILL command handler (called by services) |
| 40 |
|
|
* |
| 41 |
|
|
* \param source_p Pointer to allocated Client struct from which the message |
| 42 |
|
|
* originally comes from. This can be a local or remote client. |
| 43 |
|
|
* \param parc Integer holding the number of supplied arguments. |
| 44 |
|
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
| 45 |
|
|
* pointers. |
| 46 |
|
|
* \note Valid arguments for this command are: |
| 47 |
michael |
3096 |
* - parv[0] = command |
| 48 |
michael |
2602 |
* - parv[1] = nickname |
| 49 |
|
|
* - parv[2] = TS |
| 50 |
|
|
* - parv[3] = kill message |
| 51 |
|
|
*/ |
| 52 |
michael |
2820 |
static int |
| 53 |
michael |
3156 |
ms_svskill(struct Client *source_p, int parc, char *parv[]) |
| 54 |
michael |
2602 |
{ |
| 55 |
|
|
struct Client *target_p = NULL; |
| 56 |
|
|
const char *comment = NULL; |
| 57 |
|
|
char reason[KICKLEN + 1] = "SVSKilled: "; |
| 58 |
|
|
time_t ts = 0; |
| 59 |
|
|
|
| 60 |
|
|
if (!HasFlag(source_p, FLAGS_SERVICE)) |
| 61 |
michael |
2820 |
return 0; |
| 62 |
michael |
2602 |
|
| 63 |
|
|
if (EmptyString(parv[1])) |
| 64 |
michael |
2820 |
return 0; |
| 65 |
michael |
2602 |
|
| 66 |
|
|
if (parc > 3) |
| 67 |
|
|
{ |
| 68 |
|
|
comment = parv[3] ? parv[3] : source_p->name; |
| 69 |
|
|
ts = atol(parv[2]); |
| 70 |
|
|
} |
| 71 |
|
|
else |
| 72 |
|
|
comment = (parc > 2 && parv[2]) ? parv[2] : source_p->name; |
| 73 |
|
|
|
| 74 |
michael |
3156 |
if ((target_p = find_person(source_p, parv[1])) == NULL) |
| 75 |
michael |
2820 |
return 0; |
| 76 |
michael |
2602 |
|
| 77 |
|
|
if (ts && (ts != target_p->tsinfo)) |
| 78 |
michael |
2820 |
return 0; |
| 79 |
michael |
2602 |
|
| 80 |
michael |
2621 |
if (MyConnect(target_p)) |
| 81 |
michael |
2602 |
{ |
| 82 |
|
|
strlcpy(reason + 11, comment, sizeof(reason) - 11); |
| 83 |
|
|
exit_client(target_p, target_p, reason); |
| 84 |
michael |
2820 |
return 0; |
| 85 |
michael |
2602 |
} |
| 86 |
|
|
|
| 87 |
michael |
3156 |
if (target_p->from == source_p->from) |
| 88 |
michael |
2602 |
{ |
| 89 |
|
|
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
| 90 |
|
|
"Received wrong-direction SVSKILL " |
| 91 |
|
|
"for %s (behind %s) from %s", |
| 92 |
michael |
3156 |
target_p->name, source_p->from->name, |
| 93 |
michael |
2602 |
get_client_name(source_p, HIDE_IP)); |
| 94 |
michael |
2820 |
return 0; |
| 95 |
michael |
2602 |
} |
| 96 |
|
|
|
| 97 |
|
|
if (ts == 0) |
| 98 |
|
|
sendto_one(target_p, ":%s SVSKILL %s :%s", |
| 99 |
michael |
2888 |
ID_or_name(source_p, target_p), |
| 100 |
|
|
ID_or_name(target_p, target_p), comment); |
| 101 |
michael |
2602 |
else |
| 102 |
|
|
sendto_one(target_p, ":%s SVSKILL %s %lu :%s", |
| 103 |
michael |
2888 |
ID_or_name(source_p, target_p), |
| 104 |
|
|
ID_or_name(target_p, target_p), ts, comment); |
| 105 |
michael |
2820 |
return 0; |
| 106 |
michael |
2602 |
} |
| 107 |
|
|
|
| 108 |
michael |
2820 |
static struct Message svskill_msgtab = |
| 109 |
|
|
{ |
| 110 |
michael |
2602 |
"SVSKILL", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
| 111 |
michael |
2820 |
{ m_ignore, m_ignore, ms_svskill, m_ignore, m_ignore, m_ignore } |
| 112 |
michael |
2602 |
}; |
| 113 |
|
|
|
| 114 |
|
|
static void |
| 115 |
|
|
module_init(void) |
| 116 |
|
|
{ |
| 117 |
|
|
mod_add_cmd(&svskill_msgtab); |
| 118 |
|
|
} |
| 119 |
|
|
|
| 120 |
|
|
static void |
| 121 |
|
|
module_exit(void) |
| 122 |
|
|
{ |
| 123 |
|
|
mod_del_cmd(&svskill_msgtab); |
| 124 |
|
|
} |
| 125 |
|
|
|
| 126 |
michael |
2820 |
struct module module_entry = |
| 127 |
|
|
{ |
| 128 |
michael |
2602 |
.node = { NULL, NULL, NULL }, |
| 129 |
|
|
.name = NULL, |
| 130 |
michael |
2605 |
.version = "$Revision$", |
| 131 |
michael |
2602 |
.handle = NULL, |
| 132 |
|
|
.modinit = module_init, |
| 133 |
|
|
.modexit = module_exit, |
| 134 |
|
|
.flags = 0 |
| 135 |
|
|
}; |