From nobody@FreeBSD.org  Tue Feb 13 13:21:12 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 97DA716A511
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 13 Feb 2007 13:21:12 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id 49BAD13C4B6
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 13 Feb 2007 13:21:12 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l1DDLB71021168
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 13 Feb 2007 13:21:11 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l1DDLBG7021167;
	Tue, 13 Feb 2007 13:21:11 GMT
	(envelope-from nobody)
Message-Id: <200702131321.l1DDLBG7021167@www.freebsd.org>
Date: Tue, 13 Feb 2007 13:21:11 GMT
From: Constantin Stefanov<cstef@mail.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] pkg_add replaces symlink in path to installed file for ordinary directory
X-Send-Pr-Version: www-3.0

>Number:         109134
>Category:       bin
>Synopsis:       [patch] pkg_add(1) replaces symlink in path to installed file for ordinary directory
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 13 13:30:07 GMT 2007
>Closed-Date:    Thu Aug 23 13:05:44 GMT 2007
>Last-Modified:  Wed Sep 19 08:50:07 GMT 2007
>Originator:     Constantin Stefanov
>Release:        FreeBSD 6.1-RELEASE-p3
>Organization:
SRCC MSU
>Environment:
FreeBSD stat.srcc.msu.ru 6.1-RELEASE-p3 FreeBSD 6.1-RELEASE-p3 #2: Wed Jul 26 14:29:50 MSD 2006     coctic@stat.srcc.msu.ru:/opt/obj/opt/src/sys/STAT  i386
>Description:
I have /usr/local symlinked to /opt/local (created with mkdir -p
/opt/local; cd /usr; rmdir local; ln -s ../opt/local local). I have some
other parts of file hierarchy symlinked into /opt which is a separate
filesystem. When I try to install DrWeb Enterprise Suite package (got on
ftp://ftp.drweb.com/pub/drweb/esuite/drweb-es-433-1-200609270-unix-freebsd6.1-i386.tbz link),
it fails. After failing I see that /usr/local is not a symlink any more,
but is a real directory. In my case installation failed because the package
depends on some software installed in my symlinked /usr/local, and it
disappeared during installation.

As I can understand, this package has "@cwd /" in +CONTENTS file, and
some usr/local/... files after that @cwd. And tar that is invoked from
pkg_add deletes all symlinks in path where it installs files to and
changes it for ordinary directories. Packages from FreeBSD collection
are not affected by the issue because they (at least all I looked into)
have "@cwd /usr/local" in +CONTENTS.

And I did not find any guidelines why it is not correct to have "@cwd /"
in package and to install files in /usr/local with it.
>How-To-Repeat:
Get fresh FreeBSD 6.1-RELEASE (I also checked 6.2-RELEASE, it has the
same issue).
mkdir /opt
mkdir /opt/local
cd /usr
rmdir local
ln -s ../opt/local local

Install latest iconv (it is a dependency which is not registered in the
package).
Run
pkg_add ftp://ftp.drweb.com/pub/drweb/esuite/drweb-es-433-1-200609270-unix-freebsd6.1-i386.tbz

Press Enter three times, then accept license agreement. When user
selection table is shown, run ls -l /usr in another console. You'll see
that /usr/local is not a symlink now, but is an ordinary directory.
>Fix:
My fix was to add -P switch to tar which is invoked from pkg_add when
putting package files into place (see attached patch).
After the fix the package did install.

Patch attached with submission follows:

--- src/usr.sbin/pkg_install/add/extract.c.orig	Mon Feb 12 14:47:06 2007
+++ src/usr.sbin/pkg_install/add/extract.c	Mon Feb 12 14:47:15 2007
@@ -34,7 +34,7 @@
 
 #define PUSHOUT(todir) /* push out string */ \
     if (where_count > (int)sizeof(STARTSTRING)-1) { \
-	strcat(where_args, "|/usr/bin/tar --unlink -xpf - -C "); \
+	strcat(where_args, "|/usr/bin/tar --unlink -xpPf - -C "); \
 	strcat(where_args, todir); \
 	if (system(where_args)) { \
 	    cleanup(0); \

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: krion 
State-Changed-When: Thu Aug 23 13:05:42 UTC 2007 
State-Changed-Why:  
Committed. Thanks! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/109134: commit references a PR
Date: Thu, 23 Aug 2007 13:05:22 +0000 (UTC)

 krion       2007-08-23 13:05:11 UTC
 
   FreeBSD src repository
 
   Modified files:
     usr.sbin/pkg_install/add extract.c 
   Log:
   Fix pkg_add behaviour to preserve pathnames.
   
   PR:             bin/93915 bin/109134
   Submitted by:   Jason Heiss <heissj@yahoo-inc.com>, Constantin Stefanov<cstef@mail.ru>
   Approved by:    re@ (kensmith)
   MFC after:      7 days
   
   Revision  Changes    Path
   1.45      +1 -1      src/usr.sbin/pkg_install/add/extract.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/109134: commit references a PR
Date: Wed, 19 Sep 2007 08:41:37 +0000 (UTC)

 krion       2007-09-19 08:41:27 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     usr.sbin/pkg_install/add extract.c 
   Log:
   MFC: extract.c:1.45
   
     date: 2007/08/23 13:05:10;  author: krion;  state: Exp;  lines: +1 -1
     Fix pkg_add behaviour to preserve pathnames.
   
     PR:             bin/93915 bin/109134
     Submitted by:   Jason Heiss <heissj@yahoo-inc.com>, Constantin Stefanov<cstef@mail.ru>
     Approved by:    re@ (kensmith)
     MFC after:      7 days
   
   Revision  Changes    Path
   1.43.2.2  +1 -1      src/usr.sbin/pkg_install/add/extract.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
