ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/core/m_kick.c
Revision: 34
Committed: Sun Oct 2 21:05:51 2005 UTC (18 years, 6 months ago) by lusky
Content type: text/x-csrc
Original Path: ircd-hybrid-7.2/modules/core/m_kick.c
File size: 6826 byte(s)
Log Message:
create 7.2 branch, we can move/rename it as needed.


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

Properties

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