• SBBSecho: AreaMgr can lose the area file on an SMB/CIFS share (delete/

    From Rob Swindell@VERT to GitLab issue in main/sbbs on Mon Nov 23 22:44:09 2026
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1418
    2026-11-23 22:44:09 -0800

    When SBBSecho's AreaMgr adds or removes a node's links to areas, `alter_areas()` (`src/sbbs3/sbbsecho.c:2201`) replaces the area file (e.g. `areas.bbs` or `areas.ini`) in a way that can lose both the old and the new file when the area file is on an SMB/CIFS share and another program has it open at that moment.

    Code references are as of master 093321f948 (hero-4-babies, 2026-11-23).

    ## Where

    After writing the new area list to a temporary file (`outpath`):

    ```c
    if (cfg.areafile_backups == 0 || !backup(cfg.areafile, cfg.areafile_backups, /* ren: */ TRUE))
    delfile(cfg.areafile, __LINE__); /* Delete AREAS.BBS */
    if (xp_rename_file(outpath, cfg.areafile)) /* Rename new AREAS.BBS file */
    lprintf(LOG_ERR, "ERROR line %d renaming %s to %s", __LINE__, outpath, cfg.areafile);
    ...
    (void)remove(outpath); // expected to fail (file does not exist) much of the time
    ```

    1. With area file backups disabled, or when renaming the live file to its backup name fails (as it does on Windows/SMB while another host has the file open), the live area file is deleted.
    2. The new file is renamed into place.
    3. The temporary file is removed, on the assumption that the rename consumed it.

    ## The failure

    On a CIFS mount (seen on Linux, with a ctrl or data directory served by Samba), deleting or renaming over a file that another program has open does not take effect immediately: the file is deleted when that program closes it, and a rename onto its name can fail meanwhile. Tested on such a mount: a rename over a file held open by another process failed with ENOENT, and the target was gone once that process closed it. (The same behavior made the first fix for #1404 lose configuration files.)

    If step 2 fails that way, the old area file disappears when the reader closes it, and step 3 removes the new one, so neither remains and SBBSecho loses its echomail area list. The error is logged, but nothing is left to recover from except a backup, if backups are enabled.

    SBBSecho is normally the only reader of the area file and runs one instance at a time, so the window is small, but the consequence (echomail misrouted or rejected as unknown areas) is large.

    ## Suggested fix

    Do as #1404 now does for SCFG's configuration files: take the backup with a copy (`backup(..., /* ren: */ false)`), then rewrite the area file in place while holding it open exclusively with `fnopen()` (open without `O_TRUNC`, truncate once locked, then write). Never rename or delete the live file. At the least, do not remove the temporary file when the rename into place failed.

    -- *Authored by Claude (Claude Code), on behalf of @rswindell*

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