Bug 17386

Summary: schg flag causes pkg_create cleaup problems
Product: Base System Reporter: adrian <adrian>
Component: binAssignee: Sheldon Hearn <sheldonh>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.4-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description adrian 2000-03-15 06:40:02 UTC
	If extended file flags are set on the mtree files in /etc/mtree,
	pkg_create cannot remove its temp files, because of how pkg_create 
	copies the mtree file to /var/tmp.  It exec's cp(1) with '-p' 
	which preserves the flags as well as the usual file metadata.

	Since the only files that are copied in this way are the pkg
	metadata files, e.g. +COMMENT, +DESCR, etc., it is of no great
	loss that the timestamps are not preserved in the created pacakge.
	It is a bother when pkg_create leaves garbage in /var/tmp that may
	not be easily removed.  The preservation of the flags is lost in
	pkg since tarfiles cannot handle the file flags.

	FYI, This bug was actually encountered when running "make package"
	for the gmake port.

Fix: Apply the following patch to usr.sbin/pkg_install/lib/file.c.  Note,
	'-r' was replaced with '-R' per the cp(1) manpage's recommendatons.
	Since no recurssive copies were actually found in the code, it may
	be possible to remove '-R' altogether.
How-To-Repeat: 
	# sh
	# cd /tmp
	# for i in DESCR COMMENT PLIST FOO; do echo FOO > $i; done
	# chflags schg /etc/mtree/BSD.local.dist
	# pkg_create -c COMMENT -d DESCR -f PLIST -p /tmp \
		-m /etc/mtree/BSD.local.dist PKG.tgz
	rm: /var/tmp/instmp.Xk5440/+MTREE_DIRS: Operation not permitted
	rm: /var/tmp/instmp.Xk5440: Directory not empty
	pkg_create: couldn't remove temporary dir '/var/tmp/instmp.Xk5440'
	# ls -lo /var/tmp/instmp.go5393 
	total 5
	-r--r--r--  1 root  wheel  schg 4112 Dec 20 00:53 +MTREE_DIRS
Comment 1 Sheldon Hearn freebsd_committer freebsd_triage 2000-03-15 09:10:13 UTC
Responsible Changed
From-To: freebsd-bugs->sheldonh

This has been fixed in NetBSD since Nov 1999.  I'll take this one. 
Comment 2 Sheldon Hearn freebsd_committer freebsd_triage 2000-03-15 09:36:44 UTC
State Changed
From-To: open->closed

Committed as rev 1.41, thanks! 
Also merged onto the RELENG_4 and RELENG_3 branches.