ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_unkline.c
Revision: 9857
Committed: Fri Jan 1 04:43:22 2021 UTC (4 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 6048 byte(s)
Log Message:
- Bump copyright years

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2021 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_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 "conf_cluster.h"
34 #include "conf_shared.h"
35 #include "hostmask.h"
36 #include "numeric.h"
37 #include "log.h"
38 #include "misc.h"
39 #include "send.h"
40 #include "server_capab.h"
41 #include "parse.h"
42 #include "modules.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 void
52 kline_remove(struct Client *source_p, const struct aline_ctx *aline)
53 {
54 struct irc_ssaddr iphost, *piphost;
55 struct MaskItem *conf;
56
57 if (parse_netmask(aline->host, &iphost, NULL) != HM_HOST)
58 piphost = &iphost;
59 else
60 piphost = NULL;
61
62 if ((conf = find_conf_by_address(aline->host, piphost, CONF_KLINE, aline->user, NULL, 0)) == NULL)
63 {
64 if (IsClient(source_p))
65 sendto_one_notice(source_p, &me, ":No K-Line for [%s@%s] found", aline->user, aline->host);
66
67 return;
68 }
69
70 if (!IsConfDatabase(conf))
71 {
72 if (IsClient(source_p))
73 sendto_one_notice(source_p, &me, ":The K-Line for [%s@%s] is in the configuration file and must be removed by hand",
74 conf->user, conf->host);
75 return;
76 }
77
78 if (IsClient(source_p))
79 sendto_one_notice(source_p, &me, ":K-Line for [%s@%s] is removed",
80 conf->user, conf->host);
81
82 sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
83 "%s has removed the K-Line for: [%s@%s]",
84 get_oper_name(source_p), conf->user, conf->host);
85 ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]",
86 get_oper_name(source_p), conf->user, conf->host);
87
88 delete_one_address_conf(aline->host, conf);
89 }
90
91 /*! \brief UNKLINE command handler
92 *
93 * \param source_p Pointer to allocated Client struct from which the message
94 * originally comes from. This can be a local or remote client.
95 * \param parc Integer holding the number of supplied arguments.
96 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
97 * pointers.
98 * \note Valid arguments for this command are:
99 * - parv[0] = command
100 * - parv[1] = user\@host mask
101 * - parv[2] = "ON"
102 * - parv[3] = target server
103 */
104 static void
105 mo_unkline(struct Client *source_p, int parc, char *parv[])
106 {
107 struct aline_ctx aline = { .add = false, .simple_mask = false };
108
109 if (!HasOFlag(source_p, OPER_FLAG_UNKLINE))
110 {
111 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "unkline");
112 return;
113 }
114
115 if (parse_aline("UNKLINE", source_p, parc, parv, &aline) == false)
116 return;
117
118 if (aline.server)
119 {
120 sendto_match_servs(source_p, aline.server, CAPAB_UNKLN, "UNKLINE %s %s %s",
121 aline.server, aline.user, aline.host);
122
123 /* Allow ON to apply local unkline as well if it matches */
124 if (match(aline.server, me.name))
125 return;
126 }
127 else
128 cluster_distribute(source_p, "UNKLINE", CAPAB_UNKLN, CLUSTER_UNKLINE,
129 "%s %s", aline.user, aline.host);
130
131 kline_remove(source_p, &aline);
132 }
133
134 /*! \brief UNKLINE command handler
135 *
136 * \param source_p Pointer to allocated Client struct from which the message
137 * originally comes from. This can be a local or remote client.
138 * \param parc Integer holding the number of supplied arguments.
139 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
140 * pointers.
141 * \note Valid arguments for this command are:
142 * - parv[0] = command
143 * - parv[1] = target server mask
144 * - parv[2] = user mask
145 * - parv[3] = host mask
146 */
147 static void
148 ms_unkline(struct Client *source_p, int parc, char *parv[])
149 {
150 struct aline_ctx aline =
151 {
152 .add = false,
153 .simple_mask = false,
154 .user = parv[2],
155 .host = parv[3],
156 .server = parv[1]
157 };
158
159 sendto_match_servs(source_p, aline.server, CAPAB_UNKLN, "UNKLINE %s %s %s",
160 aline.server, aline.user, aline.host);
161
162 if (match(aline.server, me.name))
163 return;
164
165 if (HasFlag(source_p, FLAGS_SERVICE) ||
166 shared_find(SHARED_UNKLINE, source_p->servptr->name,
167 source_p->username, source_p->host))
168 kline_remove(source_p, &aline);
169 }
170
171 static struct Message unkline_msgtab =
172 {
173 .cmd = "UNKLINE",
174 .handlers[UNREGISTERED_HANDLER] = { .handler = m_unregistered },
175 .handlers[CLIENT_HANDLER] = { .handler = m_not_oper },
176 .handlers[SERVER_HANDLER] = { .handler = ms_unkline, .args_min = 4 },
177 .handlers[ENCAP_HANDLER] = { .handler = m_ignore },
178 .handlers[OPER_HANDLER] = { .handler = mo_unkline, .args_min = 2 }
179 };
180
181 static void
182 module_init(void)
183 {
184 mod_add_cmd(&unkline_msgtab);
185 capab_add("UNKLN", CAPAB_UNKLN);
186 }
187
188 static void
189 module_exit(void)
190 {
191 mod_del_cmd(&unkline_msgtab);
192 capab_del("UNKLN");
193 }
194
195 struct module module_entry =
196 {
197 .version = "$Revision$",
198 .modinit = module_init,
199 .modexit = module_exit,
200 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision