1 |
michael |
3352 |
/* |
2 |
|
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
|
* |
4 |
michael |
5346 |
* Copyright (c) 2003-2015 ircd-hybrid development team |
5 |
michael |
3352 |
* |
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 |
michael |
4564 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
michael |
3352 |
* USA |
20 |
|
|
*/ |
21 |
|
|
|
22 |
|
|
/*! \file m_unxline.c |
23 |
|
|
* \brief Includes required functions for processing the UNXLINE command. |
24 |
michael |
3353 |
* \version $Id$ |
25 |
michael |
3352 |
*/ |
26 |
|
|
|
27 |
|
|
#include "stdinc.h" |
28 |
|
|
#include "list.h" |
29 |
|
|
#include "client.h" |
30 |
|
|
#include "irc_string.h" |
31 |
|
|
#include "ircd.h" |
32 |
|
|
#include "conf.h" |
33 |
|
|
#include "numeric.h" |
34 |
|
|
#include "log.h" |
35 |
|
|
#include "send.h" |
36 |
|
|
#include "server.h" |
37 |
|
|
#include "parse.h" |
38 |
|
|
#include "modules.h" |
39 |
|
|
#include "memory.h" |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
/* static int remove_tkline_match(const char *host, const char *user) |
43 |
|
|
* |
44 |
|
|
* Inputs: gecos |
45 |
|
|
* Output: returns YES on success, NO if no tkline removed. |
46 |
|
|
* Side effects: Any matching tklines are removed. |
47 |
|
|
*/ |
48 |
|
|
static int |
49 |
michael |
5834 |
xline_remove(const char *gecos) |
50 |
michael |
3352 |
{ |
51 |
michael |
4816 |
dlink_node *node = NULL; |
52 |
michael |
3352 |
|
53 |
michael |
4816 |
DLINK_FOREACH(node, xconf_items.head) |
54 |
michael |
3352 |
{ |
55 |
michael |
4816 |
struct MaskItem *conf = node->data; |
56 |
michael |
3352 |
|
57 |
|
|
if (!IsConfDatabase(conf)) |
58 |
|
|
continue; |
59 |
|
|
|
60 |
|
|
if (!irccmp(gecos, conf->name)) |
61 |
|
|
{ |
62 |
|
|
conf_free(conf); |
63 |
|
|
return 1; |
64 |
|
|
} |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
return 0; |
68 |
|
|
} |
69 |
|
|
|
70 |
|
|
static void |
71 |
michael |
5834 |
xline_remove_and_notify(struct Client *source_p, const char *gecos) |
72 |
michael |
3352 |
{ |
73 |
michael |
5834 |
if (xline_remove(gecos)) |
74 |
michael |
3352 |
{ |
75 |
michael |
4645 |
if (IsClient(source_p)) |
76 |
|
|
sendto_one_notice(source_p, &me, ":X-Line for [%s] is removed", gecos); |
77 |
michael |
4889 |
|
78 |
michael |
6317 |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
79 |
michael |
3352 |
"%s has removed the X-Line for: [%s]", |
80 |
|
|
get_oper_name(source_p), gecos); |
81 |
|
|
ilog(LOG_TYPE_XLINE, "%s removed X-Line for [%s]", |
82 |
|
|
get_oper_name(source_p), gecos); |
83 |
|
|
} |
84 |
michael |
4645 |
else if (IsClient(source_p)) |
85 |
michael |
3352 |
sendto_one_notice(source_p, &me, ":No X-Line for %s", gecos); |
86 |
|
|
} |
87 |
|
|
|
88 |
michael |
3363 |
/*! \brief UNXLINE command handler |
89 |
michael |
3352 |
* |
90 |
michael |
3363 |
* \param source_p Pointer to allocated Client struct from which the message |
91 |
|
|
* originally comes from. This can be a local or remote client. |
92 |
|
|
* \param parc Integer holding the number of supplied arguments. |
93 |
|
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
94 |
|
|
* pointers. |
95 |
|
|
* \note Valid arguments for this command are: |
96 |
|
|
* - parv[0] = command |
97 |
michael |
3365 |
* - parv[1] = gecos |
98 |
michael |
3363 |
* - parv[2] = "ON" |
99 |
|
|
* - parv[3] = target server |
100 |
michael |
3352 |
*/ |
101 |
|
|
static int |
102 |
|
|
mo_unxline(struct Client *source_p, int parc, char *parv[]) |
103 |
|
|
{ |
104 |
|
|
char *gecos = NULL; |
105 |
|
|
char *target_server = NULL; |
106 |
|
|
|
107 |
|
|
if (!HasOFlag(source_p, OPER_FLAG_UNXLINE)) |
108 |
|
|
{ |
109 |
|
|
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "unxline"); |
110 |
|
|
return 0; |
111 |
|
|
} |
112 |
|
|
|
113 |
michael |
5775 |
if (!parse_aline("UNXLINE", source_p, parc, parv, 0, &gecos, |
114 |
|
|
NULL, NULL, &target_server, NULL)) |
115 |
michael |
3352 |
return 0; |
116 |
|
|
|
117 |
michael |
3368 |
if (target_server) |
118 |
michael |
3352 |
{ |
119 |
|
|
sendto_match_servs(source_p, target_server, CAP_CLUSTER, |
120 |
|
|
"UNXLINE %s %s", target_server, gecos); |
121 |
|
|
|
122 |
|
|
/* Allow ON to apply local unxline as well if it matches */ |
123 |
|
|
if (match(target_server, me.name)) |
124 |
|
|
return 0; |
125 |
|
|
} |
126 |
|
|
else |
127 |
michael |
4645 |
cluster_a_line(source_p, "UNXLINE", CAP_CLUSTER, SHARED_UNXLINE, "%s", gecos); |
128 |
michael |
3352 |
|
129 |
michael |
5834 |
xline_remove_and_notify(source_p, gecos); |
130 |
michael |
3352 |
return 0; |
131 |
|
|
} |
132 |
|
|
|
133 |
michael |
3363 |
/*! \brief UNXLINE command handler |
134 |
michael |
3352 |
* |
135 |
michael |
3363 |
* \param source_p Pointer to allocated Client struct from which the message |
136 |
|
|
* originally comes from. This can be a local or remote client. |
137 |
|
|
* \param parc Integer holding the number of supplied arguments. |
138 |
|
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
139 |
|
|
* pointers. |
140 |
|
|
* \note Valid arguments for this command are: |
141 |
|
|
* - parv[0] = command |
142 |
|
|
* - parv[1] = target server |
143 |
michael |
3791 |
* - parv[2] = gecos |
144 |
michael |
3352 |
*/ |
145 |
|
|
static int |
146 |
|
|
ms_unxline(struct Client *source_p, int parc, char *parv[]) |
147 |
|
|
{ |
148 |
michael |
4645 |
if (parc != 3 || EmptyString(parv[2])) |
149 |
michael |
3352 |
return 0; |
150 |
|
|
|
151 |
michael |
3368 |
sendto_match_servs(source_p, parv[1], CAP_CLUSTER, "UNXLINE %s %s", |
152 |
|
|
parv[1], parv[2]); |
153 |
michael |
3352 |
|
154 |
|
|
if (match(parv[1], me.name)) |
155 |
|
|
return 0; |
156 |
|
|
|
157 |
michael |
3368 |
if (HasFlag(source_p, FLAGS_SERVICE) || |
158 |
|
|
find_matching_name_conf(CONF_ULINE, source_p->servptr->name, |
159 |
michael |
3352 |
source_p->username, source_p->host, |
160 |
|
|
SHARED_UNXLINE)) |
161 |
michael |
5834 |
xline_remove_and_notify(source_p, parv[2]); |
162 |
michael |
3352 |
return 0; |
163 |
|
|
} |
164 |
|
|
|
165 |
|
|
static struct Message unxline_msgtab = |
166 |
|
|
{ |
167 |
michael |
5880 |
.cmd = "UNXLINE", |
168 |
|
|
.args_min = 2, |
169 |
|
|
.args_max = MAXPARA, |
170 |
|
|
.handlers[UNREGISTERED_HANDLER] = m_unregistered, |
171 |
|
|
.handlers[CLIENT_HANDLER] = m_not_oper, |
172 |
|
|
.handlers[SERVER_HANDLER] = ms_unxline, |
173 |
|
|
.handlers[ENCAP_HANDLER] = m_ignore, |
174 |
|
|
.handlers[OPER_HANDLER] = mo_unxline |
175 |
michael |
3352 |
}; |
176 |
|
|
|
177 |
|
|
static void |
178 |
|
|
module_init(void) |
179 |
|
|
{ |
180 |
|
|
mod_add_cmd(&unxline_msgtab); |
181 |
|
|
} |
182 |
|
|
|
183 |
|
|
static void |
184 |
|
|
module_exit(void) |
185 |
|
|
{ |
186 |
|
|
mod_del_cmd(&unxline_msgtab); |
187 |
|
|
} |
188 |
|
|
|
189 |
|
|
struct module module_entry = |
190 |
|
|
{ |
191 |
michael |
3353 |
.version = "$Revision$", |
192 |
michael |
3352 |
.modinit = module_init, |
193 |
|
|
.modexit = module_exit, |
194 |
|
|
}; |