diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-01-22 10:27:00 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2021-01-22 10:27:00 +0000 |
commit | f57035c7b8ddebd3391b5f83353c02100ea4c202 (patch) | |
tree | d355f80651abd4ec395411067426f31ceb562524 /src/usertree/s6-usertree-maker.c | |
parent | 36752804d4f964ebdbeee62c2c39145f8834d63f (diff) | |
download | s6-f57035c7b8ddebd3391b5f83353c02100ea4c202.tar.xz |
bugfix: multisubstitute order in s6-usertree-maker
Reported by mumahendras.
Diffstat (limited to 'src/usertree/s6-usertree-maker.c')
-rw-r--r-- | src/usertree/s6-usertree-maker.c | 27 |
1 files changed, 15 insertions, 12 deletions
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 ; |