Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Jun 2004 15:09:11 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Tim Kientzle <tim@kientzle.com>
Cc:        Nate Lawson <nate@root.org>
Subject:   Re: cvs commit: src/lib/libarchive archive_read_extract.c
Message-ID:  <20040606143616.W2060@gamplex.bde.org>
In-Reply-To: <40C22518.6060406@kientzle.com>
References:  <20040605053115.45AE416A585@hub.freebsd.org> <20040605000326.B54841@root.org> <40C22518.6060406@kientzle.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 5 Jun 2004, Tim Kientzle wrote:

> Nate Lawson wrote:
> > On Fri, 4 Jun 2004, Tim Kientzle wrote:
> >
> >>+	 * Yes, people really do type "tar -cf - foo/." for
> >>+	 * reasons that I cannot fathom.
> >
> > That's what tab completion in tcsh does.
>
> Tab completion adds the slash, but not the
> dot, which is the issue here.  I've noticed
> that "foo/." does force gtar to archive the
> dir target of a symlink, which may explain the
> usage.
>
> In particular, mkdir("foo/.") always fails, hence
> the need for an additional check.  (I'm considering
> reworking this code to explicitly check for and remove
> a trailing "/." sequence before trying to create the dir.)

Removing "/." might break handling of symlinks.

> >>+		if (stat(name, &st) == 0  &&  S_ISDIR(st.st_mode))
> >                                         ^^^^^^^
     		    ^^^^

Perhaps this or a nearby stat() should be lstat().  libarchive doesn't
use a single lstat() (though bsdtar does).

In fact, this stuff is quite broken.  After "cd /tmp; ln -s /tmp foo",
tarring up foo[/.] gives the following misbehaviours with yesterday's
versions of tars:

tar cf z foo:
    only puts foo in the archive (correct)
bsdtar cf z foo:
    same, except bsdtar seems to be too smart about padding the output
    to a block boundary for regular files, so subsequent piping of the
    file might not work
tar cf z foo/:
    only puts foo in the archive (broken)
bsdtar cf z foo/:
    same
tar cf z foo/.:
    puts files named foo/./* in the archive (everything under /tmp except
    z).  Warns about not attempting to put the archive inside itself.
bsdtar cf z foo/.:
    same, except it silently puts a truncated copy of the archive inside
    itself.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040606143616.W2060>