• src/xpdev/dirwrap.c

    From Rob Swindell (on Debian Linux)@1:103/705 to Git commit to main/sbbs/master on Sun Jul 26 23:08:15 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/d394e7bef6a9b4045a3f3f13
    Modified Files:
    src/xpdev/dirwrap.c
    Log Message:
    xpdev: copy a file's permissions along with the file

    CopyFile() creates the destination with fopen(dest, "wb"), so it was born
    with mode 0666 & ~umask and the source's permission bits were dropped.
    Copying an executable therefore produced a file that could not be
    executed -- a door binary installed this way failed at launch with
    "ERROR 13 (Permission denied)", and nothing about the copy step said why.

    This is the POSIX stand-in for the Win32 API of the same name, which
    preserves the source's attributes, so the two platforms disagreed on what file_copy() means. The function also already went to the trouble of
    preserving the source's modification time; permissions were the omission.

    fstat() the source and fchmod() the destination to match. The mode is
    masked to 0777: set-user-ID and set-group-ID bits are deliberately left
    behind rather than propagated to a copy.

    Measured before and after against source modes 0755, 0770, 0600, 0666 and
    04755 under umask 022: every destination was 0644 before, and now matches
    its source (with 04755 landing as 0755).

    GitLab #1202.

    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
    --- SBBSecho 3.37-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)