I'm trying to extract and restore a directory one level up from the
directory the archive was created in.
For each file in that upper-level directory, I get a
Member name contains `..'
message and no extraction. Doesn't matter if I extract to stdout,
whether I'm root, or what. I've also tried '--strip-level=1' but my
version of tar doesn't recognize that option, and I'm uncertain that
it would resolve this anyway.
I'm not trying to do anything funny. I'm just trying to restore some
files. So far, I haven't found any reference to '..' in 'info tar'
yet, nor the man page, nor on-line. I'm still looking, of course.
Any help appreciated.
What is the command you typed to create the tar file?
What is the command you type to extract the tar file?
What is the output of 'tar -tvf <tar file>'?
Yours,
Laurenz Albe
If those three questions are (a), (b), and (c), then:
First: The directory structure is
<home>
<foo>
<bar>
a) Within <bar>, the command was
tar -xcf foobar.tar * ../foo/*
b) Within <bar>, tar -xvf foobar.tar
c) Everything within <bar> extracts, everthing that was in <foo>
produces
../foo/file.n
tar: ../foo/file.n: Member name contains `..'
>
> Yours,
> Laurenz Albe
>
I'm not called doofus for nothing. The correct answer here is
tar -cvf foobar.tar * ../foo/*
If I understand you correcly then the directory bar resides in directory
foo. If this is true why don't you do just
tar -cvf foobar.tar * bar/*
in directory foo?
Regards,
Constantin Wiemer
No, they're peers.
I'm failing on the extraction, not the creation, of the archive.
GNU tar tries to be relatively defensive about extracting stuff
it thinks may be particularly unexpected or problematic, most
notably absolute pathnames and references to parent directories.
The extraction solution may not be immediatley obvious (relative to
the documentation), but the same option seems useful to override the
blocking of extraction in either case.
$ tar -cf tar ../foo
tar: Member names contain `..'
$ tar -tf tar
../foo/
../foo/foo
$ rm -rf ../foo
$ ls -ld ../foo
ls: ../foo: No such file or directory
$ tar -xf tar ../foo
tar: ../foo/: Member name contains `..'
tar: ../foo/foo: Member name contains `..'
tar: Error exit delayed from previous errors
$ ls -ld ../foo
ls: ../foo: No such file or directory
$ tar --absolute-names -xf tar ../foo
$ echo $?
0
$ find ../foo -print
../foo
../foo/foo
I would probably have never gleened that from the documentation.
Thank you very much.