Skip to content

Keep the .macct of a synced image owner only - #44

Closed
TomlDev wants to merge 1 commit into
linuxmuster:lmn74from
edulution-io:fix/macct-permissions
Closed

TomlDev wants to merge 1 commit into
linuxmuster:lmn74from
edulution-io:fix/macct-permissions

Conversation

@TomlDev

@TomlDev TomlDev commented Sep 29, 2026 •

Copy link
Copy Markdown

An image pushed by a satellite through receive_upload_chunk() / finalize_upload() brings its .macct, the Samba machine account secrets (unicodePwd, supplementalCredentials) of the client it was taken from. It was created with the umask default (0644) and kept that mode when moved into place and when backed up. The [linbo] rsync module serves all of /srv/linbo without login, so the file could be downloaded from the image directory, its backup, or .incoming while the upload was staged. Native LINBO keeps it root:root 0600 (rsync-post-upload.sh, linbo-torrent).

Changes in linbo/image_sync.py:

  • a staged .macct is created 0600 directly by open(), and set to 0600 again when a chunk resumes it
  • .incoming and its image subdirectory are kept 0700
  • a .macct is copied into a file opened 0600 instead of with copy2(), both for the backup and when the move has to copy across filesystems
  • a staged .macct is restricted before it is moved, and every .macct in the image directory after
  • running as root, these files and directories are root:root
  • other image files keep their mode

Files already on disk are not changed by this. To fix them:

find /srv/linbo/images -name '*.macct' -type f -exec chown root:root {} + -exec chmod 600 {} +
[ -d /srv/linbo/images/.incoming ] && chown root:root /srv/linbo/images/.incoming && chmod 700 /srv/linbo/images/.incoming

linbo-torrent's update_permissions() runs chown -R nobody:nogroup over the images tree and gives only images/*/*.macct back to root, so a .macct in a backup directory or in .incoming becomes readable to the rsync module again after it runs. That part is fixed in linuxmuster/linuxmuster-linbo7#182, which also leaves .incoming to the image sync.

Tests: linbo/pytests/test_image_sync_permissions.py (14 tests) checks modes and ownership for first and resumed chunks, the staging directories, finalize (same filesystem and across filesystems), the backup, and a .macct left in place. It also checks that a new .macct is 0600 from the start, not narrowed afterwards. 13 of them fail against the current image_sync.py; the 14th checks that other image files keep their mode.

An image pushed by a satellite brings its .macct, the Samba machine account
secrets (unicodePwd, supplementalCredentials) of the client it was taken
from. receive_upload_chunk() created it with the umask default, 0644, and
finalize_upload() kept that mode through shutil.move() and shutil.copy2().
The [linbo] rsync module serves the whole LINBO directory without login, as
nobody, so anyone reaching rsync could download it, from the image
directory, its backup or .incoming while the upload was staged.

Create a staged .macct 0600, with the mode given to open() so it is never
readable in between, and set it again on a resumed chunk. Copy it into a
file opened 0600 instead of using copy2(), which writes the copy with the
umask default first: for the backup, and for a move that has to copy
because .incoming and the image directory lie on different filesystems.
Close a staged .macct before moving it, and every .macct of the image
directory after. Keep .incoming and its image subdirectory 0700. Running as
root, all of these become root:root, as linuxmuster-linbo7 does in
rsync-post-upload.sh and linbo-torrent. Other image files keep their mode.
@kiarn

kiarn commented Oct 10, 2026

Copy link
Copy Markdown
Member

Thank you !
I fixed the .macct permissions with a separated commit.
As already said, the upload part will be removed soon and not maintained anymore.

@kiarn kiarn closed this Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants