Allow ircd to run without ircd.conf using sensible defaults
authorRemco Rijnders <remmy@serenity-irc.net>
Sat, 7 Mar 2026 17:17:36 +0000 (12:17 -0500)
committerRemco Rijnders <remmy@serenity-irc.net>
Sat, 7 Mar 2026 17:17:36 +0000 (12:17 -0500)
- 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 <noreply@anthropic.com>
src/ircd.c
src/s_conf.c
src/s_err.c
src/s_user.c
tools/convert-conf.py

index 24fb1ce618671474b49b6e55a0695467e2b5af09..b7140d6e2b321d7500ab448e64842847942684f3 100644 (file)
@@ -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);
index 97313ba36bb1e48f8a2ca42fcb0577517a0014f8..08eb005e05311a7d553cadb9c94587e6ad9e4404 100644 (file)
@@ -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);
index b61e1643f6e9307d6e9e79d79cc15d1a43a403e2..dd0427318b89a14ce8b17a9787eb0ef2cb11d59d 100644 (file)
@@ -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."},
index b22cc683e711b85d13fc2fd9d98295fbaeeb8f02..ec57021574c32457a7211f45f946e6ce5755eeec 100644 (file)
@@ -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.
index 180fe6bdfa562951eca2ef2ffd8930c5f02452a9..30736313e3f4451fa8b271b6a6e648d4897f05d1 100755 (executable)
@@ -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()