From bdb182a2cc1c0e5ca649d17ef504ed3aa67ffe6c Mon Sep 17 00:00:00 2001 From: jonathan Date: Wed, 20 Dec 1995 10:25:17 +0000 Subject: [PATCH] Change xinstall to work with strip from GNU binutils, for mips and alpha ports. When using a strip that uses a temp file and moves that to the target, unlinking the original, install would set the modes of the original (now unlinked) file, not the new stripped one. Fixed by re-opening the fd used for fchown/chmod after stripping. --- usr.bin/xinstall/xinstall.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 9988a6adad7a..789bd0e4598f 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 @@ -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.