From: Remco Rijnders Date: Sat, 7 Mar 2026 17:17:36 +0000 (-0500) Subject: Allow ircd to run without ircd.conf using sensible defaults X-Git-Url: http://git.serene-ircd.net/?a=commitdiff_plain;h=ac09a43fc068db1a30ff300b8f1fb33712316c6e;p=serene-ircd.git Allow ircd to run without ircd.conf using sensible defaults - Missing config file prints a warning and continues instead of exiting - Default listen port is 6667 when no me{} block exists - Auto-inject allow-all block when no allow{} blocks are configured - Run from current directory instead of requiring DPATH to exist - Always allow -f flag for specifying config file path - Make RPL_POLICY (AUP notice) fully runtime-configurable; skip if empty - Update convert-conf.py to emit network{}, limits{}, and general{} blocks with Serenity-IRC defaults, and fix F-line to use limits{} Co-Authored-By: Claude Opus 4.6 --- diff --git a/src/ircd.c b/src/ircd.c index 24fb1ce..b7140d6 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -67,7 +67,7 @@ int bootopt = 0; /* Server boot option flags */ char *debugmode = ""; /* -"- -"- -"- */ char *sbrk0; /* initial sbrk(0) */ static int dorehash = 0; -static char *dpath = DPATH; +static char *dpath = NULL; time_t nextconnect = 1; /* time for next try_connections call */ time_t nextping = 1; /* same as above for check_pings() */ @@ -486,12 +486,10 @@ int main (int argc, char *argv[]) (void) setuid ((uid_t) uid); bootopt |= BOOT_OPER; break; -#ifdef CMDLINE_CONFIG case 'f': (void) setuid ((uid_t) uid); configfile = p; break; -#endif /* CMDLINE_CONFIG */ case 'h': strncpyzt (me.name, p, sizeof (me.name)); break; @@ -528,12 +526,11 @@ int main (int argc, char *argv[]) } } -#ifndef CHROOT - if (chdir (dpath)) { + /* If -d was given, chdir there; otherwise stay in cwd */ + if (dpath && dpath[0] && chdir (dpath)) { perror ("chdir"); exit (-1); } -#endif #if !defined(IRC_UID) if ((uid != euid) && !euid) { @@ -602,14 +599,38 @@ int main (int argc, char *argv[]) exit (-1); } if (!(bootopt & BOOT_INETD)) { -/* static char star[] = "*"; Compiler says this is unused */ aConfItem *aconf; - if ((aconf = find_me ()) && portarg <= 0 && aconf->port > 0) - portnum = aconf->port; + aconf = find_me (); + if (aconf) { + if (portarg <= 0 && aconf->port > 0) + portnum = aconf->port; + } else { + /* No me{} block — use defaults */ + if (portarg <= 0) + portnum = 6667; + } Debug ((DEBUG_ERROR, "Port = %d", portnum)); - if (inetport (&me, aconf->passwd, portnum)) + if (inetport (&me, aconf ? aconf->passwd : "*", portnum)) exit (1); + + /* If no allow{} blocks exist, add a default allow-all */ + { + aConfItem *tmp; + int has_allow = 0; + for (tmp = conf; tmp; tmp = tmp->next) + if (tmp->status & CONF_CLIENT) { has_allow = 1; break; } + if (!has_allow) { + aConfItem *defallow = make_conf (); + defallow->status = CONF_CLIENT; + DupString (defallow->host, "*@*"); + DupString (defallow->passwd, ""); + DupString (defallow->name, "*@*"); + Class (defallow) = find_class (0); + defallow->next = conf; + conf = defallow; + } + } } else if (inetport (&me, "*", 0)) exit (1); diff --git a/src/s_conf.c b/src/s_conf.c index 97313ba..08eb005 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -1024,8 +1024,13 @@ int initconf (int opt) is_hub = 0; Debug ((DEBUG_DEBUG, "initconf(): ircd.conf = %s", configfile)); - if ((fd = openconf ()) == -1) - return -1; + if ((fd = openconf ()) == -1) { + (void) fprintf (stderr, + "WARNING: No configuration file found (%s)\n" + " Running with defaults (listening on *:6667)\n", + configfile); + return 0; + } filebuf = conf_read_file (fd); (void) close (fd); diff --git a/src/s_err.c b/src/s_err.c index b61e164..dd04273 100644 --- a/src/s_err.c +++ b/src/s_err.c @@ -697,7 +697,7 @@ static Numeric numeric_replies2[] = { {RPL_MAPMORE, ":%s%-*s --> *more*"}, /* 616 */ {RPL_POLICY, - ":Welcome to the Serenity-IRC network \2%s\2! Using Serenity-IRC constitutes agreement with our Acceptable Use Policy. You may view our policy at http://www.serenity-irc.net/aup"}, + ":Welcome to the %s network \2%s\2! Using %s constitutes agreement with our Acceptable Use Policy. You may view our policy at %s"}, /* 617 */ {ERR_HTCTOOFAST, ":You are sending too fast. Please wait %i seconds before sending new commands."}, diff --git a/src/s_user.c b/src/s_user.c index b22cc68..ec57021 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -677,7 +677,10 @@ static int register_user (aClient *cptr, aClient *sptr, char *nick, char *userna (void) m_lusers (sptr, sptr, 1, parv); update_load (); (void) m_motd (sptr, sptr, 1, parv); - sendto_one (sptr, rpl_str (RPL_POLICY), me.name, parv[0], parv[0]); + if (cfg_network_aup[0]) + sendto_one (sptr, rpl_str (RPL_POLICY), me.name, parv[0], + cfg_network_name, parv[0], cfg_network_name, + cfg_network_aup); /* * Now send a numeric to the user telling them what, if * anything, happened. diff --git a/tools/convert-conf.py b/tools/convert-conf.py index 180fe6b..3073631 100755 --- a/tools/convert-conf.py +++ b/tools/convert-conf.py @@ -183,9 +183,9 @@ def convert_line(linetype, fields): return f'# Unrecognized G-line option: {host}' elif linetype == 'F' or linetype == 'f': - # F:minutes + # F:minutes (zline time) if host: - return f'general {{\n time {host};\n}};' + return f'limits {{\n zlinetime {host};\n}};' return '' elif linetype == 'S' or linetype == 's': @@ -313,6 +313,61 @@ def main(): print() print(block) + # Emit default network/limits/general blocks for settings that + # were formerly compile-time defines. The admin should review + # and adjust these values for their network. + print() + print('# Network identity and services (formerly compile-time defines).') + print('# Review and adjust these for your network.') + print('network {') + print(' network Serenity-IRC.Net;') + print(' adminchan #help;') + print(' randomserv irc.serenity-irc.net;') + print(' website "http://www.serenity-irc.net";') + print(' aup "http://www.serenity-irc.net/aup/";') + print(' kline_address kline@serenity-irc.net;') + print(' services_name Services.Serenity-IRC.Net;') + print(' chanserv ChanServ;') + print(' nickserv NickServ;') + print(' memoserv MemoServ;') + print(' operserv OperServ;') + print(' webserv WebServ;') + print(' ircop_host IRCop.Serenity-IRC.Net;') + print(' admin_host Admin.Serenity-IRC.Net;') + print(' locop_host Local.Serenity-IRC.Net;') + print(' sadmin_host ServOp.Serenity-IRC.Net;') + print(' sroot_host SRA.Serenity-IRC.Net;') + print(' netadmin_host NetAdmin.Serenity-IRC.Net;') + print(' mask_prefix Serene;') + print(' x_prefix Serene;') + print('};') + print() + print('# Tuning limits (formerly compile-time defines).') + print('limits {') + print(' maxchannels 10;') + print(' nickdelay 30;') + print(' targetdelay 120;') + print(' clientflood 6000;') + print(' maxsendq 3000000;') + print(' bufferpool 27000000;') + print(' listenqueue 5;') + print(' htctime 5;') + print(' htctrigger 15;') + print(' clonelimit 3;') + print(' cloneperiod 15;') + print(' clonedelay 300;') + print(' zlinetime 1;') + print('};') + print() + print('# Feature toggles (formerly compile-time defines).') + print('general {') + print(' # hub yes;') + print(' throttle yes;') + print(' seeuserstats yes;') + print(' crypt_oper_password yes;') + print(' crypt_iline_password yes;') + print('};') + if __name__ == '__main__': main()