]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Various fixes and enhancements for the "Autojoin" patch
authorAlexander Barton <alex@barton.de>
Sun, 17 Sep 2023 17:38:53 +0000 (19:38 +0200)
committerAlexander Barton <alex@barton.de>
Sun, 17 Sep 2023 17:56:07 +0000 (19:56 +0200)
- Bring sample-ngircd.conf and ngircd.conf.5 description in line.
- Fix configuration parsing, it always showed the 'Unknown variable
  "Autojoin"' error message, even when everything was perfectly fine.
- And fix a build error (at least on macOS with Apple Clang 14):
    login.c:234:3: error: call to undeclared function 'IRC_JOIN'; ISO
    C99 and later do not support implicit function declarations
    [-Wimplicit-function-declaration]
       IRC_JOIN(Client, &Req);
       ^
  The #include for the "irc.channel.h" header was missing!
- Remove a unused variable that caused a compiler warning:
    login.c:222:12: warning: unused variable 'n' [-Wunused-variable]
       size_t i, n, channel_count = array_length(&Conf_Channels, sizeof(*conf_chan));
                 ^
- Add a explicit cast to fix a compiler warning:
    login.c:235:15: warning: assigning to 'char *' from 'const char[51]'
    discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
       Req.argv[0] = conf_chan->name;
                   ^ ~~~~~~~~~~~~~~~

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

index 2dbc3b992cd6e1e2083db9502a9687a2f572f96c..cea23a2bd39508a60582478b256dc8dd700aa241 100644 (file)
        ;Modes = +tnk mykey +l 5
        ;Modes = +b nick!~user@bad.host.example.com
 
+       # Should ngIRCd automatically join ("autojoin") all users to this
+       # channel on connect? Note: The users must have permissions to access
+       # the channel, otherwise joining them will fail!
+       ;Autojoin = yes
+
        # Key file, syntax for each line: "<user>:<nick>:<key>".
        # Default: none.
        ;KeyFile = :ETCDIR:/#chan.key
-       
-       # Autojoin - set to yes to force all users to join this channel on connect
-       ;Autojoin = yes
 
 [Channel]
        # More [Channel] sections, if you like ...
index 55b034c33cd262fceefcf971f0e1ca6b93830f26..80c00714c36e7f5360048a549de50eea5d1285e9 100644 (file)
@@ -518,7 +518,9 @@ This option can be specified multiple times, evaluated top to bottom.
 .RE
 .TP
 \fBAutojoin\fR (boolean)
-Forces users to join this channel on connect. Users must have access to the channel to make it work.
+Should ngIRCd automatically join ("autojoin") all users to this channel on
+connect? Note: The users must have permissions to access the channel, otherwise
+joining them will fail!
 .TP
 \fBKeyFile\fR (string)
 Path and file name of a "key file" containing individual channel keys for
index 5ee552e64d67fb63050b0b6f0021555527f58e3f..120db21641b671563c365697b3bdd126670ddace 100644 (file)
@@ -2000,9 +2000,11 @@ Handle_CHANNEL(const char *File, int Line, char *Var, char *Arg)
                        Config_Error_TooLong(File, Line, Var);
                return;
        }
-       if( strcasecmp( Var, "Autojoin" ) == 0 )
+       if( strcasecmp( Var, "Autojoin" ) == 0 ) {
                /* Check autojoin */
                chan->autojoin = Check_ArgIsTrue(Arg);
+               return;
+       }
        if( strcasecmp( Var, "Key" ) == 0 ) {
                /* Initial Channel Key (mode k) */
                len = strlcpy(chan->key, Arg, sizeof(chan->key));
index 0dd0bd892bb030c9cd6ac48584e27748c4d684a0..3412e337a75e6e63a1ef03afd098c1e173878814 100644 (file)
@@ -31,6 +31,7 @@
 #include "log.h"
 #include "messages.h"
 #include "ngircd.h"
+#include "irc-channel.h"
 #include "irc-info.h"
 #include "irc-mode.h"
 #include "irc-write.h"
@@ -201,24 +202,25 @@ Login_User_PostAuth(CLIENT *Client)
        } else
                IRC_SetPenalty(Client, 1);
 
-  /* Autojoin clients to the channels */
-  Login_Autojoin(Client);
+       /* Autojoin clients to the channels */
+       Login_Autojoin(Client);
 
        return CONNECTED;
 }
 
 /**
  * Autojoin clients to the channels set by administrator
- * If autojoin is not set in Config or the channel is not available for search - do nothing
  *
+ * Do nothing if autojoin is not set in the configuration or the channel is not
+ * available (any more).
  **/
 GLOBAL void
 Login_Autojoin(CLIENT *Client)
 {
-       /** make an autojoin to each channel that is good for it **/
        REQUEST Req;
        const struct Conf_Channel *conf_chan;
-       size_t i, n, channel_count = array_length(&Conf_Channels, sizeof(*conf_chan));
+       size_t i, channel_count = array_length(&Conf_Channels, sizeof(*conf_chan));
+
        conf_chan = array_start(&Conf_Channels);
        assert(channel_count == 0 || conf_chan != NULL);
 
@@ -230,7 +232,7 @@ Login_Autojoin(CLIENT *Client)
                Req.prefix = Client_ID(Client_ThisServer());
                Req.command = "JOIN";
                Req.argc = 1;
-               Req.argv[0] = conf_chan->name;
+               Req.argv[0] = (char *)conf_chan->name;
                IRC_JOIN(Client, &Req);
        }
 }