[lxc-devel] [lxc/master] hooks: drop namespace references before post-stop

brauner on Github lxc-bot at linuxcontainers.org
Sun Mar 10 10:51:56 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 662 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190310/381cf8af/attachment.bin>
-------------- next part --------------
From 048493a30739347f1e1256fa03fda2d913cd43c9 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sun, 10 Mar 2019 11:46:18 +0100
Subject: [PATCH] hooks: drop namespace references before post-stop

Callers such as LXD run post-stop hooks to perform cleanup operations on
shutdown. This can involve umount and other things. To avoid surprises with
lingering namespace references we should close all our namespace-preserving
file descriptors. We don't need them at this point anymore anyway.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/start.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/lxc/start.c b/src/lxc/start.c
index c62e56ff01..31fa3f8a4d 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1026,6 +1026,9 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
 		lxc_set_state(name, handler, STOPPED);
 	}
 
+	/* Avoid lingering namespace references. */
+	lxc_put_nsfds(handler);
+
 	ret = run_lxc_hooks(name, "post-stop", handler->conf, NULL);
 	if (ret < 0) {
 		ERROR("Failed to run lxc.hook.post-stop for container \"%s\"", name);


More information about the lxc-devel mailing list