Skip to content

Commit 83de3ff

Browse files
committed
Skip privilege drop when already running as target user
When rc.d uses daemon_user to run the process as an unprivileged user, the config may also specify the same user. setgroups requires root and fails with EPERM. Skip the drop if getuid already matches the target.
1 parent 16da988 commit 83de3ff

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

thinproxy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,8 @@ drop_privs(const char *user)
17301730
logmsg(LOG_ERR, "unknown user: %s", user);
17311731
return -1;
17321732
}
1733+
if (getuid() == pw->pw_uid)
1734+
return 0;
17331735
if (setgroups(1, &pw->pw_gid) == -1 ||
17341736
setgid(pw->pw_gid) == -1 ||
17351737
setuid(pw->pw_uid) == -1) {

0 commit comments

Comments
 (0)