Repository navigation
fix(metadata): write .nzbz stores with mode 0644 - #1059
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WriteStorewrites each.nzbzthroughos.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 ownmetadata.backupruns as altmount, so it is not affected.This matters more than for most files because altmount deletes the original
.nzbafter a successful import. From then on the.nzbzis the only copy of the release's segment list.How to reproduce: import anything, then
ls -lthe 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
.metafiles are left at 0600 on purpose.FileMetadatacarries 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_FileMode0644sets 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.