]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blame - addopkickcmd.patch
Add opernowildbadchan patch - disallows wildcards in badchan set by oper
[irc/quakenet/snircd-patchqueue.git] / addopkickcmd.patch
CommitLineData
715c825d
CP
1add opkick command, similar to opmode command, but then for kicking
2priv controlled by LOCAL_OPMODE and OPMODE
3feature controlled by OPKICK (disabled by default), new p10 token OK
4if implemented, it must not be enabled until ALL servers and services are upgraded
5generates HACK(4) snomask notice for accountability with oper as source
6probably needs some work (for one i simply copied the header from m_kick.c)
7
88a737db 8diff -r 8d3cf5a69cf8 include/handlers.h
9--- a/include/handlers.h Mon Jan 12 19:30:23 2009 +0100
10+++ b/include/handlers.h Mon Jan 12 20:26:49 2009 +0100
715c825d
CP
11@@ -167,6 +167,7 @@
12 extern int mo_kill(struct Client*, struct Client*, int, char*[]);
13 extern int mo_notice(struct Client*, struct Client*, int, char*[]);
14 extern int mo_oper(struct Client*, struct Client*, int, char*[]);
15+extern int mo_opkick(struct Client*, struct Client*, int, char*[]);
16 extern int mo_opmode(struct Client*, struct Client*, int, char*[]);
17 extern int mo_ping(struct Client*, struct Client*, int, char*[]);
18 extern int mo_privmsg(struct Client*, struct Client*, int, char*[]);
19@@ -216,6 +217,7 @@
20 extern int ms_nick(struct Client*, struct Client*, int, char*[]);
21 extern int ms_notice(struct Client*, struct Client*, int, char*[]);
22 extern int ms_oper(struct Client*, struct Client*, int, char*[]);
23+extern int ms_opkick(struct Client*, struct Client*, int, char*[]);
24 extern int ms_opmode(struct Client*, struct Client*, int, char*[]);
25 extern int ms_part(struct Client*, struct Client*, int, char*[]);
26 extern int ms_ping(struct Client*, struct Client*, int, char*[]);
88a737db 27diff -r 8d3cf5a69cf8 include/ircd_features.h
28--- a/include/ircd_features.h Mon Jan 12 19:30:23 2009 +0100
29+++ b/include/ircd_features.h Mon Jan 12 20:26:49 2009 +0100
715c825d
CP
30@@ -105,6 +105,7 @@
31 /* features that affect all operators */
32 FEAT_EXTENDED_CHECKCMD,
33 FEAT_CONFIG_OPERCMDS,
34+ FEAT_OPKICK,
35 FEAT_SETHOST,
36 FEAT_SETHOST_USER,
37 FEAT_SETHOST_AUTO,
88a737db 38diff -r 8d3cf5a69cf8 include/msg.h
39--- a/include/msg.h Mon Jan 12 19:30:23 2009 +0100
40+++ b/include/msg.h Mon Jan 12 20:26:49 2009 +0100
715c825d
CP
41@@ -236,6 +236,10 @@
42 #define TOK_KICK "K"
43 #define CMD_KICK MSG_KICK, TOK_KICK
44
45+#define MSG_OPKICK "OPKICK" /* OPKICK */
46+#define TOK_OPKICK "OK"
47+#define CMD_OPKICK MSG_OPKICK, TOK_OPKICK
48+
49 #define MSG_USERHOST "USERHOST" /* USER -> USRH */
50 #define TOK_USERHOST "USERHOST"
51 #define CMD_USERHOST MSG_USERHOST, TOK_USERHOST
88a737db 52diff -r 8d3cf5a69cf8 ircd/Makefile.in
53--- a/ircd/Makefile.in Mon Jan 12 19:30:23 2009 +0100
54+++ b/ircd/Makefile.in Mon Jan 12 20:26:49 2009 +0100
715c825d
CP
55@@ -151,6 +151,7 @@
56 m_nick.c \
57 m_notice.c \
58 m_oper.c \
59+ m_opkick.c \
60 m_opmode.c \
61 m_part.c \
62 m_pass.c \
63@@ -884,6 +885,14 @@
64 ../include/ircd_features.h ../include/s_conf.h ../include/client.h \
65 ../include/s_debug.h ../include/s_user.h ../include/s_misc.h \
66 ../include/send.h
67+m_opkick.o: m_opkick.c ../config.h ../include/channel.h \
68+ ../include/ircd_defs.h ../include/res.h ../config.h ../include/client.h \
69+ ../include/dbuf.h ../include/msgq.h ../include/ircd_events.h \
70+ ../include/ircd_handler.h ../include/capab.h ../include/hash.h \
71+ ../include/ircd.h ../include/struct.h ../include/ircd_log.h \
72+ ../include/ircd_reply.h ../include/ircd_string.h \
73+ ../include/ircd_chattr.h ../include/msg.h ../include/numeric.h \
74+ ../include/numnicks.h ../include/send.h ../include/ircd_features.h
75 m_opmode.o: m_opmode.c ../config.h ../include/client.h \
76 ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \
77 ../include/ircd_events.h ../config.h ../include/ircd_handler.h \
88a737db 78diff -r 8d3cf5a69cf8 ircd/ircd_features.c
79--- a/ircd/ircd_features.c Mon Jan 12 19:30:23 2009 +0100
80+++ b/ircd/ircd_features.c Mon Jan 12 20:26:49 2009 +0100
715c825d
CP
81@@ -359,6 +359,7 @@
82 /* features that affect all operators */
83 F_B(EXTENDED_CHECKCMD, 0, 0, 0),
84 F_B(CONFIG_OPERCMDS, 0, 0, 0),
85+ F_B(OPKICK, 0, 0, 0),
86 F_B(SETHOST, 0, 0, 0),
87 F_B(SETHOST_USER, 0, 0, 0),
88 F_B(SETHOST_AUTO, 0, 0, 0),
88a737db 89diff -r 8d3cf5a69cf8 ircd/m_opkick.c
90--- /dev/null Thu Jan 01 00:00:00 1970 +0000
91+++ b/ircd/m_opkick.c Mon Jan 12 20:26:49 2009 +0100
92@@ -0,0 +1,231 @@
93+/*
94+ * IRC - Internet Relay Chat, ircd/m_opkick.c
95+ * Copyright (C) 1990 Jarkko Oikarinen and
96+ * University of Oulu, Computing Center
97+ *
98+ * See file AUTHORS in IRC package for additional names of
99+ * the programmers.
100+ *
101+ * This program is free software; you can redistribute it and/or modify
102+ * it under the terms of the GNU General Public License as published by
103+ * the Free Software Foundation; either version 1, or (at your option)
104+ * any later version.
105+ *
106+ * This program is distributed in the hope that it will be useful,
107+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
108+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
109+ * GNU General Public License for more details.
110+ *
111+ * You should have received a copy of the GNU General Public License
112+ * along with this program; if not, write to the Free Software
113+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
114+ *
115+ */
116+
117+/*
118+ * m_functions execute protocol messages on this server:
119+ *
120+ * cptr is always NON-NULL, pointing to a *LOCAL* client
121+ * structure (with an open socket connected!). This
122+ * identifies the physical socket where the message
123+ * originated (or which caused the m_function to be
124+ * executed--some m_functions may call others...).
125+ *
126+ * sptr is the source of the message, defined by the
127+ * prefix part of the message if present. If not
128+ * or prefix not found, then sptr==cptr.
129+ *
130+ * (!IsServer(cptr)) => (cptr == sptr), because
131+ * prefixes are taken *only* from servers...
132+ *
133+ * (IsServer(cptr))
134+ * (sptr == cptr) => the message didn't
135+ * have the prefix.
136+ *
137+ * (sptr != cptr && IsServer(sptr) means
138+ * the prefix specified servername. (?)
139+ *
140+ * (sptr != cptr && !IsServer(sptr) means
141+ * that message originated from a remote
142+ * user (not local).
143+ *
144+ * combining
145+ *
146+ * (!IsServer(sptr)) means that, sptr can safely
147+ * taken as defining the target structure of the
148+ * message in this server.
149+ *
150+ * *Always* true (if 'parse' and others are working correct):
151+ *
152+ * 1) sptr->from == cptr (note: cptr->from == cptr)
153+ *
154+ * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
155+ * *cannot* be a local connection, unless it's
156+ * actually cptr!). [MyConnect(x) should probably
157+ * be defined as (x == x->from) --msa ]
158+ *
159+ * parc number of variable parameter strings (if zero,
160+ * parv is allowed to be NULL)
161+ *
162+ * parv a NULL terminated list of parameter pointers,
163+ *
164+ * parv[0], sender (prefix string), if not present
165+ * this points to an empty string.
166+ * parv[1]...parv[parc-1]
167+ * pointers to additional parameters
168+ * parv[parc] == NULL, *always*
169+ *
170+ * note: it is guaranteed that parv[0]..parv[parc-1] are all
171+ * non-NULL pointers.
172+ */
173+#include "config.h"
174+
175+#include "channel.h"
176+#include "client.h"
177+#include "hash.h"
178+#include "ircd.h"
179+#include "ircd_log.h"
180+#include "ircd_reply.h"
181+#include "ircd_string.h"
182+#include "msg.h"
183+#include "numeric.h"
184+#include "numnicks.h"
185+#include "send.h"
186+#include "ircd_features.h"
187+
188+/* #include <assert.h> -- Now using assert in ircd_log.h */
189+
190+/*
191+ * mo_opkick - oper message handler
192+ *
193+ * parv[0] = sender prefix
194+ * parv[1] = channel
195+ * parv[2] = client to kick
196+ * parv[parc-1] = kick comment
197+ */
198+int mo_opkick(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
199+{
200+ struct Client *who;
201+ struct Channel *chptr;
202+ struct Membership *member = 0;
203+ struct Membership* member2;
204+ char *name, *comment;
205+
206+ ClrFlag(sptr, FLAG_TS8);
207+
208+ if (!feature_bool(FEAT_OPKICK))
209+ return send_reply(sptr, ERR_DISABLED, "OPKICK");
210+
211+ if (parc < 3 || *parv[1] == '\0')
212+ return need_more_params(sptr, "OPKICK");
213+
214+ name = parv[1];
215+
216+ /* simple checks */
217+ if (!(chptr = get_channel(sptr, name, CGT_NO_CREATE)))
218+ return send_reply(sptr, ERR_NOSUCHCHANNEL, name);
219+
220+ if (!HasPriv(sptr, IsLocalChannel(chptr->chname) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE))
221+ return send_reply(sptr, ERR_NOPRIVILEGES);
222+
223+ if (!(who = find_chasing(sptr, parv[2], 0)))
224+ return 0; /* find_chasing sends the reply for us */
225+
226+ /* Don't allow the channel service to be kicked */
227+ if (IsChannelService(who)) {
228+ if (IsService(cli_user(who)->server))
229+ return send_reply(sptr, ERR_ISREALSERVICE, cli_name(who), chptr->chname);
230+ }
231+
232+ /* check if kicked user is actually on the channel */
233+ if (!(member = find_member_link(chptr, who)) || IsZombie(member))
234+ return send_reply(sptr, ERR_USERNOTINCHANNEL, cli_name(who), chptr->chname);
235+
236+ /* We rely on ircd_snprintf to truncate the comment */
237+ comment = EmptyString(parv[parc - 1]) ? parv[2] : parv[parc - 1];
238+
239+ if (!IsLocalChannel(name))
240+ sendcmdto_serv_butone(sptr, CMD_OPKICK, cptr, "%H %C :%s", chptr, who, comment);
241+
242+ if (IsDelayedJoin(member)) {
243+ /* If it's a delayed join, only send the KICK to the person doing
244+ * the kicking and the victim */
245+ if (MyUser(who))
246+ sendcmdto_one(feature_bool(FEAT_HIS_MODEWHO) ? &his : sptr, CMD_KICK, who, "%H %C :%s", chptr, who, comment);
247+ /* operator using OPKICK is on the channel */
248+ if ((member2 = find_member_link(chptr, sptr)) && !IsZombie(member2)) {
249+ sendcmdto_one(who, CMD_JOIN, sptr, "%H", chptr);
250+ sendcmdto_one(feature_bool(FEAT_HIS_MODEWHO) ? &his : sptr, CMD_KICK, sptr, "%H %C :%s", chptr, who, comment);
251+ }
252+ CheckDelayedJoins(chptr);
253+ } else
254+ sendcmdto_channel_butserv_butone(feature_bool(FEAT_HIS_MODEWHO) ? &his : sptr,
255+ CMD_KICK, chptr, NULL, 0, "%H %C :%s", chptr, who, comment);
256+
257+ /* Send HACK notice and log it */
258+ sendto_opmask_butone(0, SNO_HACK4, "HACK(4): %C KICK %H %C %s", sptr, chptr, who, comment);
259+ log_write(LS_OPERMODE, L_INFO, LOG_NOSNOTICE, "%#C OPKICK %H %C %s", sptr, chptr, who, comment);
260+
261+ make_zombie(member, who, cptr, sptr, chptr);
262+
263+ return 0;
264+}
265+
266+/*
267+ * ms_opkick - server message handler
268+ *
269+ * parv[0] = sender prefix
270+ * parv[1] = channel
271+ * parv[2] = client to kick
272+ * parv[parc-1] = kick comment
273+ */
274+int ms_opkick(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
275+{
276+ struct Client *who;
277+ struct Channel *chptr;
278+ struct Membership *member = 0, *sptr_link = 0;
279+ char *name, *comment;
280+
281+ ClrFlag(sptr, FLAG_TS8);
282+
283+ if (parc < 3 || *parv[1] == '\0')
284+ return need_more_params(sptr, "OPKICK");
285+
286+ name = parv[1];
287+ comment = parv[parc - 1];
288+
289+ /* figure out who gets kicked from what */
290+ if (IsLocalChannel(name) ||
291+ !(chptr = get_channel(sptr, name, CGT_NO_CREATE)) ||
292+ !(who = findNUser(parv[2])))
293+ return 0;
294+
295+ /* We go ahead and pass on the KICK for users not on the channel */
296+ if (!(member = find_member_link(chptr, who)) || IsZombie(member)) {
297+ if (member) {
298+ make_zombie(member, who, cptr, sptr, chptr);
299+ member=0;
300+ }
301+ }
302+
303+ /* Propagate kick... */
304+ sendcmdto_serv_butone(sptr, CMD_OPKICK, cptr, "%H %C :%s", chptr, who, comment);
305+
306+ if (member) { /* and tell the channel about it */
307+ if (IsDelayedJoin(member)) {
308+ if (MyUser(who))
309+ sendcmdto_one((IsServer(sptr) || feature_bool(FEAT_HIS_MODEWHO)) ? &his : sptr,
310+ CMD_KICK, who, "%H %C :%s", chptr, who, comment);
311+ } else {
312+ sendcmdto_channel_butserv_butone((IsServer(sptr) || feature_bool(FEAT_HIS_MODEWHO)) ? &his : sptr,
313+ CMD_KICK, chptr, NULL, 0, "%H %C :%s", chptr, who, comment);
314+ }
315+
316+ /* Send HACK notice and log it */
317+ sendto_opmask_butone(0, SNO_HACK4, "HACK(4): %C KICK %H %C %s", sptr, chptr, who, comment);
318+ log_write(LS_OPERMODE, L_INFO, LOG_NOSNOTICE, "%#C OPKICK %H %C %s", sptr, chptr, who, comment);
319+
320+ make_zombie(member, who, cptr, sptr, chptr);
321+ }
322+ return 0;
323+}
324diff -r 8d3cf5a69cf8 ircd/parse.c
325--- a/ircd/parse.c Mon Jan 12 19:30:23 2009 +0100
326+++ b/ircd/parse.c Mon Jan 12 20:26:49 2009 +0100
715c825d
CP
327@@ -656,6 +656,17 @@
328 0, MAXPARA, MFLG_SLOW, 0, NULL,
329 { m_unregistered, m_not_oper, m_check, m_check, m_ignore }
330 },
331+
332+ /*
333+ * Add the command for OPKICK.
334+ */
335+ {
336+ MSG_OPKICK,
337+ TOK_OPKICK,
338+ 0, MAXPARA, MFLG_SLOW, 0, NULL,
339+ /* UNREG, CLIENT, SERVER, OPER, SERVICE */
340+ { m_unregistered, m_not_oper, ms_opkick, mo_opkick, m_ignore }
341+ },
342
343 /* This command is an alias for QUIT during the unregistered part of
344 * of the server. This is because someone jumping via a broken web