From behanna@topperwein.dyndns.org  Fri Jun 15 23:48:57 2001
Return-Path: <behanna@topperwein.dyndns.org>
Received: from topperwein.dyndns.org (acs-24-154-28-172.zoominternet.net [24.154.28.172])
	by hub.freebsd.org (Postfix) with ESMTP id 8DB4137B401
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 15 Jun 2001 23:48:56 -0700 (PDT)
	(envelope-from behanna@topperwein.dyndns.org)
Received: (from behanna@localhost)
	by topperwein.dyndns.org (8.11.4/8.11.4) id f5G6nqP89676;
	Sat, 16 Jun 2001 02:49:52 -0400 (EDT)
	(envelope-from behanna)
Message-Id: <200106160649.f5G6nqP89676@topperwein.dyndns.org>
Date: Sat, 16 Jun 2001 02:49:52 -0400 (EDT)
From: Chris BeHanna <behanna@topperwein.dyndns.org>
Reply-To: behanna@topperwein.dyndns.org
To: FreeBSD-gnats-submit@freebsd.org
Cc: jdp@polstra.com
Subject: rtld-elf apparently ignores LD_LIBRARY_PATH
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         28191
>Category:       bin
>Synopsis:       rtld-elf ignores LD_LIBRARY_PATH
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    jdp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 15 23:50:01 PDT 2001
>Closed-Date:    Sun Feb 10 17:12:40 PST 2002
>Last-Modified:  Sun Feb 10 17:13:05 PST 2002
>Originator:     Chris BeHanna
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
>Environment:
System: FreeBSD topperwein.dyndns.org 4.3-STABLE FreeBSD 4.3-STABLE #0: Tue Jun 12 09:06:55 EDT 2001 root@topperwein.dyndns.org:/usr/obj/usr/src/sys/TOPPERWEIN i386

    CPU:  AMD Athlon, 1.333 GHz (AMD K-7)
    Affected file:  /usr/libexec/ld-elf.so.1
>Description:
    The XFree86 4.1.0_4 port fails on this box when attempting to
    build the Type 1 fonts.  In particular, this line fails:

LD_LIBRARY_PATH=../../../exports/lib XFT_CONFIG=../../../lib/Xft/XftConfig ../../../exports/bin/xftcache   .
/usr/libexec/ld-elf.so.1: ../../../exports/bin/xftcache: Undefined symbol "XftDirSave"

    where `pwd` is /usr/ports/x11/XFree86-4/work/xc/programs/xftcache.

    According to rtld(1), LD_LIBRARY_PATH should supercede the default
    search path except for setuid and setgid executables, of which
    xftcache is neither.

    I verified this problem by running the command by hand and by
    doing  "LD_LIBRARY_PATH=../../../exports/lib ldd xftcache".  The
    output pointed to the installed /usr/X11R6/lib/libXft.so instead of
    the one within the XFree86 build tree and, indeed the installed
    libXft.so doesn't have the symbol XftDirSave, but the one in the build
    tree does.

    Note that ldconfig -r reveals an entry for libXft.so that does
    indeed point to /usr/X11R6/lib/libXft.so.  That said, if I can't
    selectively override that by setting LD_LIBRARY_PATH on the command
    line, that's a big problem.

    From the comment from find_library(), I see that the executable's
    RPATH entry takes precedence over LD_LIBRARY_PATH.  If that's the
    case, then how can LD_LIBRARY_PATH be used to force an executable to
    bootstrap itself from a build tree?

>How-To-Repeat:
    Attempt to build XFree86 4.1.0_4 on an Athlon running 4.3-STABLE
    from the date indicated in uname -a, above.
>Fix:
    Change find_library() to look in LD_LIBRARY_PATH before RPATH for
    non-setuid, non-setgid executables:

--- rtld.c	Mon May 14 01:01:35 2001
+++ rtld.c.new	Sat Jun 16 02:45:03 2001
@@ -803,8 +803,8 @@
     dbg(" Searching for \"%s\"", name);
 
     if ((refobj != NULL &&
-      (pathname = search_library_path(name, refobj->rpath)) != NULL) ||
       (pathname = search_library_path(name, ld_library_path)) != NULL ||
+      (pathname = search_library_path(name, refobj->rpath)) != NULL) ||
       (pathname = search_library_path(name, gethints())) != NULL ||
       (pathname = search_library_path(name, STANDARD_LIBRARY_PATH)) != NULL)
 	return pathname;

If I completely misunderstand, please let me know, and I'll raise no
fuss about closing this PR.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jdp 
Responsible-Changed-By: tobez 
Responsible-Changed-When: Wed Aug 29 10:34:24 PDT 2001 
Responsible-Changed-Why:  
Rtld-elf is John's baby. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28191 

From: Sheldon Hearn <sheldonh@starjuice.net>
To: jdp@FreeBSD.org
Cc: bug-followup@freebsd.org
Subject: Re: bin/28191: rtld-elf apparently ignores LD_LIBRARY_PATH
Date: Thu, 24 Jan 2002 14:31:46 +0200

 Hi John,
 
 PR bin/28191 is assigned to you.  It remains in the open state, but you
 appear to have provided an answer in PR bin/28406 that suggests the PR
 should be closed.
 
 It's not our policy to interfere with the state of assigned PRs without
 first asking the assignee.
 
 May I close this PR?
 
 Ciao,
 Sheldon.

From: John Polstra <jdp@polstra.com>
To: Sheldon Hearn <sheldonh@starjuice.net>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/28191: rtld-elf apparently ignores LD_LIBRARY_PATH
Date: Thu, 24 Jan 2002 08:50:50 -0800 (PST)

 Sheldon Hearn wrote:
 > PR bin/28191 is assigned to you.  It remains in the open state, but you
 > appear to have provided an answer in PR bin/28406 that suggests the PR
 > should be closed.
 [...]
 > May I close this PR?
 
 Hmm, maybe not.  The standard I referred to in bin/28406 is pretty old --
 from the SVR4 days.  It now appears that Sun has switched to giving
 LD_LIBRARY_PATH precedence over the other elements of the search path.
 I'm inclined to make the same change, as requested in bin/28191.  That
 has always made more sense to me, but I didn't want to go against
 whatever standards existed.
 
 I'll take care of it in the next few days.
 
 John
 

From: John Polstra <jdp@polstra.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/28191: rtld-elf apparently ignores LD_LIBRARY_PATH
Date: Fri, 25 Jan 2002 08:38:03 -0800 (PST)

 I have fixed this problem in revision 1.56 of rtld.c.  I will merge
 the fix into -stable in about 2 weeks.  At that time I'll close this
 PR.
 
 John
State-Changed-From-To: open->closed 
State-Changed-By: jdp 
State-Changed-When: Sun Feb 10 17:12:40 PST 2002 
State-Changed-Why:  
The fix for this has been merged into the RELENG_4 branch. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28191 
>Unformatted:
