ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/core/m_squit.c
Revision: 3156
Committed: Fri Mar 14 19:57:38 2014 UTC (10 years, 1 month ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/trunk/modules/core/m_squit.c
File size: 4768 byte(s)
Log Message:
- Removed client_p pointers from everywhere

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_squit.c
23 * \brief Includes required functions for processing the SQUIT command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "irc_string.h"
32 #include "ircd.h"
33 #include "numeric.h"
34 #include "conf.h"
35 #include "log.h"
36 #include "s_serv.h"
37 #include "send.h"
38 #include "parse.h"
39 #include "modules.h"
40
41
42 /* mo_squit - SQUIT message handler
43 * parv[0] = command
44 * parv[1] = server name
45 * parv[2] = comment
46 */
47 static int
48 mo_squit(struct Client *source_p, int parc, char *parv[])
49 {
50 struct Client *target_p = NULL;
51 struct Client *p;
52 dlink_node *ptr;
53 char *comment;
54 const char *server;
55 char def_reason[] = CONF_NOREASON;
56
57 if (parc < 2 || EmptyString(parv[1]))
58 {
59 sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "SQUIT");
60 return 0;
61 }
62
63 server = parv[1];
64
65 /* The following allows wild cards in SQUIT. Only
66 * useful when the command is issued by an oper.
67 */
68 DLINK_FOREACH(ptr, global_serv_list.head)
69 {
70 p = ptr->data;
71
72 if (IsServer(p) || IsMe(p))
73 {
74 if (!match(server, p->name))
75 {
76 target_p = p;
77 break;
78 }
79 }
80 }
81
82 if ((target_p == NULL) || IsMe(target_p))
83 {
84 sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, server);
85 return 0;
86 }
87
88 if (!MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_SQUIT_REMOTE))
89 {
90 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "squit:remote");
91 return 0;
92 }
93
94 if (MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_SQUIT))
95 {
96 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "squit");
97 return 0;
98 }
99
100 comment = (parc > 2 && parv[2]) ? parv[2] : def_reason;
101
102 if (strlen(comment) > (size_t)REASONLEN)
103 comment[REASONLEN] = '\0';
104
105 if (MyConnect(target_p))
106 {
107 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
108 "Received SQUIT %s from %s (%s)",
109 target_p->name, get_client_name(source_p, HIDE_IP), comment);
110 ilog(LOG_TYPE_IRCD, "Received SQUIT %s from %s (%s)",
111 target_p->name, get_client_name(source_p, HIDE_IP), comment);
112 }
113
114 exit_client(target_p, source_p, comment);
115 return 0;
116 }
117
118 /** NOTE: I removed wildcard lookups here, because a wildcarded
119 ** SQUIT should/can never happen in ms_squit. -Michael
120 **/
121
122 /* ms_squit - SQUIT message handler
123 * parv[0] = command
124 * parv[1] = server name
125 * parv[2] = comment
126 */
127 static int
128 ms_squit(struct Client *source_p, int parc, char *parv[])
129 {
130 struct Client *target_p = NULL;
131 const char *comment = NULL;
132
133 if (parc < 2 || EmptyString(parv[parc - 1]))
134 return 0;
135
136 if ((target_p = hash_find_server(parv[1])) == NULL)
137 return 0;
138
139 if (!IsServer(target_p) && !IsMe(target_p))
140 return 0;
141
142 if (IsMe(target_p))
143 target_p = source_p->from;
144
145 comment = (parc > 2 && parv[parc - 1]) ? parv[parc - 1] : source_p->name;
146
147 if (MyConnect(target_p))
148 {
149 sendto_wallops_flags(UMODE_WALLOP, &me, "Remote SQUIT %s from %s (%s)",
150 target_p->name, source_p->name, comment);
151 sendto_server(source_p, NOCAPS, NOCAPS,
152 ":%s WALLOPS :Remote SQUIT %s from %s (%s)",
153 me.id, target_p->name, source_p->name, comment);
154 ilog(LOG_TYPE_IRCD, "SQUIT From %s : %s (%s)", source_p->name,
155 target_p->name, comment);
156 }
157
158 exit_client(target_p, source_p, comment);
159 return 0;
160 }
161
162 static struct Message squit_msgtab =
163 {
164 "SQUIT", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
165 { m_unregistered, m_not_oper, ms_squit, m_ignore, mo_squit, m_ignore }
166 };
167
168 static void
169 module_init(void)
170 {
171 mod_add_cmd(&squit_msgtab);
172 }
173
174 static void
175 module_exit(void)
176 {
177 mod_del_cmd(&squit_msgtab);
178 }
179
180 struct module module_entry =
181 {
182 .node = { NULL, NULL, NULL },
183 .name = NULL,
184 .version = "$Revision$",
185 .handle = NULL,
186 .modinit = module_init,
187 .modexit = module_exit,
188 .flags = MODULE_FLAG_CORE
189 };

Properties

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