]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool: Ensure copied files are writable.
authorBruno Haible <bruno@clisp.org>
Sat, 22 Feb 2020 14:15:01 +0000 (15:15 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 22 Feb 2020 14:15:01 +0000 (15:15 +0100)
Reported by Benno Fünfstück <benno.fuenfstueck@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-02/msg00101.html>.

* gnulib-tool (func_ensure_writable): New function.
(func_ln_s, func_hardlink, func_lookup_file, func_import,
func_create_testdir, copy-file): Invoke it after copying a file.

ChangeLog
gnulib-tool

index f90eae03de695dd7161f8d97ac3fa13f63207907..b2774e9d61d71521a2ea2e3d6e669f542d0aa0a6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-02-22  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool: Ensure copied files are writable.
+       Reported by Benno Fünfstück <benno.fuenfstueck@gmail.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2020-02/msg00101.html>.
+       * gnulib-tool (func_ensure_writable): New function.
+       (func_ln_s, func_hardlink, func_lookup_file, func_import,
+       func_create_testdir, copy-file): Invoke it after copying a file.
+
 2020-02-22  Bruno Haible  <bruno@clisp.org>
 
        users.txt: Update.
index 89f6077e57832eb878ee2d72d4e7784358653eaf..01c6745ad84979a115d5ccbdd848b0893451c636 100755 (executable)
@@ -794,6 +794,13 @@ func_relconcat ()
   done
 }
 
+# func_ensure_writable DEST
+# Ensures the file DEST is writable.
+func_ensure_writable ()
+{
+  test -w "$1" || chmod u+w "$1"
+}
+
 # func_ln_s SRC DEST
 # Like ln -s, except use cp -p if ln -s fails.
 func_ln_s ()
@@ -813,6 +820,7 @@ func_ln_s ()
     esac
 
     cp -p "$cp_src" "$2"
+    func_ensure_writable "$2"
   }
 }
 
@@ -876,6 +884,7 @@ func_hardlink ()
   ln "$1" "$2" || {
     echo "$progname: ln failed; falling back on cp -p" >&2
     cp -p "$1" "$2"
+    func_ensure_writable "$2"
   }
 }
 
@@ -1717,6 +1726,7 @@ func_lookup_file ()
     lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
     rm -f "$tmp/$lkbase"
     cp "$lookedup_file" "$tmp/$lkbase"
+    func_ensure_writable "$tmp/$lkbase"
     save_IFS="$IFS"
     IFS="$PATH_SEPARATOR"
     for patchfile in $lkpatches; do
@@ -5225,6 +5235,7 @@ s,^\(.................................................[^ ]*\) *,
     func_dest_tmpfilename "$g"
     func_lookup_file "$f"
     cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
+    func_ensure_writable "$tmpfile"
     case "$f" in
       *.class | *.mo )
         # Don't process binary files with sed.
@@ -6313,6 +6324,7 @@ func_create_testdir ()
       func_lookup_file "$f"
       if test -n "$lookedup_tmp"; then
         cp -p "$lookedup_file" "$testdir/$g"
+        func_ensure_writable "$testdir/$g"
       else
         func_should_link
         if test "$copyaction" = symlink; then
@@ -6322,6 +6334,7 @@ func_create_testdir ()
             func_hardlink "$lookedup_file" "$testdir/$g"
           else
             cp -p "$lookedup_file" "$testdir/$g"
+            func_ensure_writable "$testdir/$g"
           fi
         fi
       fi
@@ -7317,6 +7330,7 @@ s/\([.*$]\)/[\1]/g'
     # Copy the file.
     func_dest_tmpfilename "$g"
     cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
+    func_ensure_writable "$tmpfile"
     already_present=true
     if test -f "$destdir/$g"; then
       # The file already exists.