ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_kick.c
Revision: 3192
Committed: Sun Mar 23 19:46:39 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 6185 byte(s)
Log Message:
- Fixed compile error in ms_sid()
- Cleaned up find_chasing(). Removed useless third 'chasing' argument.

File Contents

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

Properties

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