diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-10-16 06:15:05 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-10-16 16:53:40 +0200 |
commit | 2c7d1ce088ba9b588652f58616eb2a8d7748ca88 (patch) | |
tree | ebc970cb55445f6e1e8b0ee50a928d0bea787f7f /passt.c | |
parent | 1fd0c9b0e1f27098f9bf86e86285335e640317a5 (diff) | |
download | passt-2c7d1ce088ba9b588652f58616eb2a8d7748ca88.tar passt-2c7d1ce088ba9b588652f58616eb2a8d7748ca88.tar.gz passt-2c7d1ce088ba9b588652f58616eb2a8d7748ca88.tar.bz2 passt-2c7d1ce088ba9b588652f58616eb2a8d7748ca88.tar.lz passt-2c7d1ce088ba9b588652f58616eb2a8d7748ca88.tar.xz passt-2c7d1ce088ba9b588652f58616eb2a8d7748ca88.tar.zst passt-2c7d1ce088ba9b588652f58616eb2a8d7748ca88.zip |
passt: Static builds: don't redefine __vsyslog(), skip getpwnam() and initgroups()
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'passt.c')
-rw-r--r-- | passt.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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); } /** |