diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-01-19 01:58:02 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-01-19 01:58:02 +0000 |
commit | 203b2b6f21764f4535bed9779ea7e2cbeb6e43cb (patch) | |
tree | 011d5f0b40f9ac673c2fd877bc5f4b1f2e786088 /src/init/s6-linux-init-maker.c | |
parent | 5e17662d138fc9c9f70a4422eab059c2bdc9432d (diff) | |
download | s6-linux-init-203b2b6f21764f4535bed9779ea7e2cbeb6e43cb.tar.xz |
Small improvements to skel and autogeneration
Diffstat (limited to 'src/init/s6-linux-init-maker.c')
-rw-r--r-- | src/init/s6-linux-init-maker.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/init/s6-linux-init-maker.c b/src/init/s6-linux-init-maker.c index 9277acd..12807aa 100644 --- a/src/init/s6-linux-init-maker.c +++ b/src/init/s6-linux-init-maker.c @@ -90,10 +90,12 @@ static int linewithargs_script (buffer *b, char const *line) static int hpr_script (buffer *b, char const *what) { - return put_shebang_options(b, "-S0") - && buffer_puts(b, S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -") >= 0 - && buffer_puts(b, what) >= 0 - && buffer_puts(b, " $@\n") >= 0 ; + if (!put_shebang_options(b, "-S0") + || buffer_puts(b, S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -") < 0 + || (inns && buffer_puts(b, "n") < 0) + || buffer_puts(b, what) < 0 + || buffer_puts(b, " $@\n") < 0) return 0 ; + return 1 ; } static int death_script (buffer *b, char const *s) @@ -141,18 +143,26 @@ static int container_exit_script (buffer *b, char const *results) static int s6_svscan_log_script (buffer *b, char const *data) { - size_t sabase = satmp.len ; if (!put_shebang(b) || buffer_puts(b, console || inns ? EXECLINE_EXTBINPREFIX "fdmove -c 1 2" : EXECLINE_EXTBINPREFIX "redirfd -w 1 /dev/null") < 0 || buffer_puts(b, "\n" - EXECLINE_EXTBINPREFIX "redirfd -rnb 0 " LOGGER_FIFO "\n" - S6_EXTBINPREFIX "s6-setuidgid ") < 0 - || !string_quote(&satmp, log_user, strlen(log_user))) return 0 ; - if (buffer_put(b, satmp.s + sabase, satmp.len - sabase) < 0) goto err ; - satmp.len = sabase ; - if (buffer_puts(b, "\ns6-log -bpd3 -- ") < 0) return 0 ; + EXECLINE_EXTBINPREFIX "redirfd -rnb 0 " LOGGER_FIFO "\n") < 0) return 0 ; + if (strcmp(log_user, "root")) + { + size_t sabase = satmp.len ; + if (buffer_puts(b, S6_EXTBINPREFIX "s6-setuidgid ") < 0 + || !string_quote(&satmp, log_user, strlen(log_user))) return 0 ; + if (buffer_put(b, satmp.s + sabase, satmp.len - sabase) < 0) + { + satmp.len = sabase ; + return 0 ; + } + satmp.len = sabase ; + if (buffer_puts(b, "\n") < 0) return 0 ; + } + if (buffer_puts(b, "s6-log -bpd3 -- ") < 0) return 0 ; if (console && buffer_puts(b, "1 ") < 0) return 0 ; if (timestamp_style & 1 && buffer_puts(b, "t ") < 0 || timestamp_style & 2 && buffer_puts(b, "T ") < 0 @@ -160,10 +170,6 @@ static int s6_svscan_log_script (buffer *b, char const *data) return 0 ; (void)data ; return 1 ; - - err: - satmp.len = sabase ; - return 0 ; } static int logouthookd_script (buffer *b, char const *data) |