Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Mar 2000 01:38:27 -0500 (EST)
From:      adrian@ubergeeks.com
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/17386: pkg_create copy_file() use of cp(1) and flags problems
Message-ID:  <200003150638.BAA05794@newbie.cho.cstone.net>

next in thread | raw e-mail | index | archive | help


>Number:         17386
>Category:       bin
>Synopsis:       schg flag causes pkg_create cleaup problems
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 14 22:40:02 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Adrian Filipi-Martin
>Release:        FreeBSD 3.4-RELEASE i386
>Organization:
Ubergeeks Consulting
>Environment:

	3.4-RELEASE w/ports from 03/12/00.

>Description:

	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.

>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


>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.

--- file.c.orig	Wed Mar 15 00:50:24 2000
+++ file.c	Wed Mar 15 00:57:57 2000
@@ -412,9 +412,9 @@
     char cmd[FILENAME_MAX];
 
     if (fname[0] == '/')
-	snprintf(cmd, FILENAME_MAX, "cp -p -r %s %s", fname, to);
+	snprintf(cmd, FILENAME_MAX, "cp -R %s %s", fname, to);
     else
-	snprintf(cmd, FILENAME_MAX, "cp -p -r %s/%s %s", dir, fname, to);
+	snprintf(cmd, FILENAME_MAX, "cp -R %s/%s %s", dir, fname, to);
     if (vsystem(cmd)) {
 	cleanup(0);
 	errx(2, "could not perform '%s'", cmd);


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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