]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
From: Daniel Lezcano <dlezcano@fr.ibm.com>
authordlezcano <dlezcano>
Tue, 4 Nov 2008 22:18:23 +0000 (22:18 +0000)
committerdlezcano <dlezcano>
Tue, 4 Nov 2008 22:18:23 +0000 (22:18 +0000)
Remove the CAP_SYS_BOOT capability from the bouding set, so we can poweroff,
halt, reboot the container safely without shutting down the real host.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/start.c

index 09dc6ff94bdd13534d222ef35a903a288a6bae82..a6d0db34f79cc25b1a00d601cc0e1c178720e5f0 100644 (file)
@@ -35,6 +35,7 @@
 #include <sys/mount.h>
 #include <sys/types.h>
 #include <sys/prctl.h>
+#include <sys/capability.h>
 #include <sys/wait.h>
 
 #include <lxc/lxc.h>
@@ -138,6 +139,11 @@ int lxc_start(const char *name, int argc, char *argv[],
                                goto out_child;
                        }
 
+               if (prctl(PR_CAPBSET_DROP, CAP_SYS_BOOT, 0, 0, 0)) {
+                       lxc_log_syserror("failed to remove CAP_SYS_BOOT capability");
+                       goto out_child;
+               }
+
                execvp(argv[0], argv);
                lxc_log_syserror("failed to exec %s", argv[0]);