ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_unxline.c
Revision: 9102
Committed: Wed Jan 1 09:58:57 2020 UTC (5 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 5519 byte(s)
Log Message:
- Bump copyright years everywhere

File Contents

# User Rev Content
1 michael 3352 /*
2     * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3     *
4 michael 9102 * Copyright (c) 2003-2020 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 michael 7208 #include "conf_cluster.h"
34 michael 7303 #include "conf_gecos.h"
35 michael 7208 #include "conf_shared.h"
36 michael 3352 #include "numeric.h"
37     #include "log.h"
38     #include "send.h"
39 michael 8165 #include "server_capab.h"
40 michael 3352 #include "parse.h"
41     #include "modules.h"
42     #include "memory.h"
43    
44    
45     /* static int remove_tkline_match(const char *host, const char *user)
46     *
47     * Inputs: gecos
48     * Output: returns YES on success, NO if no tkline removed.
49     * Side effects: Any matching tklines are removed.
50     */
51 michael 8678 static void
52 michael 8985 xline_remove(struct Client *source_p, const struct aline_ctx *aline)
53 michael 3352 {
54 michael 7303 struct GecosItem *gecos;
55 michael 3352
56 michael 8679 if ((gecos = gecos_find(aline->mask, irccmp)) == NULL)
57 michael 3352 {
58 michael 8678 if (IsClient(source_p))
59 michael 8679 sendto_one_notice(source_p, &me, ":No X-Line for %s", aline->mask);
60 michael 8678
61     return;
62 michael 3352 }
63    
64 michael 8678 if (gecos->in_database == false)
65 michael 3352 {
66 michael 4645 if (IsClient(source_p))
67 michael 8678 sendto_one_notice(source_p, &me, ":The X-Line for %s is in the configuration file and must be removed by hand",
68     gecos->mask);
69     return;
70     }
71 michael 4889
72 michael 8678 if (IsClient(source_p))
73     sendto_one_notice(source_p, &me, ":X-Line for [%s] is removed", gecos->mask);
74    
75     sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
76     "%s has removed the X-Line for: [%s]",
77     get_oper_name(source_p), gecos->mask);
78     ilog(LOG_TYPE_RESV, "%s removed X-Line for [%s]",
79     get_oper_name(source_p), gecos->mask);
80    
81 michael 8971 gecos_delete(gecos, false);
82 michael 3352 }
83    
84 michael 3363 /*! \brief UNXLINE command handler
85 michael 3352 *
86 michael 3363 * \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 michael 3365 * - parv[1] = gecos
94 michael 3363 * - parv[2] = "ON"
95     * - parv[3] = target server
96 michael 3352 */
97 michael 9078 static void
98 michael 3352 mo_unxline(struct Client *source_p, int parc, char *parv[])
99     {
100 michael 8679 struct aline_ctx aline = { .add = false, .simple_mask = true };
101 michael 3352
102     if (!HasOFlag(source_p, OPER_FLAG_UNXLINE))
103     {
104     sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "unxline");
105 michael 9078 return;
106 michael 3352 }
107    
108 michael 8669 if (parse_aline("UNXLINE", source_p, parc, parv, &aline) == false)
109 michael 9078 return;
110 michael 3352
111 michael 8669 if (aline.server)
112 michael 3352 {
113 michael 8669 sendto_match_servs(source_p, aline.server, CAPAB_CLUSTER, "UNXLINE %s %s",
114 michael 8679 aline.server, aline.mask);
115 michael 3352
116     /* Allow ON to apply local unxline as well if it matches */
117 michael 8669 if (match(aline.server, me.name))
118 michael 9078 return;
119 michael 3352 }
120     else
121 michael 8669 cluster_distribute(source_p, "UNXLINE", CAPAB_CLUSTER, CLUSTER_UNXLINE, "%s", aline.host);
122 michael 3352
123 michael 8678 xline_remove(source_p, &aline);
124 michael 3352 }
125    
126 michael 3363 /*! \brief UNXLINE command handler
127 michael 3352 *
128 michael 3363 * \param source_p Pointer to allocated Client struct from which the message
129     * originally comes from. This can be a local or remote client.
130     * \param parc Integer holding the number of supplied arguments.
131     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
132     * pointers.
133     * \note Valid arguments for this command are:
134     * - parv[0] = command
135 michael 7096 * - parv[1] = target server mask
136 michael 3791 * - parv[2] = gecos
137 michael 3352 */
138 michael 9078 static void
139 michael 3352 ms_unxline(struct Client *source_p, int parc, char *parv[])
140     {
141 michael 8669 struct aline_ctx aline =
142     {
143     .add = false,
144 michael 8679 .simple_mask = true,
145     .mask = parv[2],
146     .server = parv[1]
147 michael 8669 };
148    
149     if (parc != 3 || EmptyString(parv[parc - 1]))
150 michael 9078 return;
151 michael 3352
152 michael 8669 sendto_match_servs(source_p, aline.server, CAPAB_CLUSTER, "UNXLINE %s %s",
153 michael 8679 aline.server, aline.mask);
154 michael 3352
155 michael 8669 if (match(aline.server, me.name))
156 michael 9078 return;
157 michael 3352
158 michael 3368 if (HasFlag(source_p, FLAGS_SERVICE) ||
159 michael 7208 shared_find(SHARED_UNXLINE, source_p->servptr->name,
160     source_p->username, source_p->host))
161 michael 8678 xline_remove(source_p, &aline);
162 michael 3352 }
163    
164     static struct Message unxline_msgtab =
165     {
166 michael 5880 .cmd = "UNXLINE",
167     .args_min = 2,
168     .args_max = MAXPARA,
169     .handlers[UNREGISTERED_HANDLER] = m_unregistered,
170     .handlers[CLIENT_HANDLER] = m_not_oper,
171     .handlers[SERVER_HANDLER] = ms_unxline,
172     .handlers[ENCAP_HANDLER] = m_ignore,
173     .handlers[OPER_HANDLER] = mo_unxline
174 michael 3352 };
175    
176     static void
177     module_init(void)
178     {
179     mod_add_cmd(&unxline_msgtab);
180     }
181    
182     static void
183     module_exit(void)
184     {
185     mod_del_cmd(&unxline_msgtab);
186     }
187    
188     struct module module_entry =
189     {
190 michael 3353 .version = "$Revision$",
191 michael 3352 .modinit = module_init,
192     .modexit = module_exit,
193     };

Properties

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