ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_unxline.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: 5409 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) 2003-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_unxline.c
23 * \brief Includes required functions for processing the UNXLINE 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 "numeric.h"
34 #include "log.h"
35 #include "send.h"
36 #include "server.h"
37 #include "parse.h"
38 #include "modules.h"
39 #include "conf_db.h"
40 #include "memory.h"
41
42
43 /* static int remove_tkline_match(const char *host, const char *user)
44 *
45 * Inputs: gecos
46 * Output: returns YES on success, NO if no tkline removed.
47 * Side effects: Any matching tklines are removed.
48 */
49 static int
50 remove_xline_match(const char *gecos)
51 {
52 dlink_node *ptr = NULL, *next_ptr = NULL;
53
54 DLINK_FOREACH_SAFE(ptr, next_ptr, xconf_items.head)
55 {
56 struct MaskItem *conf = ptr->data;
57
58 if (!IsConfDatabase(conf))
59 continue;
60
61 if (!irccmp(gecos, conf->name))
62 {
63 conf_free(conf);
64 return 1;
65 }
66 }
67
68 return 0;
69 }
70
71 static void
72 remove_xline(struct Client *source_p, const char *gecos)
73 {
74 if (remove_xline_match(gecos))
75 {
76 sendto_one_notice(source_p, &me, ":X-Line for [%s] is removed", gecos);
77 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
78 "%s has removed the X-Line for: [%s]",
79 get_oper_name(source_p), gecos);
80 ilog(LOG_TYPE_XLINE, "%s removed X-Line for [%s]",
81 get_oper_name(source_p), gecos);
82 }
83 else
84 sendto_one_notice(source_p, &me, ":No X-Line for %s", gecos);
85 }
86
87 /*! \brief UNXLINE command handler
88 *
89 * \param source_p Pointer to allocated Client struct from which the message
90 * originally comes from. This can be a local or remote client.
91 * \param parc Integer holding the number of supplied arguments.
92 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
93 * pointers.
94 * \note Valid arguments for this command are:
95 * - parv[0] = command
96 * - parv[1] = gecos to UNXLINE
97 * - parv[2] = "ON"
98 * - parv[3] = target server
99 */
100 static int
101 mo_unxline(struct Client *source_p, int parc, char *parv[])
102 {
103 char *gecos = NULL;
104 char *target_server = NULL;
105
106 if (!HasOFlag(source_p, OPER_FLAG_UNXLINE))
107 {
108 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "unxline");
109 return 0;
110 }
111
112 /* UNXLINE bill ON irc.server.com */
113 if (parse_aline("UNXLINE", source_p, parc, parv, 0, &gecos,
114 NULL, NULL, &target_server, NULL) < 0)
115 return 0;
116
117 if (target_server != NULL)
118 {
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 cluster_a_line(source_p, "UNXLINE", CAP_CLUSTER, SHARED_UNXLINE,
128 "%s", gecos);
129
130 remove_xline(source_p, gecos);
131 return 0;
132 }
133
134 /*! \brief UNXLINE 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
144 * - parv[2] = gecos to UNXLINE
145 */
146 static int
147 ms_unxline(struct Client *source_p, int parc, char *parv[])
148 {
149 if (parc != 3)
150 return 0;
151
152 if (!IsClient(source_p) || EmptyString(parv[2]))
153 return 0;
154
155 sendto_match_servs(source_p, parv[1], CAP_CLUSTER,
156 "UNXLINE %s %s", parv[1], parv[2]);
157
158 if (match(parv[1], me.name))
159 return 0;
160
161 if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
162 source_p->username, source_p->host,
163 SHARED_UNXLINE))
164 remove_xline(source_p, parv[2]);
165 return 0;
166 }
167
168 static struct Message unxline_msgtab =
169 {
170 "UNXLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
171 { m_unregistered, m_not_oper, ms_unxline, m_ignore, mo_unxline, m_ignore }
172 };
173
174 static void
175 module_init(void)
176 {
177 mod_add_cmd(&unxline_msgtab);
178 }
179
180 static void
181 module_exit(void)
182 {
183 mod_del_cmd(&unxline_msgtab);
184 }
185
186 struct module module_entry =
187 {
188 .node = { NULL, NULL, NULL },
189 .name = NULL,
190 .version = "$Revision$",
191 .handle = NULL,
192 .modinit = module_init,
193 .modexit = module_exit,
194 .flags = 0
195 };

Properties

Name Value
svn:keywords Id Revision