From nobody@FreeBSD.org  Sun Feb 20 22:51:06 2011
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 D60411065670
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 20 Feb 2011 22:51:06 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id C35458FC19
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 20 Feb 2011 22:51:06 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p1KMp6BS097856
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 20 Feb 2011 22:51:06 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p1KMp673097855;
	Sun, 20 Feb 2011 22:51:06 GMT
	(envelope-from nobody)
Message-Id: <201102202251.p1KMp673097855@red.freebsd.org>
Date: Sun, 20 Feb 2011 22:51:06 GMT
From: Julian Fagir <gnrp@gnrp.in-berlin.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: jail_getid(3) does not work; jexec(8) does not work with names
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         154922
>Category:       misc
>Synopsis:       jail_getid(3) does not work; jexec(8) does not work with names
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 20 23:00:23 UTC 2011
>Closed-Date:    Mon Feb 21 04:36:20 UTC 2011
>Last-Modified:  Mon Feb 21 04:36:20 UTC 2011
>Originator:     Julian Fagir
>Release:        8.1-RELEASE
>Organization:
>Environment:
FreeBSD zweihorn1 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010     root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
jail_getid(3) returns just the same jid as a string.
jail_getname(3) returns only the jid of the jid you give (as a string).

As far as I see, it is not a problem of my understanding, as the jexec(8)-manpage explicitly states that the jail can be supplied as a name or jid.
jls does return the right name of the jail as ezjail is configured to create, and indeed both of them are doing fine when asking for the name or starting a shell in the jail.
`ezjail-admin console` does use the id of the jail, anyway.
>How-To-Repeat:
Just `jls`, pick any jailname $JAILNAME and then run `jexec $JAILNAME sh`. It will fail as it does not find the name of the jail.

Alternatively, compile the following program with -ljail and run it with the only parameter the name of the jail:

#include <sys/types.h>
#include <sys/param.h>
#include <sys/uio.h>
#include <sys/jail.h>

#include <stdio.h>
#include <jail.h>

int
main(int argc, char* argv[]) {
  int jid;
  if (argc != 2)
    return(1);
  jid = jail_getid(argv[1]);
  printf("Jail %s is running: %d\n", argv[1], jid);
  return(0);
}
>Fix:


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: gjb 
State-Changed-When: Mon Feb 21 04:35:46 UTC 2011 
State-Changed-Why:  
Closed by request of submitter. 


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