The
sysjail imprisons ("jails") a process and its descendants. Processes in a jail have a restricted view of system resources.
A jailed environment will persist until all children have exited, an internal error occurs, or the
sysjail process is signalled with a
SIGTERM.
-4 ipv4
If specified once, causes addresses to be re-written to the address specified by ipv4. Subsequent invocations denote addresses not re-written; for instance, if 192.168.1.1 is specified first, then 10.10.0.15, requests for 10.10.0.15 are left unchanged, but all others are re-written to 192.168.1.1. If unspecified (the default), IPV4 requests are denied.
-6 ipv6
Like -4, but for ipv6 addresses. If unspecified (the default), IPV6 requests are disallowed.
-b
Run in the background. This is especially useful if running
rc(8) within jails. Detaches from terminal and redirects standard input and output to
/dev/null.
-d
Enable debugging. If used once, warnings are emitted. If twice, debug messages are also printed.
-f device
Specify an alternate systrace device. Defaults to /dev/systrace.
-h
Print a help message and exit.
-i
Print the identifier of the newly-created jail.
-j file
Specify an alternate jail database. Defaults to /var/db/sysjail.db.
-l
Clean and re-set child environments prior to execution. The extant environment is discarded except for HOME, SHELL, TERM and USER. HOME and SHELL are set to the target login's default values. USER is set to the target login. TERM is imported from the current environment. The environment variables from the login class capability database for the target login are also set. This is only valid with -u or -U.
-u username
Use credentials for username as gathered from the host (pre-prison) environment.
-U username
Use credentials for username as gathered from the prison environment.
-v
Print the version number and exit.
path
Path in which to imprison processes. The dev directory in path must be under the root device or device access will fail (this may possibly be limited to OpenBSD 4.2).
hostname
Hostname used within the jail.
command
Pathname of the program (relative to the prison path) that is to be executed. May be followed by any number of arguments.
The following long options are also available (note that these may override behaviour described in this document):
--allow-raw-sockets
Allow raw sockets,
SOCK_RAW, to be used in the
socket(2) call (denied by default).
--allow-all-domains
Allow domains not in
AF_UNIX,
AF_ROUTE,
AF_INET6, and
AF_INET with thee
socket(2) call (denied by default).
--allow-ipc
Allows System V Interface Definition, Fourth Edition (“SVID4”) interprocess functions (denied by default).
--allow-chflags
Allow prison effective super-user calls to the
chflags(2) family (denied by default).
--allow-rlimit
Allow prison effective super-user calls to
setrlimit(2) to raise the maximum limit (denied by default).
Emulation
Linux and FreeBSD binaries may via kernel emulation. If a process changes into (or begins as) FreeBSD or Linux, it's afforded the same protection as native binaries. This manual differentiates supporting calls whenever relevant. Note that the operating environment may cause problems; for example, if a Linux system is using procfs, process filtering is bypassed.
Interprocess Communication Resources
All System V Interface Definition, Fourth Edition (“SVID4”) interprocess functions are denied with
EPERM, including, but not limited to,
msgctl(2) (and related message passing functions),
shmctl(2) (and related shared memory functions), and
semctl(2) (and related semaphore functions). Compliance to these functions vary greatly among systems and emulations; all are denied.
Network Resources
Calls to
gethostname(2) (Linux, SunOS?) result in the jail's internal hostname being returned.
Security note: if one accesses the returned buffer beyond the nil-pointer, the original value from the system call is still resident).
Compatibility note: Although SUS states that the buffer is not guaranteed to be nil-terminated,
sysjail will always nil-terminate the string. Calls to
sethostname(2) (SunOS?) are denied with
EPERM. Attempts to get or set the hostname by
sysctl(3) are similarly re-written or denied. Networks calls to
bind(2) are restricted to
AF_UNIX,
AF_INET, and
AF_INET6 (if running with the
-6 flag).
AF_INET addresses are re-written to the jail's address, and if
-6 has been specified,
AF_INET6 addresses are also re-written. Calls to
socket(2) are filtered for
AF_UNIX, AF_ROUTE, AF_INET6, and
AF_INET. These are denied with
EPROTONOSUPPORT.
SOCK_RAW and the IPPROTO_RAW and IPPROTO_ROUTING protocols are further denied. These
bind(2) and
socket(2) restrictions are also followed on Linux through
socketcall(2). Most
ioctl(2) writable network operations, those found in
sys/sockio.h, are denied with
EPERM (adding network interfaces, bridges, etc.).
Process Resources
Processes in a jail are denied access to processes not in the jail. All system calls with PID inputs are filtered in this regard. Relevant effected system calls are
setpriority(2),
getpriority(2),
setpgid(2),
getpgid(2),
killpg(2) (Linux),
kill(2),
getsid(2),
sched_setscheduler(2) (Linux, FreeBSD),
sched_getscheduler(2) (Linux, FreeBSD),
sched_setparam(2) (Linux, FreeBSD),
sched_getparam(2) (Linux, FreeBSD),
ptrace(2),
fktrace(2) (NetBSD), and
ktrace(2). Note that
getpgid(2),
getppid(2), and
getsid(2) may return processes outside of the prison. These processes may not be acted upon. The usual return value when processes outside of the prison are accessed is
ESRCH, although this isn't always the case. Values from
sysctl(3) are process-filtered if matching the
KERN_PROC,
KERN_PROC2, and
KERN_PROC_ARGS values (effecting
ps(1) and other utilities). Calls to
setrlimit(2) are denied with
EPERM if setting the maximum value beyond the parent
sysjail process's maximum value (does not conform to FreeBSD's jail).
The
kill(2) function requires special mention. If a process sends a signal to process 1,
init(8), the
sig value is changed to 0 and allowed (signal is ignored but non-super-user processes receive an
EPERM error). If the signal is -1 and the process owner is the super-user, all processes in the jail but the caller are delivered the relevant
sig.
Miscellaneous Resources
Calls to
reboot(2) are denied with
EPERM but will regardless cause the jail to halt if raised by the super-user. Most writable
sysctl(3) entities are denied with
EPERM. All
ioctl(2) LKM operations, those found in
sys/lkm.h, are denied with
EPERM.