From 610a46dc7a2b7459929b20e4350b3544e67c0b09 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 3 Jan 2020 12:37:20 +0000 Subject: Nip multicall chroot problems in the bud; only support 1 envdir --- src/alias/s6-frontend-alias-chpst.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/alias/s6-frontend-alias-chpst.c b/src/alias/s6-frontend-alias-chpst.c index 860654e..6611924 100644 --- a/src/alias/s6-frontend-alias-chpst.c +++ b/src/alias/s6-frontend-alias-chpst.c @@ -15,8 +15,6 @@ #include #include #include -#include -#include #include #include @@ -141,9 +139,9 @@ static inline size_t parseuggsym (char const *s, uint32_t *flags, uid_t *uid, gi int main (int argc, char const *const *argv, char const *const *envp) { static char const *valopt[6] = { "-m", "-d", "-o", "-p", "-f", "-c" } ; - genalloc envdirs = GENALLOC_ZERO ; /* char const * */ stralloc newroot = STRALLOC_ZERO ; unsigned int newargc = 0 ; + char const *edir = 0 ; char const *argv0 = 0 ; char const *lockfile = 0 ; char const *envug = 0 ; @@ -196,10 +194,7 @@ int main (int argc, char const *const *argv, char const *const *envp) if (envug[0] == ':') { flags |= 4096 ; envug++ ; newargc++ ; } else flags &= ~4096 ; if (strchr(envug, ':')) { flags |= 8192 ; newargc++ ; } else flags &= ~8192 ; break ; - case 'e' : - if (!genalloc_append(char const *, &envdirs, &l.arg)) dienomem() ; - newargc += 3 ; - break ; + case 'e' : edir = l.arg ; newargc += 3 ; break ; case '/' : newroot.len = 0 ; if (sarealpath(&newroot, l.arg) < 0 || !stralloc_0(&newroot)) dienomem() ; @@ -254,14 +249,11 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = "--" ; } - if (genalloc_len(char const *, &envdirs)) + if (edir) { - for (size_t i = 0 ; i < genalloc_len(char const *, &envdirs) ; i++) - { - newargv[m++] = S6_EXTBINPREFIX "s6-envdir" ; - newargv[m++] = "--" ; - newargv[m++] = genalloc_s(char const *, &envdirs)[i] ; - } + newargv[m++] = S6_EXTBINPREFIX "s6-envdir" ; + newargv[m++] = "--" ; + newargv[m++] = edir ; } if (lockfile) @@ -325,6 +317,12 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = "2" ; } + if (argv0 && newroot.s) + { + argv0 = 0 ; + strerr_warnw1x("the -b option is ineffective when the -/ option is also given") ; + } + if (argv0) { newargv[m++] = EXECLINE_BINPREFIX "exec" ; @@ -337,7 +335,6 @@ int main (int argc, char const *const *argv, char const *const *envp) { newargv[m++] = "chroot" ; newargv[m++] = newroot.s ; - if (argv0) strerr_warnw1x("the -b option is ineffective when the -/ option is also given") ; } for (int i = 0 ; i < argc+1 ; i++) newargv[m++] = argv[i] ; -- cgit v1.2.3