[IRCServices Coding] Chanserv patch for reg chans only

Stefan Hudson hudson at mbay.net
Wed Mar 12 15:04:41 PST 2003


Here's a patch to add an option for forbiding use unregistered channels
by normal users.  Yeah, it's a bit fascist, but sometimes this much control
is needed - on IRC servers that are used for commercial support, where it
would not be appropriate to have someone create #hotgaysex, for example.

This is the first hack I've done on ircservices, so someone please check
to make sure I didn't miss something.  I tried to cover all bases.

diff -c -r ircservices-5.0.13/data/example-modules.conf ircservices-5.0.13-local/data/example-modules.conf
*** ircservices-5.0.13/data/example-modules.conf	Mon Mar  3 01:54:47 2003
--- ircservices-5.0.13-local/data/example-modules.conf	Wed Mar 12 16:41:23 2003
***************
*** 919,924 ****
--- 919,932 ----
  
      #CSForbidShortChannel
  
+     # CSRegisteredOnly  [OPTIONAL]
+     #     When enabled, treats unregistered channels as forbidden, not
+     #     allowing normal users to join.  If enabled, services opers will
+     #     need to create any new channels on the network.  For this option
+     #     to be effective, CSEnableRegister should generally NOT be enabled.
+ 
+     #CSRegisteredOnly
+ 
  EndModule
  
  ################################ SENDPASS module
diff -c -r ircservices-5.0.13/docs/a.html ircservices-5.0.13-local/docs/a.html
*** ircservices-5.0.13/docs/a.html	Sun Mar  2 21:18:48 2003
--- ircservices-5.0.13-local/docs/a.html	Wed Mar 12 16:50:04 2003
***************
*** 1722,1727 ****
--- 1722,1739 ----
  
  <p>Example: <tt>CSForbidShortChannel</tt>
  </ul>
+ 
+ <a name="chanserv/main.CSRegisteredOnly"></a>
+ <p><ul><li>
+ <tt><b>CSRegisteredOnly</b></tt>&nbsp;&nbsp;&nbsp;&nbsp;[OPTIONAL]
+ <p>When enabled, treats unregistered channels as forbidden, not
+ allowing normal users to join.  If enabled, services opers will
+ need to create any new channels on the network.  For this option
+ to be effective, CSEnableRegister should generally NOT be enabled.
+ 
+ <p>Example: <tt>CSRegisteredOnly</tt>
+ </ul>
+ 
  <a name="chanserv/sendpass"></a>
  <p><font size="+1"><b>chanserv/sendpass</b> (SENDPASS module)</font>
  
diff -c -r ircservices-5.0.13/modules/chanserv/check.c ircservices-5.0.13-local/modules/chanserv/check.c
*** ircservices-5.0.13/modules/chanserv/check.c	Mon Mar  3 01:54:48 2003
--- ircservices-5.0.13-local/modules/chanserv/check.c	Wed Mar 12 04:55:35 2003
***************
*** 274,281 ****
  	goto kick;
      }
  
!     if (!ci)
! 	return 0;
  
      if (is_services_admin(user))
  	return 0;
--- 274,288 ----
  	goto kick;
      }
  
!     if (!ci) {
! 	if(CSRegisteredOnly && !is_oper(user)) {
! 	    mask = sstrdup("*!*@*");
! 	    reason = getstring(user->ngi, CHAN_MAY_NOT_BE_USED);
! 	    goto kick;
! 	} else {
! 	    return 0;
! 	}
!     }
  
      if (is_services_admin(user))
  	return 0;
diff -c -r ircservices-5.0.13/modules/chanserv/cs-local.h ircservices-5.0.13-local/modules/chanserv/cs-local.h
*** ircservices-5.0.13/modules/chanserv/cs-local.h	Mon Mar  3 01:54:48 2003
--- ircservices-5.0.13-local/modules/chanserv/cs-local.h	Wed Mar 12 04:45:02 2003
***************
*** 93,98 ****
--- 93,99 ----
  E time_t CSSuspendExpire;
  E time_t CSSuspendGrace;
  E int    CSForbidShortChannel;
+ E int    CSRegisteredOnly;
  E ChanOpt chanopts[];
  
  
diff -c -r ircservices-5.0.13/modules/chanserv/main.c ircservices-5.0.13-local/modules/chanserv/main.c
*** ircservices-5.0.13/modules/chanserv/main.c	Mon Mar  3 01:54:48 2003
--- ircservices-5.0.13-local/modules/chanserv/main.c	Wed Mar 12 03:47:23 2003
***************
*** 57,62 ****
--- 57,63 ----
         time_t CSSuspendExpire;
         time_t CSSuspendGrace;
         int    CSForbidShortChannel;
+        int    CSRegisteredOnly;
  EXPORT_VAR(int32,CSMaxReg)
  
  /*************************************************************************/
***************
*** 1606,1611 ****
--- 1607,1613 ----
      { "CSEnableRegister", { { CD_SET, 0, &CSEnableRegister } } },
      { "CSExpire",         { { CD_TIME, 0, &CSExpire } } },
      { "CSForbidShortChannel",{{CD_SET, 0, &CSForbidShortChannel } } },
+     { "CSRegisteredOnly", { { CD_SET, 0, &CSRegisteredOnly } } },
      { "CSInhabit",        { { CD_TIME, CF_DIRREQ, &CSInhabit } } },
      { "CSListMax",        { { CD_POSINT, CF_DIRREQ, &CSListMax } } },
      { "CSListOpersOnly",  { { CD_SET, 0, &CSListOpersOnly } } },