ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.1.12/modules/core/m_squit.c
Revision: 1867
Committed: Thu Apr 25 18:01:53 2013 UTC (13 years, 5 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/branches/8.1.x/modules/core/m_squit.c
File size: 4857 byte(s)
Log Message:
- Create 8.1.x branch

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_squit.c: Makes a server quit.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #include "client.h"
28     #include "hash.h"
29     #include "irc_string.h"
30     #include "ircd.h"
31     #include "numeric.h"
32 michael 1309 #include "conf.h"
33     #include "log.h"
34 adx 30 #include "s_serv.h"
35     #include "send.h"
36     #include "parse.h"
37     #include "modules.h"
38    
39    
40     /* mo_squit - SQUIT message handler
41     * parv[0] = sender prefix
42     * parv[1] = server name
43     * parv[2] = comment
44     */
45     static void
46     mo_squit(struct Client *client_p, struct Client *source_p,
47     int parc, char *parv[])
48     {
49     struct Client *target_p = NULL;
50     struct Client *p;
51     dlink_node *ptr;
52     char *comment;
53     const char *server;
54 michael 1794 char def_reason[] = CONF_NOREASON;
55 adx 30
56     if (parc < 2 || EmptyString(parv[1]))
57     {
58 michael 1834 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
59 adx 30 me.name, source_p->name, "SQUIT");
60     return;
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 michael 1652 if (!match(server, p->name))
75 adx 30 {
76     target_p = p;
77     break;
78     }
79     }
80     }
81    
82     if ((target_p == NULL) || IsMe(target_p))
83     {
84 michael 1834 sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
85 adx 30 me.name, source_p->name, server);
86     return;
87     }
88    
89 michael 1219 if (!MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_REMOTE))
90 adx 30 {
91 michael 1834 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
92 adx 30 me.name, source_p->name);
93     return;
94     }
95    
96     comment = (parc > 2 && parv[2]) ? parv[2] : def_reason;
97    
98     if (strlen(comment) > (size_t)REASONLEN)
99     comment[REASONLEN] = '\0';
100    
101     if (MyConnect(target_p))
102     {
103 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
104     "Received SQUIT %s from %s (%s)",
105 adx 30 target_p->name, get_client_name(source_p, HIDE_IP), comment);
106 michael 1247 ilog(LOG_TYPE_IRCD, "Received SQUIT %s from %s (%s)",
107 adx 30 target_p->name, get_client_name(source_p, HIDE_IP), comment);
108     }
109    
110     exit_client(target_p, source_p, comment);
111     }
112    
113     /** NOTE: I removed wildcard lookups here, because a wildcarded
114     ** SQUIT should/can never happen in ms_squit. -Michael
115     **/
116    
117     /* ms_squit - SQUIT message handler
118     * parv[0] = sender prefix
119     * parv[1] = server name
120     * parv[2] = comment
121     */
122     static void
123     ms_squit(struct Client *client_p, struct Client *source_p,
124     int parc, char *parv[])
125     {
126     struct Client *target_p = NULL;
127 michael 1572 const char *comment = NULL;
128 adx 30
129 michael 1572 if (parc < 2 || EmptyString(parv[parc - 1]))
130 adx 30 return;
131    
132 michael 1572 if ((target_p = hash_find_server(parv[1])) == NULL)
133 adx 30 return;
134    
135 michael 1572 if (!IsServer(target_p) && !IsMe(target_p))
136 adx 30 return;
137    
138 michael 1572 if (IsMe(target_p))
139     target_p = client_p;
140 adx 30
141 michael 1572 comment = (parc > 2 && parv[parc - 1]) ? parv[parc - 1] : client_p->name;
142 adx 30
143     if (MyConnect(target_p))
144     {
145     sendto_wallops_flags(UMODE_WALLOP, &me, "Remote SQUIT %s from %s (%s)",
146     target_p->name, source_p->name, comment);
147 michael 1474 sendto_server(NULL, CAP_TS6, NOCAPS,
148 adx 30 ":%s WALLOPS :Remote SQUIT %s from %s (%s)",
149     me.id, target_p->name, source_p->name, comment);
150 michael 1474 sendto_server(NULL, NOCAPS, CAP_TS6,
151 adx 30 ":%s WALLOPS :Remote SQUIT %s from %s (%s)",
152     me.name, target_p->name, source_p->name, comment);
153 michael 1247 ilog(LOG_TYPE_IRCD, "SQUIT From %s : %s (%s)", source_p->name,
154 adx 30 target_p->name, comment);
155     }
156    
157     exit_client(target_p, source_p, comment);
158     }
159 michael 1230
160     static struct Message squit_msgtab = {
161     "SQUIT", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
162     {m_unregistered, m_not_oper, ms_squit, m_ignore, mo_squit, m_ignore}
163     };
164    
165     static void
166     module_init(void)
167     {
168     mod_add_cmd(&squit_msgtab);
169     }
170    
171     static void
172     module_exit(void)
173     {
174     mod_del_cmd(&squit_msgtab);
175     }
176    
177     struct module module_entry = {
178     .node = { NULL, NULL, NULL },
179     .name = NULL,
180     .version = "$Revision$",
181     .handle = NULL,
182     .modinit = module_init,
183     .modexit = module_exit,
184     .flags = MODULE_FLAG_CORE
185     };

Properties

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