diff options
author | 1996-09-15 10:02:34 +0000 | |
---|---|---|
committer | 1996-09-15 10:02:34 +0000 | |
commit | 4416d3f0dd9c1efe70f5d9f7777c6bbac05982c0 (patch) | |
tree | b3d352927751c5f5baee1934af7700cd7283930c | |
parent | Build correctly when DESTDIR set (diff) | |
download | wireguard-openbsd-4416d3f0dd9c1efe70f5d9f7777c6bbac05982c0.tar.xz wireguard-openbsd-4416d3f0dd9c1efe70f5d9f7777c6bbac05982c0.zip |
use mkstemp; mentioned by sirsyko@ishiboo.com
-rw-r--r-- | usr.sbin/cron/crontab.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index 2a5491385f6..a6af2f49445 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -16,7 +16,7 @@ */ #if !defined(lint) && !defined(LINT) -static char rcsid[] = "$Id: crontab.c,v 1.2 1996/08/07 06:18:09 deraadt Exp $"; +static char rcsid[] = "$Id: crontab.c,v 1.3 1996/09/15 10:02:34 deraadt Exp $"; #endif /* crontab - install and manage per-user crontab files @@ -299,6 +299,7 @@ edit_cmd() { time_t mtime; WAIT_T waiter; PID_T pid, xpid; + mode_t um; log_it(RealUser, Pid, "BEGIN EDIT", User); (void) sprintf(n, CRON_TAB(User)); @@ -315,11 +316,14 @@ edit_cmd() { } } - (void) sprintf(Filename, "/tmp/crontab.%d", Pid); - if (-1 == (t = open(Filename, O_CREAT|O_EXCL|O_RDWR, 0600))) { + um = umask(0600); + (void) sprintf(Filename, "/tmp/crontab.XXXXXXXX"); + if ((t = mkstemp(Filename)) == -1) { perror(Filename); + (void) umask(um); goto fatal; } + (void) umask(um); #ifdef HAS_FCHOWN if (fchown(t, getuid(), getgid()) < 0) { #else |