summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2001-05-05 23:23:31 +0000
committermillert <millert@openbsd.org>2001-05-05 23:23:31 +0000
commit02d81337de3c3832757e375d835a091e5426a34c (patch)
tree7ae683372675cb58c12604306f5198f9a1fe190b
parentPrototype for nice() lives in unistd.h, not nlist.h (pasto?) (diff)
downloadwireguard-openbsd-02d81337de3c3832757e375d835a091e5426a34c.tar.xz
wireguard-openbsd-02d81337de3c3832757e375d835a091e5426a34c.zip
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>.
-rw-r--r--libexec/atrun/atrun.c18
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");