diff options
author | Bruno Haible <bruno@clisp.org> | 2020-02-22 15:15:01 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-02-22 15:15:01 +0100 |
commit | baec1bac1602ba8534320c295e120f7b658400f4 (patch) | |
tree | f3accc6e8cbf2ae2a4495ac246be60e7ac779ca2 | |
parent | 0a9326b474c2d222a6beee4f547ca5355190af8d (diff) | |
download | gnulib-baec1bac1602ba8534320c295e120f7b658400f4.tar.gz |
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.
-rw-r--r-- | ChangeLog | 9 | ||||
-rwxr-xr-x | gnulib-tool | 14 |
2 files changed, 23 insertions, 0 deletions
@@ -1,5 +1,14 @@ 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. * users.txt: Update URLs to projects that have moved or switched to git. Use canonical host names. Prefer gitweb over cgit. Prefer the tree view diff --git a/gnulib-tool b/gnulib-tool index 89f6077e57..01c6745ad8 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -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. |