summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1998-07-29 03:23:18 +0000
committerimp <imp@FreeBSD.org>1998-07-29 03:23:18 +0000
commit179d7e5a5f98deb716a58d5a6746d7dd56d8e2c9 (patch)
tree1441d864f4d1f99e3b840abcfc7e3e3c303ee710
parenteb80fc954a91302e6a1ddcfced0528aaa621355f (diff)
downloadFreeBSD-src-179d7e5a5f98deb716a58d5a6746d7dd56d8e2c9.zip
FreeBSD-src-179d7e5a5f98deb716a58d5a6746d7dd56d8e2c9.tar.gz
Fix temp file race in unused file. If someone wanted to clean the
tree a little, many files here are likely ripe for removal...
-rw-r--r--usr.sbin/amd/config/mtab_file.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/usr.sbin/amd/config/mtab_file.c b/usr.sbin/amd/config/mtab_file.c
index f08cae8..c652b12 100644
--- a/usr.sbin/amd/config/mtab_file.c
+++ b/usr.sbin/amd/config/mtab_file.c
@@ -37,7 +37,7 @@
*
* @(#)mtab_file.c 8.1 (Berkeley) 6/6/93
*
- * $Id$
+ * $Id: mtab_file.c,v 1.4 1997/02/22 16:02:27 peter Exp $
*
*/
@@ -271,7 +271,7 @@ mntlist *mp;
* directory as the target mount table
* so that rename() will work.
*/
- char tmpname[64];
+ char tmpname[MAXPATHLEN + 1];
int retries;
int tmpfd;
char *cp;
@@ -285,17 +285,7 @@ mntlist *mp;
tmpname[0] = '.'; tmpname[1] = '\0';
}
strcat(tmpname, "/mtabXXXXXX");
- mktemp(tmpname);
- retries = 0;
-enfile1:
- if ((tmpfd = open(tmpname, O_RDWR|O_CREAT|O_TRUNC, 0644)) < 0) {
- if (errno == ENFILE && retries++ < NFILE_RETRIES) {
- sleep(1);
- goto enfile1;
- }
- plog(XLOG_ERROR, "%s: open: %m", tmpname);
- return;
- }
+ tmpfd = mktemp(tmpname);
if (close(tmpfd) < 0)
plog(XLOG_ERROR, "Couldn't close tmp file descriptor: %m");
OpenPOWER on IntegriCloud