summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-03-13 21:28:31 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-03-13 21:28:31 +0000
commit79382e63982edb7a2ab023c4f15a9941f4f2be5d (patch)
tree24a17213bac20a91a8f3678cfbfa8c5fe46f0cc2 /usr.bin
parent613990ab4c180f9c2955a1ceee37aeafa7220579 (diff)
Stash uid and mode in struct at so we don't need to pass around a
struct statbuf *. Fixes a bug where atq reports all jobs as being owned by the owner of the last job in the queue. This is fallout from when I added sorting as per the historic BSD atq.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/at/at.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c
index a9c2ed911bb..a0cb4dfd28a 100644
--- a/usr.bin/at/at.c
+++ b/usr.bin/at/at.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: at.c,v 1.36 2003/03/03 18:23:13 millert Exp $ */
+/* $OpenBSD: at.c,v 1.37 2003/03/13 21:28:30 millert Exp $ */
/*
* at.c : Put file into atrun queue
@@ -42,7 +42,7 @@
#define TIMESIZE 50 /* Size of buffer passed to strftime() */
#ifndef lint
-static const char rcsid[] = "$OpenBSD: at.c,v 1.36 2003/03/03 18:23:13 millert Exp $";
+static const char rcsid[] = "$OpenBSD: at.c,v 1.37 2003/03/13 21:28:30 millert Exp $";
#endif
/* Variables to remove from the job's environment. */
@@ -435,7 +435,7 @@ byjobno(const void *v1, const void *v2)
}
static void
-print_job(struct atjob *job, int n, struct stat *st, int shortformat)
+print_job(struct atjob *job, int n, int shortformat)
{
struct passwd *pw;
struct tm runtime;
@@ -450,7 +450,7 @@ print_job(struct atjob *job, int n, struct stat *st, int shortformat)
(void)printf("%ld.%c\t%s\n", (long)job->runtimer,
job->queue, timestr);
} else {
- pw = getpwuid(st->st_uid);
+ pw = getpwuid(job->uid);
/* Rank hack shamelessly stolen from lpq */
if (n / 10 == 1)
printf("%3d%-5s", n,"th");
@@ -460,7 +460,7 @@ print_job(struct atjob *job, int n, struct stat *st, int shortformat)
(void)printf("%-21.18s%-11.8s%10ld.%c %c%s\n",
timestr, pw ? pw->pw_name : "???",
(long)job->runtimer, job->queue, job->queue,
- (S_IXUSR & st->st_mode) ? "" : " (done)");
+ (S_IXUSR & job->mode) ? "" : " (done)");
}
}
@@ -573,6 +573,8 @@ list_jobs(int argc, char **argv, int count_only, int csort)
panic("Insufficient virtual memory");
job->runtimer = runtimer;
job->ctime = stbuf.st_ctime;
+ job->uid = stbuf.st_uid;
+ job->mode = stbuf.st_mode;
job->queue = queue;
if (numjobs == maxjobs) {
maxjobs *= 2;
@@ -602,7 +604,7 @@ list_jobs(int argc, char **argv, int count_only, int csort)
"Job Queue");
for (i = 0; i < numjobs; i++) {
- print_job(atjobs[i], i + 1, &stbuf, shortformat);
+ print_job(atjobs[i], i + 1, shortformat);
free(atjobs[i]);
}
free(atjobs);