summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2014-03-18 16:43:21 +0100
committerAlexander Barton <alex@barton.de>2014-03-18 16:43:21 +0100
commitd314c75a37f0132a1a16658494d0f60a0c0083f2 (patch)
treeb2975e3f2e8a04a2e1184af65a57bad3272a8149
parent5009ab3e8c5a6fe7db5c5ad1d3fdc8aecfc64b55 (diff)
downloadngircd-d314c75a37f0132a1a16658494d0f60a0c0083f2.tar.gz
ngircd-d314c75a37f0132a1a16658494d0f60a0c0083f2.zip
Allow "DefaultUserModes" to set all possible modes
Let IRC_MODE() detect that the "fake" MODE command originated on the local
sever, which enables all modes to be settable using "DefaultUserModes"
that can be set by regular MODE commands, including modes only settable by
IRC Operators.
-rw-r--r--doc/sample-ngircd.conf.tmpl4
-rw-r--r--man/ngircd.conf.5.tmpl4
-rw-r--r--src/ngircd/irc-mode.c7
-rw-r--r--src/ngircd/login.c2
4 files changed, 12 insertions, 5 deletions
diff --git a/doc/sample-ngircd.conf.tmpl b/doc/sample-ngircd.conf.tmpl
index ec425bd2..1d07822c 100644
--- a/doc/sample-ngircd.conf.tmpl
+++ b/doc/sample-ngircd.conf.tmpl
@@ -172,8 +172,8 @@
 	;ConnectIPv4 = yes
 
 	# 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.
+	# only modes can be set that the client could set using regular MODE
+	# commands, you can't set "a" (away) for example! Default: none.
 	;DefaultUserModes = i
 
 	# Do DNS lookups when a client connects to the server.
diff --git a/man/ngircd.conf.5.tmpl b/man/ngircd.conf.5.tmpl
index 208b4611..9b2ed082 100644
--- a/man/ngircd.conf.5.tmpl
+++ b/man/ngircd.conf.5.tmpl
@@ -267,8 +267,8 @@ 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!
+can be set that the client could set using regular MODE commands, you can't
+set "a" (away) for example!
 Default: none.
 .TP
 \fBDNS\fR (boolean)
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index fe981213..79ab2ebe 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -68,6 +68,13 @@ IRC_MODE( CLIENT *Client, REQUEST *Req )
 
 	_IRC_GET_SENDER_OR_RETURN_(origin, Req, Client)
 
+	/* Test for "fake" MODE commands injected by this local instance,
+	 * for example when handling the "DefaultUserModes" settings.
+	 * This doesn't harm real commands, because prefixes of regular
+	 * clients are checked in Validate_Prefix() and can't be faked. */
+	if (Req->prefix && Client_Search(Req->prefix) == Client_ThisServer())
+		Client = Client_Search(Req->prefix);
+
 	/* Channel or user mode? */
 	cl = NULL; chan = NULL;
 	if (Client_IsValidNick(Req->argv[0]))
diff --git a/src/ngircd/login.c b/src/ngircd/login.c
index 7f427a3a..64cc8125 100644
--- a/src/ngircd/login.c
+++ b/src/ngircd/login.c
@@ -192,7 +192,7 @@ Login_User_PostAuth(CLIENT *Client)
 	/* Set default user modes */
 	if (Conf_DefaultUserModes[0]) {
 		snprintf(modes, sizeof(modes), "+%s", Conf_DefaultUserModes);
-		Req.prefix = Client_ThisServer();
+		Req.prefix = Client_ID(Client_ThisServer());
 		Req.command = "MODE";
 		Req.argc = 2;
 		Req.argv[0] = Client_ID(Client);