ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_kick.c
Revision: 1834
Committed: Fri Apr 19 19:50:27 2013 UTC (12 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 6871 byte(s)
Log Message:
- Revert to -r1831

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_kick.c: Kicks a user from a channel.
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 "channel.h"
28     #include "channel_mode.h"
29     #include "client.h"
30     #include "irc_string.h"
31     #include "ircd.h"
32     #include "numeric.h"
33     #include "send.h"
34     #include "modules.h"
35     #include "parse.h"
36     #include "hash.h"
37     #include "packet.h"
38     #include "s_serv.h"
39    
40    
41     /* m_kick()
42     * parv[0] = sender prefix
43     * parv[1] = channel
44     * parv[2] = client to kick
45     * parv[3] = kick comment
46     */
47     static void
48     m_kick(struct Client *client_p, struct Client *source_p,
49     int parc, char *parv[])
50     {
51     struct Client *who;
52     struct Channel *chptr;
53     int chasing = 0;
54     char *comment;
55     char *name;
56     char *p = NULL;
57     char *user;
58     const char *from, *to;
59     struct Membership *ms = NULL;
60     struct Membership *ms_target;
61    
62     if (!MyConnect(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
63     {
64     from = me.id;
65     to = source_p->id;
66     }
67     else
68     {
69     from = me.name;
70     to = source_p->name;
71     }
72    
73 michael 885 if (EmptyString(parv[2]))
74 adx 30 {
75 michael 1834 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
76 adx 30 from, to, "KICK");
77     return;
78     }
79    
80     if (MyClient(source_p) && !IsFloodDone(source_p))
81     flood_endgrace(source_p);
82    
83     comment = (EmptyString(parv[3])) ? parv[2] : parv[3];
84     if (strlen(comment) > (size_t)KICKLEN)
85     comment[KICKLEN] = '\0';
86    
87     name = parv[1];
88     while (*name == ',')
89     name++;
90    
91     if ((p = strchr(name,',')) != NULL)
92     *p = '\0';
93     if (*name == '\0')
94     return;
95    
96     if ((chptr = hash_find_channel(name)) == NULL)
97     {
98 michael 1834 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
99 adx 30 from, to, name);
100     return;
101     }
102    
103 michael 1219 if (!IsServer(source_p) && !HasFlag(source_p, FLAGS_SERVICE))
104 adx 30 {
105     if ((ms = find_channel_link(source_p, chptr)) == NULL)
106     {
107     if (MyConnect(source_p))
108     {
109 michael 1834 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
110 adx 30 me.name, source_p->name, name);
111     return;
112     }
113     }
114    
115     if (!has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
116     {
117     /* was a user, not a server, and user isn't seen as a chanop here */
118     if (MyConnect(source_p))
119     {
120     /* user on _my_ server, with no chanops.. so go away */
121 michael 1834 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
122 adx 30 me.name, source_p->name, name);
123     return;
124     }
125    
126     if (chptr->channelts == 0)
127     {
128     /* If its a TS 0 channel, do it the old way */
129 michael 1834 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
130 adx 30 from, to, name);
131     return;
132     }
133    
134     /* Its a user doing a kick, but is not showing as chanop locally
135     * its also not a user ON -my- server, and the channel has a TS.
136     * There are two cases we can get to this point then...
137     *
138     * 1) connect burst is happening, and for some reason a legit
139     * op has sent a KICK, but the SJOIN hasn't happened yet or
140     * been seen. (who knows.. due to lag...)
141     *
142     * 2) The channel is desynced. That can STILL happen with TS
143     *
144     * Now, the old code roger wrote, would allow the KICK to
145     * go through. Thats quite legit, but lets weird things like
146     * KICKS by users who appear not to be chanopped happen,
147     * or even neater, they appear not to be on the channel.
148     * This fits every definition of a desync, doesn't it? ;-)
149     * So I will allow the KICK, otherwise, things are MUCH worse.
150     * But I will warn it as a possible desync.
151     *
152     * -Dianora
153     */
154     }
155     }
156    
157     user = parv[2];
158    
159     while (*user == ',')
160     user++;
161    
162     if ((p = strchr(user, ',')) != NULL)
163     *p = '\0';
164    
165     if (*user == '\0')
166     return;
167    
168     if ((who = find_chasing(client_p, source_p, user, &chasing)) == NULL)
169     return;
170    
171     if ((ms_target = find_channel_link(who, chptr)) != NULL)
172     {
173     #ifdef HALFOPS
174     /* half ops cannot kick other halfops on private channels */
175     if (has_member_flags(ms, CHFL_HALFOP) && !has_member_flags(ms, CHFL_CHANOP))
176     {
177     if (((chptr->mode.mode & MODE_PRIVATE) && has_member_flags(ms_target,
178     CHFL_CHANOP|CHFL_HALFOP)) || has_member_flags(ms_target, CHFL_CHANOP))
179     {
180 michael 1834 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
181 adx 30 me.name, source_p->name, name);
182     return;
183     }
184     }
185     #endif
186    
187     /* jdc
188     * - In the case of a server kicking a user (i.e. CLEARCHAN),
189     * the kick should show up as coming from the server which did
190     * the kick.
191     * - Personally, flame and I believe that server kicks shouldn't
192     * be sent anyways. Just waiting for some oper to abuse it...
193     */
194     if (IsServer(source_p))
195 michael 1011 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s KICK %s %s :%s",
196 adx 30 source_p->name, name, who->name, comment);
197     else
198 michael 1011 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s KICK %s %s :%s",
199 adx 30 source_p->name, source_p->username,
200     source_p->host, name, who->name, comment);
201    
202 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
203 adx 30 ":%s KICK %s %s :%s",
204     ID(source_p), chptr->chname, ID(who), comment);
205 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
206 adx 30 ":%s KICK %s %s :%s", source_p->name, chptr->chname,
207     who->name, comment);
208    
209     remove_user_from_channel(ms_target);
210     }
211     else
212 michael 1834 sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL),
213 adx 30 from, to, user, name);
214     }
215 michael 1230
216     static struct Message kick_msgtab = {
217     "KICK", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
218     {m_unregistered, m_kick, m_kick, m_ignore, m_kick, m_ignore}
219     };
220    
221     static void
222     module_init(void)
223     {
224     mod_add_cmd(&kick_msgtab);
225     }
226    
227     static void
228     module_exit(void)
229     {
230     mod_del_cmd(&kick_msgtab);
231     }
232    
233     struct module module_entry = {
234     .node = { NULL, NULL, NULL },
235     .name = NULL,
236     .version = "$Revision$",
237     .handle = NULL,
238     .modinit = module_init,
239     .modexit = module_exit,
240     .flags = MODULE_FLAG_CORE
241     };

Properties

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