bin/109134: [patch] pkg_add replaces symlink in path to installed file for ordinary directory

Constantin Stefanov cstef at mail.ru
Tue Feb 13 13:30:08 UTC 2007


>Number:         109134
>Category:       bin
>Synopsis:       [patch] pkg_add replaces symlink in path to installed file for ordinary directory
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 13 13:30:07 GMT 2007
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list