Commit Diff


commit - 3b65f4e38d1ab019513f16b70581ae10574006e8
commit + 2bacb8210b4f0807eb50587bcc4329c7ea7a50c3
blob - 99960e95f0d16a40b827ed67fd08fe60b39741bf
blob + ae1b213950b8484ed4ab0ac92e9c9c03d86cea47
--- doc/sample-ngircd.conf.tmpl
+++ doc/sample-ngircd.conf.tmpl
@@ -165,7 +165,12 @@
 	;ConnectIPv6 = yes
 	;ConnectIPv4 = yes
 
-	# Do any DNS lookups when a client connects to the server.
+	# Default user mode(s) to set on new local clients. Please note that
+	# only modes can be set that the client could set on itself, you can't
+	# set "a" (away) or "o" (IRC Op), for example! Default: none.
+	;DefaultUserModes = i
+
+	# Do DNS lookups when a client connects to the server.
 	;DNS = yes
 
 	# Do IDENT lookups if ngIRCd has been compiled with support for it.
blob - c9d7bf8318c00eb2505432d11b0e6722852e5a43
blob + cf926f9a3b80845f1b45715664a66f1709fddb94
--- man/ngircd.conf.5.tmpl
+++ man/ngircd.conf.5.tmpl
@@ -257,6 +257,12 @@ Default: yes.
 Set this to no if you do not want ngIRCd to connect to other IRC servers using
 the IPv6 protocol.
 Default: yes.
+.TP
+\fBDefaultUserModes\fR (string)
+Default user mode(s) to set on new local clients. Please note that only modes
+can be set that the client could set on itself, you can't set "a" (away) or
+"o" (IRC Op), for example!
+Default: none.
 .TP
 \fBDNS\fR (boolean)
 If set to false, ngIRCd will not make any DNS lookups when clients connect.
blob - 79376b80ba8b7c33335a6f0ddc1c61aecfae29c2
blob + b10f4905c9ec7befb08b5b5717cc6397cc48bea9
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
@@ -402,6 +402,7 @@ Conf_Test( void )
 	printf("  ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
 	printf("  ConnectIPv6 = %s\n", yesno_to_str(Conf_ConnectIPv4));
 #endif
+	printf("  DefaultUserModes = %s\n", Conf_DefaultUserModes);
 	printf("  DNS = %s\n", yesno_to_str(Conf_DNS));
 #ifdef IDENT
 	printf("  Ident = %s\n", yesno_to_str(Conf_Ident));
@@ -776,6 +777,7 @@ Set_Defaults(bool InitServers)
 #else
 	Conf_ConnectIPv6 = false;
 #endif
+	strcpy(Conf_DefaultUserModes, "");
 	Conf_DNS = true;
 #ifdef IDENTAUTH
 	Conf_Ident = true;
@@ -1704,6 +1706,30 @@ Handle_OPTIONS(const char *File, int Line, char *Var, 
 	}
 	if (strcasecmp(Var, "ConnectIPv4") == 0) {
 		Conf_ConnectIPv4 = Check_ArgIsTrue(Arg);
+		return;
+	}
+	if (strcasecmp(Var, "DefaultUserModes") == 0) {
+		p = Arg;
+		Conf_DefaultUserModes[0] = '\0';
+		while (*p) {
+			if (strchr(Conf_DefaultUserModes, *p)) {
+				/* Mode is already included; ignore it */
+				p++;
+				continue;
+			}
+
+			if (strchr(USERMODES, *p)) {
+				len = strlen(Conf_DefaultUserModes) + 1;
+				assert(len < sizeof(Conf_DefaultUserModes));
+				Conf_DefaultUserModes[len - 1] = *p;
+				Conf_DefaultUserModes[len] = '\0';
+			} else {
+				Config_Error(LOG_WARNING,
+					     "%s, line %d: Unknown user mode \"%c\" in \"DefaultUserModes\"!",
+					     File, Line, *p);
+			}
+			p++;
+		}
 		return;
 	}
 	if (strcasecmp(Var, "DNS") == 0) {
blob - 93d6785f2adb9499eb3d000e7fa45689c62d950a
blob + 948749de617bc433b6302edac2633eb1fc6e2bbe
--- src/ngircd/conf.h
+++ src/ngircd/conf.h
@@ -202,6 +202,9 @@ GLOBAL bool Conf_PAMIsOptional;
 /** Disable all CTCP commands except for /me ? */
 GLOBAL bool Conf_ScrubCTCP;
 
+/** Default user modes for new local clients */
+GLOBAL char Conf_DefaultUserModes[CLIENT_MODE_LEN];
+
 /*
  * try to connect to remote systems using the ipv6 protocol,
  * if they have an ipv6 address? (default yes)
blob - bbde6359d70434748779ba96a8868134a8e1aa19
blob + 4011b8bcadd3216672b2ddfeb67a254eb3dff463
--- src/ngircd/login.c
+++ src/ngircd/login.c
@@ -19,6 +19,7 @@
 #include "imp.h"
 #include <assert.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
 #include <strings.h>
 #include <unistd.h>
@@ -37,6 +38,7 @@
 #include "ngircd.h"
 #include "pam.h"
 #include "irc-info.h"
+#include "irc-mode.h"
 #include "irc-write.h"
 
 #include "exp.h"
@@ -151,6 +153,9 @@ Login_User(CLIENT * Client)
 GLOBAL bool
 Login_User_PostAuth(CLIENT *Client)
 {
+	REQUEST Req;
+	char modes[CLIENT_MODE_LEN + 1];
+
 	assert(Client != NULL);
 
 	if (Class_HandleServerBans(Client) != CONNECTED)
@@ -185,8 +190,17 @@ Login_User_PostAuth(CLIENT *Client)
 	if (!IRC_Show_MOTD(Client))
 		return DISCONNECTED;
 
-	/* Suspend the client for a second ... */
-	IRC_SetPenalty(Client, 1);
+	/* Set default user modes */
+	if (Conf_DefaultUserModes[0]) {
+		snprintf(modes, sizeof(modes), "+%s", Conf_DefaultUserModes);
+		Req.prefix = Client_ThisServer();
+		Req.command = "MODE";
+		Req.argc = 2;
+		Req.argv[0] = Client_ID(Client);
+		Req.argv[1] = modes;
+		IRC_MODE(Client, &Req);
+	} else
+		IRC_SetPenalty(Client, 1);
 
 	return CONNECTED;
 }