[Midnightbsd-cvs] src [9019] trunk/usr.sbin/jail: reverse order of some implicit commands when stopping jails.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Thu Sep 29 21:55:48 EDT 2016


Revision: 9019
          http://svnweb.midnightbsd.org/src/?rev=9019
Author:   laffer1
Date:     2016-09-29 21:55:48 -0400 (Thu, 29 Sep 2016)
Log Message:
-----------
reverse order of some implicit commands when stopping jails.  this matters for nested file system mounts.

Modified Paths:
--------------
    trunk/usr.sbin/jail/command.c
    trunk/usr.sbin/jail/config.c
    trunk/usr.sbin/jail/jailp.h

Modified: trunk/usr.sbin/jail/command.c
===================================================================
--- trunk/usr.sbin/jail/command.c	2016-09-30 01:54:53 UTC (rev 9018)
+++ trunk/usr.sbin/jail/command.c	2016-09-30 01:55:48 UTC (rev 9019)
@@ -88,7 +88,7 @@
 next_command(struct cfjail *j)
 {
 	enum intparam comparam;
-	int create_failed;
+	int create_failed, stopping;
 
 	if (paralimit == 0) {
 		requeue(j, &runnable);
@@ -95,6 +95,7 @@
 		return 1;
 	}
 	create_failed = (j->flags & (JF_STOP | JF_FAILED)) == JF_FAILED;
+	stopping = (j->flags & JF_STOP) != 0;
 	comparam = *j->comparam;
 	for (;;) {
 		if (j->comstring == NULL) {
@@ -113,7 +114,8 @@
 			default:
 				if (j->intparams[comparam] == NULL)
 					continue;
-				j->comstring = create_failed
+				j->comstring = create_failed || (stopping &&
+				    (j->intparams[comparam]->flags & PF_REV))
 				    ? TAILQ_LAST(&j->intparams[comparam]->val,
 					cfstrings)
 				    : TAILQ_FIRST(&j->intparams[comparam]->val);
@@ -120,7 +122,8 @@
 			}
 		} else {
 			j->comstring = j->comstring == &dummystring ? NULL :
-			    create_failed
+			    create_failed || (stopping &&
+			    (j->intparams[comparam]->flags & PF_REV))
 			    ? TAILQ_PREV(j->comstring, cfstrings, tq)
 			    : TAILQ_NEXT(j->comstring, tq);
 		}

Modified: trunk/usr.sbin/jail/config.c
===================================================================
--- trunk/usr.sbin/jail/config.c	2016-09-30 01:54:53 UTC (rev 9018)
+++ trunk/usr.sbin/jail/config.c	2016-09-30 01:55:48 UTC (rev 9019)
@@ -80,18 +80,18 @@
     [IP_INTERFACE] =		{"interface",		PF_INTERNAL},
     [IP_IP_HOSTNAME] =		{"ip_hostname",		PF_INTERNAL | PF_BOOL},
 #endif
-    [IP_MOUNT] =		{"mount",		PF_INTERNAL},
+    [IP_MOUNT] =		{"mount",		PF_INTERNAL | PF_REV},
     [IP_MOUNT_DEVFS] =		{"mount.devfs",		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},
 #ifdef INET
-    [IP__IP4_IFADDR] =		{"ip4.addr",		PF_INTERNAL | PF_CONV},
+    [IP__IP4_IFADDR] =		{"ip4.addr",	PF_INTERNAL | PF_CONV | PF_REV},
 #endif
 #ifdef INET6
-    [IP__IP6_IFADDR] =		{"ip6.addr",		PF_INTERNAL | PF_CONV},
+    [IP__IP6_IFADDR] =		{"ip6.addr",	PF_INTERNAL | PF_CONV | PF_REV},
 #endif
-    [IP__MOUNT_FROM_FSTAB] =	{"mount.fstab",		PF_INTERNAL | PF_CONV},
+    [IP__MOUNT_FROM_FSTAB] =	{"mount.fstab",	PF_INTERNAL | PF_CONV | PF_REV},
     [IP__OP] =			{NULL,			PF_CONV},
     [KP_ALLOW_CHFLAGS] =	{"allow.chflags",	0},
     [KP_ALLOW_MOUNT] =		{"allow.mount",		0},

Modified: trunk/usr.sbin/jail/jailp.h
===================================================================
--- trunk/usr.sbin/jail/jailp.h	2016-09-30 01:54:53 UTC (rev 9018)
+++ trunk/usr.sbin/jail/jailp.h	2016-09-30 01:55:48 UTC (rev 9019)
@@ -50,6 +50,7 @@
 #define PF_BOOL		0x10	/* Boolean parameter */
 #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 JF_START	0x0001	/* -c */
 #define JF_SET		0x0002	/* -m */



More information about the Midnightbsd-cvs mailing list