Commit Diff


commit - 15dfdaac823c5927b096b2980753a6198a6a7741
commit + 139f5961a078dfd23a469d98c3942f42595854aa
blob - 31333ec2c7265cb40253a2e63291c781a2d47c90
blob + 99960e95f0d16a40b827ed67fd08fe60b39741bf
--- doc/sample-ngircd.conf.tmpl
+++ doc/sample-ngircd.conf.tmpl
@@ -128,6 +128,12 @@
 	# behavior of ngIRCd. If you want to get started quickly, you most
 	# probably don't have to make changes here -- they are all optional.
 
+	# List of allowed channel types (channel prefixes) for newly created
+	# channels on the local server. By default, all supported channel
+	# types are allowed. Set this variable to the empty string to disallow
+	# creation of new channels by local clients at all.
+	;AllowedChannelTypes = #&+
+
 	# Are remote IRC operators allowed to control this server, e.g.
 	# use commands like CONNECT, SQUIT, DIE, ...?
 	;AllowRemoteOper = no
@@ -209,9 +215,6 @@
 	# character prepended to their respective user names!
 	;PAMIsOptional = no
 
-	# Allow Pre-Defined Channels only (see Section [Channels])
-	;PredefChannelsOnly = no
-
 	# Let ngIRCd send an "authentication PING" when a new client connects,
 	# and register this client only after receiving the corresponding
 	# "PONG" reply.
blob - 64acd9273456f7d12dc2dba4de5ba8eb5f041bc9
blob + c9d7bf8318c00eb2505432d11b0e6722852e5a43
--- man/ngircd.conf.5.tmpl
+++ man/ngircd.conf.5.tmpl
@@ -208,6 +208,12 @@ seconds, it will be disconnected by the server. Defaul
 Optional features and configuration options to further tweak the behavior of
 ngIRCd. If you want to get started quickly, you most probably don't have to
 make changes here -- they are all optional.
+.TP
+\fBAllowedChannelTypes\fR (string)
+List of allowed channel types (channel prefixes) for newly created channels
+on the local server. By default, all supported channel types are allowed.
+Set this variable to the empty string to disallow creation of new channels
+by local clients at all. Default: #&+
 .TP
 \fBAllowRemoteOper\fR (boolean)
 Are IRC operators connected to remote servers allowed to control this server,
@@ -319,12 +325,6 @@ able to distinguish between Ident'ified and PAM-authen
 don't have a "~" character prepended to their respective user names!
 Default: no.
 .TP
-\fBPredefChannelsOnly\fR (boolean)
-If enabled, no new channels can be created. Useful if you do not want to have
-other channels than those defined in [Channel] sections in the configuration
-file on this server.
-Default: no.
-.TP
 \fBRequireAuthPing\fR (boolean)
 Let ngIRCd send an "authentication PING" when a new client connects, and
 register this client only after receiving the corresponding "PONG" reply.
blob - d07878422af960fd99070b2ba1605507fc876e4b
blob + 79376b80ba8b7c33335a6f0ddc1c61aecfae29c2
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
@@ -391,6 +391,7 @@ Conf_Test( void )
 	puts("");
 
 	puts("[OPTIONS]");
+	printf("  AllowedChannelTypes = %s\n", Conf_AllowedChannelTypes);
 	printf("  AllowRemoteOper = %s\n", yesno_to_str(Conf_AllowRemoteOper));
 	printf("  ChrootDir = %s\n", Conf_Chroot);
 	printf("  CloakHost = %s\n", Conf_CloakHost);
@@ -415,7 +416,6 @@ Conf_Test( void )
 	printf("  PAM = %s\n", yesno_to_str(Conf_PAM));
 	printf("  PAMIsOptional = %s\n", yesno_to_str(Conf_PAMIsOptional));
 #endif
-	printf("  PredefChannelsOnly = %s\n", yesno_to_str(Conf_PredefChannelsOnly));
 #ifndef STRICT_RFC
 	printf("  RequireAuthPing = %s\n", yesno_to_str(Conf_AuthPing));
 #endif
@@ -758,6 +758,8 @@ Set_Defaults(bool InitServers)
 	Conf_PongTimeout = 20;
 
 	/* Options */
+	strlcpy(Conf_AllowedChannelTypes, CHANTYPES,
+		sizeof(Conf_AllowedChannelTypes));
 	Conf_AllowRemoteOper = false;
 #ifndef STRICT_RFC
 	Conf_AuthPing = false;
@@ -792,7 +794,6 @@ Set_Defaults(bool InitServers)
 	Conf_PAM = false;
 #endif
 	Conf_PAMIsOptional = false;
-	Conf_PredefChannelsOnly = false;
 #ifdef SYSLOG
 	Conf_ScrubCTCP = false;
 #ifdef LOG_LOCAL5
@@ -1633,12 +1634,37 @@ static void
 Handle_OPTIONS(const char *File, int Line, char *Var, char *Arg)
 {
 	size_t len;
+	char *p;
 
 	assert(File != NULL);
 	assert(Line > 0);
 	assert(Var != NULL);
 	assert(Arg != NULL);
+
+	if (strcasecmp(Var, "AllowedChannelTypes") == 0) {
+		p = Arg;
+		Conf_AllowedChannelTypes[0] = '\0';
+		while (*p) {
+			if (strchr(Conf_AllowedChannelTypes, *p)) {
+				/* Prefix is already included; ignore it */
+				p++;
+				continue;
+			}
 
+			if (strchr(CHANTYPES, *p)) {
+				len = strlen(Conf_AllowedChannelTypes) + 1;
+				assert(len < sizeof(Conf_AllowedChannelTypes));
+				Conf_AllowedChannelTypes[len - 1] = *p;
+				Conf_AllowedChannelTypes[len] = '\0';
+			} else {
+				Config_Error(LOG_WARNING,
+					     "%s, line %d: Unknown channel prefix \"%c\" in \"AllowedChannelTypes\"!",
+					     File, Line, *p);
+			}
+			p++;
+		}
+		return;
+	}
 	if (strcasecmp(Var, "AllowRemoteOper") == 0) {
 		Conf_AllowRemoteOper = Check_ArgIsTrue(Arg);
 		return;
@@ -1731,7 +1757,19 @@ Handle_OPTIONS(const char *File, int Line, char *Var, 
 		return;
 	}
 	if (strcasecmp(Var, "PredefChannelsOnly") == 0) {
-		Conf_PredefChannelsOnly = Check_ArgIsTrue(Arg);
+		/*
+		 * TODO: This section and support for "PredefChannelsOnly"
+		 * could be removed starting with ngIRCd release 22 (one
+		 * release after marking it "deprecated") ...
+		 */
+		Config_Error(LOG_WARNING,
+			     "%s, line %d (section \"Options\"): \"%s\" is deprecated, please use \"AllowedChannelTypes\"!",
+			     File, Line, Var);
+		if (Check_ArgIsTrue(Arg))
+			Conf_AllowedChannelTypes[0] = '\0';
+		else
+			strlcpy(Conf_AllowedChannelTypes, CHANTYPES,
+				sizeof(Conf_AllowedChannelTypes));
 		return;
 	}
 #ifndef STRICT_RFC
blob - bbf4f36c24c4ff29d1c2b3dc99ba58897f658443
blob + 93d6785f2adb9499eb3d000e7fa45689c62d950a
--- src/ngircd/conf.h
+++ src/ngircd/conf.h
@@ -148,8 +148,8 @@ GLOBAL CONF_SERVER Conf_Server[MAX_SERVERS];
 /** Array of pre-defined channels */
 GLOBAL array Conf_Channels;
 
-/** Flag indicating if only pre-defined channels are allowed (true) or not */
-GLOBAL bool Conf_PredefChannelsOnly;
+/** String containing all locally allowed channel prefixes for new channels */
+GLOBAL char Conf_AllowedChannelTypes[8];
 
 /** Flag indicating if IRC operators are allowed to always use MODE (true) */
 GLOBAL bool Conf_OperCanMode;
blob - 7784c17470434ee7d3997767239c1b2bfe6c8d6c
blob + efe318625fa5615f0eb4be6be2304275b7a8c072
--- src/ngircd/defines.h
+++ src/ngircd/defines.h
@@ -178,6 +178,9 @@
 /** Supported channel modes. */
 #define CHANMODES "abehiIklmMnoOPqQrRstvVz"
 
+/** Supported channel types. */
+#define CHANTYPES "#&+"
+
 /** Away message for users connected to linked servers. */
 #define DEFAULT_AWAY_MSG "Away"
 
blob - 5e20deed423feef61343bf4524e09de2054d7219
blob + 07a6e5a530b677684b9f713db5bc31d4cce28f5c
--- src/ngircd/irc-channel.c
+++ src/ngircd/irc-channel.c
@@ -344,7 +344,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
 		}
 
 		chan = Channel_Search(channame);
-		if (!chan && Conf_PredefChannelsOnly) {
+		if (!chan && !strchr(Conf_AllowedChannelTypes, channame[0])) {
 			 /* channel must be created, but forbidden by config */
 			IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG,
 					   Client_ID(Client), channame);
blob - d05ce24c0934e2b55075aca07af9d8c1cd5a22e5
blob + 6fb2e31c9470c38703100983821759a5f1e7506c
--- src/ngircd/irc-info.c
+++ src/ngircd/irc-info.c
@@ -1580,7 +1580,7 @@ GLOBAL bool
 IRC_Send_ISUPPORT(CLIENT * Client)
 {
 	if (!IRC_WriteStrClient(Client, RPL_ISUPPORT1_MSG, Client_ID(Client),
-				Conf_MaxJoins))
+				CHANTYPES, CHANTYPES, Conf_MaxJoins))
 		return DISCONNECTED;
 	return IRC_WriteStrClient(Client, RPL_ISUPPORT2_MSG, Client_ID(Client),
 				  CHANNEL_NAME_LEN - 1, Conf_MaxNickLength - 1,
blob - 3a91c1838998ec1a85dba3f10978ca2a82a21563
blob + 53b96581e8a1ade48eac3c5f64a4505e7e9dda0c
--- src/ngircd/messages.h
+++ src/ngircd/messages.h
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
+ * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
 #define RPL_YOURHOST_MSG		"002 %s :Your host is %s, running version ngircd-%s (%s/%s/%s)"
 #define RPL_CREATED_MSG			"003 %s :This server has been started %s"
 #define RPL_MYINFO_MSG			"004 %s %s ngircd-%s %s %s"
-#define RPL_ISUPPORT1_MSG		"005 %s RFC2812 IRCD=ngIRCd CHARSET=UTF-8 CASEMAPPING=ascii PREFIX=(qaohv)~&@%%+ CHANTYPES=#&+ CHANMODES=beI,k,l,imMnOPQRstVz CHANLIMIT=#&+:%d :are supported on this server"
+#define RPL_ISUPPORT1_MSG		"005 %s RFC2812 IRCD=ngIRCd CHARSET=UTF-8 CASEMAPPING=ascii PREFIX=(qaohv)~&@%%+ CHANTYPES=%s CHANMODES=beI,k,l,imMnOPQRstVz CHANLIMIT=%s:%d :are supported on this server"
 #define RPL_ISUPPORT2_MSG		"005 %s CHANNELLEN=%d NICKLEN=%d TOPICLEN=%d AWAYLEN=%d KICKLEN=%d MODES=%d MAXLIST=beI:%d EXCEPTS=e INVEX=I PENALTY :are supported on this server"
 
 #define RPL_TRACELINK_MSG		"200 %s Link %s-%s %s %s V%s %ld %d %d"