[Midnightbsd-cvs] src [10736] sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jun 9 18:07:11 EDT 2018


Revision: 10736
          http://svnweb.midnightbsd.org/src/?rev=10736
Author:   laffer1
Date:     2018-06-09 18:07:11 -0400 (Sat, 09 Jun 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/usr.sbin/jail/Makefile
    trunk/usr.sbin/jail/command.c
    trunk/usr.sbin/jail/config.c
    trunk/usr.sbin/jail/jail.8
    trunk/usr.sbin/jail/jail.c
    trunk/usr.sbin/jail/jail.conf.5
    trunk/usr.sbin/jail/jaillex.l
    trunk/usr.sbin/jail/jailp.h
    trunk/usr.sbin/jail/jailparse.y
    trunk/usr.sbin/jail/state.c

Property Changed:
----------------
    trunk/usr.sbin/jail/jail.8
    trunk/usr.sbin/jail/jail.conf.5
    trunk/usr.sbin/jail/jaillex.l
    trunk/usr.sbin/jail/jailparse.y

Modified: trunk/usr.sbin/jail/Makefile
===================================================================
--- trunk/usr.sbin/jail/Makefile	2018-06-09 22:03:08 UTC (rev 10735)
+++ trunk/usr.sbin/jail/Makefile	2018-06-09 22:07:11 UTC (rev 10736)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/usr.sbin/jail/Makefile 249657 2013-04-19 19:45:00Z ed $
 
 .include <bsd.own.mk>
 
@@ -9,6 +10,8 @@
 DPADD=	${LIBJAIL} ${LIBKVM} ${LIBUTIL} ${LIBL}
 LDADD=	-ljail -lkvm -lutil -ll
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 YFLAGS+=-v
 CFLAGS+=-I. -I${.CURDIR}
 

Modified: trunk/usr.sbin/jail/command.c
===================================================================
--- trunk/usr.sbin/jail/command.c	2018-06-09 22:03:08 UTC (rev 10735)
+++ trunk/usr.sbin/jail/command.c	2018-06-09 22:07:11 UTC (rev 10736)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 James Gritton
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/jail/command.c 302958 2016-07-17 14:15:08Z jamie $");
 
 #include <sys/types.h>
 #include <sys/event.h>
@@ -47,6 +48,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <vis.h>
 
 #include "jailp.h"
 
@@ -91,9 +93,13 @@
 	int create_failed, stopping;
 
 	if (paralimit == 0) {
-		requeue(j, &runnable);
+		if (j->flags & JF_FROM_RUNQ)
+			requeue_head(j, &runnable);
+		else
+			requeue(j, &runnable);
 		return 1;
 	}
+	j->flags &= ~JF_FROM_RUNQ;
 	create_failed = (j->flags & (JF_STOP | JF_FAILED)) == JF_FAILED;
 	stopping = (j->flags & JF_STOP) != 0;
 	comparam = *j->comparam;
@@ -106,7 +112,18 @@
 			case IP_MOUNT_DEVFS:
 				if (!bool_param(j->intparams[IP_MOUNT_DEVFS]))
 					continue;
-				/* FALLTHROUGH */
+				j->comstring = &dummystring;
+				break;
+			case IP_MOUNT_FDESCFS:
+				if (!bool_param(j->intparams[IP_MOUNT_FDESCFS]))
+					continue;
+				j->comstring = &dummystring;
+				break;
+			case IP_MOUNT_PROCFS:
+				if (!bool_param(j->intparams[IP_MOUNT_PROCFS]))
+					continue;
+				j->comstring = &dummystring;
+				break;
 			case IP__OP:
 			case IP_STOP_TIMEOUT:
 				j->comstring = &dummystring;
@@ -148,20 +165,23 @@
 int
 finish_command(struct cfjail *j)
 {
+	struct cfjail *rj;
 	int error;
 
 	if (!(j->flags & JF_SLEEPQ))
 		return 0;
 	j->flags &= ~JF_SLEEPQ;
-	if (*j->comparam == IP_STOP_TIMEOUT)
-	{
+	if (*j->comparam == IP_STOP_TIMEOUT) {
 		j->flags &= ~JF_TIMEOUT;
 		j->pstatus = 0;
 		return 0;
 	}
 	paralimit++;
-	if (!TAILQ_EMPTY(&runnable))
-		requeue(TAILQ_FIRST(&runnable), &ready);
+	if (!TAILQ_EMPTY(&runnable)) {
+		rj = TAILQ_FIRST(&runnable);
+		rj->flags |= JF_FROM_RUNQ;
+		requeue(rj, &ready);
+	}
 	error = 0;
 	if (j->flags & JF_TIMEOUT) {
 		j->flags &= ~JF_TIMEOUT;
@@ -247,7 +267,7 @@
 }
 
 /*
- * Run a single command for a jail, possible inside the jail.
+ * Run a single command for a jail, possibly inside the jail.
  */
 static int
 run_command(struct cfjail *j)
@@ -263,7 +283,7 @@
 	pid_t pid;
 	int argc, bg, clean, consfd, down, fib, i, injail, sjuser, timeout;
 #if defined(INET) || defined(INET6)
-	char *addr;
+	char *addr, *extrap, *p, *val;
 #endif
 
 	static char *cleanenv;
@@ -312,16 +332,30 @@
 	switch (comparam) {
 #ifdef INET
 	case IP__IP4_IFADDR:
-		argv = alloca(8 * sizeof(char *));
+		argc = 0;
+		val = alloca(strlen(comstring->s) + 1);
+		strcpy(val, comstring->s);
+		cs = val;
+		extrap = NULL;
+		while ((p = strchr(cs, ' ')) != NULL && strlen(p) > 1) {
+			if (extrap == NULL) {
+				*p = '\0';
+				extrap = p + 1;
+			}
+			cs = p + 1;
+			argc++;
+		}
+
+		argv = alloca((8 + argc) * sizeof(char *));
 		*(const char **)&argv[0] = _PATH_IFCONFIG;
-		if ((cs = strchr(comstring->s, '|'))) {
-			argv[1] = alloca(cs - comstring->s + 1);
-			strlcpy(argv[1], comstring->s, cs - comstring->s + 1);
+		if ((cs = strchr(val, '|'))) {
+			argv[1] = alloca(cs - val + 1);
+			strlcpy(argv[1], val, cs - val + 1);
 			addr = cs + 1;
 		} else {
 			*(const char **)&argv[1] =
 			    string_param(j->intparams[IP_INTERFACE]);
-			addr = comstring->s;
+			addr = val;
 		}
 		*(const char **)&argv[2] = "inet";
 		if (!(cs = strchr(addr, '/'))) {
@@ -339,6 +373,15 @@
 			argv[3] = addr;
 			argc = 4;
 		}
+
+		if (!down) {
+			for (cs = strtok(extrap, " "); cs; cs = strtok(NULL, " ")) {
+				size_t len = strlen(cs) + 1;
+				argv[argc] = alloca(len);
+				strlcpy(argv[argc++], cs, len);
+			}
+		}
+
 		*(const char **)&argv[argc] = down ? "-alias" : "alias";
 		argv[argc + 1] = NULL;
 		break;
@@ -346,16 +389,30 @@
 
 #ifdef INET6
 	case IP__IP6_IFADDR:
-		argv = alloca(8 * sizeof(char *));
+		argc = 0;
+		val = alloca(strlen(comstring->s) + 1);
+		strcpy(val, comstring->s);
+		cs = val;
+		extrap = NULL;
+		while ((p = strchr(cs, ' ')) != NULL && strlen(p) > 1) {
+			if (extrap == NULL) {
+				*p = '\0';
+				extrap = p + 1;
+			}
+			cs = p + 1;
+			argc++;
+		}
+
+		argv = alloca((8 + argc) * sizeof(char *));
 		*(const char **)&argv[0] = _PATH_IFCONFIG;
-		if ((cs = strchr(comstring->s, '|'))) {
-			argv[1] = alloca(cs - comstring->s + 1);
-			strlcpy(argv[1], comstring->s, cs - comstring->s + 1);
+		if ((cs = strchr(val, '|'))) {
+			argv[1] = alloca(cs - val + 1);
+			strlcpy(argv[1], val, cs - val + 1);
 			addr = cs + 1;
 		} else {
 			*(const char **)&argv[1] =
 			    string_param(j->intparams[IP_INTERFACE]);
-			addr = comstring->s;
+			addr = val;
 		}
 		*(const char **)&argv[2] = "inet6";
 		argv[3] = addr;
@@ -365,6 +422,15 @@
 			argc = 6;
 		} else
 			argc = 4;
+
+		if (!down) {
+			for (cs = strtok(extrap, " "); cs; cs = strtok(NULL, " ")) {
+				size_t len = strlen(cs) + 1;
+				argv[argc] = alloca(len);
+				strlcpy(argv[argc++], cs, len);
+			}
+		}
+
 		*(const char **)&argv[argc] = down ? "-alias" : "alias";
 		argv[argc + 1] = NULL;
 		break;	
@@ -388,8 +454,14 @@
 		strcpy(comcs, comstring->s);
 		argc = 0;
 		for (cs = strtok(comcs, " \t\f\v\r\n"); cs && argc < 4;
-		     cs = strtok(NULL, " \t\f\v\r\n"))
+		     cs = strtok(NULL, " \t\f\v\r\n")) {
+			if (argc <= 1 && strunvis(cs, cs) < 0) {
+				jail_warnx(j, "%s: %s: fstab parse error",
+				    j->intparams[comparam]->name, comstring->s);
+				return -1;
+			}
 			argv[argc++] = cs;
+		}
 		if (argc == 0)
 			return 0;
 		if (argc < 3) {
@@ -452,6 +524,58 @@
 		}
 		break;
 
+	case IP_MOUNT_FDESCFS:
+		argv = alloca(7 * sizeof(char *));
+		path = string_param(j->intparams[KP_PATH]);
+		if (path == NULL) {
+			jail_warnx(j, "mount.fdescfs: no path");
+			return -1;
+		}
+		devpath = alloca(strlen(path) + 8);
+		sprintf(devpath, "%s/dev/fd", path);
+		if (check_path(j, "mount.fdescfs", devpath, 0,
+		    down ? "fdescfs" : NULL) < 0)
+			return -1;
+		if (down) {
+			*(const char **)&argv[0] = "/sbin/umount";
+			argv[1] = devpath;
+			argv[2] = NULL;
+		} else {
+			*(const char **)&argv[0] = _PATH_MOUNT;
+			*(const char **)&argv[1] = "-t";
+			*(const char **)&argv[2] = "fdescfs";
+			*(const char **)&argv[3] = ".";
+			argv[4] = devpath;
+			argv[5] = NULL;
+		}
+		break;
+
+	case IP_MOUNT_PROCFS:
+		argv = alloca(7 * sizeof(char *));
+		path = string_param(j->intparams[KP_PATH]);
+		if (path == NULL) {
+			jail_warnx(j, "mount.procfs: no path");
+			return -1;
+		}
+		devpath = alloca(strlen(path) + 6);
+		sprintf(devpath, "%s/proc", path);
+		if (check_path(j, "mount.procfs", devpath, 0,
+		    down ? "procfs" : NULL) < 0)
+			return -1;
+		if (down) {
+			*(const char **)&argv[0] = "/sbin/umount";
+			argv[1] = devpath;
+			argv[2] = NULL;
+		} else {
+			*(const char **)&argv[0] = _PATH_MOUNT;
+			*(const char **)&argv[1] = "-t";
+			*(const char **)&argv[2] = "procfs";
+			*(const char **)&argv[3] = ".";
+			argv[4] = devpath;
+			argv[5] = NULL;
+		}
+		break;
+
 	case IP_COMMAND:
 		if (j->name != NULL)
 			goto default_command;
@@ -591,6 +715,11 @@
 			if (term != NULL)
 				setenv("TERM", term, 1);
 		}
+		if (setgid(pwd->pw_gid) < 0) {
+			jail_warnx(j, "setgid %d: %s", pwd->pw_gid,
+			    strerror(errno));
+			exit(1);
+		}
 		if (setusercontext(lcap, pwd, pwd->pw_uid, username
 		    ? LOGIN_SETALL & ~LOGIN_SETGROUP & ~LOGIN_SETLOGIN
 		    : LOGIN_SETPATH | LOGIN_SETENV) < 0) {
@@ -648,7 +777,7 @@
 	if (j->timeout.tv_sec == 0)
 		requeue(j, &sleeping);
 	else {
-		/* File the jail in the sleep queue acording to its timeout. */
+		/* File the jail in the sleep queue according to its timeout. */
 		TAILQ_REMOVE(j->queue, j, tq);
 		TAILQ_FOREACH(tj, &sleeping, tq) {
 			if (!tj->timeout.tv_sec ||
@@ -764,6 +893,7 @@
 {
 	const struct passwd *pwd;
 
+	errno = 0;
 	*pwdp = pwd = username ? getpwnam(username) : getpwuid(getuid());
 	if (pwd == NULL) {
 		if (errno)

Modified: trunk/usr.sbin/jail/config.c
===================================================================
--- trunk/usr.sbin/jail/config.c	2018-06-09 22:03:08 UTC (rev 10735)
+++ trunk/usr.sbin/jail/config.c	2018-06-09 22:07:11 UTC (rev 10736)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 James Gritton
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/jail/config.c 294484 2016-01-21 04:37:16Z jamie $");
 
 #include <sys/types.h>
 #include <sys/errno.h>
@@ -51,6 +52,7 @@
 
 extern FILE *yyin;
 extern int yynerrs;
+
 extern int yyparse(void);
 
 struct cfjails cfjails = TAILQ_HEAD_INITIALIZER(cfjails);
@@ -82,6 +84,8 @@
 #endif
     [IP_MOUNT] =		{"mount",		PF_INTERNAL | PF_REV},
     [IP_MOUNT_DEVFS] =		{"mount.devfs",		PF_INTERNAL | PF_BOOL},
+    [IP_MOUNT_FDESCFS] =	{"mount.fdescfs",	PF_INTERNAL | PF_BOOL},
+    [IP_MOUNT_PROCFS] =		{"mount.procfs",	PF_INTERNAL | PF_BOOL},
     [IP_MOUNT_FSTAB] =		{"mount.fstab",		PF_INTERNAL},
     [IP_STOP_TIMEOUT] =		{"stop.timeout",	PF_INTERNAL | PF_INT},
     [IP_VNET_INTERFACE] =	{"vnet.interface",	PF_INTERNAL},
@@ -108,8 +112,8 @@
 #ifdef INET6
     [KP_IP6_ADDR] =		{"ip6.addr",		0},
 #endif
-    [KP_JID] =			{"jid",			0},
-    [KP_NAME] =			{"name",		0},
+    [KP_JID] =			{"jid",			PF_IMMUTABLE},
+    [KP_NAME] =			{"name",		PF_IMMUTABLE},
     [KP_PATH] =			{"path",		0},
     [KP_PERSIST] =		{"persist",		0},
     [KP_SECURELEVEL] =		{"securelevel",		0},
@@ -127,9 +131,8 @@
 	struct cfjail *j, *tj, *wj;
 	struct cfparam *p, *vp, *tp;
 	struct cfstring *s, *vs, *ns;
-	struct cfvar *v;
+	struct cfvar *v, *vv;
 	char *ep;
-	size_t varoff;
 	int did_self, jseq, pgen;
 
 	if (!strcmp(cfname, "-")) {
@@ -188,7 +191,6 @@
 		    p->gen = ++pgen;
 		find_vars:
 		    TAILQ_FOREACH(s, &p->val, tq) {
-			varoff = 0;
 			while ((v = STAILQ_FIRST(&s->vars))) {
 				TAILQ_FOREACH(vp, &j->params, tq)
 					if (!strcmp(vp->name, v->name))
@@ -230,11 +232,13 @@
 					goto bad_var;
 				}
 				s->s = erealloc(s->s, s->len + vs->len + 1);
-				memmove(s->s + v->pos + varoff + vs->len,
-				    s->s + v->pos + varoff,
-				    s->len - (v->pos + varoff) + 1);
-				memcpy(s->s + v->pos + varoff, vs->s, vs->len);
-				varoff += vs->len;
+				memmove(s->s + v->pos + vs->len,
+				    s->s + v->pos,
+				    s->len - v->pos + 1);
+				memcpy(s->s + v->pos, vs->s, vs->len);
+				vv = v;
+				while ((vv = STAILQ_NEXT(vv, tq)))
+					vv->pos += vs->len;
 				s->len += vs->len;
 				while ((vs = TAILQ_NEXT(vs, tq))) {
 					ns = emalloc(sizeof(struct cfstring));
@@ -359,6 +363,11 @@
 				break;
 	if (dp != NULL) {
 		/* Found it - append or replace. */
+		if (dp->flags & PF_IMMUTABLE) {
+			jail_warnx(j, "cannot redefine variable \"%s\".",
+			    dp->name);
+			return;
+		}
 		if (strcmp(dp->name, name)) {
 			free(dp->name);
 			dp->name = estrdup(name);
@@ -446,7 +455,7 @@
 	struct addrinfo hints;
 	struct addrinfo *ai0, *ai;
 	const char *hostname;
-	int gicode, defif, prefix;
+	int gicode, defif;
 #endif
 #ifdef INET
 	struct in_addr addr4;
@@ -574,7 +583,9 @@
 
 	/*
 	 * IP addresses may include an interface to set that address on,
-	 * and a netmask/suffix for that address.
+	 * a netmask/suffix for that address and options for ifconfig.
+	 * These are copied to an internal command parameter and then stripped
+	 * so they won't be passed on to jailparam_set.
 	 */
 	defif = string_param(j->intparams[IP_INTERFACE]) != NULL;
 #ifdef INET
@@ -587,18 +598,14 @@
 				strcpy(s->s, cs + 1);
 				s->len -= cs + 1 - s->s;
 			}
-			if ((cs = strchr(s->s, '/'))) {
-				prefix = strtol(cs + 1, &ep, 10);
-				if (*ep == '.'
-				    ? inet_pton(AF_INET, cs + 1, &addr4) != 1
-				    : *ep || prefix < 0 || prefix > 32) {
-					jail_warnx(j,
-					    "ip4.addr: bad netmask \"%s\"", cs);
-					error = -1;	
-				}
+			if ((cs = strchr(s->s, '/')) != NULL) {
 				*cs = '\0';
 				s->len = cs - s->s;
 			}
+			if ((cs = strchr(s->s, ' ')) != NULL) {
+				*cs = '\0';
+				s->len = cs - s->s;
+			}
 		}
 	}
 #endif
@@ -612,17 +619,14 @@
 				strcpy(s->s, cs + 1);
 				s->len -= cs + 1 - s->s;
 			}
-			if ((cs = strchr(s->s, '/'))) {
-				prefix = strtol(cs + 1, &ep, 10);
-				if (*ep || prefix < 0 || prefix > 128) {
-					jail_warnx(j,
-					    "ip6.addr: bad prefixlen \"%s\"",
-					    cs);
-					error = -1;	
-				}
+			if ((cs = strchr(s->s, '/')) != NULL) {
 				*cs = '\0';
 				s->len = cs - s->s;
 			}
+			if ((cs = strchr(s->s, ' ')) != NULL) {
+				*cs = '\0';
+				s->len = cs - s->s;
+			}
 		}
 	}
 #endif
@@ -689,6 +693,7 @@
 		if (jailparam_init(jp, p->name) < 0) {
 			error = -1;
 			jail_warnx(j, "%s", jail_errmsg);
+			jp++;
 			continue;
 		}
 		if (TAILQ_EMPTY(&p->val))

Modified: trunk/usr.sbin/jail/jail.8
===================================================================
--- trunk/usr.sbin/jail/jail.8	2018-06-09 22:03:08 UTC (rev 10735)
+++ trunk/usr.sbin/jail/jail.8	2018-06-09 22:07:11 UTC (rev 10736)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2000, 2003 Robert N. M. Watson
 .\" Copyright (c) 2008-2012 James Gritton
 .\" All rights reserved.
@@ -23,9 +24,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/jail/jail.8 298889 2016-05-01 16:49:32Z jamie $
 .\"
-.Dd May 23, 2012
+.Dd April 25, 2016
 .Dt JAIL 8
 .Os
 .Sh NAME
@@ -63,7 +64,9 @@
 The
 .Nm
 utility creates new jails, or modifies or removes existing jails.
-A jail is specified via parameters on the command line, or in the
+A jail
+.Pq or Dq prison
+is specified via parameters on the command line, or in the
 .Xr jail.conf 5
 file.
 .Pp
@@ -73,7 +76,7 @@
 or
 .Fl r
 must be specified.
-These options are used alone or in combination describe the operation to
+These options are used alone or in combination to describe the operation to
 perform:
 .Bl -tag -width indent
 .It Fl c
@@ -82,8 +85,7 @@
 .Va jid
 and
 .Va name
-parameters (if specified) on the command line,
-or any jails
+parameters (if specified on the command line)
 must not refer to an existing jail.
 .It Fl m
 Modify an existing jail.
@@ -97,14 +99,15 @@
 Remove the
 .Ar jail
 specified by jid or name.
-All jailed processes are killed, and all children of this jail are also
+All jailed processes are killed, and all jails that are
+children of this jail are also
 removed.
 .It Fl rc
 Restart an existing jail.
 The jail is first removed and then re-created, as if
+.Dq Nm Fl r
+and
 .Dq Nm Fl c
-and
-.Dq Nm Fl r
 were run in succession.
 .It Fl cm
 Create a jail if it does not exist, or modify the jail if it does exist.
@@ -134,7 +137,7 @@
 parameter (or
 .Va hostname )
 and add all IP addresses returned by the resolver
-to the list of addresses for this prison.
+to the list of addresses for this jail.
 This is equivalent to the
 .Va ip_hostname
 parameter.
@@ -146,7 +149,7 @@
 .It Fl J Ar jid_file
 Write a
 .Ar jid_file
-file, containing parameters used to start the jail.
+file, containing the parameters used to start the jail.
 .It Fl l
 Run commands in a clean environment.
 This is deprecated and is equivalent to the exec.clean parameter.
@@ -166,7 +169,7 @@
 A variation of the
 .Fl r
 option that removes an existing jail without using the configuration file.
-No removal-related parameters for this jail will be used - the jail will
+No removal-related parameters for this jail will be used \(em the jail will
 simply be removed.
 .It Fl s Ar securelevel
 Set the
@@ -183,7 +186,7 @@
 .Va exec.system_jail_user
 parameters.
 .It Fl U Ar username
-The user name from jailed environment as whom jailed commands should run.
+The user name from the jailed environment as whom jailed commands should run.
 This is deprecated and is equivalent to the
 .Va exec.jail_user
 parameter.
@@ -237,13 +240,12 @@
 .Fl c
 and
 .Fl m
-options don't apply (and must not exist).
+options do not apply (and must not be present).
 .Ss Jail Parameters
 Parameters in the
 .Xr jail.conf 5
-file, or on the command line, are generally in
-.Dq name=value
-form.
+file, or on the command line, are generally of the form
+.Dq name=value .
 Some parameters are boolean, and do not have a value but are set by the
 name alone with or without a
 .Dq no
@@ -264,9 +266,10 @@
 .Pp
 The
 .Nm
-utility recognizes two classes of parameters.  There are the true jail
+utility recognizes two classes of parameters.
+There are the true jail
 parameters that are passed to the kernel when the jail is created,
-can be seen with
+which can be seen with
 .Xr jls 8 ,
 and can (usually) be changed with
 .Dq Nm Fl m .
@@ -274,7 +277,7 @@
 .Nm
 itself.
 .Pp
-Jails have a set a core parameters, and kernel modules can add their own
+Jails have a set of core parameters, and kernel modules can add their own
 jail parameters.
 The current set of available parameters can be retrieved via
 .Dq Nm sysctl Fl d Va security.jail.param .
@@ -314,26 +317,26 @@
 file format, and need not be explicitly set when using the configuration
 file.
 .It Va path
-The directory which is to be the root of the prison.
-Any commands run inside the prison, either by
+The directory which is to be the root of the jail.
+Any commands run inside the jail, either by
 .Nm
 or from
 .Xr jexec 8 ,
 are run from this directory.
 .It Va ip4.addr
-A list of IPv4 addresses assigned to the prison.
+A list of IPv4 addresses assigned to the jail.
 If this is set, the jail is restricted to using only these addresses.
 Any attempts to use other addresses fail, and attempts to use wildcard
 addresses silently use the jailed address instead.
-For IPv4 the first address given will be kept used as the source address
-in case source address selection on unbound sockets cannot find a better
+For IPv4 the first address given will be used as the source address
+when source address selection on unbound sockets cannot find a better
 match.
-It is only possible to start multiple jails with the same IP address,
+It is only possible to start multiple jails with the same IP address
 if none of the jails has more than this single overlapping IP address
 assigned to itself.
 .It Va ip4.saddrsel
 A boolean option to change the formerly mentioned behaviour and disable
-IPv4 source address selection for the prison in favour of the primary
+IPv4 source address selection for the jail in favour of the primary
 IPv4 address of the jail.
 Source address selection is enabled by default for all jails and the
 .Va ip4.nosaddrsel
@@ -345,8 +348,8 @@
 to allow unrestricted access to all system addresses,
 .Dq new
 to restrict addresses via
-.Va ip4.addr
-above, and
+.Va ip4.addr ,
+and
 .Dq disable
 to stop the jail from using IPv4 entirely.
 Setting the
@@ -354,14 +357,14 @@
 parameter implies a value of
 .Dq new .
 .It Va ip6.addr , Va ip6.saddrsel , Va ip6
-A set of IPv6 options for the prison, the counterparts to
+A set of IPv6 options for the jail, the counterparts to
 .Va ip4.addr ,
 .Va ip4.saddrsel
 and
 .Va ip4
 above.
-.It vnet
-Create the prison with its own virtual network stack,
+.It Va vnet
+Create the jail with its own virtual network stack,
 with its own network interfaces, addresses, routing table, etc.
 The kernel must have been compiled with the
 .Sy VIMAGE option
@@ -373,7 +376,7 @@
 .Dq new
 to create a new network stack.
 .It Va host.hostname
-The hostname of the prison.
+The hostname of the jail.
 Other similar parameters are
 .Va host.domainname ,
 .Va host.hostuuid
@@ -392,7 +395,7 @@
 The value of the jail's
 .Va kern.securelevel
 sysctl.
-A jail never has a lower securelevel than the default system, but by
+A jail never has a lower securelevel than its parent system, but by
 setting this parameter it may have a higher one.
 If the system securelevel is changed, any jail securelevels will be at
 least as secure.
@@ -429,15 +432,15 @@
 .Sx "Hierarchical Jails"
 section for more information.
 .It Va children.cur
-The number of descendents of this jail, including its own child jails
+The number of descendants of this jail, including its own child jails
 and any jails created under them.
 .It Va enforce_statfs
-This determines which information processes in a jail are able to get
+This determines what information processes in a jail are able to get
 about mount points.
 It affects the behaviour of the following syscalls:
 .Xr statfs 2 ,
 .Xr fstatfs 2 ,
-.Xr getfsstat 2
+.Xr getfsstat 2 ,
 and
 .Xr fhstatfs 2
 (as well as similar compatibility syscalls).
@@ -469,6 +472,14 @@
 .Va jid
 of the parent of this jail, or zero if this is a top-level jail
 (read-only).
+.It Va osrelease
+The string for the jail's
+.Va kern.osrelease
+sysctl and uname -r.
+.It Va osreldate
+The number for the jail's
+.Va kern.osreldate
+and uname -K.
 .It Va allow.*
 Some restrictions of the jail environment may be set on a per-jail
 basis.
@@ -483,17 +494,21 @@
 .Xr sethostname 3 .
 .It Va allow.sysvipc
 A process within the jail has access to System V IPC primitives.
-In the current jail implementation, System V primitives share a single
-namespace across the host and jail environments, meaning that processes
-within a jail would be able to communicate with (and potentially interfere
-with) processes outside of the jail, and in other jails.
+This is deprecated in favor of the per-module parameters (see below).
+When this parameter is set, it is equivalent to setting
+.Va sysvmsg ,
+.Va sysvsem ,
+and
+.Va sysvshm
+all to
+.Dq inherit .
 .It Va allow.raw_sockets
-The prison root is allowed to create raw sockets.
+The jail root is allowed to create raw sockets.
 Setting this parameter allows utilities like
 .Xr ping 8
 and
 .Xr traceroute 8
-to operate inside the prison.
+to operate inside the jail.
 If this is set, the source IP addresses are enforced to comply
 with the IP address bound to the jail, regardless of whether or not
 the
@@ -523,18 +538,26 @@
 devfs file system.
 This permission is effective only together with
 .Va allow.mount
-and if
+and only when
 .Va enforce_statfs
 is set to a value lower than 2.
-Please consider restricting the devfs ruleset with the
+The devfs ruleset should be restricted from the default by using the
 .Va devfs_ruleset
 option.
+.It Va allow.mount.fdescfs
+privileged users inside the jail will be able to mount and unmount the
+fdescfs file system.
+This permission is effective only together with
+.Va allow.mount
+and only when
+.Va enforce_statfs
+is set to a value lower than 2.
 .It Va allow.mount.nullfs
 privileged users inside the jail will be able to mount and unmount the
 nullfs file system.
 This permission is effective only together with
 .Va allow.mount
-and if
+and only when
 .Va enforce_statfs
 is set to a value lower than 2.
 .It Va allow.mount.procfs
@@ -542,15 +565,39 @@
 procfs file system.
 This permission is effective only together with
 .Va allow.mount
-and if
+and only when
 .Va enforce_statfs
 is set to a value lower than 2.
+.It Va allow.mount.linprocfs
+privileged users inside the jail will be able to mount and unmount the
+linprocfs file system.
+This permission is effective only together with
+.Va allow.mount
+and only when
+.Va enforce_statfs
+is set to a value lower than 2.
+.It Va allow.mount.linsysfs
+privileged users inside the jail will be able to mount and unmount the
+linsysfs file system.
+This permission is effective only together with
+.Va allow.mount
+and only when
+.Va enforce_statfs
+is set to a value lower than 2.
+.It Va allow.mount.tmpfs
+privileged users inside the jail will be able to mount and unmount the
+tmpfs file system.
+This permission is effective only together with
+.Va allow.mount
+and only when
+.Va enforce_statfs
+is set to a value lower than 2.
 .It Va allow.mount.zfs
 privileged users inside the jail will be able to mount and unmount the
 ZFS file system.
 This permission is effective only together with
 .Va allow.mount
-and if
+and only when
 .Va enforce_statfs
 is set to a value lower than 2.
 See
@@ -558,7 +605,7 @@
 for information on how to configure the ZFS filesystem to operate from
 within a jail.
 .It Va allow.quotas
-The prison root may administer quotas on the jail's filesystem(s).
+The jail root may administer quotas on the jail's filesystem(s).
 This includes filesystems that the jail may share with other jails or
 with non-jailed parts of the system.
 .It Va allow.socket_af
@@ -568,33 +615,78 @@
 .El
 .El
 .Pp
-There are pseudo-parameters that aren't passed to the kernel, but are
+Kernel modules may add their own parameters, which only exist when the
+module is loaded.
+These are typically headed under a parameter named after the module,
+with values of
+.Dq inherit
+to give the jail full use of the module,
+.Dq new
+to encapsulate the jail in some module-specific way,
+and
+.Dq disable
+to make the module unavailable to the jail.
+There also may be other parameters to define jail behavior within the module.
+Module-specific parameters include:
+.Bl -tag -width indent
+.It Va linux
+Determine how a jail's Linux emulation environment appears.
+A value of
+.Dq inherit
+will keep the same environment, and
+.Dq new
+will give the jail it's own environment (still originally inherited when
+the jail is created).
+.It Va linux.osname , linux.osrelease , linux.oss_version
+The Linux OS name, OS release, and OSS version associated with this jail.
+.It Va sysvmsg
+Allow access to SYSV IPC message primitives.
+If set to
+.Dq inherit ,
+all IPC objects on the system are visible to this jail, whether they
+were created by the jail itself, the base system, or other jails.
+If set to
+.Dq new ,
+the jail will have its own key namespace, and can only see the objects
+that it has created;
+the system (or parent jail) has access to the jail's objects, but not to
+its keys.
+If set to
+.Dq disable ,
+the jail cannot perform any sysvmsg-related system calls.
+.It Va sysvsem, sysvshm
+Allow access to SYSV IPC semaphore and shared memory primitives, in the
+same manner as
+.Va sysvmsg.
+.El
+.Pp
+There are pseudo-parameters that are not passed to the kernel, but are
 used by
 .Nm
-to set up the prison environment, often by running specified commands
+to set up the jail environment, often by running specified commands
 when jails are created or removed.
 The
 .Va exec.*
 command parameters are
 .Xr sh 1
-command lines that are run in either the system or prison environment.
-They may be given multiple values, which run would the specified
+command lines that are run in either the system or jail environment.
+They may be given multiple values, which would run the specified
 commands in sequence.
 All commands must succeed (return a zero exit status), or the jail will
-not be created or removed.
+not be created or removed, as appropriate.
 .Pp
 The pseudo-parameters are:
 .Bl -tag -width indent
 .It Va exec.prestart
-Command(s) to run in the system environment before a prison is created.
+Command(s) to run in the system environment before a jail is created.
 .It Va exec.start
-Command(s) to run in the prison environment when a jail is created.
+Command(s) to run in the jail environment when a jail is created.
 A typical command to run is
 .Dq sh /etc/rc .
 .It Va command
 A synonym for
 .Va exec.start
-for use when specifying a prison directly on the command line.
+for use when specifying a jail directly on the command line.
 Unlike other parameters whose value is a single string,
 .Va command
 uses the remainder of the
@@ -608,7 +700,7 @@
 .It Va exec.prestop
 Command(s) to run in the system environment before a jail is removed.
 .It Va exec.stop
-Command(s) to run in the prison environment before a jail is removed,
+Command(s) to run in the jail environment before a jail is removed,
 and after any
 .Va exec.prestop
 commands have completed.
@@ -633,7 +725,7 @@
 The environment variables from the login class capability database for the
 target login are also set.
 .It Va exec.jail_user
-The user to run commands as, when running in the prison environment.
+The user to run commands as, when running in the jail environment.
 The default is to run the commands as the current user.
 .It Va exec.system_jail_user
 This boolean option looks for the
@@ -640,69 +732,77 @@
 .Va exec.jail_user
 in the system
 .Xr passwd 5
-file, instead of in the prison's file.
+file, instead of in the jail's file.
 .It Va exec.system_user
 The user to run commands as, when running in the system environment.
 The default is to run the commands as the current user.
 .It Va exec.timeout
-The maximum amount of time to wait for a command to complete.
-If a command is still running after this many seconds have passed,
-the jail not be created or removed.
+The maximum amount of time to wait for a command to complete, in
+seconds.
+If a command is still running after this timeout has passed,
+the jail will not be created or removed, as appropriate.
 .It Va exec.consolelog
 A file to direct command output (stdout and stderr) to.
 .It Va exec.fib
-The FIB (routing table) to set when running commands inside the prison.
+The FIB (routing table) to set when running commands inside the jail.
 .It Va stop.timeout
-The maximum amount of time to wait for a prison's processes to exit
+The maximum amount of time to wait for a jail's processes to exit
 after sending them a
 .Dv SIGTERM
 signal (which happens after the
 .Va exec.stop
 commands have completed).
-After this many seconds have passed, the prison will be removed, which
+After this many seconds have passed, the jail will be removed, which
 will kill any remaining processes.
 If this is set to zero, no
 .Dv SIGTERM
-is sent and the prison is immediately removed.
+is sent and the jail is immediately removed.
 The default is 10 seconds.
 .It Va interface
-A network interface to add the prison's IP addresses
+A network interface to add the jail's IP addresses
 .Va ( ip4.addr
 and
 .Va ip6.addr )
 to.
 An alias for each address will be added to the interface before the
-prison is created, and will be removed from the interface after the
-prison is removed.
-.It Op Va ip4.addr
-In addition to the IP addresses that are passed to the kernel, and
-interface and/or a netmask may also be specified, in the form
-.Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar netmask .
+jail is created, and will be removed from the interface after the
+jail is removed.
+.It Va ip4.addr
+In addition to the IP addresses that are passed to the kernel, an
+interface, netmask and additional paramters (as supported by
+.Xr ifconfig 8 Ns )
+may also be specified, in the form
+.Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar netmask param ... .
 If an interface is given before the IP address, an alias for the address
 will be added to that interface, as it is with the
 .Va interface
-parameter.  If a netmask in either dotted-quad or CIDR form is given
-after IP address, it will be used when adding the IP alias.
-.It Op Va ip6.addr
+parameter.
+If a netmask in either dotted-quad or CIDR form is given
+after an IP address, it will be used when adding the IP alias.
+If additional parameters are specified then they will also be used when
+adding the IP alias.
+.It Va ip6.addr
 In addition to the IP addresses that are passed to the kernel,
-and interface and/or a prefix may also be specified, in the form
-.Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar prefix .
+an interface, prefix and additional parameters (as supported by
+.Xr ifconfig 8 Ns )
+may also be specified, in the form
+.Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar prefix param ... .
 .It Va vnet.interface
 A network interface to give to a vnet-enabled jail after is it created.
-The interface will automatically be returned when the jail is removed.
+The interface will automatically be released when the jail is removed.
 .It Va ip_hostname
 Resolve the
 .Va host.hostname
 parameter and add all IP addresses returned by the resolver
 to the list of addresses
-.Va ( ip4.addr
+.Po Va ip4.addr
 or
-.Va ip6.addr )
-for this prison.
+.Va ip6.addr Pc
+for this jail.
 This may affect default address selection for outgoing IPv4 connections
-of prisons.
+from jails.
 The address first returned by the resolver for each address family
-will be used as primary address.
+will be used as the primary address.
 .It Va mount
 A filesystem to mount before creating the jail (and to unmount after
 removing it), given as a single
@@ -714,11 +814,25 @@
 format file containing filesystems to mount before creating a jail.
 .It Va mount.devfs
 Mount a
-.Xr devfs
-filesystem on the chrooted /dev directory, and apply the ruleset in the
+.Xr devfs 5
+filesystem on the chrooted
+.Pa /dev
+directory, and apply the ruleset in the
 .Va devfs_ruleset
 parameter (or a default of ruleset 4: devfsrules_jail)
-to restrict the devices visible inside the prison.
+to restrict the devices visible inside the jail.
+.It Va mount.fdescfs
+Mount a
+.Xr fdescfs 5
+filesystem on the chrooted
+.Pa /dev/fd
+directory.
+.It Va mount.procfs
+Mount a
+.Xr procfs 5
+filesystem on the chrooted
+.Pa /proc
+directory.
 .It Va allow.dying
 Allow making changes to a
 .Va dying
@@ -745,11 +859,11 @@
 required, so as to provide the necessary command line tools, daemons,
 libraries, application configuration files, etc.
 However, for a virtual server configuration, a fair amount of
-additional work is required so as to configure the
+additional work is required so as to replace the
 .Dq boot
 process.
 This manual page documents the configuration steps necessary to support
-either of these steps, although the configuration steps may be
+either of these steps, although the configuration steps may need to be
 refined based on local requirements.
 .Ss "Setting up a Jail Directory Tree"
 To set up a jail directory tree containing an entire
@@ -769,7 +883,7 @@
 In the other extreme case a jail might contain only one file:
 the executable to be run in the jail.
 .Pp
-We recommend experimentation and caution that it is a lot easier to
+We recommend experimentation, and caution that it is a lot easier to
 start with a
 .Dq fat
 jail and remove things until it stops working,
@@ -788,13 +902,13 @@
 Substitute below as needed with your
 own directory, IP address, and hostname.
 .Ss "Setting up the Host Environment"
-First, you will want to set up your real system's environment to be
+First, set up the real system's environment to be
 .Dq jail-friendly .
 For consistency, we will refer to the parent box as the
 .Dq "host environment" ,
 and to the jailed virtual machine as the
 .Dq "jail environment" .
-Since jail is implemented using IP aliases, one of the first things to do
+Since jails are implemented using IP aliases, one of the first things to do
 is to disable IP services on the host system that listen on all local
 IP addresses for a service.
 If a network service is present in the host environment that binds all
@@ -817,13 +931,12 @@
 is the native IP address for the host system, in this example.
 Daemons that run out of
 .Xr inetd 8
-can be easily set to use only the specified host IP address.
+can be easily configured to use only the specified host IP address.
 Other daemons
-will need to be manually configured\(emfor some this is possible through
-the
+will need to be manually configured \(em for some this is possible through
 .Xr rc.conf 5
 flags entries; for others it is necessary to modify per-application
-configuration files, or to recompile the applications.
+configuration files, or to recompile the application.
 The following frequently deployed services must have their individual
 configuration files modified to limit the application to listening
 to a specific IP address:
@@ -861,7 +974,7 @@
 hosted directly from the kernel.
 Any third-party network software running
 in the host environment should also be checked and configured so that it
-does not bind all IP addresses, which would result in those services' also
+does not bind all IP addresses, which would result in those services also
 appearing to be offered by the jail environments.
 .Pp
 Once
@@ -874,7 +987,7 @@
 Start any jail for the first time without configuring the network
 interface so that you can clean it up a little and set up accounts.
 As
-with any machine (virtual or not) you will need to set a root password, time
+with any machine (virtual or not), you will need to set a root password, time
 zone, etc.
 Some of these steps apply only if you intend to run a full virtual server
 inside the jail; others apply both for constraining a particular application
@@ -898,7 +1011,7 @@
 .It
 Configure
 .Pa /etc/resolv.conf
-so that name resolution within the jail will work correctly
+so that name resolution within the jail will work correctly.
 .It
 Run
 .Xr newaliases 1
@@ -906,13 +1019,13 @@
 .Xr sendmail 8
 warnings.
 .It
-Set a root password, probably different from the real host system
+Set a root password, probably different from the real host system.
 .It
-Set the timezone
+Set the timezone.
 .It
-Add accounts for users in the jail environment
+Add accounts for users in the jail environment.
 .It
-Install any packages the environment requires
+Install any packages the environment requires.
 .El
 .Pp
 You may also want to perform any package-specific configuration (web servers,
@@ -972,11 +1085,12 @@
 with the
 .Ql J
 flag appearing beside jailed processes.
-To see an active list of jails, use the
-.Xr jls 8
-utility.
-You should also be able to
-.Xr telnet 1
+To see an active list of jails, use
+.Xr jls 8 .
+If
+.Xr sshd 8
+is enabled in the jail environment, you should be able to
+.Xr ssh 1
 to the hostname or IP address of the jailed environment, and log
 in using the accounts you created previously.
 .Pp
@@ -1004,7 +1118,7 @@
 .Dv SIGTERM
 or
 .Dv SIGKILL
-signals to all processes in the jail - be careful not to run this from
+signals to all processes in the jail \(em be careful not to run this from
 the host environment!
 Once all of the jail's processes have died, unless the jail was created
 with the
@@ -1059,18 +1173,18 @@
 any file system inside a jail unless the file system is marked
 jail-friendly, the jail's
 .Va allow.mount
-parameter is set and the jail's
+parameter is set, and the jail's
 .Va enforce_statfs
 parameter is lower than 2.
 .Pp
 Multiple jails sharing the same file system can influence each other.
-For example a user in one jail can fill the file system also
+For example, a user in one jail can fill the file system,
 leaving no space for processes in the other jail.
 Trying to use
 .Xr quota 1
-to prevent this will not work either as the file system quotas
+to prevent this will not work either, as the file system quotas
 are not aware of jails but only look at the user and group IDs.
-This means the same user ID in two jails share the same file
+This means the same user ID in two jails share a single file
 system quota.
 One would need to use one file system per jail to make this work.
 .Ss "Sysctl MIB Entries"
@@ -1081,11 +1195,11 @@
 .Pp
 The variable
 .Va security.jail.max_af_ips
-determines how may address per address family a prison may have.
+determines how may address per address family a jail may have.
 The default is 255.
 .Pp
 Some MIB variables have per-jail settings.
-Changes to these variables by a jailed process do not effect the host
+Changes to these variables by a jailed process do not affect the host
 environment, only the jail environment.
 These variables are
 .Va kern.securelevel ,
@@ -1110,7 +1224,7 @@
 jail if the current process isn't jailed).
 .Pp
 Jailed processes are not allowed to confer greater permissions than they
-themselves are given, e.g. if a jail is created with
+themselves are given, e.g., if a jail is created with
 .Va allow.nomount ,
 it is not able to create a jail with
 .Va allow.mount
@@ -1156,9 +1270,14 @@
 .Xr pkill 1 ,
 .Xr ps 1 ,
 .Xr quota 1 ,
+.Xr ifconfig 8 ,
 .Xr jail_set 2 ,
+.Xr devfs 5 ,
+.Xr fdescfs 5 ,
 .Xr jail.conf 5 ,
 .Xr procfs 5 ,
+.Xr linprocfs 5 ,
+.Xr linsysfs 5 ,
 .Xr rc.conf 5 ,
 .Xr sysctl.conf 5 ,
 .Xr chroot 8 ,
@@ -1169,6 +1288,7 @@
 .Xr jls 8 ,
 .Xr mount 8 ,
 .Xr named 8 ,
+.Xr procfs 5 ,
 .Xr reboot 8 ,
 .Xr rpcbind 8 ,
 .Xr sendmail 8 ,
@@ -1225,3 +1345,11 @@
 access to the file space outside of the jail.
 It is recommended that directories always be copied, rather than moved, out
 of a jail.
+.Pp
+In addition, there are several ways in which an unprivileged user
+outside the jail can cooperate with a privileged user inside the jail
+and thereby obtain elevated privileges in the host environment.
+Most of these attacks can be mitigated by ensuring that the jail root
+is not accessible to unprivileged users in the host environment.
+Regardless, as a general rule, untrusted users with privileged access
+to a jail should not be given access to the host environment.


Property changes on: trunk/usr.sbin/jail/jail.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/jail/jail.c
===================================================================
--- trunk/usr.sbin/jail/jail.c	2018-06-09 22:03:08 UTC (rev 10735)
+++ trunk/usr.sbin/jail/jail.c	2018-06-09 22:07:11 UTC (rev 10736)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Poul-Henning Kamp.
  * Copyright (c) 2009-2012 James Gritton
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/jail/jail.c 311756 2017-01-09 06:07:44Z delphij $");
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -92,6 +93,8 @@
     IP_MOUNT,
     IP__MOUNT_FROM_FSTAB,
     IP_MOUNT_DEVFS,
+    IP_MOUNT_FDESCFS,
+    IP_MOUNT_PROCFS,
     IP_EXEC_PRESTART, 
     IP__OP,
     IP_VNET_INTERFACE,
@@ -108,6 +111,8 @@
     IP_STOP_TIMEOUT,
     IP__OP,
     IP_EXEC_POSTSTOP,
+    IP_MOUNT_PROCFS,
+    IP_MOUNT_FDESCFS,
     IP_MOUNT_DEVFS,
     IP__MOUNT_FROM_FSTAB,
     IP_MOUNT,
@@ -470,10 +475,12 @@
 				if (dep_check(j))
 					continue;
 				if (j->jid < 0) {
-					if (!(j->flags & (JF_DEPEND | JF_WILD))
-					    && verbose >= 0)
-						jail_quoted_warnx(j,
-						    "not found", NULL);
+					if (!(j->flags & (JF_DEPEND|JF_WILD))) {
+						if (verbose >= 0)
+							jail_quoted_warnx(j,
+							    "not found", NULL);
+						failed(j);
+					}
 					goto jail_remove_done;
 				}
 				j->comparam = stopcommands;
@@ -800,8 +807,7 @@
 	if (jailparam_get(rtparams, nrt,
 	    bool_param(j->intparams[IP_ALLOW_DYING]) ? JAIL_DYING : 0) > 0) {
 		rtjp = rtparams + 1;
-		for (jp = j->jp, rtjp = rtparams + 1; rtjp < rtparams + nrt;
-		     jp++) {
+		for (jp = j->jp; rtjp < rtparams + nrt; jp++) {
 			if (JP_RDTUN(jp) && strcmp(jp->jp_name, "jid")) {
 				if (!((jp->jp_flags & (JP_BOOL | JP_NOBOOL)) &&
 				    jp->jp_valuelen == 0 &&

Modified: trunk/usr.sbin/jail/jail.conf.5
===================================================================
--- trunk/usr.sbin/jail/jail.conf.5	2018-06-09 22:03:08 UTC (rev 10735)
+++ trunk/usr.sbin/jail/jail.conf.5	2018-06-09 22:07:11 UTC (rev 10736)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 2012 James Gritton
 .\" All rights reserved.
 .\"
@@ -22,9 +23,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/jail/jail.conf.5 262836 2014-03-06 10:26:25Z zeising $
 .\"
-.Dd May 23, 2012
+.Dd February 13, 2014
 .Dt JAIL.CONF 5
 .Os
 .Sh NAME
@@ -125,7 +126,7 @@
 strings, but not in single-quote strings.
 .Pp
 A variable is defined in the same way a parameter is, except that the
-variable name is preceeded with a dollar sign:
+variable name is preceded with a dollar sign:
 .Bd -literal -offset indent
 $parentdir = "/var/jail";
 path = "$parentdir/$name";
@@ -206,8 +207,9 @@
 }
 .Ed
 .Sh SEE ALSO
-.Xr jail_set 2
-.Xr jail 8
+.Xr jail_set 2 ,
+.Xr rc.conf 5 ,
+.Xr jail 8 ,
 .Xr jls 8
 .Sh HISTORY
 The


Property changes on: trunk/usr.sbin/jail/jail.conf.5
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/jail/jaillex.l
===================================================================
--- trunk/usr.sbin/jail/jaillex.l	2018-06-09 22:03:08 UTC (rev 10735)
+++ trunk/usr.sbin/jail/jaillex.l	2018-06-09 22:07:11 UTC (rev 10736)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 %{
 /*-
  * Copyright (c) 2011 James Gritton
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/jail/jaillex.l 316193 2017-03-30 01:37:37Z jamie $");
 
 #include <err.h>
 #include <stddef.h>
@@ -216,7 +217,7 @@
 				*d = *++s - '0';
 			else if (s[1] >= 'A' && s[1] <= 'F')
 				*d = *++s + (0xA - 'A');
-			else if (s[1] >= 'a' && s[1] <= 'a')
+			else if (s[1] >= 'a' && s[1] <= 'f')
 				*d = *++s + (0xa - 'a');
 			else
 				break;
@@ -226,7 +227,7 @@
 				*d = *d * 0x10 + (*++s - '0');
 			else if (s[1] >= 'A' && s[1] <= 'F')
 				*d = *d * 0x10 + (*++s + (0xA - 'A'));
-			else if (s[1] >= 'a' && s[1] <= 'a')
+			else if (s[1] >= 'a' && s[1] <= 'f')
 				*d = *d * 0x10 + (*++s + (0xa - 'a'));
 		}
 	}


Property changes on: trunk/usr.sbin/jail/jaillex.l
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/jail/jailp.h
===================================================================
--- trunk/usr.sbin/jail/jailp.h	2018-06-09 22:03:08 UTC (rev 10735)
+++ trunk/usr.sbin/jail/jailp.h	2018-06-09 22:07:11 UTC (rev 10736)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 James Gritton.
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/jail/jailp.h 302958 2016-07-17 14:15:08Z jamie $
  */
 
 #include <sys/param.h>
@@ -41,7 +42,7 @@
 
 #define DF_SEEN		0x01	/* Dependency has been followed */
 #define DF_LIGHT	0x02	/* Implied dependency on jail existence only */
-#define DF_NOFAIL	0x04	/* Don't propigate failed jails */
+#define DF_NOFAIL	0x04	/* Don't propagate failed jails */
 
 #define PF_VAR		0x01	/* This is a variable, not a true parameter */
 #define PF_APPEND	0x02	/* Append to existing parameter list */
@@ -51,6 +52,7 @@
 #define PF_INT		0x20	/* Integer parameter */
 #define PF_CONV		0x40	/* Parameter duplicated in converted form */
 #define PF_REV		0x80	/* Run commands in reverse order on stopping */
+#define	PF_IMMUTABLE	0x100	/* Immutable parameter */
 
 #define JF_START	0x0001	/* -c */
 #define JF_SET		0x0002	/* -m */
@@ -63,6 +65,7 @@
 #define JF_PERSIST	0x0100	/* Jail is temporarily persistent */
 #define JF_TIMEOUT	0x0200	/* A command (or process kill) timed out */
 #define JF_SLEEPQ	0x0400	/* Waiting on a command and/or timeout */
+#define JF_FROM_RUNQ	0x0800	/* Has already been on the run queue */
 
 #define JF_OP_MASK		(JF_START | JF_SET | JF_STOP)
 #define JF_RESTART		(JF_START | JF_STOP)
@@ -95,6 +98,8 @@
 #endif
 	IP_MOUNT,		/* Mount points in fstab(5) form */
 	IP_MOUNT_DEVFS,		/* Mount /dev under prison root */
+	IP_MOUNT_FDESCFS,	/* Mount /dev/fd under prison root */
+	IP_MOUNT_PROCFS,	/* Mount /proc under prison root */
 	IP_MOUNT_FSTAB,		/* A standard fstab(5) file */
 	IP_STOP_TIMEOUT,	/* Time to wait after sending SIGTERM */
 	IP_VNET_INTERFACE,	/* Assign interface(s) to vnet jail */
@@ -220,6 +225,7 @@
 extern int start_state(const char *target, int docf, unsigned state,
     int running);
 extern void requeue(struct cfjail *j, struct cfjails *queue);
+extern void requeue_head(struct cfjail *j, struct cfjails *queue);
 
 extern void yyerror(const char *);
 extern int yylex(void);

Modified: trunk/usr.sbin/jail/jailparse.y
===================================================================
--- trunk/usr.sbin/jail/jailparse.y	2018-06-09 22:03:08 UTC (rev 10735)
+++ trunk/usr.sbin/jail/jailparse.y	2018-06-09 22:07:11 UTC (rev 10736)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 %{
 /*-
  * Copyright (c) 2011 James Gritton
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/jail/jailparse.y 293290 2016-01-07 00:40:51Z bdrewery $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -103,7 +104,7 @@
 
 /*
  * Parameters have a name and an optional list of value strings,
- * which may have "+=" or "=" preceeding them.
+ * which may have "+=" or "=" preceding them.
  */
 param	: name
 	{


Property changes on: trunk/usr.sbin/jail/jailparse.y
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/jail/state.c
===================================================================
--- trunk/usr.sbin/jail/state.c	2018-06-09 22:03:08 UTC (rev 10735)
+++ trunk/usr.sbin/jail/state.c	2018-06-09 22:07:11 UTC (rev 10736)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 James Gritton
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/jail/state.c 302958 2016-07-17 14:15:08Z jamie $");
 
 #include <sys/uio.h>
 
@@ -398,6 +399,14 @@
 	}
 }
 
+void
+requeue_head(struct cfjail *j, struct cfjails *queue)
+{
+    TAILQ_REMOVE(j->queue, j, tq);
+    TAILQ_INSERT_HEAD(queue, j, tq);
+    j->queue = queue;
+}
+
 /*
  * Add a dependency edge between two jails.
  */



More information about the Midnightbsd-cvs mailing list