kern/58497: sysctl knob to return current process' jid

C. Stephen Gunn csg at
Fri Oct 24 13:40:14 PDT 2003

>Number:         58497
>Category:       kern
>Synopsis:       sysctl knob to return current process' jid
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 24 13:40:12 PDT 2003
>Originator:     C. Stephen Gunn
>Release:        FreeBSD 5.1-CURRENT i386
WaterSpout Communications, Inc.

FreeBSD 5.1-CURRENT FreeBSD 5.1-CURRENT #1: Sun Oct 19 21:57:46 CDT 2003     root at  i386

There is no easy way to tell if a process is operating in a Jail
environment.  This lever would be useful in /etc/rc to avoid
invocations of privledged commands (sysctl, mount, fsck, etc)
that are known to be prohibited in the jail.

I have other work against the /etc/rc subsystem that uses this
mechanism to avoid carping about operations that are not permitted.

Start a jail and execute /etc/rc, watch all the errors and warnings,
fiddle with 'ps | grep ..J..' for a while trying to figure out
if you are currently in a jail.


The following patch (against current), adds a sysctl knob that returns
the jid of the calling process, or 0 when the process is not jailed.
MD5 (security_jail_jid.diff) = b4b6e0fa944271977c94688e76e9f372


More information about the freebsd-bugs mailing list