From jhein@timing.com  Fri Oct 22 21:05:31 2004
Return-Path: <jhein@timing.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8A06516A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 22 Oct 2004 21:05:31 +0000 (GMT)
Received: from Daffy.timing.com (w.timing.com [206.168.13.218])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 3E2E843D53
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 22 Oct 2004 21:05:31 +0000 (GMT)
	(envelope-from jhein@timing.com)
Received: from Speedy.timing.com (speedy.timing.com [206.168.13.185])
	by Daffy.timing.com (8.12.8p2/8.12.8) with ESMTP id i9ML5UIm086274;
	Fri, 22 Oct 2004 15:05:30 -0600 (MDT)
	(envelope-from jhein@timing.com)
Received: from Speedy.timing.com (localhost [127.0.0.1])
	by Speedy.timing.com (8.13.1/8.13.1) with ESMTP id i9ML5UYD030823;
	Fri, 22 Oct 2004 15:05:30 -0600 (MDT)
	(envelope-from jhein@Speedy.timing.com)
Received: (from jhein@localhost)
	by Speedy.timing.com (8.13.1/8.13.1/Submit) id i9ML5UmA030822;
	Fri, 22 Oct 2004 15:05:30 -0600 (MDT)
	(envelope-from jhein)
Message-Id: <200410222105.i9ML5UmA030822@Speedy.timing.com>
Date: Fri, 22 Oct 2004 15:05:30 -0600 (MDT)
From: "John E. Hein" <jhein@timing.com>
Reply-To: "John E. Hein" <jhein@timing.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: imp@timing.com
Subject: chflags on wrong file in libexec/rtld-elf (if DESTDIR != "")
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         73016
>Category:       kern
>Synopsis:       [patch] chflags on wrong file in libexec/rtld-elf (if DESTDIR != "")
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    schweikh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 22 21:10:23 GMT 2004
>Closed-Date:    Sun Nov 21 10:36:29 GMT 2004
>Last-Modified:  Sun Nov 21 18:10:17 GMT 2004
>Originator:     John E. Hein
>Release:        FreeBSD 5.3-RC1
>Organization:
Timing Solutions
>Environment:
System: FreeBSD Speedy.timing.com 5.3-BETA6 FreeBSD 5.3-BETA6 #1: Fri Oct 1 15:51:39 MDT 2004 root@Speedy.timing.com:/usr/obj/usr/src/sys/SPEEDY i386


>Description:
	During installworld to a non-empty DESTDIR, an error pops up doing a
    chflags on ld-elf.so.1.  The error is ignored (prefix'd by - in the
    Makefile).  But it's easy to make it go away (see patch).
>How-To-Repeat:
	make installworld DESTDIR=/foo
>Fix:

    chflags the link target, not the sym link.

Index: libexec/rtld-elf/Makefile
===================================================================
RCS file: /base/FreeBSD-CVS/src/libexec/rtld-elf/Makefile,v
retrieving revision 1.31
diff -u -r1.31 Makefile
--- libexec/rtld-elf/Makefile	17 Jun 2004 19:01:53 -0000	1.31
+++ libexec/rtld-elf/Makefile	22 Oct 2004 15:18:04 -0000
@@ -47,7 +47,7 @@
 # Since moving rtld-elf to /libexec, we need to create a symlink.
 # Fixup the existing binary that's there so we can symlink over it.
 beforeinstall:
-	-chflags noschg ${DESTDIR}/usr/libexec/${PROG}
+	-chflags noschg ${DESTDIR}/${BINDIR}/${PROG}
 
 .PATH: ${.CURDIR}/${MACHINE_ARCH}
 
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: schweikh 
State-Changed-When: Sun Nov 14 12:47:39 GMT 2004 
State-Changed-Why:  
Fixed in -current, MFC in one week. Thanks, John! 


Responsible-Changed-From-To: freebsd-bugs->schweikh 
Responsible-Changed-By: schweikh 
Responsible-Changed-When: Sun Nov 14 12:47:39 GMT 2004 
Responsible-Changed-Why:  
My MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=73016 
State-Changed-From-To: patched->closed 
State-Changed-By: schweikh 
State-Changed-When: Sun Nov 21 10:35:34 GMT 2004 
State-Changed-Why:  
Differerent fix committed to RELENG_5. Thanks, John! 

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

From: John E Hein <jhein@timing.com>
To: Jens Schweikhardt <schweikh@FreeBSD.org>
Cc: ru@FreeBSD.org
Subject: Re: kern/73016: [patch] chflags on wrong file in libexec/rtld-elf (if DESTDIR != "")
Date: Sun, 21 Nov 2004 11:08:54 -0700

 But this brings up another problem that still causes chflags to be
 invoked for the wrong file in the case of an existing sym link
 and DESTDIR != "".
 
 When the sym link is followed for an install, it leaves the real
 /libexec/ld-elf.so.1 without the schg flag.  If this is to
 DESTDIR != "", the real /libexec/ld-elf.so.1 never gets the
 schg flag set again.
 
 Maybe this would be better:
 
 Index: Makefile
 ===================================================================
 RCS file: /base/FreeBSD-CVS/src/libexec/rtld-elf/Makefile,v
 retrieving revision 1.36
 diff -u -r1.36 Makefile
 --- Makefile    14 Nov 2004 22:18:31 -0000      1.36
 +++ Makefile    21 Nov 2004 17:30:27 -0000
 @@ -48,9 +48,7 @@
  # Since moving rtld-elf to /libexec, we need to create a symlink.
  # Fixup the existing binary that's there so we can symlink over it.
  beforeinstall:
 -.if exists(${DESTDIR}/usr/libexec/${PROG})
 -	-chflags noschg ${DESTDIR}/usr/libexec/${PROG}
 -.endif
 +	@-[ ! -h ${DESTDIR}/usr/libexec/${PROG} ] && chflags noschg ${DESTDIR}/usr/libexec/${PROG} || true
  
  .PATH: ${.CURDIR}/${MACHINE_ARCH}
 
 
 This will spawn one more shell invocation from make.
 Too bad there's not a 'islink' expression in make(1).
 
 The '|| true' is there to avoid a bogus '*** Error code 1 (ignored)'
 message from make when the sym link does exist.
 
 
 
 But now that I think about it, I think it's even better to make the
 sym link point to a relative target anyway.  How about this instead
 (leave the if .exists as is, don't bother with the -h test, and make
 the sym link relative):
 
 
 Index: Makefile
 ===================================================================
 RCS file: /base/FreeBSD-CVS/src/libexec/rtld-elf/Makefile,v
 retrieving revision 1.36
 diff -u -r1.36 Makefile
 --- Makefile	14 Nov 2004 22:18:31 -0000	1.36
 +++ Makefile	21 Nov 2004 17:37:41 -0000
 @@ -12,7 +12,7 @@
  INSTALLFLAGS=	-C -b
  PRECIOUSPROG=
  BINDIR=		/libexec
 -SYMLINKS=	${BINDIR}/${PROG} /usr/libexec/${PROG}
 +SYMLINKS=	../../${BINDIR}/${PROG} /usr/libexec/${PROG}
  MLINKS=		rtld.1 ld-elf.so.1.1 \
  		rtld.1 ld.so.1
  
 
 
 You could add the -h test in addition to this to be safe.  This would
 protect against having an old absolute sym link in any installed
 worlds that are in DESTDIR != "".
>Unformatted:
