Skip to content

Check if privddrop was successful#345

Merged
dnzbk merged 3 commits intonzbgetcom:developfrom
bket:privdrop
Aug 9, 2024
Merged

Check if privddrop was successful#345
dnzbk merged 3 commits intonzbgetcom:developfrom
bket:privdrop

Conversation

@bket
Copy link
Copy Markdown
Contributor

@bket bket commented Aug 7, 2024

Description

This PR fixes file-/dir-permission issues when starting nzbget with DaemonUsername=_not_root, and checks that privileges are dropped when daemonizing as root.

Lib changes

No changes.

Testing

Build- and run tested on OpenBSD
Tested by @dnzbk on Linux Debian 12 and macOS Ventura

bket added 2 commits August 7, 2024 17:52
When starting nzbget with `DaemonUsername=_not_root` in nzbget.conf for
the first time, a couple of directories, and nzbget.log, are created in
${MainDir} with as owner root. This causes an issue as these cannot be
used by nzbget after privileges have been dropped to `_not_root`.
Expected behaviour is that nzbget creates these directories with as
owner `_not_root`.

Previously discussed in nzbget/nzbget#500 and
nzbget/nzbget#512.
Currently, if nzbget is daemonized as root, and an invalid
`DaemonUsername` is set, privileges are not dropped. Consequence is that
nzbget runs with elevated privileges, which is undesirable for any
software with network-facing interfaces.

This should address nzbgetcom#113.
@dnzbk dnzbk self-requested a review August 7, 2024 16:34
Copy link
Copy Markdown
Member

@luckedea luckedea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thank you

@dnzbk
Copy link
Copy Markdown
Collaborator

dnzbk commented Aug 9, 2024

Thank you!

@dnzbk dnzbk merged commit 61585fa into nzbgetcom:develop Aug 9, 2024
@bket bket deleted the privdrop branch August 12, 2024 18:14
beertje44 pushed a commit to beertje44/nzbget that referenced this pull request Dec 4, 2024
Currently, if nzbget is daemonized as root, and an invalid
`DaemonUsername` is set, privileges are not dropped. Consequence is that
nzbget runs with elevated privileges, which is undesirable for any
software with network-facing interfaces.
bob-beck pushed a commit to openbsd/ports that referenced this pull request Nov 23, 2025
bket added a commit to bket/nzbget that referenced this pull request Jan 26, 2026
PR nzbgetcom#345 introduced checks for successful privdrop and ensured that
missing files/directories were created as `DaemonUsername`. However,
this was partly reverted due to regressions in extensions (nzbgetcom#353).

This partial revert caused a side effect where missing files and
folders are once again created by `root` during startup.

This commit fixes the ownership issue by explicitly calling chown(2)
after creation, ensuring the privdropped daemon can access its data.
bket added a commit to bket/nzbget that referenced this pull request Feb 15, 2026
PR nzbgetcom#345 introduced checks for successful privdrop and ensured that
missing files/directories were created as `DaemonUsername`. However,
this was partly reverted due to regressions in extensions (nzbgetcom#353).

This partial revert caused a side effect where missing files and
folders are once again created by `root` during startup.

This commit fixes the ownership issue by explicitly calling chown(2)
after creation, ensuring the privdropped daemon can access its data.
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.

3 participants