From 0114c6fc8beae0334e7e2f924e64ab09af046702 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Thu, 15 Jul 2021 02:49:23 +0100 Subject: [PATCH] jail: open() extroot folder before mounting Use open() to trigger autofs mount and check extroot folder exists before mount-binding it. Signed-off-by: Daniel Golle --- jail/jail.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jail/jail.c b/jail/jail.c index dca3992..4cc16c8 100644 --- a/jail/jail.c +++ b/jail/jail.c @@ -641,6 +641,14 @@ static int build_jail_fs(void) } if (opts.extroot) { + /* use stat to trigger autofs mount */ + DEBUG("mounting extroot from %s\n", opts.extroot); + int rootdirfd = open(opts.extroot, O_RDONLY | O_DIRECTORY); + if (rootdirfd == -1) { + ERROR("extroot %s open failed %m\n", opts.extroot); + return -1; + } + close(rootdirfd); if (mount(opts.extroot, jail_root, "bind", MS_BIND, NULL)) { ERROR("extroot mount failed %m\n"); return -1; -- 2.30.2