Browse Source

fix getpwnam

pull/465/head
Max Lv 9 years ago
parent
commit
5225efef33
1 changed files with 5 additions and 1 deletions
  1. 6
      src/utils.c

6
src/utils.c

@ -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);
}

Loading…
Cancel
Save