]> jfr.im git - irc/rqf/shadowircd.git/blame - extensions/m_omode.c
BOPM/TCM do not need the ability to global kill, so remove it from server_bot
[irc/rqf/shadowircd.git] / extensions / m_omode.c
CommitLineData
212380e3 1/*
2 * Charybdis: an advanced Internet Relay Chat Daemon(ircd).
3 * m_omode.c: allows oper mode hacking
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2004 ircd-ratbox development team
8 * Copyright (C) 2006 Charybdis development team
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 * $Id: m_omode.c 3121 2007-01-02 13:23:04Z jilles $
26 */
27
28#include "stdinc.h"
212380e3 29#include "channel.h"
30#include "client.h"
31#include "hash.h"
13ae2f4b 32#include "match.h"
212380e3 33#include "ircd.h"
34#include "numeric.h"
35#include "s_user.h"
36#include "s_conf.h"
37#include "s_newconf.h"
38#include "s_serv.h"
39#include "send.h"
40#include "msg.h"
41#include "parse.h"
42#include "modules.h"
43#include "packet.h"
44
45static int mo_omode(struct Client *, struct Client *, int, const char **);
46
47struct Message omode_msgtab = {
48 "OMODE", 0, 0, 0, MFLG_SLOW,
49 {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_omode, 3}}
50};
51
52mapi_clist_av1 omode_clist[] = { &omode_msgtab, NULL };
53
54DECLARE_MODULE_AV1(omode, NULL, NULL, omode_clist, NULL, NULL, "$Revision: 3121 $");
55
56/*
57 * mo_omode - MODE command handler
58 * parv[0] - sender
59 * parv[1] - channel
60 */
61static int
62mo_omode(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
63{
64 struct Channel *chptr = NULL;
65 struct membership *msptr;
66 char params[512];
67 int i;
68 int wasonchannel;
69
70 /* admins only */
71 if(!IsOperAdmin(source_p))
72 {
73 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
74 return 0;
75 }
76
77 /* Now, try to find the channel in question */
78 if(!IsChanPrefix(parv[1][0]) || !check_channel_name(parv[1]))
79 {
80 sendto_one_numeric(source_p, ERR_BADCHANNAME,
81 form_str(ERR_BADCHANNAME), parv[1]);
82 return 0;
83 }
84
85 chptr = find_channel(parv[1]);
86
87 if(chptr == NULL)
88 {
89 sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
90 form_str(ERR_NOSUCHCHANNEL), parv[1]);
91 return 0;
92 }
93
94 /* Now know the channel exists */
95 msptr = find_channel_membership(chptr, source_p);
96 wasonchannel = msptr != NULL;
97
98 if (is_chanop(msptr))
99 {
100 sendto_one_notice(source_p, ":Use a normal MODE you idiot");
101 return 0;
102 }
103
104 params[0] = '\0';
105 for (i = 2; i < parc; i++)
106 {
107 if (i != 2)
a64c5173
VY
108 rb_strlcat(params, " ", sizeof params);
109 rb_strlcat(params, parv[i], sizeof params);
212380e3 110 }
111
112 sendto_wallops_flags(UMODE_WALLOP, &me,
113 "OMODE called for [%s] [%s] by %s!%s@%s",
114 parv[1], params, source_p->name, source_p->username, source_p->host);
115 ilog(L_MAIN, "OMODE called for [%s] [%s] by %s",
116 parv[1], params, get_oper_name(source_p));
117
118 if(*chptr->chname != '&')
119 sendto_server(NULL, NULL, NOCAPS, NOCAPS,
120 ":%s WALLOPS :OMODE called for [%s] [%s] by %s!%s@%s",
121 me.name, parv[1], params, source_p->name, source_p->username,
122 source_p->host);
123
124#if 0
125 set_channel_mode(client_p, source_p->servptr, chptr, msptr,
126 parc - 2, parv + 2);
127#else
128 if (parc == 4 && !strcmp(parv[2], "+o") && !irccmp(parv[3], source_p->name))
129 {
130 /* Opping themselves */
131 if (!wasonchannel)
132 {
133 sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
134 form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
135 return 0;
136 }
137 sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
138 me.name, parv[1], source_p->name);
139 sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
140 ":%s TMODE %ld %s +o %s",
141 me.id, (long) chptr->channelts, parv[1],
142 source_p->id);
212380e3 143 msptr->flags |= CHFL_CHANOP;
144 }
145 else
146 {
147 /* Hack it so set_channel_mode() will accept */
148 if (wasonchannel)
149 msptr->flags |= CHFL_CHANOP;
150 else
151 {
152 add_user_to_channel(chptr, source_p, CHFL_CHANOP);
153 msptr = find_channel_membership(chptr, source_p);
154 }
155 set_channel_mode(client_p, source_p, chptr, msptr,
156 parc - 2, parv + 2);
157 /* We know they were not opped before and they can't have opped
158 * themselves as set_channel_mode() does not allow that
159 * -- jilles */
160 if (wasonchannel)
161 msptr->flags &= ~CHFL_CHANOP;
162 else
163 remove_user_from_channel(msptr);
164 }
165#endif
166 return 0;
167}