• SCFG: saving a config file removes it until the new one is written; pr

    From Rob Swindell@VERT to GitLab issue in main/sbbs on Mon Nov 23 13:08:02 2026
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1404
    2026-11-23 13:08:02 -0800

    When SCFG saves a configuration file, the file does not exist for the whole time the save takes, and any program that loads the configuration in that window runs with that part of the configuration missing.

    Seen on a live system: sbbsecho ran (FIDOIN event) while the sysop was saving in SCFG:

    ```
    evnt FIDOIN Executing external: /sbbs/exec/sbbsecho -ce
    evnt FIDOIN sbbsecho: !WARNING loading configuration files: 2 (No such file or directory) opening /sbbs/ctrl/file.ini
    ```

    ## Cause

    Each `write_*_cfg()` in `src/sbbs3/scfgsave.c` (main.ini, node.ini, msgs.ini, file.ini, xtrn.ini, chat.ini) does:

    1. `backup(inipath, cfg->config_backup_level, /* ren: */ true)`: **renames** the live file to `<name>.0.ini`. From here there is no live file.
    2. Builds the whole new file in memory (for file.ini and msgs.ini this walks every library/directory and group/sub-board, which takes a noticeable time on a large system).
    3. `fopen(inipath, "w")` and writes it. Until the write finishes, the file exists but is incomplete.

    A reader during step 1-2 gets "No such file or directory"; a reader during step 3 can read a partial file.

    ## Effect

    `load_cfg()` is called with "required" = false by sbbsecho, the FTP, Mail, Web and Services servers (on start-up and every recycle), dupefind, makeuser, qwknodes and sbbscon, so for them a missing file is only a warning and they carry on with that part of the configuration empty:

    - sbbsecho during a `msgs.ini` save would load no message areas and treat every incoming echo as unknown (most likely misfiling the echomail to the bad-echo area rather than losing it; not traced end to end). During a `file.ini` save, as above, it loses nothing, because it doesn't use file areas.
    - A server that recycles during a save runs with that configuration missing until its next recycle.
    - The Terminal Server passes "required" = true, so it fails to load instead.

    ## Proposed fix

    Write the new file under a temporary name in `ctrl/` and rename it over the live file only once it is complete, and take the backup with a copy (`backup(..., /* ren: */ false)`) rather than a rename. A reader then always sees either the complete old file or the complete new one. On Windows, `rename()` doesn't replace an existing file, so that needs `MoveFileEx(..., MOVEFILE_REPLACE_EXISTING)` (or an xpdev helper wrapping both). One helper can serve all six `write_*_cfg()` functions.

    Related clean-up: `load_cfg()`'s fifth parameter is `req_cfg` in `load_cfg.c` but `req_node` in `load_cfg.h`, and most callers label the argument `/* node: */`. It controls whether any missing configuration file is fatal, not anything node-specific.

    _Authored by Claude (Claude Code), on behalf of @rswindell_

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to GitLab note in main/sbbs on Mon Nov 23 13:16:23 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1404#note_11346

    Related: #1405 (since v3.21c, the servers and sbbsecho no longer fail to load when one of these files is missing, so they run without it during a save).

    _Authored by Claude (Claude Code), on behalf of @rswindell_

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to GitLab issue in main/sbbs on Mon Nov 23 22:45:10 2026
    close https://gitlab.synchro.net/main/sbbs/-/work_items/1404
    2026-11-23 22:45:05 -0800

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net