svn commit: r248939 - stable/9/usr.sbin/jail

Jamie Gritton jamie at FreeBSD.org
Sun Mar 31 04:10:39 UTC 2013


Author: jamie
Date: Sun Mar 31 04:10:37 2013
New Revision: 248939
URL: http://svnweb.freebsd.org/changeset/base/248939

Log:
  MFC r248854:
  
    Reverse the order of some implicit commands (FS mounts and ifconfigs)
    when stopping jails.  This matters particularly for nested filesystem
    mounts.
  
  PR:		kern/177325
  Submitted by:	Harald Schmalzbauer

Modified:
  stable/9/usr.sbin/jail/command.c
  stable/9/usr.sbin/jail/config.c
  stable/9/usr.sbin/jail/jailp.h
Directory Properties:
  stable/9/usr.sbin/jail/   (props changed)

Modified: stable/9/usr.sbin/jail/command.c
==============================================================================
--- stable/9/usr.sbin/jail/command.c	Sun Mar 31 03:56:48 2013	(r248938)
+++ stable/9/usr.sbin/jail/command.c	Sun Mar 31 04:10:37 2013	(r248939)
@@ -88,13 +88,14 @@ int
 next_command(struct cfjail *j)
 {
 	enum intparam comparam;
-	int create_failed;
+	int create_failed, stopping;
 
 	if (paralimit == 0) {
 		requeue(j, &runnable);
 		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,14 +114,16 @@ next_command(struct cfjail *j)
 			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);
 			}
 		} 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: stable/9/usr.sbin/jail/config.c
==============================================================================
--- stable/9/usr.sbin/jail/config.c	Sun Mar 31 03:56:48 2013	(r248938)
+++ stable/9/usr.sbin/jail/config.c	Sun Mar 31 04:10:37 2013	(r248939)
@@ -79,18 +79,18 @@ static const struct ipspec intparams[] =
     [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: stable/9/usr.sbin/jail/jailp.h
==============================================================================
--- stable/9/usr.sbin/jail/jailp.h	Sun Mar 31 03:56:48 2013	(r248938)
+++ stable/9/usr.sbin/jail/jailp.h	Sun Mar 31 04:10:37 2013	(r248939)
@@ -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 svn-src-stable-9 mailing list