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 |
michael |
3347 |
#include "server.h" |
41 |
adx |
30 |
|
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 |
michael |
3198 |
char reason[KICKLEN + 1] = ""; |
53 |
michael |
3196 |
struct Client *target_p = NULL; |
54 |
michael |
3198 |
struct Channel *chptr = NULL; |
55 |
|
|
struct Membership *ms_source = NULL; |
56 |
|
|
struct Membership *ms_target = NULL; |
57 |
adx |
30 |
|
58 |
michael |
885 |
if (EmptyString(parv[2])) |
59 |
adx |
30 |
{ |
60 |
michael |
3109 |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "KICK"); |
61 |
michael |
2820 |
return 0; |
62 |
adx |
30 |
} |
63 |
|
|
|
64 |
michael |
3204 |
if (!IsFloodDone(source_p)) |
65 |
adx |
30 |
flood_endgrace(source_p); |
66 |
|
|
|
67 |
michael |
3198 |
if ((chptr = hash_find_channel(parv[1])) == NULL) |
68 |
adx |
30 |
{ |
69 |
michael |
3198 |
sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[1]); |
70 |
michael |
2820 |
return 0; |
71 |
adx |
30 |
} |
72 |
|
|
|
73 |
michael |
3204 |
if ((ms_source = find_channel_link(source_p, chptr)) == NULL) |
74 |
adx |
30 |
{ |
75 |
michael |
3204 |
sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, chptr->chname); |
76 |
|
|
return 0; |
77 |
|
|
} |
78 |
adx |
30 |
|
79 |
michael |
3204 |
if (!has_member_flags(ms_source, CHFL_CHANOP|CHFL_HALFOP)) |
80 |
|
|
{ |
81 |
|
|
sendto_one_numeric(source_p, &me, ERR_CHANOPRIVSNEEDED, chptr->chname); |
82 |
|
|
return 0; |
83 |
adx |
30 |
} |
84 |
|
|
|
85 |
michael |
3198 |
if ((target_p = find_chasing(source_p, parv[2])) == NULL) |
86 |
michael |
3204 |
return 0; /* find_chasing sends ERR_NOSUCHNICK */ |
87 |
|
|
|
88 |
|
|
if (!(ms_target = find_channel_link(target_p, chptr))) |
89 |
|
|
{ |
90 |
|
|
sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->chname); |
91 |
michael |
2820 |
return 0; |
92 |
michael |
3204 |
} |
93 |
adx |
30 |
|
94 |
michael |
3204 |
#ifdef HALFOPS |
95 |
|
|
/* half ops cannot kick other halfops on private channels */ |
96 |
|
|
if (has_member_flags(ms_source, CHFL_HALFOP) && !has_member_flags(ms_source, CHFL_CHANOP)) |
97 |
adx |
30 |
{ |
98 |
michael |
3716 |
if (has_member_flags(ms_target, CHFL_CHANOP|CHFL_HALFOP)) |
99 |
adx |
30 |
{ |
100 |
michael |
3204 |
sendto_one_numeric(source_p, &me, ERR_CHANOPRIVSNEEDED, chptr->chname); |
101 |
|
|
return 0; |
102 |
adx |
30 |
} |
103 |
michael |
3204 |
} |
104 |
adx |
30 |
#endif |
105 |
michael |
3204 |
if (!EmptyString(parv[3])) |
106 |
|
|
strlcpy(reason, parv[3], sizeof(reason)); |
107 |
|
|
else |
108 |
|
|
strlcpy(reason, source_p->name, sizeof(reason)); |
109 |
adx |
30 |
|
110 |
michael |
3204 |
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s KICK %s %s :%s", |
111 |
|
|
source_p->name, source_p->username, |
112 |
|
|
source_p->host, chptr->chname, |
113 |
|
|
target_p->name, reason); |
114 |
|
|
sendto_server(source_p, NOCAPS, NOCAPS, ":%s KICK %s %s :%s", |
115 |
|
|
source_p->id, chptr->chname, |
116 |
|
|
target_p->id, reason); |
117 |
|
|
remove_user_from_channel(ms_target); |
118 |
|
|
return 0; |
119 |
|
|
} |
120 |
adx |
30 |
|
121 |
michael |
3204 |
/* ms_kick() |
122 |
|
|
* parv[0] = command |
123 |
|
|
* parv[1] = channel |
124 |
|
|
* parv[2] = client to kick |
125 |
|
|
* parv[3] = kick comment |
126 |
|
|
*/ |
127 |
|
|
static int |
128 |
|
|
ms_kick(struct Client *source_p, int parc, char *parv[]) |
129 |
|
|
{ |
130 |
|
|
char reason[KICKLEN + 1] = ""; |
131 |
|
|
struct Client *target_p = NULL; |
132 |
|
|
struct Channel *chptr = NULL; |
133 |
|
|
struct Membership *ms_target = NULL; |
134 |
|
|
|
135 |
|
|
if (EmptyString(parv[2])) |
136 |
|
|
return 0; |
137 |
|
|
|
138 |
|
|
if ((chptr = hash_find_channel(parv[1])) == NULL) |
139 |
|
|
return 0; |
140 |
|
|
|
141 |
michael |
3432 |
if ((target_p = find_person(source_p, parv[2])) == NULL) |
142 |
michael |
3204 |
return 0; |
143 |
|
|
|
144 |
|
|
if ((ms_target = find_channel_link(target_p, chptr)) == NULL) |
145 |
|
|
return 0; |
146 |
|
|
|
147 |
|
|
if (!EmptyString(parv[3])) |
148 |
|
|
strlcpy(reason, parv[3], sizeof(reason)); |
149 |
adx |
30 |
else |
150 |
michael |
3204 |
strlcpy(reason, source_p->name, sizeof(reason)); |
151 |
michael |
3109 |
|
152 |
michael |
3204 |
if (IsServer(source_p)) |
153 |
|
|
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s KICK %s %s :%s", |
154 |
|
|
source_p->name, chptr->chname, |
155 |
|
|
target_p->name, reason); |
156 |
|
|
else |
157 |
|
|
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s KICK %s %s :%s", |
158 |
|
|
source_p->name, source_p->username, |
159 |
|
|
source_p->host, chptr->chname, |
160 |
|
|
target_p->name, reason); |
161 |
|
|
|
162 |
|
|
sendto_server(source_p, NOCAPS, NOCAPS, ":%s KICK %s %s :%s", |
163 |
|
|
source_p->id, chptr->chname, |
164 |
|
|
target_p->id, reason); |
165 |
|
|
remove_user_from_channel(ms_target); |
166 |
michael |
2820 |
return 0; |
167 |
adx |
30 |
} |
168 |
michael |
1230 |
|
169 |
michael |
2820 |
static struct Message kick_msgtab = |
170 |
|
|
{ |
171 |
michael |
1230 |
"KICK", 0, 0, 3, MAXPARA, MFLG_SLOW, 0, |
172 |
michael |
3204 |
{ m_unregistered, m_kick, ms_kick, m_ignore, m_kick, m_ignore } |
173 |
michael |
1230 |
}; |
174 |
|
|
|
175 |
|
|
static void |
176 |
|
|
module_init(void) |
177 |
|
|
{ |
178 |
|
|
mod_add_cmd(&kick_msgtab); |
179 |
|
|
} |
180 |
|
|
|
181 |
|
|
static void |
182 |
|
|
module_exit(void) |
183 |
|
|
{ |
184 |
|
|
mod_del_cmd(&kick_msgtab); |
185 |
|
|
} |
186 |
|
|
|
187 |
michael |
2820 |
struct module module_entry = |
188 |
|
|
{ |
189 |
michael |
1230 |
.node = { NULL, NULL, NULL }, |
190 |
|
|
.name = NULL, |
191 |
|
|
.version = "$Revision$", |
192 |
|
|
.handle = NULL, |
193 |
|
|
.modinit = module_init, |
194 |
|
|
.modexit = module_exit, |
195 |
|
|
.flags = MODULE_FLAG_CORE |
196 |
|
|
}; |