bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Karl Berry <karl@freefriends.org>
Cc: bug-gnulib@gnu.org
Subject: Re: install-sh -s on readonly file
Date: Sun, 25 Aug 2019 19:13:00 -0700	[thread overview]
Message-ID: <d2cb1c0f-fa1f-dad6-73bf-f4c42bc83f74@cs.ucla.edu> (raw)
In-Reply-To: <201908260052.x7Q0qjAS005353@freefriends.org>

[-- Attachment #1: Type: text/plain, Size: 287 bytes --]

Karl Berry wrote:
> -    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
> +    { test -z "$stripcmd" || ($doit $chmodcmd u+w "$dsttmp"; $doit $stripcmd "$dsttmp") } &&

How about the attached Automake patch instead? It avoids the extra forks and 
exec. Admittedly it's longer.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-install-sh-support-s-with-read-only-source.patch --]
[-- Type: text/x-patch; name="0001-install-sh-support-s-with-read-only-source.patch", Size: 1281 bytes --]

From c50db415f06d3a29780fe9650654165f6fa28bf0 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 25 Aug 2019 18:51:26 -0700
Subject: [PATCH] install-sh: support -s with read-only source
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Karl Berry in:
https://lists.gnu.org/r/bug-gnulib/2019-08/msg00067.html
* lib/install-sh: If -s is given, create the temporary file
with $cp_umask so that ‘strip’ can write to it.
---
 lib/install-sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/install-sh b/lib/install-sh
index 8175c640f..1f5cdccc7 100755
--- a/lib/install-sh
+++ b/lib/install-sh
@@ -451,7 +451,16 @@ do
     trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
 
     # Copy the file name to the temp name.
-    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+    (umask $cp_umask &&
+     { test -z "$stripcmd" || {
+	 if test -z "$doit"; then
+	   : >"$dsttmp" # No need to fork-exec 'touch'.
+	 else
+	   $doit touch "$dsttmp"
+	 fi
+       }
+     } &&
+     $doit_exec $cpprog "$src" "$dsttmp") &&
 
     # and set any options; do chmod last to preserve setuid bits.
     #
-- 
2.21.0


  reply	other threads:[~2019-08-26  2:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26  0:52 install-sh -s on readonly file Karl Berry
2019-08-26  2:13 ` Paul Eggert [this message]
2019-08-26 21:34   ` Karl Berry
2019-08-26 21:46     ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d2cb1c0f-fa1f-dad6-73bf-f4c42bc83f74@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=bug-gnulib@gnu.org \
    --cc=karl@freefriends.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).