Skip to content

Commit

Permalink
Fix: DaemonUsername check on QNAP (#391)
Browse files Browse the repository at this point in the history
- added additional check for DaemonUsername if it's equal to "root" for Backward compatibility with QNAP which doesn't have a "root" user, but for historical reasons in nzbget.conf we use "root" as the default value in DaemonUsername which causes problems when running nzbget as a daemon on QNAP
  • Loading branch information
dnzbk authored Sep 13, 2024
1 parent 5c4ec4d commit 2dc6755
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion daemon/main/nzbget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,8 +1006,13 @@ void NZBGet::Daemonize()
}
}

/* Backward compatibility with QNAP which doesn't have a "root" user,
but for historical reasons in nzbget.conf we use "root" as the default value in DaemonUsername
which causes problems when running nzbget as a daemon on QNAP. */
bool backwardCompRoot = strcmp(m_options->GetDaemonUsername(), "root") == 0;

/* Drop user if there is one, and we were run as root */
if (getuid() == 0 || geteuid() == 0)
if (!backwardCompRoot && (getuid() == 0 || geteuid() == 0))
{
struct passwd *pw = getpwnam(m_options->GetDaemonUsername());
if (pw == nullptr)
Expand Down
6 changes: 3 additions & 3 deletions nzbget.conf
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ UpdateCheck=stable
# This allows NZBGet daemon to be launched in rc.local (at boot), and
# download items as a specific user id.
#
# NOTE: This option has effect only if the program was started from
# root-account, otherwise it is ignored and the daemon runs under
# current user id.
# NOTE: If DaemonUsername is not "root" and doesn't exist the daemon will not start.
# NOTE: If the daemon is running as root (superuser) and DaemonUsername exists,
# nzbget will drop root privileges to the user specified by DaemonUsername.
DaemonUsername=root

# Specify default umask, POSIX only (000-1000).
Expand Down

0 comments on commit 2dc6755

Please sign in to comment.