ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_undline.c
Revision: 4653
Committed: Mon Sep 22 15:43:43 2014 UTC (10 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 6207 byte(s)
Log Message:
- m_undline.c: fixed broken /dline remote.server

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file m_undline.c
23 * \brief Includes required functions for processing the UNDLINE 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 "conf.h"
32 #include "ircd.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_tdline_match(const char *host, const char *user)
47 * Input: An ip to undline.
48 * Output: returns YES on success, NO if no tdline removed.
49 * Side effects: Any matching tdlines are removed.
50 */
51 static int
52 remove_dline_match(const char *host)
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 if (t == HM_IPV6)
62 aftype = AF_INET6;
63 else
64 aftype = AF_INET;
65 piphost = &iphost;
66 }
67 else
68 piphost = NULL;
69
70 if ((conf = find_conf_by_address(host, piphost, CONF_DLINE, aftype, NULL, NULL, 0)))
71 {
72 if (IsConfDatabase(conf))
73 {
74 delete_one_address_conf(host, conf);
75 return 1;
76 }
77 }
78
79 return 0;
80 }
81
82 /*! \brief UNDLINE command handler
83 *
84 * \param source_p Pointer to allocated Client struct from which the message
85 * originally comes from. This can be a local or remote client.
86 * \param parc Integer holding the number of supplied arguments.
87 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
88 * pointers.
89 * \note Valid arguments for this command are:
90 * - parv[0] = command
91 * - parv[1] = IP address
92 * - parv[2] = "ON"
93 * - parv[3] = target server
94 */
95 static int
96 mo_undline(struct Client *source_p, int parc, char *parv[])
97 {
98 char *addr = NULL;
99 char *target_server = NULL;
100
101 if (!HasOFlag(source_p, OPER_FLAG_UNDLINE))
102 {
103 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "undline");
104 return 0;
105 }
106
107 if (parc < 2 || EmptyString(parv[1]))
108 {
109 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "UNDLINE");
110 return 0;
111 }
112
113 if (parse_aline("UNDLINE", source_p, parc, parv, 0, &addr,
114 NULL, NULL, &target_server, NULL) < 0)
115 return 0;
116
117 if (target_server)
118 {
119 sendto_match_servs(source_p, target_server, CAP_UNDLN,
120 "UNDLINE %s %s", target_server, addr);
121
122 /* Allow ON to apply local undline as well if it matches */
123 if (match(target_server, me.name))
124 return 0;
125 }
126 else
127 cluster_a_line(source_p, "UNDLINE", CAP_UNDLN, SHARED_UNDLINE, "%s", addr);
128
129 if (remove_dline_match(addr))
130 {
131 sendto_one_notice(source_p, &me, ":D-Line for [%s] is removed", addr);
132 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
133 "%s has removed the D-Line for: [%s]",
134 get_oper_name(source_p), addr);
135 ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]",
136 get_oper_name(source_p), addr);
137 }
138 else
139 sendto_one_notice(source_p, &me, ":No D-Line for [%s] found", addr);
140
141 return 0;
142 }
143
144 /*! \brief UNDLINE command handler
145 *
146 * \param source_p Pointer to allocated Client struct from which the message
147 * originally comes from. This can be a local or remote client.
148 * \param parc Integer holding the number of supplied arguments.
149 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
150 * pointers.
151 * \note Valid arguments for this command are:
152 * - parv[0] = command
153 * - parv[1] = target server
154 * - parv[2] = IP address
155 */
156 static int
157 ms_undline(struct Client *source_p, int parc, char *parv[])
158 {
159 const char *addr = parv[2];
160
161 if (parc != 3 || EmptyString(parv[2]))
162 return 0;
163
164 sendto_match_servs(source_p, parv[1], CAP_UNDLN, "UNDLINE %s %s",
165 parv[1], parv[2]);
166
167 if (match(parv[1], me.name))
168 return 0;
169
170 if (HasFlag(source_p, FLAGS_SERVICE) ||
171 find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
172 source_p->username, source_p->host,
173 SHARED_UNDLINE))
174 {
175 if (remove_dline_match(addr))
176 {
177 if (IsClient(source_p))
178 sendto_one_notice(source_p, &me, ":D-Line for [%s] is removed", addr);
179 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
180 "%s has removed the D-Line for: [%s]",
181 get_oper_name(source_p), addr);
182 ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]",
183 get_oper_name(source_p), addr);
184 }
185 else if (IsClient(source_p))
186 sendto_one_notice(source_p, &me, ":No D-Line for [%s] found", addr);
187 }
188
189 return 0;
190 }
191
192 static struct Message undline_msgtab =
193 {
194 "UNDLINE", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
195 { m_unregistered, m_not_oper, ms_undline, m_ignore, mo_undline, m_ignore }
196 };
197
198 static void
199 module_init(void)
200 {
201 mod_add_cmd(&undline_msgtab);
202 add_capability("UNDLN", CAP_UNDLN, 1);
203 }
204
205 static void
206 module_exit(void)
207 {
208 mod_del_cmd(&undline_msgtab);
209 delete_capability("UNDLN");
210 }
211
212 struct module module_entry =
213 {
214 .node = { NULL, NULL, NULL },
215 .name = NULL,
216 .version = "$Revision$",
217 .handle = NULL,
218 .modinit = module_init,
219 .modexit = module_exit,
220 .flags = 0
221 };

Properties

Name Value
svn:keywords Id Revision