The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/2687

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Fixes: https://discuss.linuxcontainers.org/t/are-lxc-mount-entry-available-when-lxc-hook-start-is-validated/2906/3
Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From 853f3401617ec37c3561d842727e1b0eeca20a1e Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Wed, 10 Oct 2018 13:06:21 +0200
Subject: [PATCH] conf: verify_start_hooks() after lxc.mount.entry

Fixes: 
https://discuss.linuxcontainers.org/t/are-lxc-mount-entry-available-when-lxc-hook-start-is-validated/2906/3
Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 src/lxc/conf.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 856fde1dd..807a38b5d 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -3512,7 +3512,6 @@ static bool verify_start_hooks(struct lxc_conf *conf)
 
        lxc_list_for_each (it, &conf->hooks[LXCHOOK_START]) {
                int ret;
-               struct stat st;
                char *hookname = it->elem;
 
                ret = snprintf(path, PATH_MAX, "%s%s",
@@ -3521,9 +3520,9 @@ static bool verify_start_hooks(struct lxc_conf *conf)
                if (ret < 0 || ret >= PATH_MAX)
                        return false;
 
-               ret = stat(path, &st);
+               ret = access(path, F_OK);
                if (ret < 0) {
-                       SYSERROR("Start hook %s not found in container",
+                       SYSERROR("Start hook \"%s\" not found in container",
                                 hookname);
                        return false;
                }
@@ -3602,10 +3601,6 @@ int lxc_setup(struct lxc_handler *handler)
                return -1;
        }
 
-       /* Make sure any start hooks are in the container */
-       if (!verify_start_hooks(lxc_conf))
-               return -1;
-
        if (lxc_conf->is_execute) {
                if (execveat_supported()) {
                        int fd;
@@ -3673,6 +3668,12 @@ int lxc_setup(struct lxc_handler *handler)
                }
        }
 
+       /* Make sure any start hooks are in the container */
+       if (!verify_start_hooks(lxc_conf)) {
+               ERROR("Failed to verify start hooks");
+               return -1;
+       }
+
        ret = lxc_setup_console(&lxc_conf->rootfs, &lxc_conf->console,
                                lxc_conf->ttys.dir);
        if (ret < 0) {
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to