From owner-svn-src-stable-9@FreeBSD.ORG Sun Mar 31 04:10:39 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E51D481B; Sun, 31 Mar 2013 04:10:38 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D19938CC; Sun, 31 Mar 2013 04:10:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2V4Ac5X093735; Sun, 31 Mar 2013 04:10:38 GMT (envelope-from jamie@svn.freebsd.org) Received: (from jamie@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2V4Ac5r093732; Sun, 31 Mar 2013 04:10:38 GMT (envelope-from jamie@svn.freebsd.org) Message-Id: <201303310410.r2V4Ac5r093732@svn.freebsd.org> From: Jamie Gritton Date: Sun, 31 Mar 2013 04:10:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248939 - stable/9/usr.sbin/jail X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2013 04:10:39 -0000 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 */