fix getpwnam

This commit is contained in:
Max Lv
2015-11-16 12:36:31 +08:00
parent 48cb9ad511
commit 5225efef33
+5 -1
View File
@@ -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);
}