From nobody@FreeBSD.org  Fri Jan 22 14:40:37 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E3EFE106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 22 Jan 2010 14:40:37 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id D49518FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 22 Jan 2010 14:40:37 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0MEebFs058719
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 22 Jan 2010 14:40:37 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o0MEebSt058718;
	Fri, 22 Jan 2010 14:40:37 GMT
	(envelope-from nobody)
Message-Id: <201001221440.o0MEebSt058718@www.freebsd.org>
Date: Fri, 22 Jan 2010 14:40:37 GMT
From: Dirk Engling <erdgeist@erdgeist.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: rc.d/jail creates stray softlinks
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         143084
>Category:       conf
>Synopsis:       [jail] [patch]: fix rc.d/jail creating stray softlinks
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brooks
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 22 14:50:00 UTC 2010
>Closed-Date:    Fri Feb 10 22:54:02 UTC 2012
>Last-Modified:  Fri Feb 10 22:54:02 UTC 2012
>Originator:     Dirk Engling
>Release:        FreeBSD 8.0 RELEASE
>Organization:
>Environment:
FreeBSD ruprecht.local 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:02:08 UTC 2009     root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
While debugging a stray softlink

  "log" => "../var/run/log"

in ezjail's config directory I found the following code in

/etc/rc.d/jail:593

# Transitional symlink for old binaries
if [ ! -L "${_devdir}/log" ]; then
    __pwd="`pwd`"
    cd "${_devdir}"
    ln -sf ../var/run/log log
    cd "$__pwd"
fi

First, I wonder, why the whole block is not just a

  ln -s ../var/run/log "${_devdir}/log"

Secondly I wonder why the code above does not check for errors and just
skips this part if it can't mount devfs, why the code does not check return
code of the 'cd "${_devdir}' command.
>How-To-Repeat:

>Fix:
--- jail	2009-11-21 15:31:36.000000000 +0100
+++ /home/erdgeist/jail	2010-01-22 15:39:49.776129991 +0100
@@ -591,12 +591,7 @@
 				info "Mounting devfs on ${_devdir}"
 				devfs_mount_jail "${_devdir}" ${_ruleset}
 				# Transitional symlink for old binaries
-				if [ ! -L "${_devdir}/log" ]; then
-					__pwd="`pwd`"
-					cd "${_devdir}"
-					ln -sf ../var/run/log log
-					cd "$__pwd"
-				fi
+				ln -sf ../var/run/log "${_devdir}/log"
 			fi
 
 			# XXX - It seems symlinks don't work when there


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-ports-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Jan 23 00:41:49 UTC 2010 
Responsible-Changed-Why:  
apparently a ports PR. 

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

From: Dirk Engling <erdgeist@erdgeist.org>
To: bug-followup@FreeBSD.org, erdgeist@erdgeist.org
Cc:  
Subject: Re: ports/143084: [patch] sysutils/ezjail: rc.d/jail creates stray
 softlinks
Date: Sun, 24 Jan 2010 17:09:59 +0100

 This PR certainly is NOT an issue with the ezjail port but with the
 /etc/rc.d/jail script. Please re-move it to the appropriate section.
Responsible-Changed-From-To: freebsd-ports-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Jan 24 22:44:20 UTC 2010 
Responsible-Changed-Why:  
I misread the PR, this is an issue with the baseline code.  Over to 
maintainers. 

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

From: Gavin Atkinson <gavin@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/143084: [jail] [patch]: fix rc.d/jail creating stray
 softlinks
Date: Fri, 05 Mar 2010 11:27:31 +0000

 FWIW, the code in question was brought in with this commit:
 http://www.freebsd.org/cgi/cvsweb.cgi/src/etc/rc.d/jail#rev1.10

From: Jason Grossman <jason.grossman@anu.edu.au>
To: bug-followup@FreeBSD.org,
 erdgeist@erdgeist.org
Cc:  
Subject: Re: conf/143084: [jail] [patch]: fix rc.d/jail creating stray softlinks
Date: Mon, 2 Aug 2010 17:46:31 +1000

 This is causing me problems ... fairly minor problems, but if this bug  
 could be bumped up the list that would be great.  Thanks.
State-Changed-From-To: open->patched 
State-Changed-By: brooks 
State-Changed-When: Fri Jan 20 22:55:30 UTC 2012 
State-Changed-Why:  
Committed to head. 


Responsible-Changed-From-To: freebsd-rc->brooks 
Responsible-Changed-By: brooks 
Responsible-Changed-When: Fri Jan 20 22:55:30 UTC 2012 
Responsible-Changed-Why:  
Committed to head. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/143084: commit references a PR
Date: Fri, 20 Jan 2012 22:55:40 +0000 (UTC)

 Author: brooks
 Date: Fri Jan 20 22:55:19 2012
 New Revision: 230403
 URL: http://svn.freebsd.org/changeset/base/230403
 
 Log:
   When creating the jails /dev/log symlink, do it by full path to avoid
   creating stray "log" symlinks if the mount fails.  That apparently
   happens in some ezjail configs.
   
   PR:		conf/143084
   Submitted by:	Dirk Engling <erdgeist at erdgeist.org>
   Reviewed by:	simon
   MFC after:	2 weeks
 
 Modified:
   head/etc/rc.d/jail
 
 Modified: head/etc/rc.d/jail
 ==============================================================================
 --- head/etc/rc.d/jail	Fri Jan 20 22:55:16 2012	(r230402)
 +++ head/etc/rc.d/jail	Fri Jan 20 22:55:19 2012	(r230403)
 @@ -601,10 +601,7 @@ jail_start()
  				devfs_mount_jail "${_devdir}" ${_ruleset}
  				# Transitional symlink for old binaries
  				if [ ! -L "${_devdir}/log" ]; then
 -					__pwd="`pwd`"
 -					cd "${_devdir}"
 -					ln -sf ../var/run/log log
 -					cd "$__pwd"
 +					ln -sf ../var/run/log "${_devdir}/log"
  				fi
  			fi
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/143084: commit references a PR
Date: Fri, 10 Feb 2012 15:54:32 +0000 (UTC)

 Author: brooks
 Date: Fri Feb 10 15:54:17 2012
 New Revision: 231388
 URL: http://svn.freebsd.org/changeset/base/231388
 
 Log:
   MFC r230403.
   
   When creating the jails /dev/log symlink, do it by full path to avoid
   creating stray "log" symlinks if the mount fails.  That apparently
   happens in some ezjail configs.
   
   PR:		conf/143084
   Submitted by:	Dirk Engling <erdgeist at erdgeist.org>
 
 Modified:
   stable/9/etc/rc.d/jail
 Directory Properties:
   stable/9/etc/   (props changed)
 
 Modified: stable/9/etc/rc.d/jail
 ==============================================================================
 --- stable/9/etc/rc.d/jail	Fri Feb 10 15:34:36 2012	(r231387)
 +++ stable/9/etc/rc.d/jail	Fri Feb 10 15:54:17 2012	(r231388)
 @@ -601,10 +601,7 @@ jail_start()
  				devfs_mount_jail "${_devdir}" ${_ruleset}
  				# Transitional symlink for old binaries
  				if [ ! -L "${_devdir}/log" ]; then
 -					__pwd="`pwd`"
 -					cd "${_devdir}"
 -					ln -sf ../var/run/log log
 -					cd "$__pwd"
 +					ln -sf ../var/run/log "${_devdir}/log"
  				fi
  			fi
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/143084: commit references a PR
Date: Fri, 10 Feb 2012 15:55:22 +0000 (UTC)

 Author: brooks
 Date: Fri Feb 10 15:54:39 2012
 New Revision: 231389
 URL: http://svn.freebsd.org/changeset/base/231389
 
 Log:
   MFC r230403.
   
   When creating the jails /dev/log symlink, do it by full path to avoid
   creating stray "log" symlinks if the mount fails.  That apparently
   happens in some ezjail configs.
   
   PR:		conf/143084
   Submitted by:	Dirk Engling <erdgeist at erdgeist.org>
 
 Modified:
   stable/8/etc/rc.d/jail
 Directory Properties:
   stable/8/etc/   (props changed)
 
 Modified: stable/8/etc/rc.d/jail
 ==============================================================================
 --- stable/8/etc/rc.d/jail	Fri Feb 10 15:54:17 2012	(r231388)
 +++ stable/8/etc/rc.d/jail	Fri Feb 10 15:54:39 2012	(r231389)
 @@ -592,10 +592,7 @@ jail_start()
  				devfs_mount_jail "${_devdir}" ${_ruleset}
  				# Transitional symlink for old binaries
  				if [ ! -L "${_devdir}/log" ]; then
 -					__pwd="`pwd`"
 -					cd "${_devdir}"
 -					ln -sf ../var/run/log log
 -					cd "$__pwd"
 +					ln -sf ../var/run/log "${_devdir}/log"
  				fi
  			fi
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: brooks 
State-Changed-When: Fri Feb 10 22:53:26 UTC 2012 
State-Changed-Why:  
Merged to 8 and 9.  Sorry this took 2 years to get dealt with. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143084 
>Unformatted:
