• exec/load/domains_cfg_upg

    From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Fri Nov 20 15:25:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/79e573b634611eb05190069a
    Added Files:
    exec/load/domains_cfg_upgrade.js exec/tests/inet_domains/access.js exec/tests/inet_domains/config/child.inc configured.js equivalence.js equivalence_child.inc fallback.js fallback_child.inc scratch.inc skipif exec/tests/inet_domains/mailauth.js matcher.js skipif upgrade.js
    Modified Files:
    exec/mailauth.js update.js src/sbbs3/gtkmonitor/events.c events.h gtkmonitor.glade gtkmonitor_glade.c src/sbbs3/js_system.cpp js_user.cpp mailsrvr.cpp netmail.cpp src/sbbs3/scfg/scfg.c scfgindex.h scfgnet.c src/sbbs3/scfgdefs.h scfglib.h scfglib1.c scfgsave.c src/sbbs3/umonitor/umonitor.c src/sbbs3/userdat.c userdat.h
    Removed Files:
    ctrl/domains.cfg
    Log Message:
    Additional domains: move from ctrl/domains.cfg to msgs.ini [domain:]

    The list of additional Internet domains (mail for them is local, and a
    sender claiming one from outside is suspect) was a hand-edited filter
    file, ctrl/domains.cfg, re-read by findstr() on every check. It is now
    part of the message configuration: one [domain:<name>] section per
    entry in ctrl/msgs.ini, in order, with two new settings:

    send_from = false users may send from this domain
    send_ars = requirements to do so (blank = any user allowed
    to send Internet e-mail)

    The names are matched exactly as the lines of domains.cfg were: the
    configured names are handed, in order, to findstr_in_list(), so
    wildcards, negation, sub-string and prefix patterns keep their meaning.
    A section name is stored verbatim; the ini reader takes the text up to
    the last ']', so names containing '*', '!' or ']' read back unchanged.

    Shared helpers in the configuration library:
    - inet_domain_listed(): is a host one of the additional domains (used
    by the mail server everywhere it read domains.cfg, and by
    netmail.cpp to decide that an address is not remote)
    - user_can_send_from_inet_domain(): may a user send from a domain:
    only an entry that is a plain host name (letters, digits, dots and
    hyphens) and local by the whole list, with send_from on, for an
    active, non-guest user allowed to send Internet e-mail who meets
    send_ars (the system's own address is always allowed for such a user)

    The mail server picks up a changed list when it is recycled.

    domains.cfg is never renamed or removed, because a mail server still
    running an older binary (not yet restarted, or another host sharing the
    ctrl directory) reads it for every message. Instead:
    - While msgs.ini has no [domain:] section and no
    "domains_converted = true" in its [Internet] section, the
    configuration loader reads domains.cfg as the list (send_from off),
    so binaries upgraded before "jsexec update.js" has run keep their
    domains. Everything that consults the list agrees meanwhile: the mail
    server, netmail, system.inet_domain_list, User.can_send_from_domain()
    and mailauth.js. The mail server says at startup and recycle that the
    list came from domains.cfg and that update.js converts it.
    - update.js (new library exec/load/domains_cfg_upgrade.js) appends one
    section per entry, in order, and then sets the key; it sets only the
    key when the entries are all sections already, and does nothing once
    the key is set. It then says the file is no longer used and may be
    deleted once every host sharing the ctrl directory runs this version.
    - SCFG shows the entries read from the file with a one-time notice, and
    writes the key with every save of msgs.ini. Once the key is set the
    file is never read, so a list emptied in SCFG stays empty.

    The fallback reader (C) and the converter (JS) read the file by the
    same rules, stated on both sides, so the list answers every host as
    findstr() on the file did: lines are read as find2strs() read them (1000-character pieces, leading white space skipped, c_unescape_str()
    applied, text from the first tab cut, trailing white space removed);
    comments, empty lines and later duplicates are dropped except where the
    last line decides hosts that no entry matches; a name that cannot be a
    section name (over 255 characters, CR or LF, leading white space)
    becomes an inert ";" entry, with a warning from the converter. At most
    10000 lines are read.

    As before, a list that ends with a negated ("!") entry makes every
    other host match. SCFG, the converter and the mail server now warn
    about such a list, and the help text says the first entry that matches
    a domain decides, so a negated entry belongs before the wildcard entry
    it is an exception to.

    SCFG: Networks->Internet E-mail->Additional Domains lists, adds,
    deletes and edits the entries (name, Allow Send From, and Send
    Requirements, listed only when Allow Send From is Yes); the search
    index is regenerated.

    JavaScript: system.inet_domain_list, a read-only array of strings like system.fido_addr_list: the system's primary Internet address first,
    then the configured names in order. Matching a host against it is the
    existing system.findstr(system.inet_domain_list, host). The per-user
    question is a User method, beside can_send_mail(): user.can_send_from_domain(domain), which is also true for the system's
    own address for any active, non-guest user allowed to send Internet
    e-mail.

    mailauth.js uses the list; since the list includes the system address,
    an unauthenticated outside sender claiming system.inet_addr is now
    treated as one claiming system.host_name already was (the two are often
    the same name). exec/ can be shared with a host still running a binary
    without system.inet_domain_list: there mailauth.js checks
    ctrl/domains.cfg as it did before.

    The stock, comment-only ctrl/domains.cfg is removed from the
    repository. umonitor's and gtkmonitor's "edit domains.cfg" menu entries
    are removed (gtkmonitor's embedded copy of the menu layout included).

    Tests: exec/tests/inet_domains: the conversion in a scratch directory;
    the matching rules; script access against the loaded configuration;
    mailauth.js with and without the property; and, through a child jsexec
    on a scratch ctrl directory, the configured list with scratch users,
    the fallback (file only, sections only, both, the key set or not) and
    22 variants of domains.cfg for which the old file, the fallback list and
    the converted list must give 13 hosts the same answers. The child
    jsexec tests are skipped where /proc is not available, Windows
    included. Saving from SCFG and the mail server's decisions over SMTP
    were checked by hand on scratch configurations.

    Compiled with GCC only (libsbbs, scfg, umonitor, gtkmonitor); not built
    with MSVC or for Windows.

    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>