ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_unkline.c
Revision: 3363
Committed: Mon Apr 21 11:19:50 2014 UTC (12 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 7291 byte(s)
Log Message:
- Doxygen
- Update help/undline

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2014 ircd-hybrid development team
5 *
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 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 */
21
22 /*! \file m_unkline.c
23 * \brief Includes required functions for processing the UNKLINE command.
24 * \version $Id$
25 */
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 "hostmask.h"
34 #include "numeric.h"
35 #include "log.h"
36 #include "misc.h"
37 #include "send.h"
38 #include "hash.h"
39 #include "server.h"
40 #include "parse.h"
41 #include "modules.h"
42 #include "conf_db.h"
43 #include "memory.h"
44
45
46 /* static int remove_tkline_match(const char *host, const char *user)
47 * Input: A hostname, a username to unkline.
48 * Output: returns YES on success, NO if no tkline removed.
49 * Side effects: Any matching tklines are removed.
50 */
51 static int
52 remove_kline_match(const char *host, const char *user)
53 {
54 struct irc_ssaddr iphost, *piphost;
55 struct MaskItem *conf;
56 int t = 0;
57 int aftype = 0;
58
59 if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST)
60 {
61 #ifdef IPV6
62 if (t == HM_IPV6)
63 aftype = AF_INET6;
64 else
65 #endif
66 aftype = AF_INET;
67 piphost = &iphost;
68 }
69 else
70 piphost = NULL;
71
72 if ((conf = find_conf_by_address(host, piphost, CONF_KLINE, aftype, user, NULL, 0)))
73 {
74 if (IsConfDatabase(conf))
75 {
76 delete_one_address_conf(host, conf);
77 return 1;
78 }
79 }
80
81 return 0;
82 }
83
84 /*! \brief UNKLINE command handler
85 *
86 * \param source_p Pointer to allocated Client struct from which the message
87 * originally comes from. This can be a local or remote client.
88 * \param parc Integer holding the number of supplied arguments.
89 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
90 * pointers.
91 * \note Valid arguments for this command are:
92 * - parv[0] = command
93 * - parv[1] = user\@host mask to UNKLINE
94 * - parv[2] = "ON"
95 * - parv[3] = target server
96 */
97 static int
98 mo_unkline(struct Client *source_p, int parc, char *parv[])
99 {
100 char *target_server = NULL;
101 char *user, *host;
102
103 if (!HasOFlag(source_p, OPER_FLAG_UNKLINE))
104 {
105 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "unkline");
106 return 0;
107 }
108
109 if (EmptyString(parv[1]))
110 {
111 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "UNKLINE");
112 return 0;
113 }
114
115 if (parse_aline("UNKLINE", source_p, parc, parv, 0, &user,
116 &host, NULL, &target_server, NULL) < 0)
117 return 0;
118
119 if (target_server != NULL)
120 {
121 sendto_match_servs(source_p, target_server, CAP_UNKLN,
122 "UNKLINE %s %s %s",
123 target_server, user, host);
124
125 /* Allow ON to apply local unkline as well if it matches */
126 if (match(target_server, me.name))
127 return 0;
128 }
129 else
130 cluster_a_line(source_p, "UNKLINE", CAP_UNKLN, SHARED_UNKLINE,
131 "%s %s", user, host);
132
133 if (remove_kline_match(host, user))
134 {
135 sendto_one_notice(source_p, &me, ":K-Line for [%s@%s] is removed",
136 user, host);
137 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
138 "%s has removed the K-Line for: [%s@%s]",
139 get_oper_name(source_p), user, host);
140 ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]",
141 get_oper_name(source_p), user, host);
142 }
143 else
144 sendto_one_notice(source_p, &me, ":No K-Line for [%s@%s] found",
145 user, host);
146 return 0;
147 }
148
149 /*! \brief UNKLINE command handler
150 *
151 * \param source_p Pointer to allocated Client struct from which the message
152 * originally comes from. This can be a local or remote client.
153 * \param parc Integer holding the number of supplied arguments.
154 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
155 * pointers.
156 * \note Valid arguments for this command are:
157 * - parv[0] = command
158 * - parv[1] = target server
159 * - parv[2] = user mask to UNKLINE
160 * - parv[3] = host mask to UNKLINE
161 */
162 static int
163 me_unkline(struct Client *source_p, int parc, char *parv[])
164 {
165 const char *kuser, *khost;
166
167 if (parc != 4)
168 return 0;
169
170 kuser = parv[2];
171 khost = parv[3];
172
173 if (!IsClient(source_p) || match(parv[1], me.name))
174 return 0;
175
176 if (HasFlag(source_p, FLAGS_SERVICE) ||
177 find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
178 source_p->username, source_p->host,
179 SHARED_UNKLINE))
180 {
181 if (remove_kline_match(khost, kuser))
182 {
183 sendto_one_notice(source_p, &me, ":K-Line for [%s@%s] is removed",
184 kuser, khost);
185 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
186 "%s has removed the K-Line for: [%s@%s]",
187 get_oper_name(source_p), kuser, khost);
188 ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]",
189 get_oper_name(source_p), kuser, khost);
190 }
191 else
192 sendto_one_notice(source_p, &me, ":No K-Line for [%s@%s] found",
193 kuser, khost);
194 }
195
196 return 0;
197 }
198
199 /*! \brief UNKLINE command handler
200 *
201 * \param source_p Pointer to allocated Client struct from which the message
202 * originally comes from. This can be a local or remote client.
203 * \param parc Integer holding the number of supplied arguments.
204 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
205 * pointers.
206 * \note Valid arguments for this command are:
207 * - parv[0] = command
208 * - parv[1] = target server
209 * - parv[2] = user mask to UNKLINE
210 * - parv[3] = host mask to UNKLINE
211 */
212 static int
213 ms_unkline(struct Client *source_p, int parc, char *parv[])
214 {
215 if (parc != 4)
216 return 0;
217
218 sendto_match_servs(source_p, parv[1], CAP_UNKLN,
219 "UNKLINE %s %s %s",
220 parv[1], parv[2], parv[3]);
221
222 return me_unkline(source_p, parc, parv);
223 }
224
225 static struct Message unkline_msgtab =
226 {
227 "UNKLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
228 { m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore }
229 };
230
231 static void
232 module_init(void)
233 {
234 mod_add_cmd(&unkline_msgtab);
235 add_capability("UNKLN", CAP_UNKLN, 1);
236 }
237
238 static void
239 module_exit(void)
240 {
241 mod_del_cmd(&unkline_msgtab);
242 delete_capability("UNKLN");
243 }
244
245 struct module module_entry =
246 {
247 .node = { NULL, NULL, NULL },
248 .name = NULL,
249 .version = "$Revision$",
250 .handle = NULL,
251 .modinit = module_init,
252 .modexit = module_exit,
253 .flags = 0
254 };

Properties

Name Value
svn:keywords Id Revision