Module Name:    src
Committed By:   gson
Date:           Sat Jul 25 11:45:58 UTC 2009

Modified Files:
        src/usr.bin/xinstall: xinstall.c

Log Message:
When installing via a temporary file, base the name of the temporary
file on the name of the target file, not just the target directory, to
ensure uniqueness when multiple concurrent invocations of install(1)
simultaneously install files in the same directory.  Fixes bin/41512.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/xinstall/xinstall.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xinstall/xinstall.c
diff -u src/usr.bin/xinstall/xinstall.c:1.111 src/usr.bin/xinstall/xinstall.c:1.112
--- src/usr.bin/xinstall/xinstall.c:1.111	Mon Jun  8 21:58:44 2009
+++ src/usr.bin/xinstall/xinstall.c	Sat Jul 25 11:45:58 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: xinstall.c,v 1.111 2009/06/08 21:58:44 yamt Exp $	*/
+/*	$NetBSD: xinstall.c,v 1.112 2009/07/25 11:45:58 gson Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)xinstall.c	8.1 (Berkeley) 7/21/93";
 #else
-__RCSID("$NetBSD: xinstall.c,v 1.111 2009/06/08 21:58:44 yamt Exp $");
+__RCSID("$NetBSD: xinstall.c,v 1.112 2009/07/25 11:45:58 gson Exp $");
 #endif
 #endif /* not lint */
 
@@ -418,8 +418,7 @@
 	int ret;
 
 	if (dorename) {
-		(void)snprintf(tmpl, sizeof(tmpl), "%s/inst.XXXXXX",
-		    xdirname(to_name));
+		(void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name);
 		/* This usage is safe. */
 		if (mktemp(tmpl) == NULL)
 			err(1, "%s: mktemp", tmpl);
@@ -448,8 +447,7 @@
 	char tmpl[MAXPATHLEN];
 
 	if (dorename) {
-		(void)snprintf(tmpl, sizeof(tmpl), "%s/inst.XXXXXX",
-		    xdirname(to_name));
+		(void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name);
 		/* This usage is safe. */
 		if (mktemp(tmpl) == NULL)
 			err(1, "%s: mktemp", tmpl);
@@ -668,8 +666,7 @@
 		(void)chflags(to_name, to_sb.st_flags & ~(NOCHANGEBITS));
 #endif
 	if (dorename) {
-		(void)snprintf(tmpl, sizeof(tmpl), "%s/inst.XXXXXX",
-		    xdirname(to_name));
+		(void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name);
 		oto_name = to_name;
 		to_name = tmpl;
 	} else {

Reply via email to