diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-07-15 19:13:30 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-07-15 19:13:30 +0000 |
commit | ebcbb2b2d2b68ee6347b5018b9212bbe5fccd946 (patch) | |
tree | e71531558e9d84cf8ad053a7652ab38b58160e8d /usr.sbin/cron/popen.c | |
parent | 55ae52781373a832341554a38aebe998ada66dcc (diff) |
Move atrun(8) functionality into cron(8) proper. This fixes the
long-standing annoyance that atrun's granularity is 10 minutes.
Most at jobs run with a 1 minute granularity. Jobs submitted via
"at now" or "batch" will run immediately. Includes a rewritten
cron(8) man page. at(1) will be integrated more closely into
cron at a future date.
Upgrading notes:
the atrun job in root's crontab should be removed.
the /var/at/spool directory is no longer used
Diffstat (limited to 'usr.sbin/cron/popen.c')
-rw-r--r-- | usr.sbin/cron/popen.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/usr.sbin/cron/popen.c b/usr.sbin/cron/popen.c index e2963ac747e..e8f5cfdd3c1 100644 --- a/usr.sbin/cron/popen.c +++ b/usr.sbin/cron/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.16 2002/07/09 00:24:50 millert Exp $ */ +/* $OpenBSD: popen.c,v 1.17 2002/07/15 19:13:29 millert Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -42,7 +42,7 @@ #if 0 static const sccsid[] = "@(#)popen.c 8.3 (Berkeley) 4/6/94"; #else -static const char rcsid[] = "$OpenBSD: popen.c,v 1.16 2002/07/09 00:24:50 millert Exp $"; +static const char rcsid[] = "$OpenBSD: popen.c,v 1.17 2002/07/15 19:13:29 millert Exp $"; #endif #endif /* not lint */ @@ -60,7 +60,7 @@ static PID_T *pids; static int fds; FILE * -cron_popen(char *program, char *type, entry *e) { +cron_popen(char *program, char *type, struct passwd *pw) { char *cp; FILE *iop; int argc, pdes[2]; @@ -93,28 +93,23 @@ cron_popen(char *program, char *type, entry *e) { return (NULL); /* NOTREACHED */ case 0: /* child */ - if (e) { + if (pw) { #if defined(LOGIN_CAP) - struct passwd *pwd; - - pwd = getpwuid(e->uid); - if (pwd == NULL) { - fprintf(stderr, "getpwuid: couldn't get entry for %u\n", e->uid); - _exit(ERROR_EXIT); - } - if (setusercontext(0, pwd, e->uid, LOGIN_SETALL) < 0) { - fprintf(stderr, "setusercontext failed for %u\n", e->uid); + if (setusercontext(0, pw, pw->pw_uid, LOGIN_SETALL) < 0) { + fprintf(stderr, + "setusercontext failed for %s\n", + pw->pw_name); _exit(ERROR_EXIT); } #else - if (setgid(e->gid) || + if (setgid(pw->pw_gid) || setgroups(0, NULL) || - initgroups(env_get("LOGNAME", e->envp), e->gid)) + initgroups(pw->pw_name, pw->pw_gid)) _exit(1); - setlogin(env_get("LOGNAME", e->envp)); - if (setuid(e->uid)) + setlogin(pw->pw_name); + if (setuid(pw->pw_uid)) _exit(1); - chdir(env_get("HOME", e->envp)); + chdir(pw->pw_dir); #endif /* LOGIN_CAP */ } if (*type == 'r') { |