summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-21 14:47:10 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-21 14:47:10 +0000
commitb350a21c4dcfee2bdb3c19a82444fda4ed4711d8 (patch)
tree998b118a3fab764fb84ddeb243b8b85f3f860ef9 /usr.bin
parent2967f9d4ba55ef9eb3cddf411aa5aa2aa4cbbd3f (diff)
from netbsd: some versions of strip generate a new file; thus we should
re-open the file before doing chown/chmod operations on it.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xinstall/xinstall.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index 9988a6adad7..789bd0e4598 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -1,4 +1,4 @@
-/* $NetBSD: xinstall.c,v 1.8 1995/08/10 04:20:57 ghudson Exp $ */
+/* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93";
#endif
-static char rcsid[] = "$NetBSD: xinstall.c,v 1.8 1995/08/10 04:20:57 ghudson Exp $";
+static char rcsid[] = "$NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -243,8 +243,19 @@ install(from_name, to_name, fset, flags)
copy(from_fd, from_name, to_fd, to_name, from_sb.st_size);
(void)close(from_fd);
}
- if (dostrip)
+
+ if (dostrip) {
strip(to_name);
+
+ /*
+ * Re-open our fd on the target, in case we used a strip
+ * that does not work in-place -- like gnu binutils strip.
+ */
+ close(to_fd);
+ if ((to_fd = open(to_name, O_RDONLY, S_IRUSR | S_IWUSR)) < 0)
+ err(1, "stripping %s", to_name);
+ }
+
/*
* Set owner, group, mode for target; do the chown first,
* chown may lose the setuid bits.