Commit Diff


commit - 5e929effcae7a273f55a0011632b86a0811cf35f
commit + 1d08d51e2eaff14b71f20d3f0898d5a86582b7e5
blob - 13891598022b7b51646f338b92e3fe45daa7b910
blob + b87633950d17ac9b50fa2c58f80a0916605a7d4b
--- ChangeLog
+++ ChangeLog
@@ -12,6 +12,10 @@
 
 ngIRCd CVSHEAD
 
+  - New configuration option "OperServerMode" to enable a workaround needed
+    when running an network with ircd2 servers and "OperCanUseMode" enabled
+    to prevent the ircd2 daemon to drop mode changes of IRC operators.
+    Patch by Florian Westphal, <westphal@foo.fh-furtwangen.de>.
   - Implemented support for "secret channels" (channel mode "s").
   - New configuration option "Mask" for [Operator] sections to limit OPER
     commands to ussers with a specific IRC mask. Patch from Florian Westphal.
@@ -589,4 +593,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
-$Id: ChangeLog,v 1.263 2005/03/02 16:35:10 alex Exp $
+$Id: ChangeLog,v 1.264 2005/03/15 16:56:16 alex Exp $
blob - 6a49e1496acfcb7e918c759ec05619602b8a8c07
blob + ec83f17b58adad8af5a142a88fe3f11c828cf25d
--- NEWS
+++ NEWS
@@ -12,6 +12,10 @@
 
 ngIRCd CVSHEAD
 
+  - New configuration option "OperServerMode" to enable a workaround needed
+    when running an network with ircd2 servers and "OperCanUseMode" enabled
+    to prevent the ircd2 daemon to drop mode changes of IRC operators.
+    Patch by Florian Westphal, <westphal@foo.fh-furtwangen.de>.
   - Implemented support for "secret channels" (channel mode "s").
   - New configuration option "Mask" for [Operator] sections to limit OPER
     commands to ussers with a specific IRC mask. Patch from Florian Westphal.
@@ -201,4 +205,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
-$Id: NEWS,v 1.70 2005/03/02 16:35:10 alex Exp $
+$Id: NEWS,v 1.71 2005/03/15 16:56:16 alex Exp $
blob - 72d2e4671fbe82ce6483d1a3d52ea9b5b5965cae
blob + 166e9d2a6155e8831d2f638396f9c238d37b319f
--- doc/sample-ngircd.conf
+++ doc/sample-ngircd.conf
@@ -1,4 +1,4 @@
-# $Id: sample-ngircd.conf,v 1.31 2005/03/02 16:07:30 alex Exp $
+# $Id: sample-ngircd.conf,v 1.32 2005/03/15 16:56:16 alex Exp $
 
 #
 # This is a sample configuration file for the ngIRCd, which must be adepted
@@ -89,6 +89,10 @@
 	# they are not(!) channel-operators?
 	;OperCanUseMode = no
 
+	# Mask IRC Operator mode requests as if they were coming from the server?
+	# (This is a compatibility hack for ircd-irc2 servers )
+	;OperServerMode = no
+	
 	# Maximum number of simultaneous connection the server is allowed
 	# to accept (<=0: unlimited):
 	;MaxConnections = -1
blob - e7f44c6d6875f998127565ba5e1ec29773c6563c
blob + 29346e5575723863d79eaecc055951a656ea16c7
--- man/ngircd.conf.5
+++ man/ngircd.conf.5
@@ -1,5 +1,5 @@
 .\"
-.\" $Id: ngircd.conf.5,v 1.15 2005/03/02 16:07:31 alex Exp $
+.\" $Id: ngircd.conf.5,v 1.16 2005/03/15 16:56:17 alex Exp $
 .\"
 .TH ngircd.conf 5 "February 2005" ngircd "ngIRCd Manual"
 .SH NAME
@@ -137,6 +137,11 @@ The server tries every <ConnectRetry> seconds to estab
 Should IRC Operators be allowed to use the MODE command even if they are
 not(!) channel-operators? Default: no.
 .TP
+\fBOperServerMode\fR
+If OperCanUseMode is enabled, this may lead the compatibility problems with
+Servers that run the ircd-irc2 Software. This Option "masks" mode requests
+by non-chanops as if they were coming from the server. Default: no.
+.TP
 \fBMaxConnections\fR
 Maximum number of simultaneous connection the server is allowed to accept
 (<=0: unlimited). Default: -1.
blob - 312ebff9a1cfcb724b3065613b1acefe904abdd0
blob + f00c263346cdbc250cf525a57f9bbe05a01c4d7e
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.69 2005/03/02 16:07:31 alex Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.70 2005/03/15 16:56:18 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -142,6 +142,7 @@ Conf_Test( VOID )
 	printf( "  PongTimeout = %d\n", Conf_PongTimeout );
 	printf( "  ConnectRetry = %d\n", Conf_ConnectRetry );
 	printf( "  OperCanUseMode = %s\n", Conf_OperCanMode == TRUE ? "yes" : "no" );
+	printf( "  OperServerMode = %s\n", Conf_OperServerMode == TRUE ? "yes" : "no" );
 	if( Conf_MaxConnections > 0 ) printf( "  MaxConnections = %ld\n", Conf_MaxConnections );
 	else printf( "  MaxConnections = -1\n" );
 	if( Conf_MaxConnectionsIP > 0 ) printf( "  MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP );
@@ -374,6 +375,7 @@ Set_Defaults( BOOLEAN InitServers )
 	Conf_Channel_Count = 0;
 
 	Conf_OperCanMode = FALSE;
+	Conf_OperServerMode = FALSE;
 	
 	Conf_MaxConnections = -1;
 	Conf_MaxConnectionsIP = 5;
@@ -559,6 +561,17 @@ Read_Config( VOID )
 		Conf_ListenPorts[0] = 6667;
 	}
 } /* Read_Config */
+
+
+LOCAL BOOLEAN
+Check_ArgIsTrue( const char *Arg )
+{
+	if( strcasecmp( Arg, "yes" ) == 0 ) return TRUE;
+	if( strcasecmp( Arg, "true" ) == 0 ) return TRUE;
+	if( atoi( Arg ) != 0 ) return TRUE;
+
+	return FALSE;
+} /* Check_ArgIsTrue */
 
 
 LOCAL VOID
@@ -734,10 +747,13 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
 	if( strcasecmp( Var, "OperCanUseMode" ) == 0 )
 	{
 		/* Are IRC operators allowed to use MODE in channels they aren't Op in? */
-		if( strcasecmp( Arg, "yes" ) == 0 ) Conf_OperCanMode = TRUE;
-		else if( strcasecmp( Arg, "true" ) == 0 ) Conf_OperCanMode = TRUE;
-		else if( atoi( Arg ) != 0 ) Conf_OperCanMode = TRUE;
-		else Conf_OperCanMode = FALSE;
+		Conf_OperCanMode = Check_ArgIsTrue( Arg );
+		return;
+	}
+	if( strcasecmp( Var, "OperServerMode" ) == 0 )
+	{
+		/* Mask IRC operator as if coming from the server? (ircd-irc2 compat hack) */
+		Conf_OperServerMode = Check_ArgIsTrue( Arg );
 		return;
 	}
 	if( strcasecmp( Var, "MaxConnections" ) == 0 )
blob - 3c180160a2746a48cb050c17ed9ce541fde5e2cf
blob + 797c5a5c6d935a6e0b8f02247e7042cc499bc493
--- src/ngircd/conf.h
+++ src/ngircd/conf.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: conf.h,v 1.31 2005/03/02 16:07:31 alex Exp $
+ * $Id: conf.h,v 1.32 2005/03/15 16:56:18 alex Exp $
  *
  * Configuration management (header)
  */
@@ -114,6 +114,11 @@ GLOBAL INT Conf_Channel_Count;
 /* Are IRC operators allowed to always use MODE? */
 GLOBAL BOOLEAN Conf_OperCanMode;
 
+/* If an IRC op gives chanop privileges without being a chanop,
+ * ircd2 will ignore the command. This enables a workaround:
+ * It masks the command as coming from the server */
+GLOBAL BOOLEAN Conf_OperServerMode;
+
 /* Maximum number of connections to this server */
 GLOBAL LONG Conf_MaxConnections;
 
blob - 2f657f271fdcd911971e8023c1116c6e25730bb4
blob + 6fcb9e3307efd7a65084865651562c330ebeb7aa
--- src/ngircd/irc-mode.c
+++ src/ngircd/irc-mode.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-mode.c,v 1.38 2005/03/05 11:44:01 alex Exp $";
+static char UNUSED id[] = "$Id: irc-mode.c,v 1.39 2005/03/15 16:56:18 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -242,7 +242,7 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Or
 	/* Handle channel and channel-user modes */
 
 	CHAR the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2], argadd[CLIENT_PASS_LEN], *mode_ptr;
-	BOOLEAN ok, set, modeok, skiponce;
+	BOOLEAN ok, set, modeok = FALSE, skiponce, use_servermode = FALSE;
 	INT mode_arg, arg_arg;
 	CLIENT *client;
 	LONG l;
@@ -286,11 +286,13 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Or
 
 		/* Is he channel operator? */
 		if( strchr( Channel_UserModes( Channel, Origin ), 'o' )) modeok = TRUE;
-		else modeok = FALSE;
-		if( Conf_OperCanMode )
+		else if( Conf_OperCanMode )
 		{
-			/* auch IRC-Operatoren duerfen MODE verwenden */
-			if( Client_OperByMe( Origin )) modeok = TRUE;
+			/* IRC-Operators can use MODE as well */
+			if( Client_OperByMe( Origin )) {
+				modeok = TRUE;
+				if ( Conf_OperServerMode ) use_servermode = TRUE; /* Change Origin to Server */
+			}
 		}
 	}
 	else modeok = TRUE;
@@ -584,6 +586,8 @@ chan_exit:
 		}
 		else
 		{
+			if ( use_servermode ) Origin = Client_ThisServer();
+
 			/* Send reply to client and inform other servers and channel users */
 			ok = IRC_WriteStrClientPrefix( Client, Origin, "MODE %s %s%s", Channel_Name( Channel ), the_modes, the_args );
 			IRC_WriteStrServersPrefix( Client, Origin, "MODE %s %s%s", Channel_Name( Channel ), the_modes, the_args );