]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conf.c
Block nicknames that are reserved for services
[ngircd-alex.git] / src / ngircd / conf.c
index 36eff905ecce8b04b4cfd9e20371c78c72c52b4b..41b5469a8140f4c5a07d1874dd6d048fcbf6ae3b 100644 (file)
@@ -359,7 +359,7 @@ Conf_Test( void )
        printf("  ChrootDir = %s\n", Conf_Chroot);
        printf("  CloakHost = %s\n", Conf_CloakHost);
        printf("  CloakHostModeX = %s\n", Conf_CloakHostModeX);
-       printf("  CloakHostModeXSalt = %s\n", Conf_CloakHostModeXSalt);
+       printf("  CloakHostSalt = %s\n", Conf_CloakHostSalt);
        printf("  CloakUserToNick = %s\n", yesno_to_str(Conf_CloakUserToNick));
 #ifdef WANT_IPV6
        printf("  ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
@@ -636,16 +636,42 @@ Conf_AddServer(const char *Name, UINT16 Port, const char *Host,
 }
 
 /**
- * Check if the given nick name is an service.
+ * Check if the given nick name is reserved for services on a particular server.
  *
+ * @param ConfServer The server index to check.
+ * @param Nick The nick name to check.
  * @returns true if the given nick name belongs to an "IRC service".
  */
 GLOBAL bool
-Conf_IsService(int ConfServer, const char *Nick)
+Conf_NickIsService(int ConfServer, const char *Nick)
 {
+       assert (ConfServer >= 0);
+       assert (ConfServer < MAX_SERVERS);
+
        return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick);
 }
 
+/**
+ * Check if the given nick name is blocked for "normal client" use.
+ *
+ * @param ConfServer The server index or NONE to check all configured servers.
+ * @param Nick The nick name to check.
+ * @returns true if the given nick name belongs to an "IRC service".
+ */
+GLOBAL bool
+Conf_NickIsBlocked(const char *Nick)
+{
+       int i;
+
+       for(i = 0; i < MAX_SERVERS; i++) {
+               if (!Conf_Server[i].name[0])
+                       continue;
+               if (Conf_NickIsService(i, Nick))
+                       return true;
+       }
+       return false;
+}
+
 /**
  * Initialize configuration settings with their default values.
  */
@@ -653,7 +679,7 @@ static void
 Set_Defaults(bool InitServers)
 {
        int i;
-       char random[RANDOM_SALT_LEN];
+       char random[RANDOM_SALT_LEN + 1];
 
        /* Global */
        strcpy(Conf_ServerName, "");
@@ -688,7 +714,7 @@ Set_Defaults(bool InitServers)
        strlcpy(Conf_Chroot, CHROOT_DIR, sizeof(Conf_Chroot));
        strcpy(Conf_CloakHost, "");
        strcpy(Conf_CloakHostModeX, "");
-       strcpy(Conf_CloakHostModeXSalt,ngt_RandomStr(random,RANDOM_SALT_LEN));
+       strcpy(Conf_CloakHostSalt, ngt_RandomStr(random, RANDOM_SALT_LEN));
        Conf_CloakUserToNick = false;
        Conf_ConnectIPv4 = true;
 #ifdef WANT_IPV6
@@ -1488,9 +1514,9 @@ Handle_OPTIONS(int Line, char *Var, char *Arg)
                        Config_Error_TooLong(Line, Var);
                return;
        }
-       if (strcasecmp(Var, "CloakHostModeXSalt") == 0) {
-               len = strlcpy(Conf_CloakHostModeXSalt, Arg, sizeof(Conf_CloakHostModeXSalt));
-               if (len >= sizeof(Conf_CloakHostModeX))
+       if (strcasecmp(Var, "CloakHostSalt") == 0) {
+               len = strlcpy(Conf_CloakHostSalt, Arg, sizeof(Conf_CloakHostSalt));
+               if (len >= sizeof(Conf_CloakHostSalt))
                        Config_Error_TooLong(Line, Var);
                return;
        }