mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-23 08:03:54 +00:00
fix getpwnam
This commit is contained in:
+5
-1
@@ -102,7 +102,11 @@ int run_as(const char *user)
|
||||
/* Note that we use getpwnam_r() instead of getpwnam(),
|
||||
which returns its result in a statically allocated buffer and
|
||||
cannot be considered thread safe. */
|
||||
#ifndef __sun
|
||||
err = getpwnam_r(user, &pwdbuf, buf, buflen, &pwd);
|
||||
#else
|
||||
pwd = getpwnam_r(user, &pwdbuf, buf, buflen);
|
||||
#endif
|
||||
if (err == 0 && pwd) {
|
||||
/* setgid first, because we may not be allowed to do it anymore after setuid */
|
||||
if (setgid(pwd->pw_gid) != 0) {
|
||||
@@ -309,7 +313,7 @@ void daemonize(const char * path)
|
||||
FATAL("Invalid pid file\n");
|
||||
}
|
||||
|
||||
fprintf(file, "%d", pid);
|
||||
fprintf(file, "%d", (int)pid);
|
||||
fclose(file);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user