Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 143206 - app-arch/tar-1.15.1-r1 fails to extract archives with some permissions
Summary: app-arch/tar-1.15.1-r1 fails to extract archives with some permissions
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL: http://lists.gnu.org/archive/html/bug...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-08 06:43 UTC by Oleg Stopolenko
Modified: 2006-08-12 17:22 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Example of buggy tar archive (tarbug.tbz,285 bytes, application/octet-stream)
2006-08-09 01:09 UTC, Oleg Stopolenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Stopolenko 2006-08-08 06:43:24 UTC
On my Gentoo box I'm trying to extract an archive I've just created under FreeBSD on another host. There are files and dirs with permissions set to 000. Tar fails to extract some of these files, because it can not get access to directories created by itself.

I've noticed some directories were created with correct permissions 000 and there were files. "Permission denied" message appears when there are complex directory structure.

Here is the bash script I used to test the bug (must be run as root):

=====================
chess# uname -a
FreeBSD chess.z8.ru 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Thu Nov  3 09:36:13 UTC 2005     root@x64.samsco.home:/usr/obj/usr/src/sys/GENERIC  i386
chess# cat makebug.sh
#!/bin/sh

mkdir -p dir1/dir2/dir3/dir4
mkdir -p dir1/dir2/dir3/dir4-1
echo test4_1 > dir1/dir2/dir3/dir4/test4_1
echo test > dir1/dir2/dir3/dir4/test4_2
echo test > dir1/dir2/dir3/dir4/test4_3
echo test > dir1/dir2/dir3/dir4-1/test4-1_1
echo test > dir1/dir2/dir3/dir4-1/test4-1_2
echo test > dir1/dir2/dir3/dir4-1/test4-1_3

chmod -R 000 dir1/dir2/dir3/dir4
chmod -R 000 dir1/dir2/dir3/dir4-1

tar -jcvf tarbug.tbz dir1
rm -rf dir1

mv tarbug.tbz ~subadm/ ; chown subadm ~subadm/tarbug.tbz

==============================

Then I scp this .tbz to my host and untar it. Tar exits with error messages.

==============================
cronfy@cronfy ~ $ uname -a
Linux cronfy 2.6.17-gentoo-r4cronfy #7 SMP Thu Aug 3 11:30:09 MSD 2006 i686 Intel(R) Celeron(R) CPU 2.40GHz GenuineIntel GNU/Linux
cronfy@cronfy ~ $ scp subadm@chess.z8.ru:tarbug.tbz ./
cronfy@cronfy ~ $ tar jxvf tarbug.tbz
dir1
dir1/dir2
dir1/dir2/dir3
dir1/dir2/dir3/dir4
dir1/dir2/dir3/dir4-1
dir1/dir2/dir3/dir4-1/test4-1_1
dir1/dir2/dir3/dir4-1/test4-1_2
dir1/dir2/dir3/dir4-1/test4-1_3
dir1/dir2/dir3/dir4/test4_1
tar: dir1/dir2/dir3/dir4/test4_1: Cannot open: Permission denied
dir1/dir2/dir3/dir4/test4_2
tar: dir1/dir2/dir3/dir4/test4_2: Cannot open: Permission denied
dir1/dir2/dir3/dir4/test4_3
tar: dir1/dir2/dir3/dir4/test4_3: Cannot open: Permission denied
tar: Error exit delayed from previous errors

==========================

I tried to run this script on Gentoo, but an archive created by it is extracted just fine after. 

Also there is no errors if there is no 'dir4-1' directory.
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2006-08-08 06:50:55 UTC

*** This bug has been marked as a duplicate of 141197 ***
Comment 2 Oleg Stopolenko 2006-08-08 23:19:10 UTC
Are you sure this bug is a duplicate for 141197? 

Look:

BUG 141197 says tar extracts files WITH WRONG PERMISSIONS.

THIS BUG   says tar extracts files WITH CORRECT PERMISSIONS (perms were set by my with `chmod -R 000 dir1`), but tar sets these perms too early so it can not continue an extraction due lack of permissions.

Looks like tar 

1.  extracts everything (as it thinks) from dir4
1.1 sets perms on dir4
2.  extracts everything from dir4-1
2.2 sets perms on dir4-1
3.  and NOW it suddenly finds out there are still unextracted content for dir4, but perms were already set at step 1.1 - tar can't write anything to this directory.

Comment 3 Jakub Moc (RETIRED) gentoo-dev 2006-08-08 23:22:51 UTC
tar version? emerge --info?
Comment 4 Oleg Stopolenko 2006-08-08 23:48:07 UTC
Here it is.

cronfy@cronfy ~ $ tar --version
tar (GNU tar) 1.15.1

cronfy@cronfy ~ $ emerge --info
Portage 2.1-r1 (default-linux/x86/2006.0, gcc-3.4.4, glibc-2.3.5-r2, 2.6.17-gentoo-r4cronfy i686)
=================================================================
System uname: 2.6.17-gentoo-r4cronfy i686 Intel(R) Celeron(R) CPU 2.40GHz
Gentoo Base System version 1.6.14
app-admin/eselect-compiler: [Not Present]
dev-lang/python:     2.4.2
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.12
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.12-r6
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O3 -march=pentium4 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/lib/mozilla/defaults/pref /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-O3 -march=pentium4 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="ftp://phil.pht/ http://ftp.citkit.ru/pub/Linux/gentoo http://mirror.aiya.ru/pub/gentoo/"
LINGUAS="en ru"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 X apm avi berkdb bitmap-fonts cli crypt dlloader dri eds emboss encode foomaticdb fortran gdbm gif gpm gtk2 imlib isdnlog jpeg kde libg++ libwww mad mikmod motif mpeg ncurses nls nptl opengl pam pcre pdflib perl png pppd python qt qt3 qt4 quicktime readline reflection session spl ssl tcpd truetype truetype-fonts type1-fonts udev xml xorg zlib elibc_glibc input_devices_keyboard input_devices_mouse input_devices_evdev kernel_linux linguas_en linguas_ru userland_GNU video_cards_i915"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, MAKEOPTS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
Comment 5 Oleg Stopolenko 2006-08-09 00:13:41 UTC
tar was emerged this way:

cronfy@cronfy ~ $ emerge -pv tar

[ebuild   R   ] app-arch/tar-1.15.1-r1  USE="nls -build -bzip2 -static" 0 kB
Comment 6 Oleg Stopolenko 2006-08-09 01:09:14 UTC
Created attachment 93830 [details]
Example of buggy tar archive

This is the archive I created with makebug.sh on my FreeBSD system. I could not extract all it's files on my Gentoo box.
Comment 7 SpanKY gentoo-dev 2006-08-11 06:23:22 UTC
upstream answer:

Run tar with --delay-directory-restore option in this case.
Comment 8 Oleg Stopolenko 2006-08-11 07:45:13 UTC
tar does not know anything about this option:

cronfy@cronfy ~/tmp $ tar -jxvf tarbug.tbz --delay-directory-restore
tar: unrecognized option `--delay-directory-restore'
Try `tar --help' or `tar --usage' for more information.
Comment 9 SpanKY gentoo-dev 2006-08-12 17:22:22 UTC
it's in tar-1.15.9x+