unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

nokick.c (2751B)

      1 /*
      2  * Prevents you from being kicked (User mode +q)
      3  * (C) Copyright 2000-.. Bram Matthys (Syzop) and the UnrealIRCd team
      4  *
      5  * This program is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License as published by
      7  * the Free Software Foundation; either version 1, or (at your option)
      8  * any later version.
      9  *
     10  * This program is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  * GNU General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License
     16  * along with this program; if not, write to the Free Software
     17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18  */
     19 
     20 #include "unrealircd.h"
     21 
     22 #define IsNokick(client)    (client->umodes & UMODE_NOKICK)
     23 
     24 /* Module header */
     25 ModuleHeader MOD_HEADER
     26   = {
     27 	"usermodes/nokick",
     28 	"4.2",
     29 	"User Mode +q",
     30 	"UnrealIRCd Team",
     31 	"unrealircd-6",
     32     };
     33 
     34 /* Global variables */
     35 long UMODE_NOKICK = 0L;
     36 
     37 /* Forward declarations */
     38 int umode_allow_unkickable_oper(Client *client, int what);
     39 int nokick_can_kick(Client *client, Client *target, Channel *channel,
     40                     const char *comment, const char *client_member_modes, const char *target_member_modes, const char **reject_reason);
     41 
     42 MOD_TEST()
     43 {
     44 	return MOD_SUCCESS;
     45 }
     46 
     47 MOD_INIT()
     48 {
     49 	UmodeAdd(modinfo->handle, 'q', UMODE_GLOBAL, 1, umode_allow_unkickable_oper, &UMODE_NOKICK);
     50 	
     51 	HookAdd(modinfo->handle, HOOKTYPE_CAN_KICK, 0, nokick_can_kick);
     52 	
     53 	MARK_AS_OFFICIAL_MODULE(modinfo);
     54 	return MOD_SUCCESS;
     55 }
     56 
     57 MOD_LOAD()
     58 {
     59 	return MOD_SUCCESS;
     60 }
     61 
     62 MOD_UNLOAD()
     63 {
     64 	return MOD_SUCCESS;
     65 }
     66 
     67 int umode_allow_unkickable_oper(Client *client, int what)
     68 {
     69 	if (MyUser(client))
     70 	{
     71 		if (IsOper(client) && ValidatePermissionsForPath("self:unkickablemode",client,NULL,NULL,NULL))
     72 			return 1;
     73 		return 0;
     74 	}
     75 	/* Always allow remotes: */
     76 	return 1;
     77 }
     78 
     79 int nokick_can_kick(Client *client, Client *target, Channel *channel, const char *comment,
     80                     const char *client_member_modes, const char *target_member_modes, const char **reject_reason)
     81 {
     82 	static char errmsg[NICKLEN+256];
     83 
     84 	if (IsNokick(target) && !IsULine(client) && MyUser(client) && !ValidatePermissionsForPath("channel:override:kick:nokick",client,target,channel,NULL))
     85 	{
     86 		ircsnprintf(errmsg, sizeof(errmsg), ":%s %d %s %s :%s",
     87 		            me.name, ERR_CANNOTDOCOMMAND, client->name, "KICK",
     88 				   "user is unkickable (user mode +q)");
     89 
     90 		*reject_reason = errmsg;
     91 
     92 		sendnotice(target,
     93 			"*** umode q: %s tried to kick you from channel %s (%s)",
     94 			client->name, channel->name, comment);
     95 		
     96 		return EX_ALWAYS_DENY;
     97 	}
     98 
     99 	return EX_ALLOW;
    100 }