]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Allow "DefaultUserModes" to set all possible modes
authorAlexander Barton <alex@barton.de>
Tue, 18 Mar 2014 15:43:21 +0000 (16:43 +0100)
committerAlexander Barton <alex@barton.de>
Tue, 18 Mar 2014 15:43:21 +0000 (16:43 +0100)
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.

doc/sample-ngircd.conf.tmpl
man/ngircd.conf.5.tmpl
src/ngircd/irc-mode.c
src/ngircd/login.c

index ec425bd284686546de2cc36bb330b82151937ba3..1d07822c5b405e748af8da30f13c397837afa8fc 100644 (file)
        ;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.
index 208b46110a00824fbab5d1844a1c1acc2a73023c..9b2ed08259b3e0ea2b2fd95c3f6ad5a7382e00e6 100644 (file)
@@ -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)
index fe981213b33c8d85a3ad3ccb467e54fd6b54b56d..79ab2ebe94beaa41b904b01b1493a83d125e5e25 100644 (file)
@@ -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]))
index 7f427a3a753e0fd3b0b9886d641439b521a3f08b..64cc81251c6594cbd129a56270262fa9fede6c19 100644 (file)
@@ -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);