1
0
Fork 0
mirror of https://passt.top/passt synced 2025-06-09 00:55:35 +02:00

passt: Static builds: don't redefine __vsyslog(), skip getpwnam() and initgroups()

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2021-10-16 06:15:05 +02:00
parent 1fd0c9b0e1
commit 2c7d1ce088
5 changed files with 21 additions and 12 deletions

15
passt.c
View file

@ -212,17 +212,22 @@ static void check_root(void)
close(fd);
fprintf(stderr, "Don't run this as root. Changing to nobody...\n");
#ifndef GLIBC_NO_STATIC_NSS
pw = getpwnam("nobody");
if (!pw) {
perror("getpwnam");
exit(EXIT_FAILURE);
}
if (initgroups(pw->pw_name, pw->pw_gid) ||
setgid(pw->pw_gid) || setuid(pw->pw_uid)) {
fprintf(stderr, "Can't change to user/group nobody, exiting");
exit(EXIT_FAILURE);
}
if (!initgroups(pw->pw_name, pw->pw_gid) &&
!setgid(pw->pw_gid) && !setuid(pw->pw_uid))
return;
#else
(void)pw;
#endif
fprintf(stderr, "Can't change to user/group nobody, exiting");
exit(EXIT_FAILURE);
}
/**