fix: apply UMASK env var via os.umask() at Python startup#111
fix: apply UMASK env var via os.umask() at Python startup#111nitrobass24 merged 2 commits intomasterfrom
Conversation
The shell umask set in entrypoint.sh via `umask "$UMASK"` was not being reliably inherited by the lftp subprocess (spawned via pexpect) through the setpriv exec chain in all container environments. As a result, downloaded files were created with the system default umask (0002 → 0664) instead of the user-configured value. Fix by reading the UMASK env var directly in Python and calling os.umask() before any child processes are spawned, ensuring lftp inherits the correct file creation mask. Fixes #109 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds UMASK handling at startup: reads UMASK from the environment, attempts octal parsing, applies it via os.umask(), and prints a stderr warning on invalid values. This runs before spawning child processes and does not change other control flow. Changes
Sequence Diagram(s)sequenceDiagram
participant Env as Environment
participant Main as Main process
participant Child as Child processes
Env->>Main: UMASK value (or absent)
Main->>Main: parse UMASK as octal (try/except)
alt valid UMASK
Main->>Main: call os.umask(parsed_value)
else invalid UMASK
Main->>Main: print warning to stderr
end
Main->>Child: spawn child processes (inherit umask)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/python/seedsync.py`:
- Line 412: Replace the .format-based print call in seedsync.py with an
f-string: locate the print call that emits the warning for an invalid UMASK (the
line using "_umask_str" and print(..., file=sys.stderr)) and rewrite the message
to use an f-string (e.g., f"WARNING: Invalid UMASK value {_umask_str!r},
ignoring") while preserving the target (sys.stderr) and surrounding behavior.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
umaskset inentrypoint.shis not reliably inherited by thelftpsubprocess through thesetprivexec chain in all container environments0002→0664) instead of the user-configured valueUMASKenv var directly in Python and callsos.umask()at startup, before pexpect spawns lftpFixes #109
Test plan
UMASK=000in Docker environment variables0666permissions (rw-rw-rw-) instead of06640777permissionsUMASK(empty string, the default) leaves system umask unchangedSummary by CodeRabbit