It appears that toybox tar can't untar archives with files inside
non-writable directories. GNU and BSD tar handle this.

The output below is with 0.8.9, but the same thing happens with
https://landley.net/toybox/git/commit/a3e5f1b1eaf2.

I ran into this while working around `adb push`'s lack of "dereference
symlinks" support.
https://issuetracker.google.com/120171523

---8<--------------------------------------

#!/bin/bash

set -euo pipefail

D=$(mktemp -d)

# Create a file inside a non-writable dir.
mkdir -p $D/foo/bar
echo quux > $D/foo/bar/baz
chmod 0555 $D/foo/bar

tar -cf $D/foo.tar -C $D foo

# Untar with GNU tar.
mkdir $D/gnu
tar --version
tar -xf $D/foo.tar -C $D/gnu
cat $D/gnu/foo/bar/baz

# And with BSD tar.
mkdir $D/bsd
bsdtar --version
bsdtar -xf $D/foo.tar -C $D/bsd
cat $D/bsd/foo/bar/baz

# And with toybox tar.
mkdir $D/toybox
toybox --version
toybox tar -xf $D/foo.tar -C $D/toybox
cat $D/toybox/foo/bar/baz

---8<--------------------------------------

tar (GNU tar) 1.35
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
quux
bsdtar 3.7.4 - libarchive 3.7.4 zlib/1.3.1 liblzma/5.8.1 bz2lib/1.0.8
liblz4/1.10.0 libzstd/1.5.6
quux
toybox 0.8.9
tar: foo/bar/baz: Permission denied
tar: had errors
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to