ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_kick.c
Revision: 3186
Committed: Thu Mar 20 18:09:34 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 6214 byte(s)
Log Message:
- Get rid of the ID() macro

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

Properties

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