Commit Graph

124 Commits

Author SHA1 Message Date
Bjoern A. Zeeb
3bcceea40e MFC r202468:
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]
2010-01-23 16:40:35 +00:00
Ed Schouten
f36e7051c7 MFC various commits back to stable/8:
SVN r197174:
  Make sure we never place the cursor outside the screen.

  For some vague reason, it may be possible that scp->cursor_pos exceeds
  scp->ysize * scp->xsize. This means that teken_set_cursor() may get
  called with an invalid position. Just ignore the old cursor position in
  this case.

  Reported by:  Paul B. Mahol <onemda gmail com>

SVN r198213:
  Make lock devices work properly.

  It turned out I did add the code to use the init state devices to set
  the termios structure when opening the device, but it seems I totally
  forgot to add the bits required to force the actual locking of flags
  through the lock state devices.

  Reported by:	ru

SVN r198215, r198217:
  Fix a typo in the jail(8) manpage.

  Submitted by: Jille Timmermans <jille quis cx>

SVN r198216:
  Fix qouting in a comment, to make it look more consistent

  Submitted by: Jille Timmermans <jille quis cx>

SVN r198223:
  Properly set the low watermarks when reducing the baud rate.

  Now that buffers are deallocated lazily, we should not use
  tty*q_getsize() to obtain the buffer size to calculate the low
  watermarks. Doing this may cause the watermark to be placed outside the
  typical buffer size.

  This caused some regressions after my previous commit to the TTY code,
  which allows pseudo-devices to resize the buffers as well.

  Reported by:  yongari, dougb
2009-11-01 10:30:30 +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