summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xskel/rc.init11
-rw-r--r--src/init/s6-linux-init-maker.c36
2 files changed, 32 insertions, 15 deletions
diff --git a/skel/rc.init b/skel/rc.init
index 47824d7..4c7211f 100755
--- a/skel/rc.init
+++ b/skel/rc.init
@@ -36,3 +36,14 @@ shift
### override the default.
# exec /etc/s6-linux-init/current/scripts/runlevel "$rl"
+
+
+### If this script is run in a container, then 1. and 2. above do not
+### apply and you should just call your CMD, if any, or let your
+### services run.
+### Something like this:
+
+# if test -z "$*" ; then return 0 ; fi
+# $@
+# echo $? > /run/s6-linux-init-container-results/exitcode
+# halt
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)