From: Daniel Golle Date: Thu, 15 Jul 2021 01:49:23 +0000 (+0100) Subject: jail: open() extroot folder before mounting X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0114c6fc8b;p=project%2Fprocd.git 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 --- 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;