Skip to content

fix(metadata): write .nzbz stores with mode 0644 - #1059

Merged
javi11 merged 1 commit into
kipsilabs:mainfrom
firestaerter3:fix/nzbz-store-mode
Nov 11, 2026
Merged

javi11 merged 1 commit into
kipsilabs:mainfrom
firestaerter3:fix/nzbz-store-mode

Conversation

@firestaerter3

Copy link
Copy Markdown
Contributor

WriteStore writes each .nzbz through os.CreateTemp, which always creates the file 0600 whatever the umask, and the rename keeps that mode. A backup job that runs under a different uid from altmount can't read the stores. Ours is an external file backup. Altmount's own metadata.backup runs as altmount, so it is not affected.

This matters more than for most files because altmount deletes the original .nzb after a successful import. From then on the .nzbz is the only copy of the release's segment list.

How to reproduce: import anything, then ls -l the new file under .nzbs/. It is -rw------- even with umask 022.

The fix chmods the temp file to 0644 before closing and renaming it. A store holds the NZB's file entries (subject, poster, groups, message-ids), the same text as the original .nzb. If a poster put an archive password in a subject line, it is in the store too, just as it was in the .nzb.

The .meta files are left at 0600 on purpose. FileMetadata carries the archive password altmount extracted, the rclone crypt password and salt, and the AES key and IV for encrypted archives, so those should stay owner-only. (Our own backup also leaves the metadata folder out, so we had no reason to touch it.)

The mode is a fixed 0644 rather than one derived from the umask. That keeps it simple, but say if you'd rather follow the umask or use 0640.

Test: TestStoreService_WriteStore_FileMode0644 sets umask 077 and checks the mode for a new ref and for a replaced one. It fails on current main (0600) and passes with this change. go test ./internal/metadata/ passes. We have been running this since 2026-10-01.

WriteStore writes through os.CreateTemp, which always creates the file
0600 regardless of umask, and the rename keeps that mode. A backup job
running under another uid cannot read the stores, and after an import
the .nzbz is the only copy of the release's segment list.

Chmod the temp file to 0644 before closing and renaming it. A store holds
the NZB's file entries (subject, poster, groups, message-ids), the same
text as the original .nzb. The .meta files are left at 0600 on purpose:
FileMetadata carries the archive password altmount extracted, the rclone
crypt password and salt, and the AES key and IV of encrypted archives.

The test sets umask 077 and checks the mode for a new ref and for a
replaced one. It fails on the current code (0600).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@javi11
javi11 merged commit 3be6add into kipsilabs:main Nov 11, 2026
2 checks passed
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