[IRCServices] NSRegRestricted and CSRegRestricted

Jordi Murgo jordi at lleida.com
Fri Nov 2 12:49:00 PST 2001


This small patch for ircservices-4.5.29 can be usefull on custom IRC
installations, or under some circumstances where you may need to
disallow NickServ REGISTER or/and ChanServ REGISTER to mere humans.

The keywords for ircservices.conf are:

	# It allows nick registration only to IRCOPs
	NSRegRestricted

	# It allows channel registration only to IRCOPs and CS-Admins
	CSRegRestricted

Enjoy,		<jordi/>
-------------- next part --------------
Common subdirectories: ircservices/CVS and ircservices-custom/CVS
diff -uN ircservices/chanserv.c ircservices-custom/chanserv.c
--- ircservices/chanserv.c	Wed Oct 31 14:22:24 2001
+++ ircservices-custom/chanserv.c	Fri Nov  2 11:27:50 2001
@@ -1460,6 +1460,12 @@
 	return;
     }
 
+    /*--- CUSTOM: ChanServ REGISTER only IRCOPS/ADMINS ---*/
+    if(CSRegRestricted && !is_oper(u->nick) && !is_services_admin(u) ) {
+        notice_lang(s_ChanServ, u, CHAN_REGISTER_DISABLED);
+        return;
+    }
+
     if (!desc) {
 	syntax_error(s_ChanServ, u, "REGISTER", CHAN_REGISTER_SYNTAX);
     } else if (*chan == '&') {
diff -uN ircservices/config.c ircservices-custom/config.c
--- ircservices/config.c	Wed Oct 31 14:22:24 2001
+++ ircservices-custom/config.c	Wed Oct 31 17:05:55 2001
@@ -144,6 +144,10 @@
 int   SessionLimitAkillExpiry;
 char *SessionLimitAkillReason;
 
+/*--- CUSTOM CONFIGS ---*/
+int   NSRegRestricted;
+int   CSRegRestricted;
+
 /******* Local use only: *******/
 
 static int   NSDefNone;
@@ -324,6 +328,11 @@
     { "WallSetpass",      { { PARAM_SET, 0, &WallSetpass } } },
     { "WallSU",           { { PARAM_SET, 0, &WallSU } } },
     { "WarningTimeout",   { { PARAM_TIME, 0, &WarningTimeout } } },
+
+    /*-- CUSTOM --*/
+    { "NSRegRestricted",   { { PARAM_SET, 0, &NSRegRestricted } } },
+    { "CSRegRestricted",   { { PARAM_SET, 0, &CSRegRestricted } } },
+
 };
 
 /*************************************************************************/
Common subdirectories: ircservices/data and ircservices-custom/data
diff -uN ircservices/extern.h ircservices-custom/extern.h
--- ircservices/extern.h	Wed Oct 31 14:22:24 2001
+++ ircservices-custom/extern.h	Wed Oct 31 17:05:55 2001
@@ -251,6 +251,10 @@
 E char *SessionLimitDetailsLoc;
 E char *SessionLimitExceeded;
 
+/*--- CUSTOM ---*/
+E int   NSRegRestricted;
+E int   CSRegRestricted;
+
 E int read_config(void);
 
 
Common subdirectories: ircservices/lang and ircservices-custom/lang
diff -uN ircservices/nickserv.c ircservices-custom/nickserv.c
--- ircservices/nickserv.c	Wed Oct 31 15:45:03 2001
+++ ircservices-custom/nickserv.c	Wed Oct 31 17:05:55 2001
@@ -1114,6 +1114,12 @@
 	return;
     }
 
+    /*--- CUSTOM: Nickserv REGISTER only IRCOPS ---*/
+    if(NSRegRestricted && !is_oper(u->nick)) {
+        notice_lang(s_NickServ, u, NICK_REGISTRATION_DISABLED);
+        return;
+    }
+
 #ifdef HAVE_NICKCHANGE
     /* Prevent "Guest" nicks from being registered. -TheShadow */
     if (NSForceNickChange) {