]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Merge branch 'bug152-AllowedChannelTypes'
authorAlexander Barton <alex@barton.de>
Sun, 4 Aug 2013 12:11:12 +0000 (14:11 +0200)
committerAlexander Barton <alex@barton.de>
Sun, 4 Aug 2013 12:11:12 +0000 (14:11 +0200)
* bug152-AllowedChannelTypes:
  Implement new configuration option "AllowedChannelTypes"
  Introduce "CHANTYPES" #define

1  2 
src/ngircd/conf.c
src/ngircd/irc-channel.c
src/ngircd/irc-info.c

diff --combined src/ngircd/conf.c
index d07878422af960fd99070b2ba1605507fc876e4b,70c96092a12912c7042d4d36226f3f6b099dcb64..79376b80ba8b7c33335a6f0ddc1c61aecfae29c2
@@@ -317,7 -317,7 +317,7 @@@ opers_puts(void
   * This function waits for a keypress of the user when stdin/stdout are valid
   * tty's ("you can read our nice message and we can read in your keypress").
   *
 - * @return    0 on succes, 1 on failure(s); therefore the result code can
 + * @return    0 on success, 1 on failure(s); therefore the result code can
   *            directly be used by exit() when running "ngircd --configtest".
   */
  GLOBAL int
@@@ -391,6 -391,7 +391,7 @@@ Conf_Test( void 
        puts("");
  
        puts("[OPTIONS]");
+       printf("  AllowedChannelTypes = %s\n", Conf_AllowedChannelTypes);
        printf("  AllowRemoteOper = %s\n", yesno_to_str(Conf_AllowRemoteOper));
        printf("  ChrootDir = %s\n", Conf_Chroot);
        printf("  CloakHost = %s\n", Conf_CloakHost);
        printf("  PAM = %s\n", yesno_to_str(Conf_PAM));
        printf("  PAMIsOptional = %s\n", yesno_to_str(Conf_PAMIsOptional));
  #endif
-       printf("  PredefChannelsOnly = %s\n", yesno_to_str(Conf_PredefChannelsOnly));
  #ifndef STRICT_RFC
        printf("  RequireAuthPing = %s\n", yesno_to_str(Conf_AuthPing));
  #endif
@@@ -758,6 -758,8 +758,8 @@@ Set_Defaults(bool InitServers
        Conf_PongTimeout = 20;
  
        /* Options */
+       strlcpy(Conf_AllowedChannelTypes, CHANTYPES,
+               sizeof(Conf_AllowedChannelTypes));
        Conf_AllowRemoteOper = false;
  #ifndef STRICT_RFC
        Conf_AuthPing = false;
        Conf_PAM = false;
  #endif
        Conf_PAMIsOptional = false;
-       Conf_PredefChannelsOnly = false;
  #ifdef SYSLOG
        Conf_ScrubCTCP = false;
  #ifdef LOG_LOCAL5
@@@ -1633,12 -1634,37 +1634,37 @@@ static voi
  Handle_OPTIONS(const char *File, int Line, char *Var, char *Arg)
  {
        size_t len;
+       char *p;
  
        assert(File != NULL);
        assert(Line > 0);
        assert(Var != NULL);
        assert(Arg != NULL);
  
+       if (strcasecmp(Var, "AllowedChannelTypes") == 0) {
+               p = Arg;
+               Conf_AllowedChannelTypes[0] = '\0';
+               while (*p) {
+                       if (strchr(Conf_AllowedChannelTypes, *p)) {
+                               /* Prefix is already included; ignore it */
+                               p++;
+                               continue;
+                       }
+                       if (strchr(CHANTYPES, *p)) {
+                               len = strlen(Conf_AllowedChannelTypes) + 1;
+                               assert(len < sizeof(Conf_AllowedChannelTypes));
+                               Conf_AllowedChannelTypes[len - 1] = *p;
+                               Conf_AllowedChannelTypes[len] = '\0';
+                       } else {
+                               Config_Error(LOG_WARNING,
+                                            "%s, line %d: Unknown channel prefix \"%c\" in \"AllowedChannelTypes\"!",
+                                            File, Line, *p);
+                       }
+                       p++;
+               }
+               return;
+       }
        if (strcasecmp(Var, "AllowRemoteOper") == 0) {
                Conf_AllowRemoteOper = Check_ArgIsTrue(Arg);
                return;
                return;
        }
        if (strcasecmp(Var, "PredefChannelsOnly") == 0) {
-               Conf_PredefChannelsOnly = Check_ArgIsTrue(Arg);
+               /*
+                * TODO: This section and support for "PredefChannelsOnly"
+                * could be removed starting with ngIRCd release 22 (one
+                * release after marking it "deprecated") ...
+                */
+               Config_Error(LOG_WARNING,
+                            "%s, line %d (section \"Options\"): \"%s\" is deprecated, please use \"AllowedChannelTypes\"!",
+                            File, Line, Var);
+               if (Check_ArgIsTrue(Arg))
+                       Conf_AllowedChannelTypes[0] = '\0';
+               else
+                       strlcpy(Conf_AllowedChannelTypes, CHANTYPES,
+                               sizeof(Conf_AllowedChannelTypes));
                return;
        }
  #ifndef STRICT_RFC
@@@ -2281,7 -2319,7 +2319,7 @@@ Conf_DebugDump(void
  #endif
  
  /**
 - * Initialize server configuration structur to default values.
 + * Initialize server configuration structure to default values.
   *
   * @param Server      Pointer to server structure to initialize.
   */
diff --combined src/ngircd/irc-channel.c
index 5e20deed423feef61343bf4524e09de2054d7219,16501becbaed1651625942c0c9f675bf33ce21e9..07a6e5a530b677684b9f713db5bc31d4cce28f5c
@@@ -175,7 -175,7 +175,7 @@@ join_set_channelmodes(CHANNEL *chan, CL
  /**
   * Forward JOIN command to a specific server
   *
 - * This function diffentiates between servers using RFC 2813 mode that
 + * This function differentiates between servers using RFC 2813 mode that
   * support the JOIN command with appended ASCII 7 character and channel
   * modes, and servers using RFC 1459 protocol which require separate JOIN
   * and MODE commands.
@@@ -253,7 -253,7 +253,7 @@@ join_forward(CLIENT *Client, CLIENT *ta
  } /* join_forward */
  
  /**
 - * Aknowledge user JOIN request and send "channel info" numerics.
 + * Acknowledge user JOIN request and send "channel info" numerics.
   *
   * @param Client      Client used to prefix the genrated commands
   * @param target      Forward commands/numerics to this user
@@@ -344,7 -344,7 +344,7 @@@ IRC_JOIN( CLIENT *Client, REQUEST *Req 
                }
  
                chan = Channel_Search(channame);
-               if (!chan && Conf_PredefChannelsOnly) {
+               if (!chan && !strchr(Conf_AllowedChannelTypes, channame[0])) {
                         /* channel must be created, but forbidden by config */
                        IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG,
                                           Client_ID(Client), channame);
@@@ -495,7 -495,7 +495,7 @@@ IRC_TOPIC( CLIENT *Client, REQUEST *Re
                                          Client_ID(from), Req->argv[0]);
  
        /* Only remote servers and channel members are allowed to change the
 -       * channel topic, and IRC opreators when the Conf_OperCanMode option
 +       * channel topic, and IRC operators when the Conf_OperCanMode option
         * is set in the server configuration. */
        if (Client_Type(Client) != CLIENT_SERVER) {
                topic_power = Client_HasMode(from, 'o');
@@@ -745,7 -745,7 +745,7 @@@ IRC_CHANINFO( CLIENT *Client, REQUEST *
                }
        }
  
 -      /* Forward CHANINFO to other serevrs */
 +      /* Forward CHANINFO to other servers */
        if (Req->argc == 5)
                IRC_WriteStrServersPrefixFlag(Client, from, 'C',
                                              "CHANINFO %s %s %s %s :%s",
diff --combined src/ngircd/irc-info.c
index d05ce24c0934e2b55075aca07af9d8c1cd5a22e5,bc27b8d0297fa639aec8bb98fc1b1ace67437b60..6fb2e31c9470c38703100983821759a5f1e7506c
@@@ -387,11 -387,11 +387,11 @@@ IRC_WHOIS_SendReply(CLIENT *Client, CLI
                        return DISCONNECTED;
  
                /* Certificate fingerprint? */
 -              if (Conn_GetFingerprint(Client_Conn(c)) &&
 +              if (Conn_GetCertFp(Client_Conn(c)) &&
                    from == c &&
                    !IRC_WriteStrClient(from, RPL_WHOISCERTFP_MSG,
                                        Client_ID(from), Client_ID(c),
 -                                      Conn_GetFingerprint(Client_Conn(c))))
 +                                      Conn_GetCertFp(Client_Conn(c))))
                        return DISCONNECTED;
        }
  
@@@ -462,10 -462,10 +462,10 @@@ Show_MOTD_SSLInfo(CLIENT *Client
                        return false;
        }
  
 -      if (Conn_GetFingerprint(Client_Conn(Client))) {
 +      if (Conn_GetCertFp(Client_Conn(Client))) {
                snprintf(buf, sizeof(buf),
                         "Your client certificate fingerprint is: %s",
 -                       Conn_GetFingerprint(Client_Conn(Client)));
 +                       Conn_GetCertFp(Client_Conn(Client)));
                if (!IRC_WriteStrClient(Client, RPL_MOTD_MSG,
                                        Client_ID(Client), buf))
                        return false;
@@@ -1404,7 -1404,7 +1404,7 @@@ IRC_Send_LUSERS(CLIENT *Client
  
        assert(Client != NULL);
  
 -      /* Users, services and serevers in the network */
 +      /* Users, services and servers in the network */
        if (!IRC_WriteStrClient(Client, RPL_LUSERCLIENT_MSG, Client_ID(Client),
                                Client_UserCount(), Client_ServiceCount(),
                                Client_ServerCount()))
@@@ -1580,7 -1580,7 +1580,7 @@@ GLOBAL boo
  IRC_Send_ISUPPORT(CLIENT * Client)
  {
        if (!IRC_WriteStrClient(Client, RPL_ISUPPORT1_MSG, Client_ID(Client),
-                               Conf_MaxJoins))
+                               CHANTYPES, CHANTYPES, Conf_MaxJoins))
                return DISCONNECTED;
        return IRC_WriteStrClient(Client, RPL_ISUPPORT2_MSG, Client_ID(Client),
                                  CHANNEL_NAME_LEN - 1, Conf_MaxNickLength - 1,