Opers still seeing notices on log out

These are old archives. They are kept for historic purposes only.
cards
Posts: 85
Joined: Sat Jun 12, 2004 5:04 am

Re: Opers still seeing notices on log out

Post by cards »

Try this module:

put it in a file called m_kickoper.c placed in the src/modules

then from main Unreal directory: make custommodule MODULEFILE=m_kickoper
add a loadmodule directive to the .so file and rehash. I have tested it on Win32, so It should work on linux as well.

Code: Select all

/*
 * =================================================================
 * Filename:          m_kickoper.c
 * Description:       Hooks Umode and checks if Oper uses /mode -o
 * Author:            Cards <[email protected]
 * Version: 1.0
 * Documentation:    
 *		This Module hooks UMODE_CHANGE and detects if an oper deops
 * themselves.  If so, it removed them from all AdminOnly and 
 * OperOnly Channels.  Tested on Win32.
 * =================================================================
 */

#include "config.h"
#include "struct.h"
#include "common.h"
#include "channel.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "proto.h"
#include "channel.h"
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#endif
#include <fcntl.h>
#include "h.h"
#ifdef STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif

extern void             sendto_one(aClient *to, char *pattern, ...);
DLLFUNC char *check_oper(aClient *sptr, long oldflags, long newflags);

//Hook *HookDeop = NULL;
#define DelCommand(x)	if (x) CommandDel(x); x = NULL


ModuleHeader MOD_HEADER(m_kickoper)
  = {
	"check_oper",
	"$Id: m_checkoper.c,v 1..0 2012/07/13 cards",
	"hook UMODE",
	"3.2-b8-1",
	NULL 
    };

DLLFUNC int MOD_INIT(m_kickoper)(ModuleInfo *modinfo)
{
	HookAddPCharEx(modinfo->handle, HOOKTYPE_UMODE_CHANGE, check_oper);
        return MOD_SUCCESS;
}

DLLFUNC int MOD_LOAD(m_kickoper)(int module_load)
{
	return MOD_SUCCESS;
}

DLLFUNC int MOD_UNLOAD(m_kickoper)(int module_unload)
{
	//DelCommand(HookDeop);
	return MOD_SUCCESS;
}

/*  This is the command to execute on Umode2 */
DLLFUNC char *check_oper(aClient *sptr, long oldflags, long newflags)
{
	aClient *cptr;
	Membership *lp;
	aChannel *chptr;
	aChannel *kchan[50];  // Max 50 channels.  Not really needing this many, but they are opers
	int count = 0;
	int c;
	if (oldflags & UMODE_OPER){
		if (newflags & UMODE_OPER) {
			return HOOK_CONTINUE;
		}
		for (lp = sptr->user->channel; lp; lp = lp->next)
			{
				chptr = lp->chptr;
				if (chptr->mode.mode & MODE_OPERONLY || chptr->mode.mode & MODE_ADMONLY)
				{
					//Build list of channels the user is on that they need to be removed from.  We cannot remove here due to read-after-free issues
						kchan[count] = chptr;
						++count;
				}
				
			}
		for (c=0; c<count; c++) { 
			//send kick to client and remove them from channel list
			sendnotice(sptr, "You are being removed from the Oper/Admin Only Channels");
			sendto_prefix_one(sptr, sptr, ":%s KICK %s %s :You are no longer an oper!", me.name, kchan[c]->chname, sptr->name);
			remove_user_from_channel(sptr, kchan[c]);
		} 
		
		return HOOK_CONTINUE;
	} else {
		return HOOK_CONTINUE;
	}
return HOOK_CONTINUE;
}
NetAdmin
irc.420-HighTimes.com
Stealth
Head of Support
Posts: 2085
Joined: Tue Jun 15, 2004 8:50 pm
Location: Chino Hills, CA, US
Contact:

Re: Opers still seeing notices on log out

Post by Stealth »

As Syzop mentioned, a few examples of the notices the user is still receiving would be nice.

He also mentioned that users can use +k and +s snomasks, and these will stay set when the user de-opers. +k will send all KILL notices, and +s will send general server notices.

As for the oper still being in #opers when +O is set, that relates back to what was mentioned about +O being like +k or +i. It only checks user access when a user joins. This is just how modes that restrict joins work. Without a 3rd part module there is no way to have the sever automatically remove a user from the channel (with the exception of +f).

If you don't want your opers to see any information or be in oper-only channels when they are not logged in, you should make that the oper's responsibility to do themselves.

It may be possible to create a module to provide a deoper command that removes all oper-related usermodes and parts from +O channels, it would also be extremely easy to write a script to do the same for mIRC:

Code: Select all

alias deoper {
  mode $me -o+s -ks
  var %x = 1
  while ($chan(%x)) {
    if (O isincs $chan(%x).mode) { part $chan(%x) }
    inc %x
  }
}
cheiron
Posts: 74
Joined: Sun May 29, 2011 6:17 pm

Re: Opers still seeing notices on log out

Post by cheiron »

thanks Stealth but i have an equivalent already on my windows box :D

.. sadly .. my windows box is minus a mobo having blown the bios... so i am stuck on xchat which i am unfamiliar with and irssi .. also unfamiliar with
cards
Posts: 85
Joined: Sat Jun 12, 2004 5:04 am

Re: Opers still seeing notices on log out

Post by cards »

Do you need a dll version of the mod as well?
NetAdmin
irc.420-HighTimes.com
cards
Posts: 85
Joined: Sat Jun 12, 2004 5:04 am

Re: Opers still seeing notices on log out

Post by cards »

http://schaffner.org/m_kickoper.c
http://schaffner.org/m_kickoper.dll

Code is above. DLL is compile on VS2008, so it is compatible with Unreal's build
NetAdmin
irc.420-HighTimes.com
cheiron
Posts: 74
Joined: Sun May 29, 2011 6:17 pm

Re: Opers still seeing notices on log out

Post by cheiron »

I am on a debian 6 vps so no dll version needed. what i would like though .. re the kickoper.. they only need to be taken from 1 channel on deoper.. as the force join on oper takes them to 3.. main channel, help channel and #opers <--- that's the one they need to leave only
cards
Posts: 85
Joined: Sat Jun 12, 2004 5:04 am

Re: Opers still seeing notices on log out

Post by cards »

The Modules is only going to remove the user from channels that are /mode #chan +O or /mode #chan +A. You are not going to set your main channel or help channels as oper only, as it would be pointless. So it should work just fine for you.
NetAdmin
irc.420-HighTimes.com
cheiron
Posts: 74
Joined: Sun May 29, 2011 6:17 pm

Re: Opers still seeing notices on log out

Post by cheiron »

ok compiled it and ran it.

*** check_oper - $Id: m_checkoper.c,v 1..0 2012/07/13 cards (hook UMODE) [3RD]
from /module so you can see its loaded

from my messages
<Global> UserMode: WhiteWolf[s] (~[email protected] => [email protected]) is no longer a Global IRC Operator (-o)

he got kicked... but for some reason xchat doesnt show kicks...

he still saw the oper notices when i rehashed during the time he was deopered....

how does that get fixed ?
Stealth
Head of Support
Posts: 2085
Joined: Tue Jun 15, 2004 8:50 pm
Location: Chino Hills, CA, US
Contact:

Re: Opers still seeing notices on log out

Post by Stealth »

Stealth wrote:He also mentioned that users can use +k and +s snomasks, and these will stay set when the user de-opers. +k will send all KILL notices, and +s will send general server notices.
cheiron
Posts: 74
Joined: Sun May 29, 2011 6:17 pm

Re: Opers still seeing notices on log out

Post by cheiron »

hah.. sorry for being a bit slow :) i had added the sk to restrict "usermodes" instead of commenting out the snomask on connect lol
thanks guys :)
cheiron
Posts: 74
Joined: Sun May 29, 2011 6:17 pm

Re: Opers still seeing notices on log out

Post by cheiron »

would it be possible please to have the check_oper module modified to remove +k and +s snomasks from deopering opers please :)
that will be the module perfect then :)

cheers
cards
Posts: 85
Joined: Sat Jun 12, 2004 5:04 am

Re: Opers still seeing notices on log out

Post by cards »

I will see what I can do for you
NetAdmin
irc.420-HighTimes.com
cards
Posts: 85
Joined: Sat Jun 12, 2004 5:04 am

Re: Opers still seeing notices on log out

Post by cards »

Version 1.1 Release. It now removes +s (SnoMasks) from non-opers. This removes the kill notices ans server notices per your request, although normal members are allowed to see if by default. YOu must Restrict mode (s), in order for this to work.

http://schaffner.org/m_kickoper.c
NetAdmin
irc.420-HighTimes.com
cheiron
Posts: 74
Joined: Sun May 29, 2011 6:17 pm

Re: Opers still seeing notices on log out

Post by cheiron »

Works a treat cards :)
nice job and a job well done.
you should publish this on the unrealircd modules page as a functional module to the masses :)
cards
Posts: 85
Joined: Sat Jun 12, 2004 5:04 am

Re: Opers still seeing notices on log out

Post by cards »

Sure will. As soon as Syzop allows me to open it up :)
NetAdmin
irc.420-HighTimes.com
Post Reply