summaryrefslogtreecommitdiffstats
path: root/usr.sbin/jail
diff options
context:
space:
mode:
authorjamie <jamie@FreeBSD.org>2013-03-28 21:02:49 +0000
committerjamie <jamie@FreeBSD.org>2013-03-28 21:02:49 +0000
commit82d58114889a20fcd15b9f51da2e60600642ed77 (patch)
treea7ea5132957188b191c1034669ee8f49822084d2 /usr.sbin/jail
parent2380294328e0c3c80c578a4b4889748084c237ac (diff)
downloadFreeBSD-src-82d58114889a20fcd15b9f51da2e60600642ed77.zip
FreeBSD-src-82d58114889a20fcd15b9f51da2e60600642ed77.tar.gz
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 MFC after: 3 days
Diffstat (limited to 'usr.sbin/jail')
-rw-r--r--usr.sbin/jail/command.c9
-rw-r--r--usr.sbin/jail/config.c8
-rw-r--r--usr.sbin/jail/jailp.h1
3 files changed, 11 insertions, 7 deletions
diff --git a/usr.sbin/jail/command.c b/usr.sbin/jail/command.c
index 3bdedad..452a079 100644
--- a/usr.sbin/jail/command.c
+++ b/usr.sbin/jail/command.c
@@ -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);
}
diff --git a/usr.sbin/jail/config.c b/usr.sbin/jail/config.c
index d0b7d26..a201f31 100644
--- a/usr.sbin/jail/config.c
+++ b/usr.sbin/jail/config.c
@@ -81,18 +81,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},
diff --git a/usr.sbin/jail/jailp.h b/usr.sbin/jail/jailp.h
index ffd35cc..63995b2 100644
--- a/usr.sbin/jail/jailp.h
+++ b/usr.sbin/jail/jailp.h
@@ -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 */
OpenPOWER on IntegriCloud