summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorHeikki Korpela <heko@cvs.openbsd.org>2001-08-25 19:52:06 +0000
committerHeikki Korpela <heko@cvs.openbsd.org>2001-08-25 19:52:06 +0000
commite6a70557c835aa6f17ca521395e547126f13152c (patch)
tree4cb0e68be8f10a9ccef67c13281558ee28be145d /usr.bin
parent163c6f94ed9908760f05b0fa1702cda394b632bf (diff)
It is ok for the target file not to exist even if -b was specified
to install(1), so silently ignore rename(2) ENOENT. Closes PR 2028. ok millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xinstall/xinstall.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index e298cd9dcae..0ad53a0d0cb 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xinstall.c,v 1.27 2001/07/09 07:04:58 deraadt Exp $ */
+/* $OpenBSD: xinstall.c,v 1.28 2001/08/25 19:52:05 heko Exp $ */
/* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93";
#endif
-static char rcsid[] = "$OpenBSD: xinstall.c,v 1.27 2001/07/09 07:04:58 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: xinstall.c,v 1.28 2001/08/25 19:52:05 heko Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -354,7 +354,8 @@ install(from_name, to_name, fset, flags)
char backup[MAXPATHLEN];
(void)snprintf(backup, MAXPATHLEN, "%s%s", to_name,
suffix);
- if (rename(to_name, backup) < 0) {
+ /* It is ok for the target file not to exist. */
+ if (rename(to_name, backup) < 0 && errno != ENOENT) {
serrno = errno;
unlink(tempfile);
errx(EX_OSERR, "rename: %s to %s: %s", to_name,
@@ -662,8 +663,9 @@ create_newfile(path, sbp)
if (dobackup) {
(void)snprintf(backup, MAXPATHLEN, "%s%s", path, suffix);
- if (rename(path, backup) < 0)
- err(EX_OSERR, "rename: %s to %s", path, backup);
+ /* It is ok for the target file not to exist. */
+ if (rename(path, backup) < 0 && errno != ENOENT)
+ err(EX_OSERR, "rename: %s to %s (errno %d)", path, backup, errno);
} else
(void)unlink(path);