NetBSD Problem Report #35257
From gson@gson.org Thu Dec 14 18:46:17 2006
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id EC0FB63BA6D
for <gnats-bugs@gnats.NetBSD.org>; Thu, 14 Dec 2006 18:46:16 +0000 (UTC)
Message-Id: <20061214184600.90BCA75F5F@guava.gson.org>
Date: Thu, 14 Dec 2006 20:45:59 +0200 (EET)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: tar(1) opens excluded files
X-Send-Pr-Version: 3.95
>Number: 35257
>Category: bin
>Synopsis: tar(1) opens excluded files
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Dec 14 18:50:00 +0000 2006
>Closed-Date:
>Last-Modified: Wed Jan 09 14:44:08 +0000 2008
>Originator: Andreas Gustafsson
>Release: NetBSD 4.99.3
>Organization:
>Environment:
System: NetBSD guava.gson.org 4.99.3 NetBSD 4.99.3 (GENERIC) #0: Mon Sep 25 00:54:38 EEST 2006 root@guru.araneus.fi:/usr/build/1007/obj/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
When a file is excluded from a tar archive using the --exclude-from
option to the tar(1) command, an attempt is nevertheless made to open
the file. If the file can't be opened, an error message to that
effect is printed, which is confusing because it makes it appear as if
the file is not actually being excluded.
For example, if a procfs is mounted with "-o linux" and you try to
back up the parent file system using tar, you will get error messages
about files on the procfs even if you exclude it from the backup using
--exclude-from.
GNU tar does not exhibit this behavior.
>How-To-Repeat:
Run the following shell script as root:
mkdir -p test/emul/linux/proc
mount -t procfs -o linux procfs test/emul/linux/proc
echo "./emul/linux" >excludes
( cd test && tar --exclude-from ../excludes -c -f - . | tar tfv - )
umount test/emul/linux/proc
Notice how tar prints error messages similar to the following:
tar: Unable to access ./emul/linux/proc/19829/fd/7 (Bad file descriptor)
tar: Unable to access ./emul/linux/proc/19327/fd/7 (Bad file descriptor)
Here is another test case which doesn't involve procfs and should be
run as a non-root user:
mkdir -p test/foo
touch test/foo/a
touch test/foo/b
chmod 000 test/foo/b
echo "./foo" >excludes
( cd test && tar --exclude-from ../excludes -c -f - . | tar tfv - )
Notice how tar prints the error message
tar: Unable to open ./foo/b to read (Permission denied)
even though both foo/a and foo/b are successfully excluded
from the archive.
>Fix:
None provided.
>Release-Note:
>Audit-Trail:
From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: re: bin/35257: tar(1) opens excluded files
Date: Fri, 15 Dec 2006 06:54:52 +1100
ah.
i'd guess this is due to the --exclude functionality being implemented
on top of pax's -s flag. i wonder if there is an easy way to check that
the output file name isn't "" before trying to open the file...
.mrg.
From: Christos Zoulas <christos@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/35257 CVS commit: src/bin/pax
Date: Thu, 14 Dec 2006 23:18:11 +0000 (UTC)
Module Name: src
Committed By: christos
Date: Thu Dec 14 23:18:11 UTC 2006
Modified Files:
src/bin/pax: ar_subs.c
Log Message:
PR/35257: Andreas Gustafsson: tar(1) opens excluded files
Apply the file modification function in the input files so that we can
de-select matched patterns.
To generate a diff of this commit:
cvs rdiff -r1.50 -r1.51 src/bin/pax/ar_subs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: christos@netbsd.org
State-Changed-When: Fri, 15 Dec 2006 10:22:10 -0500
State-Changed-Why:
fixed, thanks
From: Christos Zoulas <christos@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/35257 CVS commit: src/bin/pax
Date: Fri, 4 May 2007 21:19:37 +0000 (UTC)
Module Name: src
Committed By: christos
Date: Fri May 4 21:19:37 UTC 2007
Modified Files:
src/bin/pax: ar_subs.c extern.h pat_rep.c pat_rep.h tar.1
Log Message:
PR/36275: john at iastate dot edu: tar -s modifies symlink targets
- This is explained in a comment in pat_rep.c inside mod_name(). I did not
want to change the default behavior, so I added another modifier "s" which
when set, the pattern will not modify the symlink destination.
- While here I fixed another bug that was introduced before by the fix in
PR/35257 where the renaming was happening twice since we called rep_name
twice.
- Finally if we are renaming hard of soft-link targets print the renames for
those too.
To generate a diff of this commit:
cvs rdiff -r1.53 -r1.54 src/bin/pax/ar_subs.c
cvs rdiff -r1.52 -r1.53 src/bin/pax/extern.h
cvs rdiff -r1.26 -r1.27 src/bin/pax/pat_rep.c
cvs rdiff -r1.5 -r1.6 src/bin/pax/pat_rep.h
cvs rdiff -r1.24 -r1.25 src/bin/pax/tar.1
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/35257: tar(1) opens excluded files
Date: Wed, 9 Jan 2008 16:36:38 +0200
The problem I reported in bin/35257 is back, or perhaps it was never
completely fixed. For example, running the following as root on 4.99.48:
mkdir -p test/emul/linux/proc
mount -t procfs -o linux procfs test/emul/linux/proc
echo "./emul/linux" >excludes
( cd test && tar --exclude-from ../excludes -c -f - . | tar tfv - )
umount test/emul/linux/proc
yields the error message
tar: Unable to read symlink ./emul/linux/proc/443/fd/8 (No such file or directory)
Running ktrace on the tar process shows that in addition to the failed
readlink() call evident from the error message, many other excluded
files are being passed to readlink() or open(), but those don't cause
additional error messages as the calls are successful.
--
Andreas Gustafsson, gson@gson.org
State-Changed-From-To: closed->open
State-Changed-By: gson@netbsd.org
State-Changed-When: Wed, 09 Jan 2008 14:44:08 +0000
State-Changed-Why:
The problem has reappeared, or was never fully fixed.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.