]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
fix console overwrite any file
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)
Prevent to specify a file not belonging to us as the output for the console

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

index 1ab2b29e13977798eb2b4adcd3a22a09c79be813..edefc41c2e08fe61167894a981f53bc84a3f7325 100644 (file)
 #include <sys/types.h>
 #include <sys/un.h>
 
-#include <lxc/log.h>
-#include <lxc/conf.h>
-#include <lxc/start.h>         /* for struct lxc_handler */
-
+#include "log.h"
+#include "conf.h"
+#include "start.h"     /* for struct lxc_handler */
+#include "caps.h"
 #include "commands.h"
 #include "mainloop.h"
 #include "af_unix.h"
@@ -192,7 +192,8 @@ int lxc_create_console(struct lxc_conf *conf)
                goto err;
        }
 
-       fd = open(console->path, O_CLOEXEC | O_RDWR | O_CREAT | O_APPEND, 0600);
+       fd = lxc_unpriv(open(console->path, O_CLOEXEC | O_RDWR | O_CREAT |
+                            O_APPEND, 0600));
        if (fd < 0) {
                SYSERROR("failed to open '%s'", console->path);
                goto err;