From harry@schmalzbauer.de  Mon Aug 29 14:55:34 2005
Return-Path: <harry@schmalzbauer.de>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1277016A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 Aug 2005 14:55:34 +0000 (GMT)
	(envelope-from harry@schmalzbauer.de)
Received: from flb.schmalzbauer.de (flb.schmalzbauer.de [62.245.232.135])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 50F4243D49
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 Aug 2005 14:55:32 +0000 (GMT)
	(envelope-from harry@schmalzbauer.de)
Received: from korso.flintsbach.schmalzbauer.de (korso.flintsbach.schmalzbauer.de [172.21.2.3])
	by flb.schmalzbauer.de (8.13.1/8.13.1) with ESMTP id j7TEtVL5015111
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 Aug 2005 16:55:31 +0200 (CEST)
	(envelope-from harry@cale.flintsbach.schmalzbauer.de)
Received: from cale.flintsbach.schmalzbauer.de (cale.flintsbach.schmalzbauer.de [172.21.1.252])
	by korso.flintsbach.schmalzbauer.de (Postfix) with ESMTP id 5693A4207
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 Aug 2005 16:55:31 +0200 (CEST)
Received: from cale.flintsbach.schmalzbauer.de (localhost [127.0.0.1])
	by cale.flintsbach.schmalzbauer.de (8.13.4/8.13.4) with ESMTP id j7TEtUi0001403
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 Aug 2005 16:55:30 +0200 (CEST)
	(envelope-from harry@cale.flintsbach.schmalzbauer.de)
Received: (from harry@localhost)
	by cale.flintsbach.schmalzbauer.de (8.13.4/8.13.4/Submit) id j7TEtU3J001402;
	Mon, 29 Aug 2005 16:55:30 +0200 (CEST)
	(envelope-from harry)
Message-Id: <200508291455.j7TEtU3J001402@cale.flintsbach.schmalzbauer.de>
Date: Mon, 29 Aug 2005 16:55:30 +0200 (CEST)
From: Harald Schmalzbauer <harry@schmalzbauer.de>
Reply-To: Harald Schmalzbauer <harry@schmalzbauer.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: bsdtar doesn't restore file flags (cpio also doesn't)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         85439
>Category:       bin
>Synopsis:       bsdtar doesn't restore file flags (cpio also doesn't)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kientzle
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 29 15:00:22 GMT 2005
>Closed-Date:    Wed Sep 21 03:16:53 GMT 2005
>Last-Modified:  Wed Sep 21 03:16:53 GMT 2005
>Originator:     Harald Schmalzbauer
>Release:        FreeBSD 6.0-BETA2 i386
>Organization:
>Environment:
System: FreeBSD cale.flintsbach.schmalzbauer.de 6.0-BETA2 FreeBSD 6.0-BETA2 #0: Thu Aug 18 05:29:38 CEST 2005 root@:/usr/obj/usr/src/sys/CALE i386


	
>Description:
	Short description says it all, I'm llosing file flags when restoring
	tar archive.
>How-To-Repeat:
#!/bin/tcsh
mtree -U -p /mnt/ -f /etc/mtree/BIND.chroot.dist
set testflags = 'arch opaque nodump sappnd schg sunlnk uappnd uchg uunlnk'
foreach flag ( $testflags )
echo "This file should have flag $flag set" > /mnt/etc/testfile.$flag
chflags $flag /mnt/etc/testfile.$flag
end
tar -C /mnt -cvf /mnt/.flagstest.tar etc
foreach flag ( $testflags )
# Don't care about the nonodump error
chflags no$flag /mnt/etc/testfile.$flag
end
rm -R /mnt/*
tar -C /mnt -xvpf /mnt/.flagstest.tar

Now you can see all files are there, also mtime is correctly restored, but
no flags.

>Fix:

	


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->kientzle 
Responsible-Changed-By: rodrigc 
Responsible-Changed-When: Wed Aug 31 00:56:17 GMT 2005 
Responsible-Changed-Why:  
Over to libarchive author 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85439 

From: Tim Kientzle <tim@kientzle.com>
To: bug-followup@FreeBSD.org, harry@schmalzbauer.de
Cc:  
Subject: Re: bin/85439: bsdtar doesn't restore file flags (cpio also doesn't)
Date: Mon, 05 Sep 2005 03:36:31 -0700

 This is a multi-part message in MIME format.
 --------------030504000907060301060302
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 
 Harry,
 
 Would you please try this patch and see if it fixes it for you?
 
 Tim
 
 
 
 --------------030504000907060301060302
 Content-Type: text/plain;
  name="libarchive_flags_restore.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="libarchive_flags_restore.patch"
 
 --- libarchive-6stable/archive_read_extract.c	Sat Jun  4 15:30:36 2005
 +++ libarchive/archive_read_extract.c	Mon Sep  5 03:23:55 2005
 @@ -1054,8 +1054,10 @@
  	 */
  	if (!S_ISLNK(archive_entry_mode(entry))) {
  #ifdef HAVE_FCHMOD
 -		if (fd >= 0 && fchmod(fd, mode) == 0)
 -			return (ARCHIVE_OK);
 +		if (fd >= 0 && fchmod(fd, mode) != 0) {
 +			archive_set_error(a, errno, "Can't set permissions");
 +			return (ARCHIVE_WARN);
 +		}
  #endif
  		if (chmod(name, mode) != 0) {
  			archive_set_error(a, errno, "Can't set permissions");
 
 --------------030504000907060301060302--
 

From: Harald Schmalzbauer <harry@schmalzbauer.de>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/85439: bsdtar doesn't restore file flags (cpio also doesn't)
Date: Mon, 5 Sep 2005 23:27:30 +0200

 Am Montag, 5. September 2005 12:36 CEST schrieb Tim Kientzle:
 > Harry,
 >
 > Would you please try this patch and see if it fixes it for you?
 
 Thanks a lot, tar does now restore fflags.
 Doesn't cpio also make use of that library?
 
 Another question:
 If I create a archive as user with files belonging to root, owner (root) 
 can't be restored although I'm (the user) the owner of the driectory. Same 
 with chown command. Why can't I change the owner of a file that belongs to 
 me? (in a directory that belongs to me!)
 I can't see any security related reason for that... What am I missing?
 
 Thanks a lot,
 
 -Harry
State-Changed-From-To: open->closed 
State-Changed-By: kientzle 
State-Changed-When: Wed Sep 21 03:14:59 GMT 2005 
State-Changed-Why:  
Fixed in 7-CURRENT (archive_read_extract.c 1.43) and in 6-STABLE 
(archive_read_extract.c 1.41.2.1). 

cpio is a separate program that will require separate attention. 
However, it should be noted that no standard cpio format supports 
file flags. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=85439 
>Unformatted:
