diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-25 22:23:19 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-25 22:23:19 +0000 |
commit | dbccedb222a0d39588ccba593a1846b985fb3fc8 (patch) | |
tree | 3309194181e2a8a8a7c1d2565e7841303c97d8c0 | |
parent | 5b3a269f79da3c3cee6ba1b0ac2ff83fa1ad6a8f (diff) |
mkstemp & fdopen
-rw-r--r-- | usr.bin/rdist/message.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/rdist/message.c b/usr.bin/rdist/message.c index 844b1bb2928..b94be4c14c6 100644 --- a/usr.bin/rdist/message.c +++ b/usr.bin/rdist/message.c @@ -33,7 +33,7 @@ #ifndef lint static char RCSid[] = -"$Id: message.c,v 1.2 1996/03/05 03:16:08 dm Exp $"; +"$Id: message.c,v 1.3 1996/06/25 22:23:18 deraadt Exp $"; static char sccsid[] = "@(#)common.c"; @@ -445,6 +445,8 @@ static void msgsendnotify(msgfac, mtype, flags, msgbuf) int flags; char *msgbuf; { + int fd; + if (IS_ON(flags, MT_DEBUG)) return; @@ -465,10 +467,13 @@ static void msgsendnotify(msgfac, mtype, flags, msgbuf) (void) sprintf(tempfile, "%s/%s", cp, _RDIST_TMP); msgfac->mf_filename = tempfile; - (void) mktemp(msgfac->mf_filename); - if ((msgfac->mf_fptr = fopen(msgfac->mf_filename, "w"))==NULL) + if ((fd = mkstemp(msgfac->mf_filename)) == -1 || + (msgfac->mf_fptr = fdopen(fd, "w"))==NULL) { + if (fd != -1) + close(fd); fatalerr("Cannot open notify file for writing: %s: %s.", msgfac->mf_filename, SYSERR); + } debugmsg(DM_MISC, "Created notify temp file '%s'", msgfac->mf_filename); } |