commit f57035c7b8ddebd3391b5f83353c02100ea4c202
parent 36752804d4f964ebdbeee62c2c39145f8834d63f
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Fri, 22 Jan 2021 10:27:00 +0000
bugfix: multisubstitute order in s6-usertree-maker
Reported by mumahendras.
Diffstat:
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git 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 ;