summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-11-30 18:27:41 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-11-30 18:27:41 +0000
commit2fa0acdd248c006270010196ad02e530d8ab09ea (patch)
tree0c5f946f06a1c98d2a35c8eb350dc62d3e97a8ff /src
parentc1171b979c236ec2c486bc12e4866112a12b9a84 (diff)
downloads6-linux-init-2fa0acdd248c006270010196ad02e530d8ab09ea.tar.xz
Adapt to skalibs-2.10.0.0 and s6-2.10.0.0
Diffstat (limited to 'src')
-rw-r--r--src/init/s6-linux-init-maker.c26
-rw-r--r--src/init/s6-linux-init-telinit.c3
-rw-r--r--src/init/s6-linux-init.c9
-rw-r--r--src/shutdown/s6-linux-init-shutdownd.c14
4 files changed, 31 insertions, 21 deletions
diff --git a/src/init/s6-linux-init-maker.c b/src/init/s6-linux-init-maker.c
index f858e5f..1e6de62 100644
--- a/src/init/s6-linux-init-maker.c
+++ b/src/init/s6-linux-init-maker.c
@@ -125,20 +125,20 @@ static int container_crash_script (buffer *b, char const *data)
S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -fnp\n") >= 0 ;
}
-static int container_exit_script (buffer *b, char const *results)
+static int container_exit_script (buffer *b, char const *data)
{
- return put_shebang_options(b, "-S0")
+ (void)data ;
+ return put_shebang(b)
&& buffer_puts(b,
- EXECLINE_EXTBINPREFIX "ifelse -X { test $1 = halt }\n{\n "
- S6_EXTBINPREFIX "s6-envdir -- ") >= 0
- && buffer_puts(b, results) >= 0
- && buffer_puts(b, "\n "
- EXECLINE_EXTBINPREFIX "importas -D0 -- EXITCODE exitcode\n "
- EXECLINE_EXTBINPREFIX "exit $EXITCODE\n}\n"
- EXECLINE_EXTBINPREFIX "ifte -X\n { "
- S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -fnr }\n { "
+ S6_EXTBINPREFIX "s6-envdir -- " S6_LINUX_INIT_TMPFS "/" CONTAINER_RESULTS "\n"
+ EXECLINE_EXTBINPREFIX "multisubstitute\n{\n"
+ " importas -uD0 -- EXITCODE exitcode\n "
+ " importas -uDh -- HALTCODE haltcode\n}\n"
+ EXECLINE_EXTBINPREFIX "ifelse -X { test $HALTCODE = r } { "
+ S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -fnr }\n"
+ EXECLINE_EXTBINPREFIX "ifelse -X { test $HALTCODE = p } { "
S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -fnp }\n"
- "test $1 = reboot\n") >= 0 ;
+ EXECLINE_EXTBINPREFIX "exit $EXITCODE\n") >= 0 ;
}
static int s6_svscan_log_script (buffer *b, char const *data)
@@ -573,8 +573,8 @@ static inline void make_image (char const *base)
if (inns)
{
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/crash", &container_crash_script, "") ;
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/finish", &container_exit_script, S6_LINUX_INIT_TMPFS "/" CONTAINER_RESULTS) ;
+ auto_script(base, "run-image/" SCANDIR "/.s6-svscan/crash", &container_crash_script, 0) ;
+ auto_script(base, "run-image/" SCANDIR "/.s6-svscan/finish", &container_exit_script, 0) ;
auto_dir(base, "run-image/" CONTAINER_RESULTS, 0, 0, 0755) ;
auto_file(base, "run-image/" CONTAINER_RESULTS "/exitcode", "0\n", 2) ;
}
diff --git a/src/init/s6-linux-init-telinit.c b/src/init/s6-linux-init-telinit.c
index cf05a7e..3c8d3fe 100644
--- a/src/init/s6-linux-init-telinit.c
+++ b/src/init/s6-linux-init-telinit.c
@@ -7,6 +7,7 @@
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#include <s6/config.h>
@@ -72,5 +73,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
newargv[2] = 0 ;
}
- xpathexec_run(newargv[0], newargv, envp) ;
+ xexec_e(newargv, envp) ;
}
diff --git a/src/init/s6-linux-init.c b/src/init/s6-linux-init.c
index c68d0f9..9e2d86e 100644
--- a/src/init/s6-linux-init.c
+++ b/src/init/s6-linux-init.c
@@ -21,6 +21,7 @@
#include <skalibs/sig.h>
#include <skalibs/env.h>
#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#include <s6/config.h>
@@ -113,7 +114,7 @@ static inline void run_stage2 (char const *basedir, char const **argv, unsigned
if (fd_copy(2, 1) == -1)
strerr_diefu1sys(111, "fd_copy stdout to stderr") ;
}
- xpathexec_r(childargv, envp, envlen, modifs, modiflen) ;
+ xmexec_fm(childargv, envp, envlen, modifs, modiflen) ;
}
int main (int argc, char const **argv, char const *const *envp)
@@ -131,7 +132,7 @@ int main (int argc, char const **argv, char const *const *envp)
if (getpid() != 1)
{
argv[0] = S6_LINUX_INIT_BINPREFIX "s6-linux-init-telinit" ;
- xpathexec_run(argv[0], argv, envp) ;
+ xexec_e(argv, envp) ;
}
{
@@ -253,7 +254,7 @@ int main (int argc, char const **argv, char const *const *envp)
size_t pathlen = path ? strlen(path) : 0 ;
pid_t pid ;
char fmtfd[2 + UINT_FMT] = "-" ;
- char const *newargv[6] = { S6_EXTBINPREFIX "s6-svscan", "-st0", fmtfd, "--", S6_LINUX_INIT_TMPFS "/" SCANDIR, 0 } ;
+ char const *newargv[5] = { S6_EXTBINPREFIX "s6-svscan", fmtfd, "--", S6_LINUX_INIT_TMPFS "/" SCANDIR, 0 } ;
char pathvar[6 + pathlen] ;
if (path)
{
@@ -284,6 +285,6 @@ int main (int argc, char const **argv, char const *const *envp)
if (fd_copy(2, 1) == -1)
strerr_diefu1sys(111, "redirect output file descriptor") ;
}
- xpathexec_r(newargv, newenvp, !!path, envmodifs.s, envmodifs.len) ;
+ xmexec_fm(newargv, newenvp, !!path, envmodifs.s, envmodifs.len) ;
}
}
diff --git a/src/shutdown/s6-linux-init-shutdownd.c b/src/shutdown/s6-linux-init-shutdownd.c
index 5e681e1..b646b5c 100644
--- a/src/shutdown/s6-linux-init-shutdownd.c
+++ b/src/shutdown/s6-linux-init-shutdownd.c
@@ -43,6 +43,7 @@
#define DOTPREFIXLEN (sizeof(DOTPREFIX) - 1)
#define DOTSUFFIX ":XXXXXX"
#define DOTSUFFIXLEN (sizeof(DOTSUFFIX) - 1)
+#define CONTAINERDIR S6_LINUX_INIT_TMPFS "/" CONTAINER_RESULTS
#define USAGE "s6-linux-init-shutdownd [ -c basedir ] [ -g gracetime ] [ -C ] [ -B ]"
#define dieusage() strerr_dieusage(100, USAGE)
@@ -160,6 +161,14 @@ static inline void prepare_stage4 (char const *basedir, char what)
int fd ;
char buf[512] ;
size_t sabase = satmp.len ;
+ if (inns)
+ {
+ char s[2] = { what, '\n' } ;
+ if (mkdir(CONTAINERDIR, 0755) < 0 && errno != EEXIST)
+ strerr_diefu1sys(111, "mkdir " CONTAINERDIR) ;
+ if (!openwritenclose_unsafe(CONTAINERDIR "/haltcode", s, 2))
+ strerr_diefu1sys(111, "write to " CONTAINERDIR "/haltcode") ;
+ }
unlink_void(STAGE4_FILE ".new") ;
fd = open_excl(STAGE4_FILE ".new") ;
if (fd == -1) strerr_diefu3sys(111, "open ", STAGE4_FILE ".new", " for writing") ;
@@ -174,9 +183,8 @@ static inline void prepare_stage4 (char const *basedir, char what)
|| (!nologger && buffer_puts(&b,
EXECLINE_EXTBINPREFIX "foreground { "
S6_EXTBINPREFIX "s6-svc -Xh -- " SCANPREFIX LOGGER_SERVICEDIR " }\n ") < 0)
- || buffer_puts(&b, S6_EXTBINPREFIX "s6-svscanctl -") < 0
- || buffer_put(&b, what == 'h' ? "s" : &what, 1) < 0
- || buffer_putsflush(&b, "b -- " SCANDIRFULL "\n}\n") < 0)
+ || buffer_puts(&b,
+ S6_EXTBINPREFIX "s6-svscanctl -b -- " SCANDIRFULL "\n}\n") < 0)
strerr_diefu2sys(111, "write to ", STAGE4_FILE ".new") ;
}
else