#include <syslog.h>
#include <time.h>
#include <unistd.h>
-#include <utmp.h>
+#include <utmpx.h>
#if 1
#include <paths.h>
#else
#include <getopt.h>
#endif
+#if (MAXLOGNAME-1) > _UTX_USERSIZE
+#define LOGNAMESIZE _UTX_USERSIZE
+#else
#define LOGNAMESIZE (MAXLOGNAME-1)
+#endif
/* Local headers */
else if (pid != 0)
return;
+#ifdef __APPLE__
+ {
+ pid_t pg = setsid();
+ if (pg == -1) syslog(LOG_ERR,"setsid() failed: %m");
+ }
+#endif
+
/* Let's see who we mail to. Hopefully, we can read it from
* the command file; if not, send it to the owner, or, failing that,
* to root.
nice(tolower(queue) - 'a');
- if (initgroups(pentry->pw_name,pentry->pw_gid))
- perr("cannot delete saved userids");
-
if (setgid(gid) < 0 || setegid(pentry->pw_gid) < 0)
perr("cannot change group");
+ if (initgroups(pentry->pw_name,pentry->pw_gid))
+ perr("cannot delete saved userids");
+
if (setlogin(pentry->pw_name))
perr("cannot set login name");
{
PRIV_START
- if (initgroups(pentry->pw_name,pentry->pw_gid))
- perr("cannot delete saved userids");
-
if (setgid(gid) < 0 || setegid(pentry->pw_gid) < 0)
perr("cannot change group");
+ if (initgroups(pentry->pw_name,pentry->pw_gid))
+ perr("cannot delete saved userids");
+
if (setlogin(pentry->pw_name))
perr("cannot set login name");
run_file(batch_name, batch_uid, batch_gid);
closelog();
+#if __APPLE__
+ // allow enough time for child processes to call setsid(2)
+ sleep(1);
+#endif
exit(EXIT_SUCCESS);
}