about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/conf.c26
-rw-r--r--src/ngircd/conf.h3
-rw-r--r--src/ngircd/irc-channel.c10
3 files changed, 38 insertions, 1 deletions
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index 6cf4fe03..35fa60b1 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -417,6 +417,7 @@ Conf_Test( void )
 	printf("  ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
 	printf("  ConnectIPv6 = %s\n", yesno_to_str(Conf_ConnectIPv4));
 #endif
+	printf("  DefaultChannelModes = %s\n", Conf_DefaultChannelModes);
 	printf("  DefaultUserModes = %s\n", Conf_DefaultUserModes);
 	printf("  DNS = %s\n", yesno_to_str(Conf_DNS));
 #ifdef IDENTAUTH
@@ -810,6 +811,7 @@ Set_Defaults(bool InitServers)
 #else
 	Conf_ConnectIPv6 = false;
 #endif
+	strcpy(Conf_DefaultChannelModes, "");
 	strcpy(Conf_DefaultUserModes, "");
 	Conf_DNS = true;
 #ifdef IDENTAUTH
@@ -1654,6 +1656,30 @@ Handle_OPTIONS(const char *File, int Line, char *Var, char *Arg)
 		Conf_ConnectIPv4 = Check_ArgIsTrue(Arg);
 		return;
 	}
+	if (strcasecmp(Var, "DefaultChannelModes") == 0) {
+		p = Arg;
+		Conf_DefaultChannelModes[0] = '\0';
+		while (*p) {
+			if (strchr(Conf_DefaultChannelModes, *p)) {
+				/* Mode is already included; ignore it */
+				p++;
+				continue;
+			}
+
+			if (strchr(CHANMODES, *p)) {
+				len = strlen(Conf_DefaultChannelModes) + 1;
+				assert(len < sizeof(Conf_DefaultChannelModes));
+				Conf_DefaultChannelModes[len - 1] = *p;
+				Conf_DefaultChannelModes[len] = '\0';
+			} else {
+				Config_Error(LOG_WARNING,
+					     "%s, line %d: Unknown channel mode \"%c\" in \"DefaultChannelModes\"!",
+					     File, Line, *p);
+			}
+			p++;
+		}
+		return;
+	}
 	if (strcasecmp(Var, "DefaultUserModes") == 0) {
 		p = Arg;
 		Conf_DefaultUserModes[0] = '\0';
diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h
index 9378d17c..01056829 100644
--- a/src/ngircd/conf.h
+++ b/src/ngircd/conf.h
@@ -214,6 +214,9 @@ GLOBAL char Conf_PAMServiceName[MAX_PAM_SERVICE_NAME_LEN];
 /** Disable all CTCP commands except for /me ? */
 GLOBAL bool Conf_ScrubCTCP;
 
+/** Default channel modes for new channels */
+GLOBAL char Conf_DefaultChannelModes[CHANNEL_MODE_LEN];
+
 /** Default user modes for new local clients */
 GLOBAL char Conf_DefaultUserModes[CLIENT_MODE_LEN];
 
diff --git a/src/ngircd/irc-channel.c b/src/ngircd/irc-channel.c
index a1bb4ef5..cc34601c 100644
--- a/src/ngircd/irc-channel.c
+++ b/src/ngircd/irc-channel.c
@@ -291,7 +291,7 @@ IRC_Send_Channel_Info(CLIENT *Client, CHANNEL *Chan)
 GLOBAL bool
 IRC_JOIN( CLIENT *Client, REQUEST *Req )
 {
-	char *channame, *key = NULL, *flags, *lastkey = NULL, *lastchan = NULL;
+	char *channame, *key = NULL, *flags, *lastkey = NULL, *lastchan = NULL, *p;
 	CLIENT *target;
 	CHANNEL *chan;
 
@@ -389,6 +389,14 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
 		if (!chan) { /* channel is new; it has been created above */
 			chan = Channel_Search(channame);
 			assert(chan != NULL);
+
+			/* Set default channel modes */
+			p = Conf_DefaultChannelModes;
+			while (*p) {
+				Channel_ModeAdd(chan, *p);
+				p++;
+			}
+
 			if (Channel_IsModeless(chan)) {
 				Channel_ModeAdd(chan, 't'); /* /TOPIC not allowed */
 				Channel_ModeAdd(chan, 'n'); /* no external msgs */