]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
config: try to create workdir if not exist 3236/head
authordongxinhua <dongxinhua@huawei.com>
Mon, 23 Dec 2019 10:59:29 +0000 (18:59 +0800)
committerStéphane Graber <stgraber@stgraber.org>
Wed, 13 Dec 2023 16:25:40 +0000 (11:25 -0500)
Signed-off-by: dongxinhua <dongxinhua@huawei.com>
src/lxc/start.c

index e1dff590fc0da72c83358b67b9484caf9d1a85e7..d8f641a8d788db704852a1f8ad696f47b82fac2f 100644 (file)
@@ -1326,6 +1326,12 @@ static int do_start(void *data)
        setsid();
 
        if (handler->conf->init_cwd) {
+               struct stat st;
+               if (stat(handler->conf->init_cwd, &st) < 0 && lxc_mkdir_p(handler->conf->init_cwd, 0755) < 0) {
+                       SYSERROR("Try to create directory \"%s\" as workdir failed", handler->conf->init_cwd);
+                       goto out_warn_father;
+               }
+
                ret = chdir(handler->conf->init_cwd);
                if (ret < 0) {
                        SYSERROR("Could not change directory to \"%s\"",