diff --git a/configure b/configure index 3739e8e2..ef8f9751 100755 --- a/configure +++ b/configure @@ -1374,7 +1374,8 @@ Optional Packages: Custom branding name. --with-custom-version=NAME Custom version branding. - --with-nicklen=LENGTH Set the nick length to LENGTH (default 15, max 50) + --with-nicklen=LENGTH Set the upper-bound nick length to LENGTH (default + 50, max 50) --with-topiclen=NUMBER Set the max topic length to NUMBER (default 390, max 390) @@ -7916,7 +7917,7 @@ $as_echo "$as_me: WARNING: NICKLEN has a hard limit of 50. Setting NICKLEN=50" > fi else - NICKLEN=15 + NICKLEN=50 fi diff --git a/configure.ac b/configure.ac index f68652f2..a6e1b45f 100644 --- a/configure.ac +++ b/configure.ac @@ -893,7 +893,7 @@ dnl so enable small net unless you really need this much support fi AC_ARG_WITH(nicklen, -AC_HELP_STRING([--with-nicklen=LENGTH],[Set the nick length to LENGTH (default 15, max 50)]), +AC_HELP_STRING([--with-nicklen=LENGTH],[Set the upper-bound nick length to LENGTH (default 50, max 50)]), [ if ! expr "$withval" + 0 >/dev/null 2>&1; then AC_ERROR([NICKLEN must be a numeric value]) @@ -904,7 +904,7 @@ AC_HELP_STRING([--with-nicklen=LENGTH],[Set the nick length to LENGTH (default 1 else NICKLEN="$withval" fi -], [NICKLEN=15]) +], [NICKLEN=50]) AC_ARG_WITH(topiclen, AC_HELP_STRING([--with-topiclen=NUMBER],[Set the max topic length to NUMBER (default 390, max 390)]), diff --git a/doc/example.conf b/doc/example.conf index a3651114..bbc44012 100755 --- a/doc/example.conf +++ b/doc/example.conf @@ -80,6 +80,9 @@ serverinfo { * /quote set maxclients */ default_max_clients = 1024; + + /* nicklen: enforced nickname length (for this server only; must be 50 or smaller) */ + nicklen = 30; }; admin { diff --git a/doc/reference.conf b/doc/reference.conf index 91da8ff4..332f5cea 100755 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -160,6 +160,9 @@ serverinfo { * /quote set maxclients */ default_max_clients = 1024; + + /* nicklen: enforced nickname length (for this server only; must be 50 or smaller) */ + nicklen = 30; }; /* admin {}: contains admin information about the server. (OLD A:) */ diff --git a/include/s_conf.h b/include/s_conf.h index aa049a70..8526f06c 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -231,6 +231,7 @@ struct config_file_entry int client_flood_message_time; int client_flood_message_num; + unsigned int nicklen; }; struct config_channel_entry diff --git a/modules/core/m_nick.c b/modules/core/m_nick.c index 6361b2c6..0caa4596 100644 --- a/modules/core/m_nick.c +++ b/modules/core/m_nick.c @@ -138,7 +138,7 @@ mr_nick(struct Client *client_p, struct Client *source_p, int parc, const char * *s = '\0'; /* copy the nick and terminate it */ - rb_strlcpy(nick, parv[1], sizeof(nick)); + rb_strlcpy(nick, parv[1], ConfigFileEntry.nicklen); /* check the nickname is ok */ if(!clean_nick(nick, 1)) @@ -201,7 +201,7 @@ m_nick(struct Client *client_p, struct Client *source_p, int parc, const char *p flood_endgrace(source_p); /* terminate nick to NICKLEN, we dont want clean_nick() to error! */ - rb_strlcpy(nick, parv[1], sizeof(nick)); + rb_strlcpy(nick, parv[1], ConfigFileEntry.nicklen); /* check the nickname is ok */ if(!clean_nick(nick, 1)) @@ -566,7 +566,7 @@ clean_nick(const char *nick, int loc_client) } /* nicklen is +1 */ - if(len >= NICKLEN) + if(len >= NICKLEN && len >= ConfigFileEntry.nicklen) return 0; return 1; diff --git a/src/ircd.c b/src/ircd.c index dd6eb82c..b7448a5b 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -653,7 +653,6 @@ main(int argc, char *argv[]) init_reject(); init_cache(); init_monitor(); - init_isupport(); construct_cflags_strings(); @@ -674,6 +673,8 @@ main(int argc, char *argv[]) mod_add_path(MODULE_DIR "/autoload"); #endif + init_isupport(); + init_bandb(); init_ssld(); diff --git a/src/newconf.c b/src/newconf.c index 95013c53..e5afd0ac 100644 --- a/src/newconf.c +++ b/src/newconf.c @@ -260,6 +260,26 @@ conf_set_serverinfo_vhost6(void *data) #endif } +static void +conf_set_serverinfo_nicklen(void *data) +{ + static int nicklen_set = 0; + + if (nicklen_set) + return; + + ConfigFileEntry.nicklen = *(unsigned int *) data; + + if (ConfigFileEntry.nicklen > NICKLEN) + { + conf_report_error("Warning -- ignoring serverinfo::nicklen -- provided nicklen (%u) is greater than allowed nicklen (%u)", + ConfigFileEntry.nicklen, NICKLEN); + ConfigFileEntry.nicklen = NICKLEN; + } + + nicklen_set = 1; +} + static void conf_set_modules_module(void *data) { @@ -2085,6 +2105,8 @@ static struct ConfEntry conf_serverinfo_table[] = { "default_max_clients",CF_INT, NULL, 0, &ServerInfo.default_max_clients }, + { "nicklen", CF_INT, conf_set_serverinfo_nicklen, 0, NULL }, + { "\0", 0, NULL, 0, NULL } }; diff --git a/src/s_conf.c b/src/s_conf.c index dd167c98..36952253 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -801,6 +801,8 @@ set_default_conf(void) ServerInfo.default_max_clients = MAXCONNECTIONS; + ConfigFileEntry.nicklen = NICKLEN; + if (!alias_dict) alias_dict = irc_dictionary_create(strcasecmp); } diff --git a/src/supported.c b/src/supported.c index ff59396d..abe1d506 100644 --- a/src/supported.c +++ b/src/supported.c @@ -292,9 +292,12 @@ void init_isupport(void) { static int maxmodes = MAXMODEPARAMS; - static int nicklen = NICKLEN-1; static int channellen = LOC_CHANNELLEN; static int topiclen = TOPICLEN; + static int nicklen = NICKLEN - 1; + static int nicklen_usable; + + nicklen_usable = ConfigFileEntry.nicklen - 1; add_isupport("CHANTYPES", isupport_chantypes, NULL); add_isupport("EXCEPTS", isupport_boolean, &ConfigChannel.use_except); @@ -311,6 +314,7 @@ init_isupport(void) add_isupport("CASEMAPPING", isupport_string, "rfc1459"); add_isupport("CHARSET", isupport_string, "ascii"); add_isupport("NICKLEN", isupport_intptr, &nicklen); + add_isupport("NICKLEN_USABLE", isupport_intptr, &nicklen_usable); add_isupport("CHANNELLEN", isupport_intptr, &channellen); add_isupport("TOPICLEN", isupport_intptr, &topiclen); add_isupport("ETRACE", isupport_string, "");