Commit Graph

312 Commits

Author SHA1 Message Date
Jamie Gritton
4334a36a6a Better communicate the purpose of "-r *". 2012-01-31 19:45:32 +00:00
Martin Matuska
d637f5bf9a Try resolving jail path with realpath(3).
jail(8) does a chdir(2) to the given path argument. Kernel evaluates the
jail path from the new cwd and not from the original cwd, which leads to
undesired behavior if given a relative path.

Reviewed by:	jamie
MFC after:	2 weeks
2012-01-24 08:04:38 +00:00
Martin Matuska
435d46675d Always disable mount and unmount for jails with enforce_statfs==2.
A working statfs(2) is required for umount(8) in jail.

Reviewed by:	pjd, kib
Approved by:	re (kib)
MFC after:	2 weeks
2011-08-02 19:44:40 +00:00
Benedict Reuschling
76e54f993c Revert my last change to this file, as BETA1 is not announced yet.
Pointed out by: kib
Pointy hat to:  me
Approved by:	re (kib, implicit)
2011-07-28 12:23:32 +00:00
Benedict Reuschling
f49a230f9c Add a section to the jail chapter that explains why it is not
recommended to allow root users in the jail to access the host system.

PR:		docs/156853
Submitted by:	crees
Patch by:	crees
Approved by:	re (kib) for BETA1
2011-07-28 11:41:55 +00:00
Glen Barber
1f897ce116 Document the potential for jail escape.
Submitted by:	Vedad KAJTAZ (vedad % kajtaz net)
PR:		142341
Reviewed by:	bz, rwatson
Rewording by:	rwatson
Approved by:	re (kensmith)
MFC after:	3 days
2011-07-24 03:34:38 +00:00
Jamie Gritton
eadec913d9 Don't report errors for the exit status of processes that are killed
as part of jail removal (IP_STOP_TIMEOUT).

Note a jail as "removed" even if it wasn't jail_remove() that did
the deed, e.g. if it already went away because all its processes
were killed.
2011-07-06 21:49:56 +00:00
Jamie Gritton
600802304e Advance to the next command before running anything, so errors found in
finish_command can be processed properly.
Call failed() once in next_command() instead of multiple times in
 run_command().
Continue processing commands when a no-wait operation (IP__OP or background
 command) succeeds.
2011-06-22 21:18:37 +00:00
Jamie Gritton
c6eff841df Fix a couple of NULL dereferences. 2011-06-21 19:13:48 +00:00
Jamie Gritton
5fb611c2bf Following r222465:
Check for IPv4 or IPv6 to be available by the kernel to not
  provoke errors trying to query options not available.
  Make it possible to compile out INET or INET6 only parts.
2011-06-20 23:04:13 +00:00
Jamie Gritton
e16fb8fba8 Linty stuff. 2011-06-20 07:58:44 +00:00
Jamie Gritton
2b00f7ba65 Move the actual create/remove (IP__OP) handling into run_command,
and the cost of an ugly single-use global variable.
2011-06-18 15:23:08 +00:00
Jamie Gritton
d8352076b1 Update copyright dates and other whitespacey stuff. 2011-06-17 16:21:03 +00:00
Jamie Gritton
3b40332c44 Split run_command up into an outer function (next_command) that chooses
a single command string to run, and an inner function (run_command) that
 runs that single string.
Move the list of start/stop commands to run from a switch statement into
 an array, with a new placeholder parameter IP__OP for actually creating
 or removing the jail.
When jail creation fails, revert all non-exec commands in reverse order.
2011-06-17 16:18:44 +00:00
Jamie Gritton
2a194551a7 Change cfstrings from an STAILQ into a TAILQ to allow commands to be
traversed in reverse order.
2011-06-17 16:06:13 +00:00
Bjoern A. Zeeb
15ede76031 Check for IPv4 or IPv6 to be available by the kernel to not
provoke errors trying to query options not available.
Make it possible to compile out INET or INET6 only parts.

Reviewed by:	jamie
Sponsored by:	The FreeBSD Foundation
Sponsored by:	iXsystems
MFC after:	10 days
2011-05-29 21:03:40 +00:00
Benedict Reuschling
0f3f5331e4 Revert r221655:
Various people voiced their concerns about these changes.
Until this is resolved, we should use the old version.
2011-05-08 14:57:01 +00:00
Benedict Reuschling
7dc2d68994 Jails have a problem in that if the jail directory is world-readable,
an attacker with root access to the jail can create a setuid binary for
their own use in the host environment (if they also have this access),
thus breaking root in the host.

This exploit is impossible if the jail's files are not world-readable.
Add instructions to the man page on how to create a jail with the
correct permissions set.

PR:		docs/156853
Submitted by:	Chris Rees (utisoft at gmail dot com)
Reviewed by:	cperciva (security parts)
MFC after:	9 days
2011-05-08 12:16:39 +00:00
Jamie Gritton
aa02af5404 run_command (mostly) cleanup:
Make the parallelism limit a global instead of always passing it
 to run_command and finish_command.
In the case of an empty command string, try to run any other strings
 the command may have.
Replace JF_BACKGROUND with its sort-of opposite JF_SLEEPQ.
Change j->comstring earlier to render JF_RUNQ unncessary.
Change the if-else series to a more readable switch statement.
Treat IP_STOP_TIMEOUT like a command, calling run_command which then
 calls term_procs.
When the IP_STOP_TIMEOUT "command" finishes, it shouldn't mess with
 the parallelism limit.
Make sufficient checks in finish_command and run_command so that
 the nonintuitive j->comstring null check isn't necessary to run them.
Rename the "waiting" queue to "depend", because the "sleeping" and
 "runnable" queues are also used to wait for something.
2010-12-10 23:57:55 +00:00
Jamie Gritton
5264032f22 Check unmounts for a mount point of the right FS type. 2010-11-04 19:32:32 +00:00
Jamie Gritton
8ebbf0e287 Check paths for security:
path must be absolute.
 mount paths must exist and have no symlinks beyond the jail's path itself.
 consolelog must exist (apart from the final component) and have no
  symlinks beyond the jail's path itself.
2010-11-04 18:40:29 +00:00
Jamie Gritton
52a4962202 Reads the mount.fstab file, and put its lines separately into the
IP__MOUNT_FROM_FSTAB internal parameter.
2010-11-04 17:01:21 +00:00
Jamie Gritton
e3c69673a6 Combine check_intparams() and ip_params(), JF_CHECKINT and JF_IPPARAMS. 2010-11-01 21:37:28 +00:00
Jamie Gritton
47fdec177a Use a little more "ifdef INET6". 2010-10-27 20:25:55 +00:00
Jamie Gritton
50f0104e67 Don't assume either jid or name is set - they may not be from the
command line.
2010-10-27 16:35:23 +00:00
Jamie Gritton
5553043801 Keep all internal/known parameter names in one place, and use
enum constants everywhere else.
2010-10-27 16:22:54 +00:00
Jamie Gritton
2671ee736f Initial work on the new jail(8). There are more features to add, and some
cleaning up to do on existing features, but this is pretty much what the
final product will look like.
2010-10-20 20:42:33 +00:00
Ulrich Spörlein
0d9deed52c mdoc: drop redundant .Pp and .LP calls
They have no effect when coming in pairs, or before .Bl/.Bd
2010-10-08 12:40:16 +00:00
Jamie Gritton
743149d2ab Back out r210975, which changed documentation to match the now backed-out
r210974.
2010-08-08 23:24:23 +00:00
Jamie Gritton
10310d6706 Note that a jail without a command parameter will be persistent,
instead of explicitly requiring one of "command" or "persist".

MFC after:	3 days
2010-08-06 22:06:12 +00:00
Joel Dahl
d4352d2928 Spelling fixes. 2010-08-01 09:37:36 +00:00
Colin Percival
8fd6c56d29 Change the current working directory to be inside the jail created by
the jail(8) command. [10:04]

Fix a one-NUL-byte buffer overflow in libopie. [10:05]

Correctly sanity-check a buffer length in nfs mount. [10:06]

Approved by:	so (cperciva)
Approved by:	re (kensmith)
Security:	FreeBSD-SA-10:04.jail
Security:	FreeBSD-SA-10:05.opie
Security:	FreeBSD-SA-10:06.nfsclient
2010-05-27 03:15:04 +00:00
Ulrich Spörlein
62486687ed mdoc: consistently spell our email addresses <foo@FreeBSD.org>
Reviewed by:	ru
2010-05-19 08:57:53 +00:00
Daniel Gerzo
35939b04d3 - fix typo 2010-05-05 08:43:47 +00:00
Xin LI
90bb63899b Make 'make manlint' happy. No actual visible change. 2010-03-03 23:11:14 +00:00
Bjoern A. Zeeb
592bcae802 Add ip4.saddrsel/ip4.nosaddrsel (and equivalent for ip6) to control
whether to use source address selection (default) or the primary
jail address for unbound outgoing connections.

This is intended to be used by people upgrading from single-IP
jails to multi-IP jails but not having to change firewall rules,
application ACLs, ... but to force their connections (unless
otherwise changed) to the primry jail IP they had been used for
years, as well as for people prefering to implement similar policies.

Note that for IPv6, if configured incorrectly, this might lead to
scope violations, which single-IPv6 jails could as well, as by the
design of jails. [1]

Reviewed by:	jamie, hrs (ipv6 part)
Pointed out by:	hrs [1]
MFC After:	2 weeks
Asked for by:	Jase Thew (bazerka beardz.net)
2010-01-17 12:57:11 +00:00
Ed Schouten
71ccf09269 The last big commit: let usr.sbin/ use WARNS=6 by default. 2010-01-02 11:07:44 +00:00
Jun Kuriyama
ce8ad96abe - New style of jail(8) usage requires "-c" argument to create a jail.
Reviewed by:	jamie
2009-11-26 03:26:59 +00:00
Ed Schouten
5fd658af94 Don't forget to increment the man page date.
Reported by:	bz
2009-10-18 20:33:24 +00:00
Ed Schouten
f19fa944e6 Fix a typo in the jail(8) manpage.
Submitted by:	Jille Timmermans <jille quis cx>
MFC after:	1 week
2009-10-18 19:50:15 +00:00
Jamie Gritton
843c277bfa Handle kernels that don't have IPv6 by not sending an "ip6.addr"
parameter unless a (numeric) IPv6 address is given.  Even the default
binaries built with -DINET6 will work with IPv6-less kernels.  With an
eye to the future, similarly handle the possibility of an IPv4-less kernel.

Approved by:	re (kib), bz (mentor)
2009-07-31 14:30:06 +00:00
Jamie Gritton
7cbf72137f Some jail parameters (in particular, "ip4" and "ip6" for IP address
restrictions) were found to be inadequately described by a boolean.
Define a new parameter type with three values (disable, new, inherit)
to handle these and future cases.

Approved by:	re (kib), bz (mentor)
Discussed with:	rwatson
2009-07-25 14:48:57 +00:00
Jamie Gritton
f9bc4dcb56 Fix a typo in the examples.
Approved by:	re (kib), bz (mentor)
2009-07-08 15:46:29 +00:00
Jamie Gritton
de6f37045c Add libjail, a (somewhat) simpler interface to the jail_set and jail_get
system calls and the security.jail.param sysctls.

Approved by:	bz (mentor)
2009-06-24 18:18:35 +00:00
Jamie Gritton
b97457e2e6 Add a limit for child jails via the "children.cur" and "children.max"
parameters.  This replaces the simple "allow.jails" permission.

Approved by:	bz (mentor)
2009-06-23 20:35:51 +00:00
Jamie Gritton
ded788478f Remove obsolete comment describing how the command line is
no longer parsed.

Approved by:	bz (mentor)
2009-06-23 14:39:51 +00:00
Brooks Davis
54404cfb13 In preparation for raising NGROUPS and NGROUPS_MAX, change base
system callers of getgroups(), getgrouplist(), and setgroups() to
allocate buffers dynamically.  Specifically, allocate a buffer of size
sysconf(_SC_NGROUPS_MAX)+1 (+2 in a few cases to allow for overflow).

This (or similar gymnastics) is required for the code to actually follow
the POSIX.1-2008 specification where {NGROUPS_MAX} may differ at runtime
and where getgroups may return {NGROUPS_MAX}+1 results on systems like
FreeBSD which include the primary group.

In id(1), don't pointlessly add the primary group to the list of all
groups, it is always the first result from getgroups().  In principle
the old code was more portable, but this was only done in one of the two
places where getgroups() was called to the overall effect was pointless.

Document the actual POSIX requirements in the getgroups(2) and
setgroups(2) manpages.  We do not yet support a dynamic NGROUPS, but we
may in the future.

MFC after:	2 weeks
2009-06-19 15:58:24 +00:00
Jamie Gritton
029cb9c79d In the old-style jail command line, explicitly set parameters from the
security.jail.* sysctls since jail_set(2) doesn't do it implicitly.

Approved by:	bz (mentor)
2009-06-10 15:26:35 +00:00
Joseph Koshy
0fe7ed0085 Fix grammar.
Submitted by:	richardtoohey at paradise dot net dot nz on -doc
2009-06-08 03:37:25 +00:00
Jamie Gritton
76ca6f88da Place hostnames and similar information fully under the prison system.
The system hostname is now stored in prison0, and the global variable
"hostname" has been removed, as has the hostname_mtx mutex.  Jails may
have their own host information, or they may inherit it from the
parent/system.  The proper way to read the hostname is via
getcredhostname(), which will copy either the hostname associated with
the passed cred, or the system hostname if you pass NULL.  The system
hostname can still be accessed directly (and without locking) at
prison0.pr_host, but that should be avoided where possible.

The "similar information" referred to is domainname, hostid, and
hostuuid, which have also become prison parameters and had their
associated global variables removed.

Approved by:	bz (mentor)
2009-05-29 21:27:12 +00:00
Jamie Gritton
88812d9e1d Fix some inaccuracies in the extensible parameter addition.
Approved by:	bz (mentor)
2009-05-29 21:17:22 +00:00
Jamie Gritton
73d0971bf2 Add support for the arbitrary named jail parameters used by jail_set(2)
and jail_get(2).  Jail(8) can now create jails using a "name=value"
format instead of just specifying a limited set of fixed parameters; it
can also modify parameters of existing jails.  Jls(8) can display all
parameters of jails, or a specified set of parameters.  The available
parameters are gathered from the kernel, and not hard-coded into these
programs.

Small patches on killall(1) and jexec(8) to support jail names with
jail_get(2).

Approved by:	bz (mentor)
2009-05-27 14:30:26 +00:00
Jamie Gritton
7074cfa223 With the permission of phk@ change the license on remaining jail code
to a 2 clause BSD license.

Approved by:	phk
Approved by:	bz (mentor)
2009-04-29 16:02:52 +00:00
Bjoern A. Zeeb
6e2dc05379 New sentence starts on a new line.
MFC after:	2 week
2009-01-24 15:56:44 +00:00
Bjoern A. Zeeb
2737772d1c Update the description of the '-h' option wrt to primary addresses
per address family and add a reference to the ip-addresses option.

MFC after:	1 week
2009-01-24 15:53:37 +00:00
Bjoern A. Zeeb
12aec2f21a s,unmount 8,umount 8, it is unmount(2) which I did not mean.
Submitted by:	pluknet@gmail.com
MFC after:	1 week
2009-01-17 14:52:26 +00:00
Maxim Konovalov
d65e5ff8d1 o Sort .Xr. 2009-01-12 07:45:03 +00:00
Bjoern A. Zeeb
0bd0dfaad0 Add a short section talking about jails and file systems; mention the
mountand jail-aware file systems as well as quota.

PR:		kern/68192
Reviewed by:	simon
MFC after:	2 weeks
2009-01-11 18:40:56 +00:00
Bjoern A. Zeeb
413628a7e3 MFp4:
Bring in updated jail support from bz_jail branch.

This enhances the current jail implementation to permit multiple
addresses per jail. In addtion to IPv4, IPv6 is supported as well.
Due to updated checks it is even possible to have jails without
an IP address at all, which basically gives one a chroot with
restricted process view, no networking,..

SCTP support was updated and supports IPv6 in jails as well.

Cpuset support permits jails to be bound to specific processor
sets after creation.

Jails can have an unrestricted (no duplicate protection, etc.) name
in addition to the hostname. The jail name cannot be changed from
within a jail and is considered to be used for management purposes
or as audit-token in the future.

DDB 'show jails' command was added to aid debugging.

Proper compat support permits 32bit jail binaries to be used on 64bit
systems to manage jails. Also backward compatibility was preserved where
possible: for jail v1 syscalls, as well as with user space management
utilities.

Both jail as well as prison version were updated for the new features.
A gap was intentionally left as the intermediate versions had been
used by various patches floating around the last years.

Bump __FreeBSD_version for the afore mentioned and in kernel changes.

Special thanks to:
- Pawel Jakub Dawidek (pjd) for his multi-IPv4 patches
  and Olivier Houchard (cognet) for initial single-IPv6 patches.
- Jeff Roberson (jeff) and Randall Stewart (rrs) for their
  help, ideas and review on cpuset and SCTP support.
- Robert Watson (rwatson) for lots and lots of help, discussions,
  suggestions and review of most of the patch at various stages.
- John Baldwin (jhb) for his help.
- Simon L. Nielsen (simon) as early adopter testing changes
  on cluster machines as well as all the testers and people
  who provided feedback the last months on freebsd-jail and
  other channels.
- My employer, CK Software GmbH, for the support so I could work on this.

Reviewed by:	(see above)
MFC after:	3 months (this is just so that I get the mail)
X-MFC Before:   7.2-RELEASE if possible
2008-11-29 14:32:14 +00:00
Pawel Jakub Dawidek
4e9f341722 Bump date. 2007-04-05 21:17:52 +00:00
Pawel Jakub Dawidek
f3a8d2f93c Add security.jail.mount_allowed sysctl, which allows to mount and
unmount jail-friendly file systems from within a jail.
Precisely it grants PRIV_VFS_MOUNT, PRIV_VFS_UNMOUNT and
PRIV_VFS_MOUNT_NONUSER privileges for a jailed super-user.
It is turned off by default.

A jail-friendly file system is a file system which driver registers
itself with VFCF_JAIL flag via VFS_SET(9) API.
The lsvfs(1) command can be used to see which file systems are
jail-friendly ones.

There currently no jail-friendly file systems, ZFS will be the first one.
In the future we may consider marking file systems like nullfs as
jail-friendly.

Reviewed by:	rwatson
2007-04-05 21:03:05 +00:00
Craig Rodrigues
91f9dc8492 Change mount_devfs reference to "mount -t devfs".
Reminded by:	ru
2006-11-21 23:45:44 +00:00
Ruslan Ermilov
bc84aa4ba3 Markup fixes. 2006-09-29 17:57:04 +00:00
Bjoern A. Zeeb
f855cc4f36 Use IP addresses out of "TEST-NET" (for use in documentation and
example code) [RFC3330].

Reviewed by: simon
2006-06-11 12:57:41 +00:00
Simon L. B. Nielsen
0f9fc191de Revert 1.73, since mounting devfs without a devfs ruleset inside a
jail is a very bad idea security wise.

Approved by:	trhodes (jcamou mentor)
No response:	jcamou
2006-05-28 09:44:13 +00:00
Matteo Riondato
fdf1353cec Mention ruleset #4 (devfsrules_jail) in jail's man page.
MFC after:	3
2006-05-28 08:29:49 +00:00
Matteo Riondato
b484e04bf9 correct strtol(3) usage and style(9)
Reviewed by:	maxim
MFC after:	2 weeks
2006-05-12 15:14:43 +00:00
Maxim Konovalov
6dc044b45b o Style(9) the previous commit a bit. 2006-05-11 19:06:33 +00:00
Matteo Riondato
7deb00ccd9 Add the -s option to set jail's securelevel. This is useful for jails run with non-root privileges.
PR:	bin/80242
MFC after:	2 weeks
2006-05-11 13:04:23 +00:00
Matteo Riondato
feefdb0ceb Use .Vt for struct xprison
Suggested by: keramida
2006-05-10 14:26:53 +00:00
Matteo Riondato
f7bb71361e document security.jail.list sysctl in jail(8)
PR:	docs/96807
MFC after:	3
2006-05-08 19:55:17 +00:00
Maxim Konovalov
17d10fccac o Document security.jail.jailed sysctl.
PR:		docs/94711
Submitted by:	Andreas Kohn
MFC after:	2 weeks
2006-05-03 20:13:33 +00:00
Maxim Konovalov
2edf0a4432 o Do not mangle current session user login name with jail -u|-U.
PR:		bin/94730
Submitted by:	Frank Behrens
MFC after:	1 month
2006-04-16 12:32:04 +00:00
Jesus R. Camou
888a664b2d Do `mount_devfs' when starting a jail.
PR:		docs/86044
Noticed by:	Dan Langille <dan@langille.org>
Reviewed by:	Jose Biskofski <jbiskofski@grmims.com>
Approved by:	trhodes (mentor)
2006-03-16 14:31:35 +00:00
Philip Paeps
cdafc85119 Add [-J jid_file] option to write out a JidFile, similar to a PidFile,
containing the jailid, path, hostname, ip and the command used to start
the jail.

PR:		misc/89883
Submitted by:	L. Jason Godsey <lannygodsey -at- yahoo.com>
Reviewed by:	phk
MFC after:	1 week
2005-12-03 17:32:39 +00:00
Giorgos Keramidas
fd891a579d Note that the jail setup example is meant to be fed to sh(1), not csh(1).
PR:		docs/87351
Submitted by:	"Eli K. Breen" <bsd@unixforge.net>
Approved by:	simon, brooks
MFC after:	3 days
2005-10-26 20:19:39 +00:00
Christian Brueffer
23fe4fa258 Add some more info about jail startup and shutdown.
Submitted by:	Jeremie Le Hen <jeremie@le-hen.org>
MFC after:	3 days
2005-08-07 20:53:29 +00:00
Tilman Keskinoz
11af798cf0 Move DNS configuration before sendmail configuration, because
newaliases(1) may hang without proper DNS configuration.

Approved by:	brueffer
2005-07-25 16:04:30 +00:00
Jesus R. Camou
c815850173 Mention that it is possible to have jails
started at boot time if specified in
/etc/rc.conf.

PR:		docs/81040
Submitted by:	matteo
Approved by:	trhodes (mentor)
MFC after:	1 week
2005-07-20 00:32:01 +00:00
Ruslan Ermilov
9d73fabda7 Markup fixes.
Approved by:	re (blanket)
2005-06-14 12:26:36 +00:00
Pawel Jakub Dawidek
98b60f9da3 Update manual page after sysctl rename.
Corrected by:	brueffer
2005-06-09 20:52:22 +00:00
Pawel Jakub Dawidek
2856a282ee Document 'jid' keyword for ps(1) and '-j' option for pgrep(1)/pkill(1). 2005-05-28 16:23:29 +00:00
Pawel Jakub Dawidek
870739f5e6 Remove symblic link kernel->dev/null creation. We don't need it in 5.x/6.x
world (there is no /kernel file anymore).

Reminded by:	Isaac Levy presentation
2005-05-14 18:54:58 +00:00
Joel Dahl
214b17c261 Fix spelling errors.
Approved by:	brueffer (mentor)
2005-04-30 09:26:22 +00:00
Ruslan Ermilov
9bdd3e8497 Added the convenience "distribution" target which calls the
target of the same name from src/etc/Makefile with a proper
environment, suitable to be used during upgrades and cross-
builds.
2005-02-27 12:11:35 +00:00
Colin Percival
79653046d8 Add a new sysctl, "security.jail.chflags_allowed", which controls the
behaviour of chflags within a jail.  If set to 0 (the default), then a
jailed root user is treated as an unprivileged user; if set to 1, then
a jailed root user is treated the same as an unjailed root user.

This is necessary to allow "make installworld" to work inside a jail,
since it attempts to manipulate the system immutable flag on certain
files.

Discussed with:	csjp, rwatson
MFC after:	2 weeks
2005-02-08 21:31:11 +00:00
Ruslan Ermilov
ead5223f54 Fixed punctuation in xrefs. 2005-01-21 20:48:00 +00:00
Ruslan Ermilov
1a74e6a157 Scheduled mdoc(7) sweep. 2005-01-11 11:47:22 +00:00
Xin LI
d1df3fcd3f Initialize lcap and pwd to NULL. This allows a WARNS=6 clean build,
hence bump it to 6.

Note that the last commit message was not quite accurate.  While the
assumption exists in the code, it's not possible to have an
uninitialized p there because if lflag is set when username is NULL
then execution would be terminated earlier.
2004-11-17 10:01:48 +00:00
Xin LI
95751846f1 The code path in main() dealing with lflag assumes that p was
initialized with NULL, while it is not.  So let's initialize
it.
2004-11-17 09:52:10 +00:00
Stefan Farfeleder
950cc39559 Pass an array of gid_t rather than an array of int to getgroups().
PR:	56646
2004-10-02 11:40:48 +00:00
Maxim Konovalov
5b242e8c08 o Add -l option to jail(8) similar to su(1): before running jail'ed
program under specific user's credentials, clean the environment and
set only a few variables.

PR:		bin/70024
Submitted by:	demon
MFC after:	1 month
2004-08-15 08:21:50 +00:00
Ruslan Ermilov
07bfccd71e Mechanically kill hard sentence breaks. 2004-07-02 23:13:00 +00:00
Pawel Jakub Dawidek
232a681888 Prepare jail(8) utility for new functionality which will limit
seeing status of mounted file system for jailed processes.
Pass full path of jail's root directory to the kernel. mount(8) utility is
doing the same thing already.
2004-06-27 10:10:16 +00:00
Ruslan Ermilov
eba9a3d1e3 Markup nits. 2004-06-05 20:27:10 +00:00
Christian S.J. Peron
44f79297b3 Sentences should not start with conjunctions. Change "Because"
to "Since".

Pointed out by:	Ceri
2004-06-01 20:32:44 +00:00
Christian S.J. Peron
8bac4dbf71 Add a warning note to security.jail.allow_raw_sockets
about the risks of enabling raw sockets in prisons.

Because raw sockets can be used to configure and interact
with various network subsystems, extra caution should be
used where privileged access to jails is given out to
untrusted parties. As such, by default this option is disabled.

A few others and I are currently auditing the kernel
source code to ensure that the use of raw sockets by
privledged prison users is safe.

Approved by:	bmilekic (mentor)
2004-06-01 00:25:44 +00:00
Maxim Konovalov
927b481001 o Implement -U flag: run command as user which exists only in jail.
o getpwnam(3) returns NULL and does not set errno when the user does
  not exist.  Bail out with "no such user" instead of "Unknown error: 0".

PR:		bin/67262
Submitted by:	demon (-U flag)
MFC after:	3 weeks
2004-05-29 18:39:27 +00:00
Daniel Harris
3e580b38ba Typos and nits. 2004-05-20 06:37:44 +00:00
Pawel Jakub Dawidek
147110cb2d Document security.jail.getfsstatroot_only sysctl.
Obtained from:	rwatson's commit log
Approved by:	rwatson
2004-05-20 05:30:16 +00:00
Simon L. B. Nielsen
b2206719c5 mdoc(7) cleanup for the last commit to this file.
OK'ed by:	bmilekic
2004-05-04 14:39:32 +00:00
Bosko Milekic
5fb5184a47 Ammend jail(8) man page to explain new sysctl for raw-sockets
inside jails, Christian's last submission.

Submitted by: Christian S.J. Peron <maneo@bsdpro.com>
2004-05-03 21:12:23 +00:00
Lukas Ertl
82d4902dc0 Correct typo. 2004-02-06 21:05:42 +00:00
Robert Watson
a5ca5c1a75 A variety of content cleanups:
(1) Document the notion of using jail(8) to run "virtual servers" or
    just to constrain specific applications.  If only running specific
    applications, some configuration steps are unnecessary (such as
    editing rc.conf).

(2) Add some more subsection headers to break up the bigger chunks of
    text.

(3) Clarify the problems associated with applications binding all IP
    addresses in the host, and attempt to be more specific about
    potential application problems.  Document how to force sshd to
    bind the the right socket.

(4) Suggest that in a jailed application scenario, you might want to
    have the host syslogd listen on the socket in the jail, rather
    than running syslogd in the jail.

(5) Catch another reference to /stand/sysinstall.

Approved by:	re (bmah implicitly)
2003-11-20 03:47:50 +00:00
Robert Watson
9395ecb1cf No need to copy sysinstall into a jail with -CURRENT, since in
-CURRENT, we have /usr/sbin/sysinstall.

Approved by:	re (bmah implicitly)
2003-11-20 02:46:44 +00:00
Ken Smith
d1b10a6289 - Add a note that there are two MIB variables that have per-jail
settings.

Reviewed by:	rwatson
Approved by:	blackend (mentor)
2003-11-11 18:34:29 +00:00
Philippe Charnier
54ede02d10 add FBSDID 2003-07-06 12:44:11 +00:00
Robert Watson
d82dae3ec9 When pointing users at mount_devfs to populate the /dev of a jail,
tell them that they also need to use devfs rules to prevent
inappropriate devices from appearing in the jail; add an Xref.  In
earlier versions of this man page, the user was instructed to use
sh MAKEDEV jail, which only created a minimal set of device nodes.
2003-06-26 19:04:15 +00:00
Mike Barcroft
25639ca722 Force output of jail ID (if necessary) before excuting the command,
otherwise redirection of stdout to a file using block buffering will
not complete in time.
2003-04-21 17:20:48 +00:00
Mike Barcroft
ebf5d9bc2c o Add jls(8) for listing active jails.
o Add jexec(8) to execute a command in an existing jail.
o Add -j option for killall(1) to kill all processes in a specified
  jail.
o Add -i option to jail(8) to output jail ID of newly created jail.
2003-04-09 03:04:12 +00:00
Maxim Konovalov
0389572f96 Free login_cap(3) resources after usage.
Submitted by:	demon
2003-04-07 10:16:37 +00:00
Maxim Konovalov
b026ec0eb8 o Fix error messages formatting, style.
Prodded by:	bde
Reviewed by:	bde
2003-04-02 09:20:08 +00:00
Maxim Konovalov
d6131f4b8e o Add -u <username> flag to jail(8): set user context before exec.
PR:		bin/44320
Submitted by:	Mike Matsnev <mike@po.cs.msu.su>
Reviewed by:	-current
MFC after:	6 weeks
2003-03-27 12:16:58 +00:00
Maxim Konovalov
3b8a7d4f4f portmap_enable -> rpcbind_enable.
Spotted by:	Andrew Khlebutin <andreyh@perm.ru>
2003-03-18 14:01:02 +00:00
Giorgos Keramidas
35adbc4d5c Remove traces of MAKEDEV & add xref to mount_devfs(8).
DEVFS is now mandatory in CURRENT.

PR:		docs/48095
Submitted by:	Grzegorz Czaplinski <G.Czaplinski@prioris.mini.pw.edu.pl>
2003-02-28 22:47:18 +00:00
Poul-Henning Kamp
c0dc344665 Fix example, we do not need NO_MAKEDEV_RUN any more.
XXX: this example should be updated with a good example of devfs(8) rules.
2002-10-22 15:03:51 +00:00
Philippe Charnier
490d5836b5 The .Nm utility 2002-07-14 14:47:15 +00:00
Dima Dorfman
a0cfa93972 Fix IP address typo.
PR:		38313
Submitted by:	Jeff Ito <jeffi@rcn.com>
2002-05-20 07:29:25 +00:00
Dag-Erling Smørgrav
d397408818 Usage style sweep: spell "usage" with a small 'u'.
Also change one case of blatant __progname abuse (several more remain)
This commit does not touch anything in src/{contrib,crypto,gnu}/.
2002-04-22 13:44:47 +00:00
Andrew R. Reiter
d0615c64a5 - Attempt to help declutter kern. sysctl by moving security out from
beneath it.

Reviewed by: rwatson
2002-01-16 06:55:30 +00:00
Ruslan Ermilov
fe9a332ddf mdoc(7) police: ispell rev. 1.32. 2002-01-10 15:15:44 +00:00
Ruslan Ermilov
3551a1c577 mdoc(7) police: tidy up previous delta. 2002-01-10 15:14:22 +00:00
Poul-Henning Kamp
c579474cea Add some wisdom to the jail setup instructions. 2001-12-14 20:20:50 +00:00
Ruslan Ermilov
1a6ec3e8a3 mdoc(7) police overhaul. 2001-12-14 10:18:15 +00:00
Andrew R. Reiter
94b3b598b9 - Update the sysctl mibs in order to reflect the recent kern_jail.c
changes.

Approved by:	rwatson
Reviewed by:	rwatson
2001-12-12 05:24:50 +00:00
Dima Dorfman
979d474a6d syslogd can now be configured to bind to a specific address. 2001-09-03 15:42:10 +00:00
Dima Dorfman
4b526751b5 This is not jail(2), or anything else suitable to be referenced with .Fn. 2001-08-27 12:15:44 +00:00
David E. O'Brien
90e655ea4e Perform a major cleanup of the usr.sbin Makefiles.
These are not perfectly in agreement with each other style-wise, but they
are orders of orders of magnitude more consistent style-wise than before.
2001-07-20 06:20:32 +00:00
Dima Dorfman
f247324df7 Remove whitespace at EOL. 2001-07-15 08:06:20 +00:00
Ruslan Ermilov
a4c37c816b mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 15:12:08 +00:00
Ruslan Ermilov
e287e9b188 mdoc(7) police: sort xrefs. 2001-07-05 08:13:03 +00:00
Dima Dorfman
f6751868e4 Set WARNS=2 on programs that compile cleanly with it; add $FreeBSD$
where necessary.

Submitted by:	Mike Barcroft <mike@q9media.com>
2001-06-30 05:39:36 +00:00
Dima Dorfman
3876038a6f Add missing includes and sort includes. 2001-06-24 20:28:19 +00:00
Dima Dorfman
2694efd413 Include missing header files which define functions for which gcc has
builtints (e.g., exit, strcmp).
2001-06-24 20:25:23 +00:00
Maxim Sobolev
8657581bfd Correct cross-reference:
portmap.8 --> rpcbind.8

Submitted by:	.Xr testing script
2001-06-07 16:59:19 +00:00
Jeroen Ruigrok van der Werven
723f7e3025 Change NO_MAKEDEV to a finer granularity method:
NO_MAKEDEV_INSTALL and NO_MAKEDEV_RUN.  The former implying the latter.
The names imply what they do.  The last commit by DES based on a PR defeated
the original idea behind NO_MAKEDEV, which was not to run MAKEDEV, but to do
the installation of MAKEDEV.  This should satisfy both parties on the MAKEDEV
challenge.
Reflect this in the documentation.
2001-03-29 14:03:29 +00:00
Ruslan Ermilov
345e52e742 - Backout botched attempt to introduce MANSECT feature.
- MAN[1-9] -> MAN.
2001-03-26 14:42:20 +00:00
Ruslan Ermilov
c73e22c3d4 Set the default manual section for usr.sbin/ to 8. 2001-03-20 18:17:26 +00:00
Robert Watson
9a67c2cd11 o Replace part-wise instructions for building world for jail(8) with
a simple make world; while this does a bit more work, it means that
  jail(8) doesn't have to be kept in sync with /usr/src/Makefile{,.inc1}
  which is a moving target.  MFC candidate.

Submitted by:	FUJISHIMA Satsuki <sf@FreeBSD.org>
Reviewed by:	phk
Also pointed out by:	Phil Kernick <Phil@Kernick.org>
2001-03-11 20:37:11 +00:00
Ruslan Ermilov
610a5778c5 mdoc(7) police: split punctuation characters + misc fixes. 2001-02-01 16:44:04 +00:00
Ruslan Ermilov
ed40311694 mdoc(7) police: removed history info from the .Os FreeBSD call. 2000-12-14 11:52:05 +00:00
Ruslan Ermilov
e97407b4f2 mdoc(7) police: use the new features of the Nm macro. 2000-11-20 20:10:44 +00:00
Ruslan Ermilov
b5c508fba3 Use Fx macro wherever possible. 2000-11-14 11:20:58 +00:00
Sheldon Hearn
12d1ad83de Whitespace only: Correct poor line-breaking introduced in rev 1.17,
which was limited to correcting mark-up.
2000-11-01 07:51:14 +00:00
Sheldon Hearn
88a2f8f5e9 Correct mark-up used in rev 1.16, as discussed with its contributor:
* Use a sub-section (Ss) instead of a section (Sh) for
  "Sysctl MIB Entries".

* Use a tagged list (Bl, El and It) instead of sub-sections (Ss) for
  the actual MIB entries.

* Mark paths up as such (Pa).

* Mark defined values up as such (Dv).
2000-11-01 07:49:29 +00:00
Robert Watson
98965adac8 o Document various sysctl's available for managing services available
within jail()
2000-10-31 01:47:59 +00:00
Daniel Harris
00f1e9626b Typo: "is unreliably by default" to "is unreliable by default".
PR:		19411
Submitted by:	Benno Rice <benno@netizen.com.au>
2000-07-08 14:12:34 +00:00
Mike Pritchard
69bd852dd0 Some minor mdoc style and spelling fixes. 2000-03-24 02:05:54 +00:00
Sheldon Hearn
f2e366a105 Remove single-space hard sentence breaks. These degrade the quality
of the typeset output, tend to make diffs harder to read and provide
bad examples for new-comers to mdoc.
2000-03-01 14:09:25 +00:00
Robert Watson
d98722bcb9 - As jail(8) has been almost completely rewritten, prepend another copyright/
BSD-style license, as an add-on to phk's beerware license.  Please fedex
  some beer to phk.

- Add a ``make depend'' line to the jail-building, which fixes openssl,
  among other things.  Suggested by: kris

- Add ``newaliases'' to the list of things to do when setting up a new
  jail, so that the jailed sendmail doesn't complain.

- Correct references to ``kern.jail.set_hostname_allowed'' which now read
  ``jail.set_hostname_allowed''.

- Add a reference to sysctl.conf where the sysctl can easily be set in
  a persistent way.

- Add a list of cross references to the man page.

- Fix a formatting nit or two.
2000-02-20 02:51:11 +00:00
Robert Watson
c2edcb1a5c Fix up a few documentation nits in jail(8), as well as improve the
instructions so as to reduce warnings during jail startup, etc.
Add a somewhat bolder warning recommending the use of
kern.jail.set_hostname to limit jail renamining.
2000-02-18 19:02:22 +00:00
Robert Watson
09aa405f34 Modified jail.8 to correct a typo (inetd_flas vs. inetd_flags), and add
a comment to the effect that I'm responsible for the additional
documentation, et al, so that phk gets fewer messages about my errors.
2000-02-16 23:50:43 +00:00
Chris Costello
05181f633f Add Robert Watson's much extended documentation including that of the
kern.jail.set_hostname_allowed sysctl MIB.

Submitted by:	rwatson
2000-02-13 05:15:29 +00:00
Robert Watson
34d226d7ff Clean up the jail(8) documentation so that it suggests building a jail
userland in a safer way.  Using the NO_MAKEDEV argument in make
distribution prevents the creation of a number of unsafe device nodes
in the jailed /dev, including disk devices, and more.  This depends
on an earlier commit to /etc/Makefile to provide the NO_MAKEDEV
support.

Approved by:	jkh
2000-02-09 04:17:41 +00:00
Jeroen Ruigrok van der Werven
5e4614fe95 Properly manify this manpage. 1999-12-21 11:25:10 +00:00
Poul-Henning Kamp
ad1720d30c A procfs mount is no longer needed for a jail. 1999-12-05 09:28:59 +00:00
Poul-Henning Kamp
7248ef86e0 Add a version number field to the jail(2) argument so that future changes
can be handled intelligently.

WARNING:  you will need to reinstall #includes and recompile jail(8).
1999-09-19 08:36:37 +00:00
Peter Wemm
97d92980a9 $Id$ -> $FreeBSD$ 1999-08-28 01:35:59 +00:00
Poul-Henning Kamp
df99b42329 Add example of how to create a jail. 1999-07-09 21:35:50 +00:00
Poul-Henning Kamp
c020621f03 Various cosmetics.
Submitted by:	Rudolf Cejka <cejkar@dcse.fee.vutbr.cz>
Reviewed by:	phk
1999-05-05 19:23:45 +00:00
Poul-Henning Kamp
ce5c1cd1ff Fix various bogons.
Submitted by:	Rudolf Cejka <cejkar@dcse.fee.vutbr.cz>
Reviewed by:	phk
1999-05-04 18:20:53 +00:00
Poul-Henning Kamp
75c1354190 This Implements the mumbled about "Jail" feature.
This is a seriously beefed up chroot kind of thing.  The process
is jailed along the same lines as a chroot does it, but with
additional tough restrictions imposed on what the superuser can do.

For all I know, it is safe to hand over the root bit inside a
prison to the customer living in that prison, this is what
it was developed for in fact:  "real virtual servers".

Each prison has an ip number associated with it, which all IP
communications will be coerced to use and each prison has its own
hostname.

Needless to say, you need more RAM this way, but the advantage is
that each customer can run their own particular version of apache
and not stomp on the toes of their neighbors.

It generally does what one would expect, but setting up a jail
still takes a little knowledge.

A few notes:

   I have no scripts for setting up a jail, don't ask me for them.

   The IP number should be an alias on one of the interfaces.

   mount a /proc in each jail, it will make ps more useable.

   /proc/<pid>/status tells the hostname of the prison for
   jailed processes.

   Quotas are only sensible if you have a mountpoint per prison.

   There are no privisions for stopping resource-hogging.

   Some "#ifdef INET" and similar may be missing (send patches!)

If somebody wants to take it from here and develop it into
more of a "virtual machine" they should be most welcome!

Tools, comments, patches & documentation most welcome.

Have fun...

Sponsored by:   http://www.rndassociates.com/
Run for almost a year by:       http://www.servetheweb.com/
1999-04-28 11:38:52 +00:00