- sp_ptr = NULL;
- status = getpwnam_r (pl->user, &sp, nambuf, sizeof (nambuf), &sp_ptr);
- if (status != 0)
- {
- ERROR ("exec plugin: Failed to get user information for user ``%s'': %s",
- pl->user, sstrerror (errno, errbuf, sizeof (errbuf)));
- exit (-1);
- }
- if (sp_ptr == NULL)
- {
- ERROR ("exec plugin: No such user: `%s'", pl->user);
- exit (-1);
- }
-
- uid = sp.pw_uid;
- gid = sp.pw_gid;
- if (uid == 0)
- {
- ERROR ("exec plugin: Cowardly refusing to exec program as root.");
- exit (-1);
- }
-
- /* The group configured in the configfile is set as effective group, because
- * this way the forked process can (re-)gain the user's primary group. */
- egid = -1;
- if (NULL != pl->group)
- {
- if ('\0' != *pl->group) {
- struct group *gr_ptr = NULL;
- struct group gr;
-
- status = getgrnam_r (pl->group, &gr, nambuf, sizeof (nambuf), &gr_ptr);
- if (0 != status)
- {
- ERROR ("exec plugin: Failed to get group information "
- "for group ``%s'': %s", pl->group,
- sstrerror (errno, errbuf, sizeof (errbuf)));
- exit (-1);
- }
- if (NULL == gr_ptr)
- {
- ERROR ("exec plugin: No such group: `%s'", pl->group);
- exit (-1);
- }
-
- egid = gr.gr_gid;
- }
- else
- {
- egid = gid;
- }
- } /* if (pl->group == NULL) */
-