From nobody@FreeBSD.org  Wed Sep 15 18:33:18 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 3CD361065672
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 15 Sep 2010 18:33:18 +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 2D30E8FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 15 Sep 2010 18:33:18 +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 o8FIXH9Y095005
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 15 Sep 2010 18:33:17 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o8FIXHxN095004;
	Wed, 15 Sep 2010 18:33:17 GMT
	(envelope-from nobody)
Message-Id: <201009151833.o8FIXHxN095004@www.freebsd.org>
Date: Wed, 15 Sep 2010 18:33:17 GMT
From: Uffe Jakobsen <uffe@uffe.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: /etc/rc.d/jail does not set jailname.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         150599
>Category:       conf
>Synopsis:       [patch] /etc/rc.d/jail does not set jailname.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-jail
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 15 18:40:01 UTC 2010
>Closed-Date:    Fri May 06 19:21:06 UTC 2011
>Last-Modified:  Fri May 06 19:21:06 UTC 2011
>Originator:     Uffe Jakobsen
>Release:        FreeBSD 8.1-RELEASE
>Organization:
>Environment:
FreeBSD asp1410 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:55:53 UTC 2010     root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
/etc/rc.d/jail does not set jailname.

Using FreeBSD 8.1-STABLE I've found that the standard /etc/rc.d/jail script does not create jails with "proper" names.

If you inspect your running jails (the ones started with /etc/rc.jail) with # jls -n you will see that jailname is equal to the jail id (jid)

Now I know that this is not directly a bug - but merely a matter of approach in /etc/rc.d/jail. Jails created without specific/explicit names will get their jid as the jailname by default.

But having "jid" and "jailname" equal each other reduces the usability for utilities like jls and jps that according to their man pages can take either jid or jailname as an argument.

The next question is what the jailname actually should be set to ?

1) should it be the jail "name" as referred to in /etc/rc.conf (eg "xyz" as in "jail_xyz_ip") ?

2) should it be the hostname (jail_xyz_hostname=) ?

3) or should the jailname have a (new) separate attribute in /etc/rc.conf (eg. "jail_xyz_name") ?


>How-To-Repeat:

Create a jail enable it in /etc/rc.conf and let it start through /etc/rc.d/jail


>Fix:

For every jail that is started through /etc/rc.d/jail add the line below into /etc/rc.conf:

jail_xyz_flags="-n somename"



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-jail 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Sep 26 20:57:37 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

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

From: Uffe Jakobsen <uffe@uffe.org>
To: bug-followup@FreeBSD.org, uffe@uffe.org
Cc:  
Subject: Re: conf/150599: [patch] /etc/rc.d/jail does not set jailname.
Date: Mon, 06 Dec 2010 13:30:34 +0100

 This is a multi-part message in MIME format.
 --------------030308060500020604000201
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 
 I purpose the attached patch
 
 
 
 --------------030308060500020604000201
 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
  name="jail.rc.head.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="jail.rc.head.patch"
 
 --- jail.rc.head	2010-12-06 12:49:49.000000000 +0100
 +++ jail.rc.head.fix	2010-12-06 13:20:26.000000000 +0100
 @@ -39,6 +39,7 @@
  	_devdir="${_rootdir}/dev"
  	_fdescdir="${_devdir}/fd"
  	_procdir="${_rootdir}/proc"
 +	eval _jailname=\"\$jail_${_j}_name\"
  	eval _hostname=\"\$jail_${_j}_hostname\"
  	eval _ip=\"\$jail_${_j}_ip\"
  	eval _interface=\"\${jail_${_j}_interface:-${jail_interface}}\"
 @@ -644,6 +645,9 @@
  			i=$((i + 1))
  		done
  
 +		if [ -n "${_jailname}" ] ; then
 +			_flags="${_flags} -n ${_jailname}";
 +		fi
  		eval ${_setfib} jail ${_flags} -i ${_rootdir} ${_hostname} \
  			\"${_addrl}\" ${_exec_start} > ${_tmp_jail} 2>&1 \
  			</dev/null
 
 --------------030308060500020604000201--
State-Changed-From-To: open->closed 
State-Changed-By: trasz 
State-Changed-When: Fri May 6 19:21:05 UTC 2011 
State-Changed-Why:  
The same functionality can already be achieved using jail_<n>_flags, 
e.g. 'jail_shell_flags="-l -U root -n shell"'. 

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