diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-05-05 23:23:32 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-05-05 23:23:32 +0000 |
commit | d6caa78e2b3bfe6943a022d56e396604cf4f8a65 (patch) | |
tree | be2860cce8e08bc89f82ef650993f7f85b94f16f /libexec/atrun | |
parent | a1478f55fdfcb6b2fc0c97284c35014c0bd87f0e (diff) |
We must lower the process priority *after* the call to setusercontext()
otherwise the priority will just be what login.conf decrees. Convert
from nice() to setpriority() in the process. Based on a patch from
<hgw@d1906.inka.de>.
Diffstat (limited to 'libexec/atrun')
-rw-r--r-- | libexec/atrun/atrun.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libexec/atrun/atrun.c b/libexec/atrun/atrun.c index 3129a8c54e0..e396245da90 100644 --- a/libexec/atrun/atrun.c +++ b/libexec/atrun/atrun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atrun.c,v 1.11 2001/04/19 22:57:27 deraadt Exp $ */ +/* $OpenBSD: atrun.c,v 1.12 2001/05/05 23:23:31 millert Exp $ */ /* * atrun.c - run jobs queued by at; run with root privileges. @@ -30,6 +30,8 @@ #include <sys/fcntl.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/time.h> +#include <sys/resource.h> #include <sys/wait.h> #include <sys/param.h> #include <ctype.h> @@ -68,7 +70,7 @@ /* File scope variables */ static char *namep; -static char rcsid[] = "$OpenBSD: atrun.c,v 1.11 2001/04/19 22:57:27 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: atrun.c,v 1.12 2001/05/05 23:23:31 millert Exp $"; static int debug = 0; /* Local functions */ @@ -242,7 +244,7 @@ run_file(filename, uid, gid) perr2("Cannot chdir to ", _PATH_ATSPOOL); /* - * Create a file to hold the output of the job we are about to + * Create a file to hold the output of the job we are about to * run. Write the mail header. */ @@ -297,17 +299,17 @@ run_file(filename, uid, gid) if (chdir(_PATH_ATJOBS) < 0) perr2("Cannot chdir to ", _PATH_ATJOBS); - queue = *filename; - - if (queue > 'b') - nice(queue - 'b'); - if (setusercontext(0, pentry, pentry->pw_uid, LOGIN_SETALL) < 0) perr("Cannot set user context"); if (chdir(pentry->pw_dir) < 0) chdir("/"); + /* First letter indicates requested job priority */ + queue = tolower((unsigned char) *filename); + if (queue > 'b') + (void) setpriority(PRIO_PROCESS, 0, queue - 'b'); + if (execle(_PATH_BSHELL, "sh", NULL, nenvp) != 0) perr("Exec failed for /bin/sh"); |