From f57035c7b8ddebd3391b5f83353c02100ea4c202 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 22 Jan 2021 10:27:00 +0000 Subject: bugfix: multisubstitute order in s6-usertree-maker Reported by mumahendras. --- src/usertree/s6-usertree-maker.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/usertree') diff --git a/src/usertree/s6-usertree-maker.c b/src/usertree/s6-usertree-maker.c index 2d4adb5..6a9a42b 100644 --- a/src/usertree/s6-usertree-maker.c +++ b/src/usertree/s6-usertree-maker.c @@ -59,6 +59,21 @@ static inline void write_run (char const *runfile, char const *user, char const || buffer_put(&b, sa.s, sa.len) < 0 || buffer_put(&b, "\n", 1) < 0) goto err ; sa.len = 0 ; + if (varlen) + { + if (buffer_puts(&b, EXECLINE_EXTBINPREFIX "multisubstitute\n{\n") < 0) goto err ; + for (size_t i = 0 ; i < varlen ; i++) + { + if (!string_quote(&sa, vars[i], strlen(vars[i]))) goto errq ; + if (buffer_puts(&b, " importas -D \"\" -- ") < 0 + || buffer_put(&b, sa.s, sa.len) < 0 + || buffer_put(&b, " ", 1) < 0 + || buffer_put(&b, sa.s, sa.len) < 0 + || buffer_put(&b, "\n", 1) < 0) goto err ; + sa.len = 0 ; + } + if (buffer_put(&b, "}\n", 2) < 0) goto err ; + } } if (buffer_puts(&b, EXECLINE_EXTBINPREFIX "multisubstitute\n{\n" " importas -i USER USER\n" @@ -68,18 +83,6 @@ static inline void write_run (char const *runfile, char const *user, char const " importas -i GIDLIST GIDLIST\n}\n") < 0) goto err ; if (userenvdir && varlen) { - if (buffer_puts(&b, EXECLINE_EXTBINPREFIX "multisubstitute\n{\n") < 0) goto err ; - for (size_t i = 0 ; i < varlen ; i++) - { - if (!string_quote(&sa, vars[i], strlen(vars[i]))) goto errq ; - if (buffer_puts(&b, " importas -D \"\" -- ") < 0 - || buffer_put(&b, sa.s, sa.len) < 0 - || buffer_put(&b, " ", 1) < 0 - || buffer_put(&b, sa.s, sa.len) < 0 - || buffer_put(&b, "\n", 1) < 0) goto err ; - sa.len = 0 ; - } - if (buffer_put(&b, "}\n", 2) < 0) goto err ; for (size_t i = 0 ; i < varlen ; i++) { if (!string_quote(&sa, vars[i], strlen(vars[i]))) goto errq ; -- cgit v1.2.3