ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_squit.c
Revision: 2012
Committed: Sun May 12 14:47:26 2013 UTC (13 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 4936 byte(s)
Log Message:
- Removed 'remote', and 'global_kill' oper flags, and added 'connect',
  'squit', and 'kill' flags for better fine-tuning instead. Whether or 
  not a specific action is allowed on a remote server can be controlled
  by appeding the ':remote' flag. For example: 'kill' allows only local
  clients to be killed, whereas 'kill:remote' allows to issue a KILL for
  remote clients

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 2012 if ((!MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_SQUIT_REMOTE)) ||
90     (MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_SQUIT)))
91 adx 30 {
92 michael 1834 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
93 adx 30 me.name, source_p->name);
94     return;
95     }
96    
97     comment = (parc > 2 && parv[2]) ? parv[2] : def_reason;
98    
99     if (strlen(comment) > (size_t)REASONLEN)
100     comment[REASONLEN] = '\0';
101    
102     if (MyConnect(target_p))
103     {
104 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
105     "Received SQUIT %s from %s (%s)",
106 adx 30 target_p->name, get_client_name(source_p, HIDE_IP), comment);
107 michael 1247 ilog(LOG_TYPE_IRCD, "Received SQUIT %s from %s (%s)",
108 adx 30 target_p->name, get_client_name(source_p, HIDE_IP), comment);
109     }
110    
111     exit_client(target_p, source_p, comment);
112     }
113    
114     /** NOTE: I removed wildcard lookups here, because a wildcarded
115     ** SQUIT should/can never happen in ms_squit. -Michael
116     **/
117    
118     /* ms_squit - SQUIT message handler
119     * parv[0] = sender prefix
120     * parv[1] = server name
121     * parv[2] = comment
122     */
123     static void
124     ms_squit(struct Client *client_p, struct Client *source_p,
125     int parc, char *parv[])
126     {
127     struct Client *target_p = NULL;
128 michael 1572 const char *comment = NULL;
129 adx 30
130 michael 1572 if (parc < 2 || EmptyString(parv[parc - 1]))
131 adx 30 return;
132    
133 michael 1572 if ((target_p = hash_find_server(parv[1])) == NULL)
134 adx 30 return;
135    
136 michael 1572 if (!IsServer(target_p) && !IsMe(target_p))
137 adx 30 return;
138    
139 michael 1572 if (IsMe(target_p))
140     target_p = client_p;
141 adx 30
142 michael 1572 comment = (parc > 2 && parv[parc - 1]) ? parv[parc - 1] : client_p->name;
143 adx 30
144     if (MyConnect(target_p))
145     {
146     sendto_wallops_flags(UMODE_WALLOP, &me, "Remote SQUIT %s from %s (%s)",
147     target_p->name, source_p->name, comment);
148 michael 1474 sendto_server(NULL, CAP_TS6, NOCAPS,
149 adx 30 ":%s WALLOPS :Remote SQUIT %s from %s (%s)",
150     me.id, target_p->name, source_p->name, comment);
151 michael 1474 sendto_server(NULL, NOCAPS, CAP_TS6,
152 adx 30 ":%s WALLOPS :Remote SQUIT %s from %s (%s)",
153     me.name, target_p->name, source_p->name, comment);
154 michael 1247 ilog(LOG_TYPE_IRCD, "SQUIT From %s : %s (%s)", source_p->name,
155 adx 30 target_p->name, comment);
156     }
157    
158     exit_client(target_p, source_p, comment);
159     }
160 michael 1230
161     static struct Message squit_msgtab = {
162     "SQUIT", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
163     {m_unregistered, m_not_oper, ms_squit, m_ignore, mo_squit, m_ignore}
164     };
165    
166     static void
167     module_init(void)
168     {
169     mod_add_cmd(&squit_msgtab);
170     }
171    
172     static void
173     module_exit(void)
174     {
175     mod_del_cmd(&squit_msgtab);
176     }
177    
178     struct module module_entry = {
179     .node = { NULL, NULL, NULL },
180     .name = NULL,
181     .version = "$Revision$",
182     .handle = NULL,
183     .modinit = module_init,
184     .modexit = module_exit,
185     .flags = MODULE_FLAG_CORE
186     };

Properties

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