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