]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
move the capabilities function to caps.c
authorDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 20 Jul 2010 11:45:44 +0000 (13:45 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 20 Jul 2010 11:45:44 +0000 (13:45 +0200)
Move the reset of the capabilities to the caps.c file and
initialize correctly the capabilities for lxc-init.

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

index 70bfcb2e4a2465ef55b12fffb4c292e50d4c8958..58634bad0ba27479f0f0b2746f459c8afaa2195e 100644 (file)
 
 lxc_log_define(lxc_caps, lxc);
 
+int lxc_caps_reset(void)
+{
+       cap_t cap = cap_init();
+       int ret = 0;
+
+       if (!cap) {
+               ERROR("cap_init() failed : %m");
+               return -1;
+       }
+
+       if (cap_set_proc(cap)) {
+               ERROR("cap_set_proc() failed : %m");
+               ret = -1;
+       }
+
+       cap_free(cap);
+       return ret;
+}
+
 int lxc_caps_down(void)
 {
        cap_t caps;
index 6b2764899d66faaf47798772e64a6a70e9f19b0b..4c07b69f67dbf3ebc4e2b82f284c8503a8027dd1 100644 (file)
@@ -23,6 +23,7 @@
 #ifndef _caps_h
 #define _caps_h
 
+extern int lxc_caps_reset(void);
 extern int lxc_caps_down(void);
 extern int lxc_caps_up(void);
 extern int lxc_caps_init(void);
index 5c264c65d23af0fb5042225a1579a4b58b1edecd..a534b51e1593c0af83e3206be2a8fed786f2bac3 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <sys/capability.h>
 #define _GNU_SOURCE
 #include <getopt.h>
 
-#include <lxc/log.h>
-#include <lxc/error.h>
+#include "log.h"
+#include "caps.h"
+#include "error.h"
 #include "utils.h"
 
 lxc_log_define(lxc_init, lxc);
@@ -49,25 +49,6 @@ static struct option options[] = {
 
 static int was_interrupted = 0;
 
-static int cap_reset(void)
-{
-       cap_t cap = cap_init();
-       int ret = 0;
-
-       if (!cap) {
-               ERROR("cap_init() failed : %m");
-               return -1;
-       }
-
-       if (cap_set_proc(cap)) {
-               ERROR("cap_set_proc() failed : %m");
-               ret = -1;
-       }
-
-       cap_free(cap);
-       return ret;
-}
-
 int main(int argc, char *argv[])
 {
 
@@ -95,6 +76,9 @@ int main(int argc, char *argv[])
                nbargs++;
        }
 
+       if (lxc_caps_init())
+               exit(err);
+
        if (lxc_log_init(NULL, 0, basename(argv[0]), quiet))
                exit(err);
 
@@ -128,7 +112,7 @@ int main(int argc, char *argv[])
        if (lxc_setup_fs())
                exit(err);
 
-       if (cap_reset())
+       if (lxc_caps_reset())
                exit(err);
 
        pid = fork();