nfqws2: support rare partial root environment

This commit is contained in:
bol-van committed 2026-10-04 10:18:18 +03:00
1 parent ca950d838a
commit a1adf7b868
1 file changed
+10 -2
+10 -2
View File
@@ -14,6 +14,7 @@
#include <sys/prctl.h>
#include <sys/syscall.h>
#include <linux/securebits.h>
#include <linux/seccomp.h>
#include <linux/filter.h>
// __X32_SYSCALL_BIT defined in linux/unistd.h
@@ -266,8 +267,15 @@ bool droproot(uid_t uid, const char *user, const gid_t *gid, int gid_count)
#ifdef __linux__
if (prctl(PR_SET_KEEPCAPS, 1L))
{
DLOG_PERROR("prctl(PR_SET_KEEPCAPS)");
return false;
int e=errno;
// if SECBIT_NO_SETUID_FIXUP is set PR_SET_KEEPCAPS is not necessary
int bits = prctl(PR_GET_SECUREBITS);
if (bits<0 || !(bits & SECBIT_NO_SETUID_FIXUP))
{
errno=e;
DLOG_PERROR("prctl(PR_SET_KEEPCAPS)");
return false;
}
}
#endif
if (user)