From 14c0ee1fd880d587f6c818255166cf6f4eec5ae7 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 3 Aug 1996 20:16:58 +0000 Subject: Was runing most of the code with real and effective uid of 0, contrary to the comments. Fixed that and made sure unlink of job file is done as root so it can succeed. Also will now detect empty input. --- usr.bin/at/at.c | 17 +++++++---------- usr.bin/at/panic.c | 15 +++++++++++---- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c index d1de84d0c35..39ee135c94a 100644 --- a/usr.bin/at/at.c +++ b/usr.bin/at/at.c @@ -1,4 +1,4 @@ -/* $OpenBSD: at.c,v 1.2 1996/06/26 05:31:27 deraadt Exp $ */ +/* $OpenBSD: at.c,v 1.3 1996/08/03 20:16:52 millert Exp $ */ /* $NetBSD: at.c,v 1.4 1995/03/25 18:13:31 glass Exp $ */ /* @@ -65,7 +65,7 @@ /* File scope variables */ #ifndef lint -static char rcsid[] = "$OpenBSD: at.c,v 1.2 1996/06/26 05:31:27 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: at.c,v 1.3 1996/08/03 20:16:52 millert Exp $"; #endif char *no_export[] = @@ -247,13 +247,6 @@ writefile(runtimer, queue) PRIV_END - /* - * We no longer need suid root; now we just need to be able to - * write to the directory, if necessary. - */ - - REDUCE_PRIV(effective_uid); - /* * We've successfully created the file; let's set the flag so it * gets removed in case of an interrupt or error. @@ -345,8 +338,12 @@ writefile(runtimer, queue) */ fprintf(fp, "cd %s\n", cwdname()); - while ((ch = getchar()) != EOF) + if ((ch = getchar()) == EOF) + panic("Input error"); + + do { fputc(ch, fp); + } while ((ch = getchar()) != EOF); fprintf(fp, "\n"); if (ferror(fp)) diff --git a/usr.bin/at/panic.c b/usr.bin/at/panic.c index b616899085e..d6b03db8edd 100644 --- a/usr.bin/at/panic.c +++ b/usr.bin/at/panic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: panic.c,v 1.2 1996/06/26 05:31:28 deraadt Exp $ */ +/* $OpenBSD: panic.c,v 1.3 1996/08/03 20:16:57 millert Exp $ */ /* $NetBSD: panic.c,v 1.2 1995/03/25 18:13:33 glass Exp $ */ /* @@ -38,11 +38,12 @@ #include "panic.h" #include "at.h" +#include "privs.h" /* File scope variables */ #ifndef lint -static char rcsid[] = "$OpenBSD: panic.c,v 1.2 1996/06/26 05:31:28 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: panic.c,v 1.3 1996/08/03 20:16:57 millert Exp $"; #endif /* External variables */ @@ -56,8 +57,11 @@ panic(a) /* Something fatal has happened, print error message and exit. */ fprintf(stderr, "%s: %s\n", namep, a); - if (fcreated) + if (fcreated) { + PRIV_START unlink(atfile); + PRIV_END + } exit(EXIT_FAILURE); } @@ -69,8 +73,11 @@ perr(a) /* Some operating system error; print error message and exit. */ perror(a); - if (fcreated) + if (fcreated) { + PRIV_START unlink(atfile); + PRIV_END + } exit(EXIT_FAILURE); } -- cgit v1.2.3