From 4416d3f0dd9c1efe70f5d9f7777c6bbac05982c0 Mon Sep 17 00:00:00 2001 From: deraadt Date: Sun, 15 Sep 1996 10:02:34 +0000 Subject: [PATCH] use mkstemp; mentioned by sirsyko@ishiboo.com --- usr.sbin/cron/crontab.c | 10 +++++++--- 1 file 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 -- 2.20.1