summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8170b5a)
raw | patch | inline | side by side (parent: 8170b5a)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 10 Mar 2007 09:38:05 +0000 (10:38 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 10 Mar 2007 09:38:05 +0000 (10:38 +0100) |
src/exec.c | patch | blob | history |
diff --git a/src/exec.c b/src/exec.c
index ee8f8bf9886a38136a9f3dafec6cec1801c6aa7a..63401bec3c4c53f79b6206cf81a3bea3fb870d63 100644 (file)
--- a/src/exec.c
+++ b/src/exec.c
static void exec_child (program_list_t *pl)
{
- struct passwd *sp;
int status;
int uid;
char *arg0;
- /* FIXME: Not thread safe! */
- sp = getpwnam (pl->user);
- if (sp == NULL)
+ struct passwd *sp_ptr;
+ struct passwd sp;
+ char pwnambuf[2048];
+
+ sp_ptr = NULL;
+ status = getpwnam_r (pl->user, &sp, pwnambuf, sizeof (pwnambuf), &sp_ptr);
+ if (status != 0)
+ {
+ syslog (LOG_ERR, "exec plugin: getpwnam_r failed: %s", strerror (status));
+ exit (-1);
+ }
+ if (sp_ptr == NULL)
{
- syslog (LOG_ERR, "exec plugin: getpwnam failed: %s", strerror (errno));
+ syslog (LOG_ERR, "exec plugin: No such user: `%s'", pl->user);
exit (-1);
}
- uid = sp->pw_uid;
+ uid = sp.pw_uid;
if (uid == 0)
{
syslog (LOG_ERR, "exec plugin: Cowardly refusing to exec program as root.");