aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-11-04 22:23:28 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2025-11-04 22:23:28 +0000
commit3b56d41ef579c18feafbf47d170a6ea4375beb6f (patch)
tree87d634d029dba1f786d04df4f35b75af996c74b3
parent2ea40fd0c6b05d29edf5a3b62f4c0f1af6e8b8d8 (diff)
downloads6-frontend-3b56d41ef579c18feafbf47d170a6ea4375beb6f.tar.gz
Lots of work done, doesn't build yet, next commit will
- alias subsystem moved to s6 - config subsystem deleted - new helpers subsystem, with a s6-frontend-helper-kill program - new s6f_equote function, to execline-quote an argv - started the adaptation to the new s6-rc functions, in progress
-rw-r--r--INSTALL5
-rwxr-xr-xconfigure92
-rw-r--r--doc/index.html2
-rw-r--r--package/configure-snippets/configure_case_lines10
-rw-r--r--package/configure-snippets/configure_expand_dirs2
-rw-r--r--package/configure-snippets/configure_generate_configh42
-rw-r--r--package/configure-snippets/configure_generate_make21
-rw-r--r--package/configure-snippets/configure_help_install4
-rw-r--r--package/configure-snippets/configure_help_options3
-rw-r--r--package/configure-snippets/configure_init_vars10
-rw-r--r--package/deps-build8
-rw-r--r--package/deps.mak44
-rw-r--r--package/modes5
-rw-r--r--package/targets.mak90
-rw-r--r--src/alias/deps-exe/s6-frontend-alias-chpst3
-rw-r--r--src/alias/deps-exe/s6-frontend-alias-sv3
-rw-r--r--src/alias/s6-frontend-alias-chpst.c344
-rw-r--r--src/alias/s6-frontend-alias-sv.c448
-rw-r--r--src/alias/s6-frontend-alias.c229
-rw-r--r--src/config/deps-exe/s6-frontend-config-preprocess1
-rw-r--r--src/config/s6-frontend-config-preprocess.c286
-rw-r--r--src/config/s6-frontend-config-preprocess.txt38
-rw-r--r--src/helpers/deps-exe/s6-frontend-helper-kill (renamed from src/alias/deps-exe/s6-frontend-alias)0
-rw-r--r--src/helpers/s6-frontend-helper-kill.c31
-rw-r--r--src/include-local/s6f.h7
-rw-r--r--src/libs6f/deps-lib/s6f1
-rw-r--r--src/libs6f/s6f_equote.c24
-rw-r--r--src/libs6f/s6f_user_get_confdirs.c2
-rw-r--r--src/s6-frontend/help.c2
-rw-r--r--src/s6-frontend/process.c98
-rw-r--r--src/s6-frontend/process_kill.c70
-rw-r--r--src/s6-frontend/process_restart.c26
-rw-r--r--src/s6-frontend/process_startstop.c36
-rw-r--r--src/s6-frontend/process_status.c2
-rw-r--r--src/s6-frontend/s6-frontend-internal.h (renamed from src/s6-frontend/s6-internal.h)37
-rw-r--r--src/s6-frontend/s6-frontend.c87
-rw-r--r--src/s6-frontend/s6.c6
-rw-r--r--src/s6-frontend/service.c4
-rw-r--r--src/s6-frontend/service_startstop.c2
-rw-r--r--src/s6-frontend/service_status.c2
40 files changed, 371 insertions, 1756 deletions
diff --git a/INSTALL b/INSTALL
index 710ab8a..6daa312 100644
--- a/INSTALL
+++ b/INSTALL
@@ -9,9 +9,10 @@ Build Instructions
- skalibs version 2.14.5.0 or later: https://skarnet.org/software/skalibs/
- nsss version 0.2.1.1 or later: https://skarnet.org/software/nsss/
- execline version 2.9.8.0 or later: https://skarnet.org/software/execline/
- - s6 version 2.13.3.0 or later: https://skarnet.org/software/s6/
+ - s6 version 2.14.0.0 or later: https://skarnet.org/software/s6/
- s6-rc version 0.6.0.0 or later: https://skarnet.org/software/s6-rc/
- - s6-linux-init version 1.2.0.0 or later: https://skarnet.org/software/s6-linux-init/
+ - optional: s6-linux-init version 1.2.0.0 or later: https://skarnet.org/software/s6-linux-init/
+ - optional: util-linux v2.41.2 or later: https://en.wikipedia.org/wiki/Util-linux
* Standard usage
diff --git a/configure b/configure
index ffd610d..e888aa2 100755
--- a/configure
+++ b/configure
@@ -28,10 +28,10 @@ Fine tuning of the installation directories:
--scandir=DIR assume s6-svscan is running on DIR [s6li default: /run/service]
--livedir=DIR run s6-rc live directory in DIR [s6-rc default: /run/s6-rc]
--repodir=DIR default s6-rc repository [s6-rc default: /var/lib/s6-frontend/repository]
- --bootdir=DIR location of the bootable s6-rc compiled db [/etc/s6-rc]
+ --bootdb=LINK location of the bootable s6-rc compiled db [s6-rc default: /etc/s6-rc/compiled/current]
--stmpdir=DIR secure location for temporary s6-frontend files [/run/s6-frontend]
--conffile=FILE default configuration file for s6 command [SYSCONFDIR/s6-frontend.conf]
- --with-def-path=PATH path to service files [LIBDIR/s6-frontend/s6-rc/source:SYSCONFDIR/s6-frontend/s6-rc/source]
+ --with-store-path=PATH path to service stores [PREFIX/share/s6-frontend/s6-rc/sources:SYSCONFDIR/s6-frontend/s6-rc/sources]
If no --prefix option is given, by default libdir (but not dynlibdir) will be
/usr/lib, and includedir will be /usr/include.
@@ -57,9 +57,6 @@ Optional features:
--enable-nsss use the nsss library for user information [disabled]
--disable-s6li do not use s6-linux-init functionality [enabled]
--enable-util-linux use util-linux functionality [disabled]
- --enable-aliases-daemontools build emulation of daemontools programs [disabled]
- --enable-aliases-runit build emulation of runit programs [disabled]
- --disable-aliases-symlinks do not create daemontools/runit multicall symlinks [enabled]
EOF
exit 0
@@ -182,17 +179,15 @@ vpathd=''
build=
scandir=
livedir=
-repodir=/var/lib/s6-frontend/s6-rc/repository
-bootdir=/etc/s6-rc
+repodir=
+bootdb=
stmpdir=/run/s6-frontend
conffile='$sysconfdir/s6-frontend.conf'
-defpath='$libdir/s6-frontend/s6-rc/source:$sysconfdir/s6-frontend/s6-rc/source'
+storepath='$prefix/share/s6-rc/sources:$sysconfdir/s6-rc/sources'
+
usensss=false
uses6li=true
useutillinux=false
-adaemontools=false
-arunit=false
-asymlinks=true
for arg ; do
case "$arg" in
@@ -233,22 +228,16 @@ for arg ; do
--scandir=*) scandir=${arg#*=} ;;
--livedir=*) livedir=${arg#*=} ;;
--repodir=*) repodir=${arg#*=} ;;
- --bootdir=*) bootdir=${arg#*=} ;;
+ --bootdb=*) bootdb=${arg#*=} ;;
--stmpdir=*) stmpdir=${arg#*=} ;;
--conffile=*) conffile=${arg#*=} ;;
- --with-def-path=*) defpath=${arg#*=} ;;
+ --with-store-path=*) storepath=${arg#*=} ;;
--enable-nsss|--enable-nsss=yes) usensss=true ;;
--disable-nsss|--enable-nsss=no) usensss=false ;;
--enable-s6li|--enable-s6li=yes) uses6li=true ;;
--disable-s6li|--enable-s6li=no) uses6li=false ;;
--enable-util-linux|--enable-util-linux=yes) useutillinux=true ;;
--disable-util-linux|--enable-util-linux=no) useutillinux=false ;;
- --enable-aliases-daemontools|--enable-aliases-daemontools=yes) adaemontools=true ;;
- --disable-aliases-daemontools|--enable-aliases-daemontools=no) adaemontools=false ;;
- --enable-aliases-runit|--enable-aliases-runit=yes) arunit=true ;;
- --disable-aliases-runit|--enable-aliases-runit=no) arunit=false ;;
- --enable-aliases-symlinks|--enable-aliases-symlinks=yes) asymlinks=true ;;
- --disable-aliases-symlinks|--enable-aliases-symlinks=no) asymlinks=false ;;
--enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
--enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
--host=*|--target=*) target=${arg#*=} ;;
@@ -277,7 +266,7 @@ fi
# Expand installation directories
stripdir prefix
-for i in exec_prefix dynlibdir libexecdir bindir libdir includedir sysconfdir pkgconfdir sysdeps sproot stmpdir conffile defpath ; do
+for i in exec_prefix dynlibdir libexecdir bindir libdir includedir sysconfdir pkgconfdir sysdeps sproot stmpdir conffile storepath ; do
eval tmp=\${$i}
eval $i=$tmp
stripdir $i
@@ -554,10 +543,12 @@ if $allpic ; then
else
echo "STATIC_LIBS_ARE_PIC :="
fi
+echo "SCANDIR := $scandir"
+echo "LIVEDIR := $livedir"
echo "REPODIR := $repodir"
-echo "BOOTDIR := $bootdir"
+echo "BOOTDB := $bootdb"
echo "STMPDIR := $stmpdir"
-echo "DEFPATH := $defpath"
+echo "STOREPATH := $storepath"
if $usensss ; then
echo "LIBNSSS := -lnsss"
@@ -566,21 +557,6 @@ else
echo "LIBNSSS :="
echo "MAYBEPTHREAD_LIB :="
fi
-if $adaemontools ; then
- echo "WRAP_DAEMONTOOLS := 1"
-else
- echo "WRAP_DAEMONTOOLS :="
-fi
-if $arunit ; then
- echo "WRAP_RUNIT := 1"
-else
- echo "WRAP_RUNIT :="
-fi
-if $asymlinks ; then
- echo "WRAP_SYMLINKS := 1"
-else
- echo "WRAP_SYMLINKS :="
-fi
exec 1>&3 3>&-
echo " ... done."
@@ -633,45 +609,49 @@ else
echo "#define ${package_macro_name}_SCANDIR $scandirdefault"
fi
+needs6rcconfig=true
echo "#undef ${package_macro_name}_LIVEDIR"
if test -n "$livedir" ; then
echo "#define ${package_macro_name}_LIVEDIR \"$livedir\""
else
- echo "#include <s6-rc/config.h>"
- echo "#define ${package_macro_name}_LIVEDIR S6RC_LIVE_BASE"
+ if $needs6rcconfig ; then
+ needs6rcconfig=false
+ echo "#include <s6-rc/config.h>"
+ fi
+ echo "#define ${package_macro_name}_LIVEDIR S6RC_LIVEDIR"
fi
echo "#undef ${package_macro_name}_REPODIR"
if test -n "$repodir" ; then
echo "#define ${package_macro_name}_REPODIR \"$repodir\""
else
- if test -n "$livedir" ; then
+ if $needs6rcconfig ; then
+ needs6rcconfig=false
echo "#include <s6-rc/config.h>"
fi
- echo "#define ${package_macro_name}_REPODIR S6RC_REPO_BASE"
+ echo "#define ${package_macro_name}_REPODIR S6RC_REPODIR"
fi
-echo "#undef ${package_macro_name}_BOOTDIR"
-echo "#define ${package_macro_name}_BOOTDIR \"$bootdir\""
+echo "#undef ${package_macro_name}_BOOTDB"
+if test -n "$bootdb" ; then
+ echo "#define ${package_macro_name}_BOOTDB \"$bootdb\""
+else
+ if $needs6rcconfig ; then
+ needs6rcconfig=false
+ echo "#include <s6-rc/config.h>"
+ fi
+ echo "#define ${package_macro_name}_BOOTDB S6RC_BOOTDB"
+fi
echo "#undef ${package_macro_name}_STMPDIR"
echo "#define ${package_macro_name}_STMPDIR \"$stmpdir\""
-echo "#undef ${package_macro_name}_CONFFILE"
-echo "#define ${package_macro_name}_CONFFILE \"$conffile\""
-
-echo "#undef ${package_macro_name}_DEFPATH"
-echo "#define ${package_macro_name}_DEFPATH \"$defpath\""
+echo "#undef ${package_macro_name}_CONF"
+echo "#define ${package_macro_name}_CONF \"$conffile\""
-echo "#undef ${package_macro_name}_WRAP_DAEMONTOOLS"
-if $adaemontools ; then
- echo "#define ${package_macro_name}_WRAP_DAEMONTOOLS"
-fi
+echo "#undef ${package_macro_name}_STOREPATH"
+echo "#define ${package_macro_name}_STOREPATH \"$storepath\""
-echo "#undef ${package_macro_name}_WRAP_RUNIT"
-if $arunit ; then
- echo "#define ${package_macro_name}_WRAP_RUNIT"
-fi
echo
echo "#endif"
exec 1>&3 3>&-
diff --git a/doc/index.html b/doc/index.html
index bae229b..e262f5b 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -73,7 +73,7 @@ they implement a powerful, fast, turnkey init system that is usable on
<li> <a href="//skarnet.org/software/execline/">execline</a> version
2.9.8.0 or later </li>
<li> <a href="//skarnet.org/software/s6/">s6</a> version
-2.13.3.0 or later </li>
+2.14.0.0 or later </li>
<li> <a href="//skarnet.org/software/s6-rc/">s6-rc</a> version
0.6.0.0 or later </li>
<li> <a href="//skarnet.org/software/s6-linux-init/">s6-linux-init</a> version
diff --git a/package/configure-snippets/configure_case_lines b/package/configure-snippets/configure_case_lines
index 2844a69..c8ddb82 100644
--- a/package/configure-snippets/configure_case_lines
+++ b/package/configure-snippets/configure_case_lines
@@ -1,19 +1,13 @@
--scandir=*) scandir=${arg#*=} ;;
--livedir=*) livedir=${arg#*=} ;;
--repodir=*) repodir=${arg#*=} ;;
- --bootdir=*) bootdir=${arg#*=} ;;
+ --bootdb=*) bootdb=${arg#*=} ;;
--stmpdir=*) stmpdir=${arg#*=} ;;
--conffile=*) conffile=${arg#*=} ;;
- --with-def-path=*) defpath=${arg#*=} ;;
+ --with-store-path=*) storepath=${arg#*=} ;;
--enable-nsss|--enable-nsss=yes) usensss=true ;;
--disable-nsss|--enable-nsss=no) usensss=false ;;
--enable-s6li|--enable-s6li=yes) uses6li=true ;;
--disable-s6li|--enable-s6li=no) uses6li=false ;;
--enable-util-linux|--enable-util-linux=yes) useutillinux=true ;;
--disable-util-linux|--enable-util-linux=no) useutillinux=false ;;
- --enable-aliases-daemontools|--enable-aliases-daemontools=yes) adaemontools=true ;;
- --disable-aliases-daemontools|--enable-aliases-daemontools=no) adaemontools=false ;;
- --enable-aliases-runit|--enable-aliases-runit=yes) arunit=true ;;
- --disable-aliases-runit|--enable-aliases-runit=no) arunit=false ;;
- --enable-aliases-symlinks|--enable-aliases-symlinks=yes) asymlinks=true ;;
- --disable-aliases-symlinks|--enable-aliases-symlinks=no) asymlinks=false ;;
diff --git a/package/configure-snippets/configure_expand_dirs b/package/configure-snippets/configure_expand_dirs
index dcf795f..7b2c617 100644
--- a/package/configure-snippets/configure_expand_dirs
+++ b/package/configure-snippets/configure_expand_dirs
@@ -1 +1 @@
-stmpdir conffile defpath
+stmpdir conffile storepath
diff --git a/package/configure-snippets/configure_generate_configh b/package/configure-snippets/configure_generate_configh
index 23ce34c..b5b2179 100644
--- a/package/configure-snippets/configure_generate_configh
+++ b/package/configure-snippets/configure_generate_configh
@@ -19,42 +19,46 @@ else
echo "#define ${package_macro_name}_SCANDIR $scandirdefault"
fi
+needs6rcconfig=true
echo "#undef ${package_macro_name}_LIVEDIR"
if test -n "$livedir" ; then
echo "#define ${package_macro_name}_LIVEDIR \"$livedir\""
else
- echo "#include <s6-rc/config.h>"
- echo "#define ${package_macro_name}_LIVEDIR S6RC_LIVE_BASE"
+ if $needs6rcconfig ; then
+ needs6rcconfig=false
+ echo "#include <s6-rc/config.h>"
+ fi
+ echo "#define ${package_macro_name}_LIVEDIR S6RC_LIVEDIR"
fi
echo "#undef ${package_macro_name}_REPODIR"
if test -n "$repodir" ; then
echo "#define ${package_macro_name}_REPODIR \"$repodir\""
else
- if test -n "$livedir" ; then
+ if $needs6rcconfig ; then
+ needs6rcconfig=false
echo "#include <s6-rc/config.h>"
fi
- echo "#define ${package_macro_name}_REPODIR S6RC_REPO_BASE"
+ echo "#define ${package_macro_name}_REPODIR S6RC_REPODIR"
fi
-echo "#undef ${package_macro_name}_BOOTDIR"
-echo "#define ${package_macro_name}_BOOTDIR \"$bootdir\""
+echo "#undef ${package_macro_name}_BOOTDB"
+if test -n "$bootdb" ; then
+ echo "#define ${package_macro_name}_BOOTDB \"$bootdb\""
+else
+ if $needs6rcconfig ; then
+ needs6rcconfig=false
+ echo "#include <s6-rc/config.h>"
+ fi
+ echo "#define ${package_macro_name}_BOOTDB S6RC_BOOTDB"
+fi
echo "#undef ${package_macro_name}_STMPDIR"
echo "#define ${package_macro_name}_STMPDIR \"$stmpdir\""
-echo "#undef ${package_macro_name}_CONFFILE"
-echo "#define ${package_macro_name}_CONFFILE \"$conffile\""
-
-echo "#undef ${package_macro_name}_DEFPATH"
-echo "#define ${package_macro_name}_DEFPATH \"$defpath\""
+echo "#undef ${package_macro_name}_CONF"
+echo "#define ${package_macro_name}_CONF \"$conffile\""
-echo "#undef ${package_macro_name}_WRAP_DAEMONTOOLS"
-if $adaemontools ; then
- echo "#define ${package_macro_name}_WRAP_DAEMONTOOLS"
-fi
+echo "#undef ${package_macro_name}_STOREPATH"
+echo "#define ${package_macro_name}_STOREPATH \"$storepath\""
-echo "#undef ${package_macro_name}_WRAP_RUNIT"
-if $arunit ; then
- echo "#define ${package_macro_name}_WRAP_RUNIT"
-fi
diff --git a/package/configure-snippets/configure_generate_make b/package/configure-snippets/configure_generate_make
index 3603f53..da6004c 100644
--- a/package/configure-snippets/configure_generate_make
+++ b/package/configure-snippets/configure_generate_make
@@ -1,7 +1,9 @@
+echo "SCANDIR := $scandir"
+echo "LIVEDIR := $livedir"
echo "REPODIR := $repodir"
-echo "BOOTDIR := $bootdir"
+echo "BOOTDB := $bootdb"
echo "STMPDIR := $stmpdir"
-echo "DEFPATH := $defpath"
+echo "STOREPATH := $storepath"
if $usensss ; then
echo "LIBNSSS := -lnsss"
@@ -10,18 +12,3 @@ else
echo "LIBNSSS :="
echo "MAYBEPTHREAD_LIB :="
fi
-if $adaemontools ; then
- echo "WRAP_DAEMONTOOLS := 1"
-else
- echo "WRAP_DAEMONTOOLS :="
-fi
-if $arunit ; then
- echo "WRAP_RUNIT := 1"
-else
- echo "WRAP_RUNIT :="
-fi
-if $asymlinks ; then
- echo "WRAP_SYMLINKS := 1"
-else
- echo "WRAP_SYMLINKS :="
-fi
diff --git a/package/configure-snippets/configure_help_install b/package/configure-snippets/configure_help_install
index 8be3412..080a30e 100644
--- a/package/configure-snippets/configure_help_install
+++ b/package/configure-snippets/configure_help_install
@@ -1,7 +1,7 @@
--scandir=DIR assume s6-svscan is running on DIR [s6li default: /run/service]
--livedir=DIR run s6-rc live directory in DIR [s6-rc default: /run/s6-rc]
--repodir=DIR default s6-rc repository [s6-rc default: /var/lib/s6-frontend/repository]
- --bootdir=DIR location of the bootable s6-rc compiled db [/etc/s6-rc]
+ --bootdb=LINK location of the bootable s6-rc compiled db [s6-rc default: /etc/s6-rc/compiled/current]
--stmpdir=DIR secure location for temporary s6-frontend files [/run/s6-frontend]
--conffile=FILE default configuration file for s6 command [SYSCONFDIR/s6-frontend.conf]
- --with-def-path=PATH path to service files [LIBDIR/s6-frontend/s6-rc/source:SYSCONFDIR/s6-frontend/s6-rc/source]
+ --with-store-path=PATH path to service stores [PREFIX/share/s6-frontend/s6-rc/sources:SYSCONFDIR/s6-frontend/s6-rc/sources]
diff --git a/package/configure-snippets/configure_help_options b/package/configure-snippets/configure_help_options
index 8ef4317..877c5d9 100644
--- a/package/configure-snippets/configure_help_options
+++ b/package/configure-snippets/configure_help_options
@@ -1,7 +1,4 @@
--enable-nsss use the nsss library for user information [disabled]
--disable-s6li do not use s6-linux-init functionality [enabled]
--enable-util-linux use util-linux functionality [disabled]
- --enable-aliases-daemontools build emulation of daemontools programs [disabled]
- --enable-aliases-runit build emulation of runit programs [disabled]
- --disable-aliases-symlinks do not create daemontools/runit multicall symlinks [enabled]
diff --git a/package/configure-snippets/configure_init_vars b/package/configure-snippets/configure_init_vars
index e0b2853..6325b8a 100644
--- a/package/configure-snippets/configure_init_vars
+++ b/package/configure-snippets/configure_init_vars
@@ -1,13 +1,11 @@
scandir=
livedir=
-repodir=/var/lib/s6-frontend/s6-rc/repository
-bootdir=/etc/s6-rc
+repodir=
+bootdb=
stmpdir=/run/s6-frontend
conffile='$sysconfdir/s6-frontend.conf'
-defpath='$libdir/s6-frontend/s6-rc/source:$sysconfdir/s6-frontend/s6-rc/source'
+storepath='$prefix/share/s6-rc/sources:$sysconfdir/s6-rc/sources'
+
usensss=false
uses6li=true
useutillinux=false
-adaemontools=false
-arunit=false
-asymlinks=true
diff --git a/package/deps-build b/package/deps-build
index 4298f5b..32e84d9 100644
--- a/package/deps-build
+++ b/package/deps-build
@@ -1,6 +1,6 @@
true true /package/prog/skalibs 2.14.5.0 libskarnet
-$usensss $usensss /package/admin/nsss 0.2.1.0 libnsss
-true false /package/admin/execline 2.9.7.0 libexecline
-true false /package/admin/s6 2.13.3.0 libs6 libs6auto
+$usensss $usensss /package/admin/nsss 0.2.1.1 libnsss
+true false /package/admin/execline 2.9.8.0 libexecline
+true false /package/admin/s6 2.14.0.0 libs6 libs6auto
true false /package/admin/s6-rc 0.6.0.0 libs6rc
-true false /package/admin/s6-linux-init 1.1.3.0
+true false /package/admin/s6-linux-init 1.2.0.0
diff --git a/package/deps.mak b/package/deps.mak
index e28fdce..c5f3895 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -2,40 +2,32 @@
# This file has been generated by tools/gen-deps.sh
#
-src/s6-frontend/s6-internal.h: src/include/s6-frontend/config.h src/include-local/s6f.h
-src/alias/s6-frontend-alias-chpst.o src/alias/s6-frontend-alias-chpst.lo: src/alias/s6-frontend-alias-chpst.c
-src/alias/s6-frontend-alias-sv.o src/alias/s6-frontend-alias-sv.lo: src/alias/s6-frontend-alias-sv.c
-src/alias/s6-frontend-alias.o src/alias/s6-frontend-alias.lo: src/alias/s6-frontend-alias.c src/include/s6-frontend/config.h
-src/config/s6-frontend-config-preprocess.o src/config/s6-frontend-config-preprocess.lo: src/config/s6-frontend-config-preprocess.c
+src/s6-frontend/s6-frontend-internal.h: src/include/s6-frontend/config.h src/include-local/s6f.h
+src/helpers/s6-frontend-helper-kill.o src/helpers/s6-frontend-helper-kill.lo: src/helpers/s6-frontend-helper-kill.c
src/libs6f/s6f_confdir_open.o src/libs6f/s6f_confdir_open.lo: src/libs6f/s6f_confdir_open.c src/include-local/s6f.h
+src/libs6f/s6f_equote.o src/libs6f/s6f_equote.lo: src/libs6f/s6f_equote.c src/include-local/s6f.h
src/libs6f/s6f_lock.o src/libs6f/s6f_lock.lo: src/libs6f/s6f_lock.c src/include-local/s6f.h
src/libs6f/s6f_report_state_change.o src/libs6f/s6f_report_state_change.lo: src/libs6f/s6f_report_state_change.c src/include-local/s6f.h
src/libs6f/s6f_user_get_confdirs.o src/libs6f/s6f_user_get_confdirs.lo: src/libs6f/s6f_user_get_confdirs.c src/include-local/s6f.h
-src/s6-frontend/help.o src/s6-frontend/help.lo: src/s6-frontend/help.c src/s6-frontend/s6-internal.h
-src/s6-frontend/process.o src/s6-frontend/process.lo: src/s6-frontend/process.c src/s6-frontend/s6-internal.h
-src/s6-frontend/process_kill.o src/s6-frontend/process_kill.lo: src/s6-frontend/process_kill.c src/s6-frontend/s6-internal.h
-src/s6-frontend/process_restart.o src/s6-frontend/process_restart.lo: src/s6-frontend/process_restart.c src/s6-frontend/s6-internal.h
-src/s6-frontend/process_startstop.o src/s6-frontend/process_startstop.lo: src/s6-frontend/process_startstop.c src/s6-frontend/s6-internal.h
-src/s6-frontend/process_status.o src/s6-frontend/process_status.lo: src/s6-frontend/process_status.c src/s6-frontend/s6-internal.h
-src/s6-frontend/s6-frontend.o src/s6-frontend/s6-frontend.lo: src/s6-frontend/s6-frontend.c src/include/s6-frontend/config.h src/s6-frontend/s6-internal.h
+src/s6-frontend/help.o src/s6-frontend/help.lo: src/s6-frontend/help.c src/include-local/s6-internal.h
+src/s6-frontend/process.o src/s6-frontend/process.lo: src/s6-frontend/process.c src/include-local/s6-internal.h
+src/s6-frontend/process_kill.o src/s6-frontend/process_kill.lo: src/s6-frontend/process_kill.c src/s6-frontend/s6-frontend-internal.h src/include-local/s6f.h
+src/s6-frontend/process_restart.o src/s6-frontend/process_restart.lo: src/s6-frontend/process_restart.c src/include-local/s6-internal.h
+src/s6-frontend/process_startstop.o src/s6-frontend/process_startstop.lo: src/s6-frontend/process_startstop.c src/s6-frontend/s6-frontend-internal.h
+src/s6-frontend/process_status.o src/s6-frontend/process_status.lo: src/s6-frontend/process_status.c src/include-local/s6-internal.h
+src/s6-frontend/s6-frontend.o src/s6-frontend/s6-frontend.lo: src/s6-frontend/s6-frontend.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h
src/s6-frontend/s6.o src/s6-frontend/s6.lo: src/s6-frontend/s6.c src/include/s6-frontend/config.h
-src/s6-frontend/service.o src/s6-frontend/service.lo: src/s6-frontend/service.c src/s6-frontend/s6-internal.h
-src/s6-frontend/service_startstop.o src/s6-frontend/service_startstop.lo: src/s6-frontend/service_startstop.c src/s6-frontend/s6-internal.h
-src/s6-frontend/service_status.o src/s6-frontend/service_status.lo: src/s6-frontend/service_status.c src/s6-frontend/s6-internal.h
-src/s6-frontend/util.o src/s6-frontend/util.lo: src/s6-frontend/util.c src/s6-frontend/s6-internal.h
+src/s6-frontend/service.o src/s6-frontend/service.lo: src/s6-frontend/service.c src/include-local/s6-internal.h
+src/s6-frontend/service_startstop.o src/s6-frontend/service_startstop.lo: src/s6-frontend/service_startstop.c src/include-local/s6-internal.h
+src/s6-frontend/service_status.o src/s6-frontend/service_status.lo: src/s6-frontend/service_status.c src/include-local/s6-internal.h
+src/s6-frontend/util.o src/s6-frontend/util.lo: src/s6-frontend/util.c src/include-local/s6-internal.h
-s6-frontend-alias: EXTRA_LIBS :=
-s6-frontend-alias: src/alias/s6-frontend-alias.o -lskarnet
-s6-frontend-alias-chpst: EXTRA_LIBS := ${MAYBEPTHREAD_LIB}
-s6-frontend-alias-chpst: src/alias/s6-frontend-alias-chpst.o ${LIBNSSS} -lskarnet
-s6-frontend-alias-sv: EXTRA_LIBS := ${SPAWN_LIB}
-s6-frontend-alias-sv: src/alias/s6-frontend-alias-sv.o -ls6 -lskarnet
-s6-frontend-config-preprocess: EXTRA_LIBS :=
-s6-frontend-config-preprocess: src/config/s6-frontend-config-preprocess.o -lskarnet
+s6-frontend-helper-kill: EXTRA_LIBS :=
+s6-frontend-helper-kill: src/helpers/s6-frontend-helper-kill.o -lskarnet
ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)
-libs6f.a.xyzzy: src/libs6f/s6f_confdir_open.o src/libs6f/s6f_lock.o src/libs6f/s6f_report_state_change.o src/libs6f/s6f_user_get_confdirs.o
+libs6f.a.xyzzy: src/libs6f/s6f_confdir_open.o src/libs6f/s6f_equote.o src/libs6f/s6f_lock.o src/libs6f/s6f_report_state_change.o src/libs6f/s6f_user_get_confdirs.o
else
-libs6f.a.xyzzy:src/libs6f/s6f_confdir_open.lo src/libs6f/s6f_lock.lo src/libs6f/s6f_report_state_change.lo src/libs6f/s6f_user_get_confdirs.lo
+libs6f.a.xyzzy:src/libs6f/s6f_confdir_open.lo src/libs6f/s6f_equote.lo src/libs6f/s6f_lock.lo src/libs6f/s6f_report_state_change.lo src/libs6f/s6f_user_get_confdirs.lo
endif
s6: EXTRA_LIBS :=
s6: src/s6-frontend/s6.o -lskarnet
diff --git a/package/modes b/package/modes
index 2c9188f..5245abe 100644
--- a/package/modes
+++ b/package/modes
@@ -1,6 +1,3 @@
s6 0755
s6-frontend 0755
-s6-frontend-config-preprocess 0755
-s6-frontend-alias 0755
-s6-frontend-alias-sv 0755
-s6-frontend-alias-chpst 0755
+s6-frontend-helper-kill 0755
diff --git a/package/targets.mak b/package/targets.mak
index 2cdb392..13bab6f 100644
--- a/package/targets.mak
+++ b/package/targets.mak
@@ -2,92 +2,6 @@ BIN_TARGETS := \
s6 \
s6-frontend
-LIBEXEC_TARGETS :=
+LIBEXEC_TARGETS := \
+s6-frontend-helper-kill \
-WRAP_ANY :=
-
-ifdef WRAP_DAEMONTOOLS
-
-WRAP_ANY := 1
-
-ifdef WRAP_SYMLINKS
-
-DAEMONTOOLS_TARGETS := \
-envdir \
-envuidgid \
-fghack \
-multilog \
-pgrphack \
-readproctitle \
-setlock \
-setuidgid \
-softlimit \
-supervise \
-svc \
-svok \
-svscan \
-svscanboot \
-svstat \
-tai64n \
-tai64nlocal
-
-else
-
-DAEMONTOOLS_TARGETS :=
-
-endif
-
-install-bin: $(DAEMONTOOLS_TARGETS:%=$(DESTDIR)$(bindir)/%)
-
-ifneq ($(exthome),)
-global-links: $(DAEMONTOOLS_TARGETS:%=$(DESTDIR)$(sproot)/command/%)
-endif
-
-endif
-
-ifdef WRAP_RUNIT
-
-WRAP_ANY := 1
-
-ifdef WRAP_SYMLINKS
-
-RUNIT_TARGETS := \
-runit \
-runit-init \
-runsv \
-runsvchdir \
-runsvdir \
-svlogd \
-utmpset
-RUNIT_SPECIAL_TARGETS := chpst sv
-
-else
-
-RUNIT_TARGETS :=
-RUNIT_SPECIAL_TARGETS :=
-
-endif
-
-BIN_TARGETS += s6-frontend-alias-sv s6-frontend-alias-chpst
-
-install-bin: $(RUNIT_TARGETS:%=$(DESTDIR)$(bindir)/%) $(RUNIT_SPECIAL_TARGETS:%=$(DESTDIR)$(bindir)/%)
-
-ifneq ($(exthome),)
-global-links: $(RUNIT_TARGETS:%=$(DESTDIR)$(sproot)/command/%) $(RUNIT_SPECIAL_TARGETS:%=$(DESTDIR)$(sproot)/command/%)
-endif
-
-$(DESTDIR)$(bindir)/chpst: $(DESTDIR)$(bindir)/s6-frontend-alias-chpst
- exec $(INSTALL) -D -l s6-frontend-alias-chpst $@
-$(DESTDIR)$(bindir)/sv: $(DESTDIR)$(bindir)/s6-frontend-alias-sv
- exec $(INSTALL) -D -l s6-frontend-alias-sv $@
-
-endif
-
-ifdef WRAP_ANY
-
-BIN_TARGETS += s6-frontend-alias
-
-$(DAEMONTOOLS_TARGETS:%=$(DESTDIR)$(bindir)/%) $(RUNIT_TARGETS:%=$(DESTDIR)$(bindir)/%): $(DESTDIR)$(bindir)/s6-frontend-alias
- exec $(INSTALL) -D -l s6-frontend-alias $@
-
-endif
diff --git a/src/alias/deps-exe/s6-frontend-alias-chpst b/src/alias/deps-exe/s6-frontend-alias-chpst
deleted file mode 100644
index ee4ed0b..0000000
--- a/src/alias/deps-exe/s6-frontend-alias-chpst
+++ /dev/null
@@ -1,3 +0,0 @@
-${LIBNSSS}
--lskarnet
-${MAYBEPTHREAD_LIB}
diff --git a/src/alias/deps-exe/s6-frontend-alias-sv b/src/alias/deps-exe/s6-frontend-alias-sv
deleted file mode 100644
index b3e8440..0000000
--- a/src/alias/deps-exe/s6-frontend-alias-sv
+++ /dev/null
@@ -1,3 +0,0 @@
--ls6
--lskarnet
-${SPAWN_LIB}
diff --git a/src/alias/s6-frontend-alias-chpst.c b/src/alias/s6-frontend-alias-chpst.c
deleted file mode 100644
index 7232d60..0000000
--- a/src/alias/s6-frontend-alias-chpst.c
+++ /dev/null
@@ -1,344 +0,0 @@
- /* ISC license. */
-
-#include <string.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <errno.h>
-#include <pwd.h>
-#include <grp.h>
-
-#include <skalibs/uint64.h>
-#include <skalibs/types.h>
-#include <skalibs/bytestr.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/buffer.h>
-#include <skalibs/strerr.h>
-#include <skalibs/exec.h>
-
-#include <execline/config.h>
-
-#include <s6/config.h>
-
-#define USAGE "s6-frontend-alias-chpst [ -v ] [ -P ] [ -0 ] [ -1 ] [ -2 ] [ -u user ] [ -U user ] [ -b argv0 ] [ -e dir ] [ -n niceness ] [ -l lock | -L lock ] [ -m bytes ] [ -d bytes ] [ -o n ] [ -p n ] [ -f bytes ] [ -c bytes ] prog..."
-
-#define dienomem() strerr_diefu1sys(111, "stralloc_catb")
-#define dieusage() strerr_dieusage(100, USAGE)
-
-static unsigned int verbosity = 0 ;
-
-static void printit (char const *const *argv)
-{
- buffer_puts(buffer_2, PROG) ;
- buffer_puts(buffer_2, ": info: executing the following command line:") ;
- for (; *argv ; argv++)
- {
- buffer_puts(buffer_2, " ") ;
- buffer_puts(buffer_2, *argv) ;
- }
- buffer_putsflush(buffer_2, "\n") ;
-}
-
-static inline size_t parseuggnum (char const *s, uint32_t *flags, uid_t *uid, gid_t *gid, gid_t *tab)
-{
- size_t n = 0 ;
- size_t pos = uid_scan(s, uid) ;
- if (!pos) dieusage() ;
- if (!s[pos]) return 0 ;
- if (s[pos] != ':') dieusage() ;
- s += pos+1 ;
- pos = gid_scan(s, gid) ;
- if (!pos) dieusage() ;
- *flags |= 32768 ;
- if (!s[pos]) return 0 ;
- if (s[pos] != ':') dieusage() ;
- s += pos+1 ;
- if (!gid_scanlist(tab, NGROUPS_MAX, s, &n)) dieusage() ;
- return n ;
-}
-
-static struct passwd *do_getpwnam (char const *s)
-{
- struct passwd *pw = getpwnam(s) ;
- if (!pw)
- {
- if (errno) strerr_diefu1sys(111, "read user database") ;
- else strerr_dief2x(100, "user not found in user database: ", s) ;
- }
- return pw ;
-}
-
-static struct group *do_getgrnam (char const *s)
-{
- struct group *gr = getgrnam(s) ;
- if (!gr)
- {
- if (errno) strerr_diefu1sys(111, "read group database") ;
- else strerr_dief2x(100, "group not found in group database: ", s) ;
- }
- return gr ;
-}
-
-static inline size_t parseuggsym (char const *s, uint32_t *flags, uid_t *uid, gid_t *gid, gid_t *tab)
-{
- size_t n = 0 ;
- struct passwd *pw ;
- struct group *gr ;
- size_t pos = str_chr(s, ':') ;
- *flags |= 32768 ;
- errno = 0 ;
- if (!s[pos]) pw = do_getpwnam(s) ;
- else
- {
- char tmp[pos+1] ;
- memcpy(tmp, s, pos) ;
- tmp[pos] = 0 ;
- pw = do_getpwnam(tmp) ;
- }
- *uid = pw->pw_uid ;
- if (!s[pos])
- {
- *gid = pw->pw_gid ;
- return 0 ;
- }
- s += pos+1 ;
- pos = str_chr(s, ':') ;
- errno = 0 ;
- if (!s[pos]) gr = do_getgrnam(s) ;
- else
- {
- char tmp[pos+1] ;
- memcpy(tmp, s, pos) ;
- tmp[pos] = 0 ;
- gr = do_getgrnam(tmp) ;
- }
- *gid = gr->gr_gid ;
- if (!s[pos]) return 0 ;
- s += pos+1 ;
- while (*s)
- {
- if (n >= NGROUPS_MAX)
- strerr_dief1x(100, "too many supplementary groups listed for the -u option") ;
- pos = str_chr(s, ':') ;
- errno = 0 ;
- if (!s[pos]) gr = do_getgrnam(s) ;
- else
- {
- char tmp[pos+1] ;
- memcpy(tmp, s, pos) ;
- tmp[pos] = 0 ;
- gr = do_getgrnam(tmp) ;
- }
- tab[n++] = gr->gr_gid ;
- s += s[pos] ? pos+1 : pos ;
- }
- return n ;
-}
-
-int main (int argc, char const *const *argv)
-{
- static char const *valopt[6] = { "-m", "-d", "-o", "-p", "-f", "-c" } ;
- unsigned int newargc = 0 ;
- char const *newroot = 0 ;
- char const *edir = 0 ;
- char const *argv0 = 0 ;
- char const *lockfile = 0 ;
- char const *envug = 0 ;
- uint32_t flags = 0 ;
- int niceval = 0 ;
- char valfmt[6][UINT64_FMT] ;
- char nicefmt[INT_FMT] ;
- char uidfmt[UID_FMT] ;
- char gidfmt[GID_FMT] ;
- char gidlistfmt[GID_FMT * NGROUPS_MAX] ;
- PROG = "s6-frontend-alias-chpst" ;
-
- {
- subgetopt l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "vP012u:U:b:e:/:n:l:L:m:d:o:p:f:c:", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 'v' : verbosity++ ; break ;
- case '0' : flags |= 1 ; newargc += 2 ; break ;
- case '1' : flags |= 2 ; newargc += 2 ; break ;
- case '2' : flags |= 4 ; newargc += 2 ; break ;
- case 'P' : flags |= 8 ; newargc += 2 ; break ;
- case 'b' : argv0 = l.arg ; newargc += 4 ; break ;
- case 'u' :
- {
- size_t n ;
- uid_t uid ;
- gid_t gid ;
- gid_t tab[NGROUPS_MAX] ;
- newargc += 6 ;
- flags |= 16384 ; flags &= ~32768 ;
- n = l.arg[0] == ':' ?
- parseuggnum(l.arg + 1, &flags, &uid, &gid, tab) :
- parseuggsym(l.arg, &flags, &uid, &gid, tab) ;
- uidfmt[uid_fmt(uidfmt, uid)] = 0 ;
- if (flags & 32768)
- {
- newargc += 2 ;
- gidfmt[gid_fmt(gidfmt, gid)] = 0 ;
- }
- gidlistfmt[gid_fmtlist(gidlistfmt, tab, n)] = 0 ;
- break ;
- }
- case 'U' :
- envug = l.arg ;
- newargc += 3 ;
- if (envug[0] == ':') { flags |= 4096 ; envug++ ; newargc++ ; } else flags &= ~4096 ;
- if (strchr(envug, ':')) { flags |= 8192 ; newargc++ ; } else flags &= ~8192 ;
- break ;
- case 'e' : edir = l.arg ; newargc += 3 ; break ;
- case '/' : newroot = l.arg ; newargc += 2 ; break ;
- case 'n' :
- if (!int0_scan(l.arg, &niceval)) dieusage() ;
- newargc += 3 ;
- break ;
- case 'l' : lockfile = l.arg ; flags &= ~16 ; newargc += 4 ; break ;
- case 'L' : lockfile = l.arg ; flags |= 16 ; newargc += 4 ; break ;
- case 'm' :
- case 'd' :
- case 'o' :
- case 'p' :
- case 'f' :
- case 'c' :
- {
- uint64_t val ;
- size_t pos = byte_chr("mdopfc", 6, opt) ;
- if (!uint640_scan(l.arg, &val)) dieusage() ;
- valfmt[pos][uint64_fmt(valfmt[pos], val)] = 0 ;
- flags |= 32 | (1 << (6 + pos)) ;
- newargc += 2 ;
- break ;
- }
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- }
-
- if (newroot)
- {
- newroot = realpath(newroot, 0) ;
- if (!newroot) dienomem() ;
- }
- if (flags & 32) newargc += 2 ;
- newargc += argc ;
-
- {
- unsigned int m = 0 ;
- char const *newargv[newargc + 1] ;
-
- if (niceval)
- {
- nicefmt[int_fmt(nicefmt, niceval)] = 0 ;
- newargv[m++] = "nice" ;
- newargv[m++] = "-n" ;
- newargv[m++] = nicefmt ;
- newargv[m++] = "--" ;
- }
-
- if (flags & 8)
- {
- newargv[m++] = S6_EXTBINPREFIX "s6-setsid" ;
- newargv[m++] = "--" ;
- }
-
- if (edir)
- {
- newargv[m++] = S6_EXTBINPREFIX "s6-envdir" ;
- newargv[m++] = "--" ;
- newargv[m++] = edir ;
- }
-
- if (lockfile)
- {
- newargv[m++] = S6_EXTBINPREFIX "s6-setlock" ;
- newargv[m++] = flags & 16 ? "-n" : "-N" ;
- newargv[m++] = "--" ;
- newargv[m++] = lockfile ;
- }
-
- if (flags & 16384)
- {
- newargv[m++] = S6_EXTBINPREFIX "s6-applyuidgid" ;
- newargv[m++] = "-u" ;
- newargv[m++] = uidfmt ;
- if (flags & 32768)
- {
- newargv[m++] = "-g" ;
- newargv[m++] = gidfmt ;
- }
- newargv[m++] = "-G" ;
- newargv[m++] = gidlistfmt ;
- newargv[m++] = "--" ;
- }
-
- if (envug)
- {
- newargv[m++] = S6_EXTBINPREFIX "s6-envuidgid" ;
- if (flags & 4096) newargv[m++] = "-n" ;
- if (flags & 8192) newargv[m++] = "-B" ;
- newargv[m++] = "--" ;
- newargv[m++] = envug ;
- }
-
- if (flags & 32)
- {
- newargv[m++] = S6_EXTBINPREFIX "s6-softlimit" ;
- for (unsigned int i = 0 ; i < 6 ; i++) if (flags & (1 << (i + 6)))
- {
- newargv[m++] = valopt[i] ;
- newargv[m++] = valfmt[i] ;
- }
- newargv[m++] = "--" ;
- }
-
- if (flags & 1)
- {
- newargv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ;
- newargv[m++] = "0" ;
- }
-
- if (flags & 2)
- {
- newargv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ;
- newargv[m++] = "1" ;
- }
-
- if (flags & 4)
- {
- newargv[m++] = EXECLINE_EXTBINPREFIX "fdclose" ;
- newargv[m++] = "2" ;
- }
-
- if (argv0 && newroot)
- {
- argv0 = 0 ;
- strerr_warnw1x("the -b option is ineffective when the -/ option is also given") ;
- }
-
- if (argv0)
- {
- newargv[m++] = EXECLINE_BINPREFIX "exec" ;
- newargv[m++] = "-a" ;
- newargv[m++] = argv0 ;
- newargv[m++] = "--" ;
- }
-
- if (newroot)
- {
- newargv[m++] = "chroot" ;
- newargv[m++] = newroot ;
- }
-
- for (int i = 0 ; i < argc+1 ; i++) newargv[m++] = argv[i] ;
- if (verbosity) printit(newargv) ;
- xexec0(newargv) ;
- }
-}
diff --git a/src/alias/s6-frontend-alias-sv.c b/src/alias/s6-frontend-alias-sv.c
deleted file mode 100644
index e55aaaa..0000000
--- a/src/alias/s6-frontend-alias-sv.c
+++ /dev/null
@@ -1,448 +0,0 @@
- /* ISC license. */
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#include <skalibs/uint32.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/buffer.h>
-#include <skalibs/strerr.h>
-#include <skalibs/cspawn.h>
-#include <skalibs/djbunix.h>
-
-#include <s6/config.h>
-#include <s6/supervise.h>
-
-#define USAGE "s6-frontend-alias-sv [ -v ] [ -w sec ] command services..."
-#define dieusage() strerr_dieusage(100, USAGE)
-#define dienomem() strerr_diefu1sys(111, "stralloc_catb")
-
-typedef int exec_func (char const *, char const *const *) ;
-typedef exec_func *exec_func_ref ;
-
-typedef struct info_s info_t, *info_t_ref ;
-struct info_s
-{
- char const *name ;
- exec_func_ref f ;
-} ;
-
-static int dowait = 0 ;
-static uint32_t secs = 7 ;
-
-static void warnnolog (void)
-{
- strerr_warnw1x("s6-svc only sends commands to a single service, even if it has a dedicated logger") ;
-}
-
-static void warnnokill (void)
-{
- strerr_warnw1x("s6-supervise pilots a kill signal via the timeout-kill file in the service directory") ;
-}
-
-static int info_cmp (void const *a, void const *b)
-{
- char const *name = a ;
- info_t const *info = b ;
- return strcmp(name, info->name) ;
-}
-
-static int spawnit (char const *const *argv, char const *const *envp)
-{
- int wstat ;
- pid_t r ;
- pid_t pid = cspawn(argv[0], argv, envp, 0, 0, 0) ;
- if (!pid)
- {
- strerr_warnwu2sys("spawn ", argv[0]) ;
- return 1 ;
- }
- r = wait_pid(pid, &wstat) ;
- if (r != pid)
- {
- strerr_warnwu2sys("wait for ", argv[0]) ;
- return 1 ;
- }
- return !!WIFSIGNALED(wstat) || !!WEXITSTATUS(wstat) ;
-}
-
-static int simple_svc (char const *dir, char const *options, char const *const *envp)
-{
- char const *argv[5] = { S6_EXTBINPREFIX "s6-svc", options, "--", dir, 0 } ;
- return spawnit(argv, envp) ;
-}
-
-static int complex_svc (char const *dir, char const *order, char waitfor, char const *const *envp)
-{
- char warg[4] = "-w?" ;
- char fmt[2 + UINT32_FMT] = "-T" ;
- char const *argv[7] = { S6_EXTBINPREFIX "s6-svc", warg, fmt, order, "--", dir, 0 } ;
- fmt[2 + uint32_fmt(fmt + 2, 1000 * secs)] = 0 ;
- warg[2] = waitfor ;
- return spawnit(argv, envp) ;
-}
-
-static int status (char const *dir, char const *const *envp)
-{
- int e ;
- char const *argv[4] = { S6_EXTBINPREFIX "s6-svstat", "--", dir, 0 } ;
- size_t dirlen = strlen(dir) ;
- buffer_puts(buffer_1, dir) ;
- buffer_putsflush(buffer_1, ": ") ;
- e = spawnit(argv, envp) ;
- if (dirlen < 5 || strcmp(dir + dirlen - 4, "/log"))
- {
- struct stat st ;
- char log[dirlen + 5] ;
- memcpy(log, dir, dirlen) ;
- memcpy(log + dirlen, "/log", 5) ;
- if (stat(log, &st) < 0)
- {
- if (errno != ENOENT)
- {
- strerr_warnwu2sys("stat", log) ;
- e = 1 ;
- }
- }
- else if (S_ISDIR(st.st_mode))
- {
- argv[2] = log ;
- buffer_puts(buffer_1, log) ;
- buffer_putsflush(buffer_1, ": ") ;
- e |= spawnit(argv, envp) ;
- }
- }
- return e ;
-}
-
-static int action (char const *dir, char const *simple, char const *cplx, char waitchar, char const *const *envp)
-{
- if (dowait)
- {
- int e = complex_svc(dir, cplx, waitchar, envp) ;
- return e | status(dir, envp) ;
- }
- else return simple_svc(dir, simple, envp) ;
-}
-
-static int usr1_h (char const *dir, char const *const *envp)
-{
- return simple_svc(dir, "-1", envp) ;
-}
-
-static int usr2_h (char const *dir, char const *const *envp)
-{
- return simple_svc(dir, "-2", envp) ;
-}
-
-static int alarm_h (char const *dir, char const *const *envp)
-{
- return simple_svc(dir, "-a", envp) ;
-}
-
-static int cont_h (char const *dir, char const *const *envp)
-{
- return action(dir, "-c", "-o", 'U', envp) ;
-}
-
-static int down (char const *dir, char const *const *envp)
-{
- return action(dir, "-d", "-d", 'D', envp) ;
-}
-
-static int forcedown (char const *dir, char const *const *envp)
-{
- warnnokill() ;
- return down(dir, envp) ;
-}
-
-static int bail (char const *dir, char const *const *envp)
-{
- int e ;
- warnnolog() ;
- e = action(dir, "-xd", "-d", 'D', envp) ;
- if (dowait) e |= simple_svc(dir, "-x", envp) ;
- return e ;
-}
-
-static int forcebail (char const *dir, char const *const *envp)
-{
- warnnokill() ;
- return bail(dir, envp) ;
-}
-
-static int hup_h (char const *dir, char const *const *envp)
-{
- return simple_svc(dir, "-h", envp) ;
-}
-
-static int int_h (char const *dir, char const *const *envp)
-{
- return simple_svc(dir, "-i", envp) ;
-}
-
-static int kill_h (char const *dir, char const *const *envp)
-{
- return simple_svc(dir, "-k", envp) ;
-}
-
-static int once (char const *dir, char const *const *envp)
-{
- return action(dir, "-o", "-o", 'U', envp) ;
-}
-
-static int pause_h (char const *dir, char const *const *envp)
-{
- return simple_svc(dir, "-p", envp) ;
-}
-
-static int quit_h (char const *dir, char const *const *envp)
-{
- return simple_svc(dir, "-q", envp) ;
-}
-
-static int term_h (char const *dir, char const *const *envp)
-{
- return action(dir, "-t", "-r", 'R', envp) ;
-}
-
-static int up (char const *dir, char const *const *envp)
-{
- return action(dir, "-u", "-u", 'U', envp) ;
-}
-
-static int check (char const *dir, char const *const *envp)
-{
- int e ;
- s6_svstatus_t svst ;
- char warg[3] = "-?" ;
- char fmt[2 + UINT32_FMT] = "-t" ;
- char const *argv[6] = { S6_EXTBINPREFIX "s6-svwait", warg, fmt, "--", dir, 0 } ;
- fmt[2 + uint32_fmt(fmt + 2, 1000 * secs)] = 0 ;
- if (!s6_svstatus_read(dir, &svst)) return 1 ;
- warg[1] = svst.flagwantup ? 'U' : 'D' ;
- e = spawnit(argv, envp) ;
- return e | status(dir, envp) ;
-}
-
-static int lsb_reload (char const *dir, char const *const *envp)
-{
- hup_h(dir, envp) ;
- return status(dir, envp) ;
-}
-
-static int lsb_restart (char const *dir, char const *const *envp)
-{
- int e = complex_svc(dir, "-ru", 'U', envp) ;
- return e | status(dir, envp) ;
-}
-
-static int lsb_start (char const *dir, char const *const *envp)
-{
- int e = complex_svc(dir, "-u", 'U', envp) ;
- return e | status(dir, envp) ;
-}
-
-static int lsb_stop (char const *dir, char const *const *envp)
-{
- int e = complex_svc(dir, "-d", 'D', envp) ;
- return e | status(dir, envp) ;
-}
-
-static int lsb_shutdown (char const *dir, char const *const *envp)
-{
- int e ;
- warnnolog() ;
- e = complex_svc(dir, "-d", 'D', envp) ;
- e |= status(dir, envp) ;
- return e | simple_svc(dir, "-x", envp) ;
-}
-
-static int lsb_forcereload (char const *dir, char const *const *envp)
-{
- warnnokill() ;
- return lsb_reload(dir, envp) ;
-}
-
-static int lsb_forcerestart (char const *dir, char const *const *envp)
-{
- warnnokill() ;
- return lsb_restart(dir, envp) ;
-}
-
-static int lsb_forcestop (char const *dir, char const *const *envp)
-{
- warnnokill() ;
- return lsb_stop(dir, envp) ;
-}
-
-static int lsb_forceshutdown (char const *dir, char const *const *envp)
-{
- warnnokill() ;
- return lsb_shutdown(dir, envp) ;
-}
-
-static int lsb_tryrestart (char const *dir, char const *const *envp)
-{
- int e = 0 ;
- s6_svstatus_t svst ;
- if (s6_svstatus_read(dir, &svst) && svst.flagwantup && svst.pid && !svst.flagfinishing)
- e = complex_svc(dir, "-r", 'U', envp) ;
- return e | status(dir, envp) ;
-}
-
-static int lsb_forcetryrestart (char const *dir, char const *const *envp)
-{
- warnnokill() ;
- return lsb_tryrestart(dir, envp) ;
-}
-
-static info_t const commands[] =
-{
- { .name = "1", .f = &usr1_h },
- { .name = "2", .f = &usr2_h },
- { .name = "D", .f = &forcedown },
- { .name = "E", .f = &forcebail },
- { .name = "T", .f = &lsb_forcetryrestart },
- { .name = "X", .f = &forcebail },
- { .name = "a", .f = &alarm_h },
- { .name = "al", .f = &alarm_h },
- { .name = "ala", .f = &alarm_h },
- { .name = "alar", .f = &alarm_h },
- { .name = "alarm", .f = &alarm_h },
- { .name = "c", .f = &cont_h },
- { .name = "check", .f = &check },
- { .name = "co", .f = &cont_h },
- { .name = "con", .f = &cont_h },
- { .name = "cont", .f = &cont_h },
- { .name = "d", .f = &down },
- { .name = "do", .f = &down },
- { .name = "dow", .f = &down },
- { .name = "down", .f = &down },
- { .name = "e", .f = &bail },
- { .name = "ex", .f = &bail },
- { .name = "exi", .f = &bail },
- { .name = "exit", .f = &bail },
- { .name = "force-reload", .f = &lsb_forcereload },
- { .name = "force-restart", .f = &lsb_forcerestart },
- { .name = "force-shutdown", .f = &lsb_forceshutdown },
- { .name = "force-stop", .f = &lsb_forcestop },
- { .name = "h", .f = &hup_h },
- { .name = "hu", .f = &hup_h },
- { .name = "hup", .f = &hup_h },
- { .name = "i", .f = &int_h },
- { .name = "in", .f = &int_h },
- { .name = "int", .f = &int_h },
- { .name = "inte", .f = &int_h },
- { .name = "inter", .f = &int_h },
- { .name = "interr", .f = &int_h },
- { .name = "interru", .f = &int_h },
- { .name = "interrup", .f = &int_h },
- { .name = "interrupt", .f = &int_h },
- { .name = "k", .f = &kill_h },
- { .name = "ki", .f = &kill_h },
- { .name = "kil", .f = &kill_h },
- { .name = "kill", .f = &kill_h },
- { .name = "o", .f = &once },
- { .name = "on", .f = &once },
- { .name = "onc", .f = &once },
- { .name = "once", .f = &once },
- { .name = "p", .f = &pause_h },
- { .name = "pa", .f = &pause_h },
- { .name = "pau", .f = &pause_h },
- { .name = "paus", .f = &pause_h },
- { .name = "pause", .f = &pause_h },
- { .name = "q", .f = &quit_h },
- { .name = "qu", .f = &quit_h },
- { .name = "qui", .f = &quit_h },
- { .name = "quit", .f = &quit_h },
- { .name = "reload", .f = &lsb_reload },
- { .name = "restart", .f = &lsb_restart },
- { .name = "s", .f = &status },
- { .name = "shutdown", .f = &lsb_shutdown },
- { .name = "st", .f = &status },
- { .name = "sta", .f = &status },
- { .name = "start", .f = &lsb_start },
- { .name = "stat", .f = &status },
- { .name = "statu", .f = &status },
- { .name = "status", .f = &status },
- { .name = "stop", .f = &lsb_stop },
- { .name = "t", .f = &term_h },
- { .name = "te", .f = &term_h },
- { .name = "ter", .f = &term_h },
- { .name = "term", .f = &term_h },
- { .name = "try-restart", .f = &lsb_tryrestart },
- { .name = "u", .f = &up },
- { .name = "up", .f = &up },
- { .name = "x", .f = &bail }
-} ;
-
-int main (int argc, char const *const *argv, char const *const *envp)
-{
- int e = 0 ;
- info_t *p ;
- char const *x = getenv("SVWAIT") ;
- char const *scandir = getenv("SVDIR") ;
- size_t scandirlen ;
- PROG = "s6-frontend-alias-sv" ;
- if (!scandir) scandir = "/run/service" ; /* TODO: infer from s6li config */
- scandirlen = strlen(scandir) ;
- if (x)
- {
- if (!uint320_scan(x, &secs))
- strerr_warnw1x("invalid SVWAIT value") ;
- }
-
- {
- subgetopt l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "vw:", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 'v' : dowait = 1 ; break ;
- case 'w' : if (!uint320_scan(l.arg, &secs)) dieusage() ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- }
-
- if (argc < 2) dieusage() ;
- p = bsearch(argv[0], commands, sizeof(commands) / sizeof(info_t), sizeof(info_t), &info_cmp) ;
- if (!p) strerr_dief2x(100, "unknown command: ", argv[0]) ;
-
- for (argv++ ; *argv ; argv++)
- {
- if (!argv[0][0]) continue ;
- if (argv[0][0] == '/' || argv[0][strlen(argv[0]) - 1] == '/' || (argv[0][0] == '.' && (!argv[0][1] || argv[0][1] == '/' || (argv[0][1] == '.' && (!argv[0][2] || argv[0][2] == '/')))))
- e += (*p->f)(*argv, envp) ;
- else
- {
- int what = 1 ;
- struct stat st ;
- size_t len = strlen(*argv) ;
- char fn[scandirlen + len + 2] ;
- memcpy(fn, scandir, scandirlen) ;
- fn[scandirlen] = '/' ;
- memcpy(fn + scandirlen + 1, *argv, len + 1) ;
- if (stat(fn, &st) < 0) /* XXX: TOCTOU but we don't care */
- {
- if (errno != ENOENT)
- {
- e++ ;
- what = 0 ;
- strerr_warnwu2sys("stat ", fn) ;
- }
- }
- else if (S_ISDIR(st.st_mode)) what = 2 ;
- if (what) e += (*p->f)(what > 1 ? fn : *argv, envp) ;
- }
- }
- return e ;
-}
diff --git a/src/alias/s6-frontend-alias.c b/src/alias/s6-frontend-alias.c
deleted file mode 100644
index ae07489..0000000
--- a/src/alias/s6-frontend-alias.c
+++ /dev/null
@@ -1,229 +0,0 @@
- /* ISC license. */
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <skalibs/buffer.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/strerr.h>
-#include <skalibs/stralloc.h>
-#include <skalibs/djbunix.h>
-#include <skalibs/skamisc.h>
-#include <skalibs/exec.h>
-
-#include <s6/config.h>
-
-#include <s6-frontend/config.h>
-
-#define USAGE "s6-frontend-alias [ -v ] cmdname options..."
-#define dienomem() strerr_diefu1sys(111, "stralloc_catb")
-#define dieusage() strerr_dieusage(100, USAGE)
-
-static unsigned int verbosity = 0 ;
-
-typedef void exec_func (int, char const *const *) ;
-typedef exec_func *exec_func_ref ;
-
-typedef struct info_s info_t, *info_t_ref ;
-struct info_s
-{
- char const *name ;
- char const *cmd ;
- exec_func_ref f ;
-} ;
-
-static int info_cmp (void const *a, void const *b)
-{
- char const *name = a ;
- info_t const *info = b ;
- return strcmp(name, info->name) ;
-}
-
-#if defined(S6_FRONTEND_WRAP_DAEMONTOOLS) || defined (S6_FRONTEND_WRAP_RUNIT)
-static void noboot (char const *name)
-{
- strerr_dief3x(100, "s6 does not provide a ", name, " emulation. To boot on a s6 supervision tree, please consider the s6-linux-init package.") ;
-}
-#endif
-
-#ifdef S6_FRONTEND_WRAP_DAEMONTOOLS
-
-static void readproctitle (int argc, char const *const *argv)
-{
- (void)argc ;
- (void)argv ;
- noboot("readproctitle") ;
-}
-
-static void svscanboot (int argc, char const *const *argv)
-{
- (void)argc ;
- (void)argv ;
- noboot("svscanboot") ;
-}
-
-#endif
-
-#ifdef S6_FRONTEND_WRAP_RUNIT
-
-static void runit (int argc, char const *const *argv)
-{
- (void)argc ;
- (void)argv ;
- noboot("runit") ;
-}
-
-static void runit_init (int argc, char const *const *argv)
-{
- (void)argc ;
- (void)argv ;
- noboot("runit-init") ;
-}
-
-static void runsvchdir (int argc, char const *const *argv)
-{
- (void)argc ;
- (void)argv ;
- strerr_dief1x(100, "s6 does not provide a runsvchdir emulation. To handle several different sets of services, please consider the s6-rc package.") ;
-}
-
-static void runsvdir (int argc, char const *const *argv)
-{
- char const *newargv[4] = { S6_EXTBINPREFIX "s6-svscan", "-t14000", 0, 0 } ;
- int dosetsid = 0 ;
- subgetopt l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "P", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 'P' : dosetsid = 1 ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- if (dosetsid)
- strerr_warnw1x("-P option ignored: s6-svscan does not run its supervisor processes (s6-supervise) in a new session. However, by default, it runs every service in a new session.") ;
- if (argc >= 2)
- strerr_warnw1x("s6-svscan does not support logging to a readproctitle process. To log the output of your supervision tree, please consider using the s6-linux-init package.") ;
- newargv[2] = argv[0] ;
- if (verbosity)
- {
- buffer_puts(buffer_2, PROG) ;
- buffer_puts(buffer_2, ": info: executing command line:") ;
- for (char const *const *p = argv ; *p ; p++)
- {
- buffer_puts(buffer_2, " ") ;
- buffer_puts(buffer_2, *p) ;
- }
- buffer_putsflush(buffer_2, "\n") ;
- }
- xexec(newargv) ;
-}
-
-static void svlogd (int argc, char const *const *argv)
-{
- (void)argc ;
- (void)argv ;
- strerr_dief1x(100, "the s6-log program is similar to svlogd, but uses a different filtering syntax and does not use a config file in the logdir. Please see https://skarnet.org/software/s6/s6-log.html") ;
-}
-
-static void utmpset (int argc, char const *const *argv)
-{
- (void)argc ;
- (void)argv ;
- strerr_dief1x(100, "s6 does not provide a utmpset emulation. To handle utmp records, please consider the s6-linux-init package, along with the utmps package if necessary.") ;
-}
-
-#endif
-
-static info_t const aliases[] =
-{
-#ifdef S6_FRONTEND_WRAP_RUNIT
- { .name = "chpst", .cmd = S6_FRONTEND_BINPREFIX "s6-frontend-alias-chpst", .f = 0 },
-#endif
-#ifdef S6_FRONTEND_WRAP_DAEMONTOOLS
- { .name = "envdir", .cmd = S6_EXTBINPREFIX "s6-envdir", .f = 0 },
- { .name = "envuidgid", .cmd = S6_EXTBINPREFIX "s6-envuidgid", .f = 0 },
- { .name = "fghack", .cmd = S6_EXTBINPREFIX "s6-fghack", .f = 0 },
- { .name = "multilog", .cmd = S6_EXTBINPREFIX "s6-log", .f = 0 },
- { .name = "pgrphack", .cmd = S6_EXTBINPREFIX "s6-setsid", .f = 0 },
- { .name = "readproctitle", .cmd = 0, .f = &readproctitle },
-#endif
-#ifdef S6_FRONTEND_WRAP_RUNIT
- { .name = "runit", .cmd = 0, .f = &runit },
- { .name = "runit-init", .cmd = 0, .f = &runit_init },
- { .name = "runsv", .cmd = S6_EXTBINPREFIX "s6-supervise", .f = 0 },
- { .name = "runsvchdir", .cmd = 0, .f = &runsvchdir },
- { .name = "runsvdir", .cmd = 0, .f = &runsvdir },
-#endif
-#ifdef S6_FRONTEND_WRAP_DAEMONTOOLS
- { .name = "setlock", .cmd = S6_EXTBINPREFIX "s6-setlock", .f = 0 },
- { .name = "setuidgid", .cmd = S6_EXTBINPREFIX "s6-setuidgid", .f = 0 },
- { .name = "softlimit", .cmd = S6_EXTBINPREFIX "s6-softlimit", .f = 0 },
- { .name = "supervise", .cmd = S6_EXTBINPREFIX "s6-supervise", .f = 0 },
-#endif
-#ifdef S6_FRONTEND_WRAP_RUNIT
- { .name = "sv", .cmd = S6_FRONTEND_BINPREFIX "s6-frontend-alias-sv", .f = 0 },
-#endif
-#ifdef S6_FRONTEND_WRAP_DAEMONTOOLS
- { .name = "svc", .cmd = S6_EXTBINPREFIX "s6-svc", .f = 0 },
-#endif
-#ifdef S6_FRONTEND_WRAP_RUNIT
- { .name = "svlogd", .cmd = 0, .f = &svlogd },
-#endif
-#ifdef S6_FRONTEND_WRAP_DAEMONTOOLS
- { .name = "svok", .cmd = S6_EXTBINPREFIX "s6-svok", .f = 0 },
- { .name = "svscan", .cmd = S6_EXTBINPREFIX "s6-svscan", .f = 0 },
- { .name = "svscanboot", .cmd = 0, .f = &svscanboot },
- { .name = "svstat", .cmd = S6_EXTBINPREFIX "s6-svstat", .f = 0 },
- { .name = "tai64n", .cmd = S6_EXTBINPREFIX "s6-tai64n", .f = 0 },
- { .name = "tai64nlocal", .cmd = S6_EXTBINPREFIX "s6-tai64nlocal", .f = 0 },
-#endif
-#ifdef S6_FRONTEND_WRAP_RUNIT
- { .name = "utmpset", .cmd = 0, .f = &utmpset },
-#endif
-} ;
-
-int main (int argc, char const **argv)
-{
- char const *name = argv[0] ;
- stralloc sa = STRALLOC_ZERO ;
- info_t *p ;
- PROG = "s6-frontend-alias" ;
-
- if (!sabasename(&sa, name, strlen(name)) || !stralloc_0(&sa)) dienomem() ;
- if (!strcmp(sa.s, PROG))
- {
- subgetopt l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "v", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 'v' : verbosity++ ; break ;
- default : strerr_dieusage(100, USAGE) ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- if (!argc) dieusage() ;
- name = *argv ;
- stralloc_free(&sa) ;
- }
- else name = sa.s ;
-
- p = bsearch(name, aliases, sizeof(aliases) / sizeof(info_t), sizeof(info_t), &info_cmp) ;
- if (!p) strerr_dief2x(100, "unknown alias: ", name) ;
- if (p->cmd)
- {
- argv[0] = p->cmd ;
- if (verbosity)
- strerr_warni4x("the s6 version of ", name, " is ", p->cmd) ;
- xexec(argv) ;
- }
- else (*p->f)(argc, argv) ;
- strerr_dief1x(101, "can't happen: incorrect alias handler. Please submit a bug-report.") ;
-}
diff --git a/src/config/deps-exe/s6-frontend-config-preprocess b/src/config/deps-exe/s6-frontend-config-preprocess
deleted file mode 100644
index e7187fe..0000000
--- a/src/config/deps-exe/s6-frontend-config-preprocess
+++ /dev/null
@@ -1 +0,0 @@
--lskarnet
diff --git a/src/config/s6-frontend-config-preprocess.c b/src/config/s6-frontend-config-preprocess.c
deleted file mode 100644
index 038b83a..0000000
--- a/src/config/s6-frontend-config-preprocess.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/* ISC license. */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <skalibs/uint64.h>
-#include <skalibs/sgetopt.h>
-#include <skalibs/buffer.h>
-#include <skalibs/strerr.h>
-#include <skalibs/stralloc.h>
-#include <skalibs/genalloc.h>
-#include <skalibs/direntry.h>
-#include <skalibs/djbunix.h>
-#include <skalibs/skamisc.h>
-#include <skalibs/avltree.h>
-
-#define USAGE "s6-frontend-config-preprocess file"
-#define dieusage() strerr_dieusage(100, USAGE)
-#define dienomem() strerr_diefu1sys(111, "stralloc_catb") ;
-#define MAXDEPTH 100
-
-static stralloc sa = STRALLOC_ZERO ;
-static unsigned int depth = 0 ;
-
-
- /* Name storage */
-
-static stralloc namesa = STRALLOC_ZERO ;
-
-static void *name_dtok (uint32_t pos, void *aux)
-{
- (void)aux ;
- return namesa.s + pos ;
-}
-
-static int name_cmp (void const *a, void const *b, void *aux)
-{
- (void)aux ;
- return strcmp((char const *)a, (char const *)b) ;
-}
-
-static avltree namemap = AVLTREE_INIT(8, 3, 8, &name_dtok, &name_cmp, 0) ;
-
-
- /* Directory sorting */
-
-static char *dname_cmp_base ;
-static int dname_cmp (void const *a, void const *b)
-{
- return strcmp(dname_cmp_base + *(size_t *)a, dname_cmp_base + *(size_t *)b) ;
-}
-
-
- /* Recursive inclusion functions */
-
-static int includefromhere (char const *, int) ;
-
-static inline void includecwd (int once)
-{
- genalloc ga = GENALLOC_ZERO ; /* size_t */
- DIR *dir ;
- size_t sabase = sa.len ;
- if (sagetcwd(&sa) < 0 || !stralloc_0(&sa)) dienomem() ;
- dir = opendir(".") ;
- if (!dir) strerr_diefu2sys(111, "opendir ", sa.s + sabase) ;
-
- for (;;)
- {
- direntry *d ;
- errno = 0 ;
- d = readdir(dir) ;
- if (!d) break ;
- if (d->d_name[0] == '.') continue ;
- if (!genalloc_catb(size_t, &ga, &sa.len, 1)) break ;
- if (!stralloc_catb(&sa, d->d_name, strlen(d->d_name)+1)) break ;
- }
- dir_close(dir) ;
- if (errno) strerr_diefu2sys(111, "readdir ", sa.s + sabase) ;
-
- dname_cmp_base = sa.s ;
- qsort(genalloc_s(size_t, &ga), genalloc_len(size_t, &ga), sizeof(size_t), &dname_cmp) ;
-
- for (size_t i = 0 ; i < genalloc_len(size_t, &ga) ; i++)
- if (!includefromhere(sa.s + genalloc_s(size_t, &ga)[i], once))
- strerr_dief4sys(1, "in ", sa.s + sabase, ": unable to include ", sa.s + genalloc_s(size_t, &ga)[i]) ;
-
- genalloc_free(size_t, &ga) ;
- sa.len = sabase ;
-}
-
-static int include (char const *file, int once)
-{
- size_t sabase = sa.len ;
- size_t filelen = strlen(file) ;
- if (!sadirname(&sa, file, filelen) || !stralloc_0(&sa)) dienomem() ;
- if (chdir(sa.s + sabase) < 0) return 0 ;
- sa.len = sabase ;
- if (!sabasename(&sa, file, filelen)) dienomem() ;
- {
- char fn[sa.len + 1 - sabase] ;
- memcpy(fn, sa.s + sabase, sa.len - sabase) ;
- fn[sa.len - sabase] = 0 ;
- sa.len = sabase ;
- return includefromhere(fn, once) ;
- }
-}
-
-static inline int idcmd (char const *s)
-{
- static char const *commands[] =
- {
- "include",
- "includeonce",
- "includedir",
- "includedironce",
- 0
- } ;
- for (char const **p = commands ; *p ; p++)
- if (!strcmp(s, *p)) return p - commands ;
- return -1 ;
-}
-
-static inline unsigned char cclass (char c)
-{
- static unsigned char const classtable[34] = "0444444443144344444444444444444432" ;
- return (unsigned char)c < 34 ? classtable[(unsigned char)c] - '0' : 4 ;
-}
-
-static int includefromhere (char const *file, int once)
-{
- size_t sabase = sa.len ;
- if (sarealpath(&sa, file) < 0 || !stralloc_0(&sa)) return 0 ;
-
- if (once)
- {
- uint32_t dummy ;
- if (avltree_search(&namemap, sa.s + sabase, &dummy)) goto end ;
- {
- size_t cur = namesa.len ;
- size_t filelen = strlen(file) ;
- if (cur + filelen + 2 < cur || cur + filelen + 2 > UINT32_MAX)
- strerr_dief3x(3, "in ", sa.s + sabase, ": too much nesting") ;
- if (!stralloc_catb(&namesa, sa.s + sabase, sa.len - sabase)) dienomem() ;
- if (!avltree_insert(&namemap, cur)) dienomem() ;
- }
- }
-
- if (depth++ > MAXDEPTH)
- strerr_dief3x(3, "in ", sa.s + sabase, ": too much nesting") ;
-
- {
- static unsigned char const table[8][5] =
- {
- { 0x08, 0x10, 0x02, 0x11, 0x11 },
- { 0x08, 0x10, 0x11, 0x11, 0x11 },
- { 0x08, 0x00, 0x03, 0x04, 0x25 },
- { 0x08, 0x00, 0x03, 0x03, 0x03 },
- { 0x09, 0x09, 0x09, 0x04, 0x25 },
- { 0x09, 0x09, 0x09, 0x46, 0x25 },
- { 0x0a, 0x0a, 0x07, 0x06, 0x27 },
- { 0x88, 0x80, 0x27, 0x27, 0x27 }
- } ;
- stralloc localsa = STRALLOC_ZERO ;
- uint64_t line = 1 ;
- size_t sacur = sa.len ;
- int cmd = -1 ;
- buffer b ;
- char buf[4096] ;
- unsigned char state = 0 ;
- int fd = open_readb(file) ;
- if (fd < 0) strerr_diefu2sys(111, "open ", sa.s + sabase) ;
- buffer_init(&b, &buffer_read, fd, buf, 4096) ;
-
- if (buffer_put(buffer_1, "! 0 ", 4) < 4
- || buffer_put(buffer_1, sa.s + sabase, sacur - 1 - sabase) < sacur - 1 - sabase
- || buffer_put(buffer_1, "\n", 1) < 1)
- strerr_diefu1sys(111, "write to stdout") ;
-
- while (state < 8)
- {
- uint16_t what ;
- char c = 0 ;
- if (buffer_get(&b, &c, 1) < 0)
- strerr_diefu2sys(111, "read from ", sa.s + sabase) ;
- what = table[state][cclass((unsigned char)c)] ;
- state = what & 0x000f ;
- if (what & 0x0010)
- if (buffer_put(buffer_1, &c, 1) < 1)
- strerr_diefu1sys(111, "write to stdout") ;
- if (what & 0x0020)
- if (!stralloc_catb(&localsa, &c, 1)) dienomem() ;
- if (what & 0x0040)
- {
- if (!stralloc_0(&localsa)) dienomem() ;
- cmd = idcmd(localsa.s) ;
- if (cmd < 0)
- {
- char fmt[UINT64_FMT] ;
- fmt[uint64_fmt(fmt, line)] = 0 ;
- strerr_dief6x(2, "in ", sa.s + sabase, " line ", fmt, ": unrecognized directive: ", localsa.s) ;
- }
- localsa.len = 0 ;
- }
- if (what & 0x0080)
- {
- int fdhere = open2(".", O_RDONLY) ;
- if (fdhere < 0)
- strerr_dief3sys(111, "in ", sa.s + sabase, ": unable to open base directory: ") ;
- if (!stralloc_0(&localsa)) dienomem() ;
- if (cmd & 2)
- {
- if (chdir(localsa.s) < 0)
- {
- char fmt[UINT64_FMT] ;
- fmt[uint64_fmt(fmt, line)] = 0 ;
- strerr_dief6sys(111, "in ", sa.s + sabase, " line ", fmt, ": unable to chdir to ", localsa.s) ;
- }
- includecwd(cmd & 1) ;
- }
- else if (!include(localsa.s, cmd & 1))
- {
- char fmt[UINT64_FMT] ;
- fmt[uint64_fmt(fmt, line)] = 0 ;
- strerr_dief6sys(111, "in ", sa.s + sabase, " line ", fmt, ": unable to include ", localsa.s) ;
- }
- if (fchdir(fdhere) < 0)
- strerr_dief3sys(111, "in ", sa.s + sabase, ": unable to fchdir back") ;
- fd_close(fdhere) ;
- localsa.len = 0 ;
- {
- char fmt[UINT64_FMT] ;
- size_t fmtlen = uint64_fmt(fmt, line) ;
- fmt[fmtlen++] = ' ' ;
- if (buffer_put(buffer_1, "! ", 2) < 2
- || buffer_put(buffer_1, fmt, fmtlen) < fmtlen
- || buffer_put(buffer_1, sa.s + sabase, sacur - 1 - sabase) < sacur - 1 - sabase
- || buffer_put(buffer_1, "\n", 1) < 1)
- strerr_diefu1sys(111, "write to stdout") ;
- }
- }
- if (c == '\n' && state <= 8) line++ ;
- }
- if (state > 8)
- {
- char fmt[UINT64_FMT] ;
- fmt[uint64_fmt(fmt, line)] = 0 ;
- strerr_dief5x(2, "in ", sa.s + sabase, " line ", fmt, ": syntax error: invalid ! line") ;
- }
- fd_close(fd) ;
- stralloc_free(&localsa) ;
- }
-
- depth-- ;
- end:
- sa.len = sabase ;
- return 1 ;
-}
-
-int main (int argc, char const *const *argv, char const *const *envp)
-{
- PROG = "s6-frontend-config-preprocess" ;
- {
- subgetopt l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- }
- if (!argc) dieusage() ;
-
- if (!include(argv[0], 1)) strerr_diefu2sys(1, "preprocess ", argv[0]) ;
- if (!buffer_flush(buffer_1))
- strerr_diefu1sys(111, "write to stdout") ;
- return 0 ;
-}
diff --git a/src/config/s6-frontend-config-preprocess.txt b/src/config/s6-frontend-config-preprocess.txt
deleted file mode 100644
index e81c86e..0000000
--- a/src/config/s6-frontend-config-preprocess.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-
- Automaton for the preprocessor:
-
-
-class | 0 1 2 3 4
-st\ev | \0 \n ! space other
-
-START | print print print
-0 | END START CMD NORMAL NORMAL
-
-NORMAL | print print print print
-1 | END START NORMAL NORMAL NORMAL
-
-CMD | add
-2 | END START IGNORE CMD1 CMD2
-
-IGNORE |
-3 | END START IGNORE IGNORE IGNORE
-
-CMD1 | add
-4 | X X X CMD1 CMD2
-
-CMD2 | idcmd add
-5 | X X X ARG CMD2
-
-ARG | add
-6 | X X ARG1 ARG ARG1
-
-ARG1 | proc proc add add add
-7 | END START ARG1 ARG1 ARG1
-
-states: 0-7 plus END and X -> 4 bits
-actions: 4. -> 8 bits total, fits in a char.
-
-print 0x10 copies the character to stdout
-add 0x20 adds the character to the processing string
-idcmd 0x40 ids the processing string for an !include cmd
-proc 0x80 gets the filename and procs the include
diff --git a/src/alias/deps-exe/s6-frontend-alias b/src/helpers/deps-exe/s6-frontend-helper-kill
index e7187fe..e7187fe 100644
--- a/src/alias/deps-exe/s6-frontend-alias
+++ b/src/helpers/deps-exe/s6-frontend-helper-kill
diff --git a/src/helpers/s6-frontend-helper-kill.c b/src/helpers/s6-frontend-helper-kill.c
new file mode 100644
index 0000000..c217373
--- /dev/null
+++ b/src/helpers/s6-frontend-helper-kill.c
@@ -0,0 +1,31 @@
+/* ISC license. */
+
+#include <unistd.h>
+#include <signal.h>
+
+#include <skalibs/types.h>
+#include <skalibs/prog.h>
+#include <skalibs/strerr.h>
+
+#define USAGE "s6-frontend-helper-kill signal pid..."
+#define dieusage() strerr_dieusage(100, USAGE)
+
+int main (int argc, char const *const *argv)
+{
+ unsigned int sig ;
+ PROG = "s6-frontend-helper-kill" ;
+ if (argc-- < 3) dieusage() ;
+ argv++ ;
+ if (!uint0_scan(*argv++, &sig)) dieusage() ;
+ argc-- ;
+
+ pid_t pids[argc] ;
+ for (unsigned int i = 0 ; i < argc ; i++)
+ if (!pid0_scan(argv[i], pids + i))
+ strerr_dief1x(100, "pids must be numerical") ;
+
+ for (unsigned int i = 0 ; i < argc ; i++)
+ kill(sig, pids[i]) ;
+
+ _exit(0) ;
+}
diff --git a/src/include-local/s6f.h b/src/include-local/s6f.h
index b11da75..a775eef 100644
--- a/src/include-local/s6f.h
+++ b/src/include-local/s6f.h
@@ -3,7 +3,6 @@
#ifndef S6F_H
#define S6F_H
-#include <sys/stat.h>
#include <stdint.h>
#include <skalibs/stralloc.h>
@@ -14,11 +13,10 @@ struct s6f_confdirs_s
char const *scan ; /* $XDG_RUNTIME_DIR/service */
char const *live ; /* $XDG_RUNTIME_DIR/s6-rc */
char const *repo ; /* $XDG_DATA_HOME/s6-frontend/repository */
- char const *boot ; /* $XDG_CONFIG_HOME/s6-rc */
+ char const *boot ; /* $XDG_CONFIG_HOME/s6-rc/compiled/current */
char const *stmp ; /* $XDG_RUNTIME_DIR/s6-frontend */
} ;
-extern void s6f_mkdirp (char const *, mode_t) ;
extern int s6f_confdir_open (char const *, int) ;
extern int s6f_lock (char const *, int) ;
@@ -26,4 +24,7 @@ extern void s6f_report_state_change (uint32_t, unsigned char const *, unsigned c
extern void s6f_user_get_confdirs (s6f_confdirs *, stralloc *) ;
+extern size_t s6f_equote_space (char const *const *, unsigned int) ;
+extern unsigned int s6f_equote (char const **, char const *const *, unsigned int, char *) ;
+
#endif
diff --git a/src/libs6f/deps-lib/s6f b/src/libs6f/deps-lib/s6f
index 464cc81..b1d1ddb 100644
--- a/src/libs6f/deps-lib/s6f
+++ b/src/libs6f/deps-lib/s6f
@@ -1,4 +1,5 @@
s6f_confdir_open.o
+s6f_equote.o
s6f_lock.o
s6f_report_state_change.o
s6f_user_get_confdirs.o
diff --git a/src/libs6f/s6f_equote.c b/src/libs6f/s6f_equote.c
new file mode 100644
index 0000000..41cef42
--- /dev/null
+++ b/src/libs6f/s6f_equote.c
@@ -0,0 +1,24 @@
+/* ISC license. */
+
+#include <string.h>
+
+#include "s6f.h"
+
+size_t s6f_equote_space (char const *const *argv, unsigned int argc)
+{
+ size_t l = 0 ;
+ for (unsigned int i = 0 ; i < argc ; i++) l += i + 2 + strlen(argv[i]) ;
+ return l ;
+}
+
+unsigned int s6f_equote (char const **newargv, char const *const *argv, unsigned int argc, char *s)
+{
+ for (unsigned int i = 0 ; i < argc ; i++)
+ {
+ newargv[i] = s ;
+ *s++ = ' ' ;
+ s = stpcpy(s, argv[i]) + 1 ;
+ }
+ newargv[argc] = "" ;
+ return argc + 1 ;
+}
diff --git a/src/libs6f/s6f_user_get_confdirs.c b/src/libs6f/s6f_user_get_confdirs.c
index b062650..5617bf9 100644
--- a/src/libs6f/s6f_user_get_confdirs.c
+++ b/src/libs6f/s6f_user_get_confdirs.c
@@ -68,7 +68,7 @@ void s6f_user_get_confdirs (s6f_confdirs *dirs, stralloc *storage)
bootpos = storage->len ;
if (!(confighome ? stralloc_cats(storage, confighome) : stralloc_cats(storage, home) && stralloc_cats(storage, "/.config"))
- || !stralloc_cats(storage, "/s6-rc")
+ || !stralloc_cats(storage, "/s6-rc/compiled/current")
|| !stralloc_0(storage)) dienomem() ;
stmppos = storage->len ;
diff --git a/src/s6-frontend/help.c b/src/s6-frontend/help.c
index ac2205c..f2832c6 100644
--- a/src/s6-frontend/help.c
+++ b/src/s6-frontend/help.c
@@ -3,7 +3,7 @@
#include <skalibs/buffer.h>
#include <skalibs/strerr.h>
-#include "s6-internal.h"
+#include "s6-frontend-internal.h"
#define MAIN_HELP_MESSAGE "This is the main help message.\n"
diff --git a/src/s6-frontend/process.c b/src/s6-frontend/process.c
index 1dca89d..bce29c6 100644
--- a/src/s6-frontend/process.c
+++ b/src/s6-frontend/process.c
@@ -1,18 +1,18 @@
/* ISC license. */
#include <string.h>
-#include <sys/stat.h>
#include <errno.h>
+#include <skalibs/uint64.h>
+#include <skalibs/stat.h>
+#include <skalibs/types.h>
#include <skalibs/posixplz.h>
-#include <skalibs/prog.h>
-#include <skalibs/strerr.h>
-#include <skalibs/cspawn.h>
+#include <skalibs/envexec.h>
#include <skalibs/djbunix.h>
#include <s6/config.h>
-#include "s6-internal.h"
+#include "s6-frontend-internal.h"
#define USAGE "s6 process [ process options ] subcommand [ subcommand options ] services... Type \"s6 process help\" for details."
#define dieusage() strerr_dieusage(100, USAGE)
@@ -31,7 +31,7 @@ static int check_service (char const *name, size_t scandirlen)
void process_check_services (char const *const *argv, size_t argc)
{
- size_t scandirlen = strlen(g->dirs.scan) ;
+ size_t const scandirlen = strlen(g->dirs.scan) ;
for (size_t i = 0 ; i < argc ; i++)
{
int r = check_service(argv[i], scandirlen) ;
@@ -42,48 +42,82 @@ void process_check_services (char const *const *argv, size_t argc)
}
}
-int process_send_svc (char const *svcopt, char const *const *argv, size_t argc)
+void process_send_svc (char const *svcopt, char const *const *argv, size_t argc, unsigned int timeout)
{
- char const *newargv[5] = { S6_EXTBINPREFIX "s6-svc", svcopt, "--", 0, 0 } ;
- size_t scandirlen = strlen(g->dirs.scan) ;
- int wstat ;
- pid_t pids[argc] ;
+ size_t const scandirlen = strlen(g->dirs.scan) ;
+ size_t len = 0 ;
+ unsigned int m = 0 ;
+ for (size_t i = 0 ; i < argc ; i++) len += scandirlen + 2 + strlen(argv[i]) ;
+ char const *newargv[4 + (timeout ? 2 : 0) + argc] ;
+ char s[len] ;
+ char fmtt[timeout ? UINT_FMT : 1] ;
+ newargv[m++] = S6_EXTBINPREFIX "s6-svc" ;
+ newargv[m++] = svcopt ;
+ if (timeout)
+ {
+ fmtt[uint_fmt(fmtt, timeout)] = 0 ;
+ newargv[m++] = "-T" ;
+ newargv[m++] = fmtt ;
+ }
+ newargv[m++] = "--" ;
+
+ len = 0 ;
for (size_t i = 0 ; i < argc ; i++)
{
- size_t arglen = strlen(argv[i]) ;
- char path[scandirlen + arglen + 2] ;
- memcpy(path, g->dirs.scan, scandirlen) ;
- path[scandirlen] = '/' ;
- memcpy(path + scandirlen + 1, argv[i], arglen) ;
- path[scandirlen + 1 + arglen] = 0 ;
- newargv[3] = path ;
- pids[i] = cspawn(newargv[0], newargv, (char const *const *)environ, 0, 0, 0) ;
- if (!pids[i])
- strerr_diefu4sys(111, "spawn ", newargv[0], " command for service ", argv[i]) ;
+ size_t l = strlen(argv[i]) ;
+ newargv[m++] = s + len ;
+ memcpy(s + len, g->dirs.scan, scandirlen) ; len += scandirlen ;
+ s[len++] = '/' ;
+ memcpy(s + len, argv[i], l + 1) ; len += l + 1 ;
}
- waitn_posix(pids, argc, &wstat) ;
- return 0 ;
+ newargv[m++] = 0 ;
+ xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ;
}
-static struct command_s const process_commands[] =
+enum golb_e
+{
+ GOLB_WAIT = 0x01,
+} ;
+
+enum gola_e
{
- { .s = "help", .f = &process_help },
- { .s = "kill", .f = &process_kill },
- { .s = "restart", .f = &process_restart },
- { .s = "start", .f = &process_start },
- { .s = "status", .f = &process_status },
- { .s = "stop", .f = &process_stop },
+ GOLA_TIMEOUT,
+ GOLA_N
} ;
int process (char const *const *argv)
{
+ static struct command_s const process_commands[] =
+ {
+ { .s = "help", .f = &process_help },
+ { .s = "kill", .f = &process_kill },
+ { .s = "restart", .f = &process_restart },
+ { .s = "start", .f = &process_start },
+ { .s = "status", .f = &process_status },
+ { .s = "stop", .f = &process_stop },
+ } ;
+ static gol_bool const rgolb[] =
+ {
+ { .so = 'W', .lo = "nowait", .clear = GOLB_WAIT, .set = 0 },
+ { .so = 'w', .lo = "wait", .clear = 0, .set = GOLB_WAIT }
+ } ;
+ static gol_arg const rgola[] =
+ {
+ { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT },
+ } ;
+
struct command_s *cmd ;
+ process_options options = PROCESS_OPTIONS_ZERO ;
+ char const *wgola[GOLA_N] = { 0 } ;
- PROG = "s6 process" ;
+ PROG = "s6-frontend: process" ;
+ argv += GOL_argv(argv, rgolb, rgola, &options.flags, wgola) ;
if (!*argv) dieusage() ;
+ if (wgola[GOLA_TIMEOUT] && !uint0_scan(wgola[GOLA_TIMEOUT], &options.timeout))
+ strerr_dief1x(100, "timeout must be a numerical argument (milliseconds)") ;
cmd = BSEARCH(struct command_s, *argv, process_commands) ;
if (!cmd) dieusage() ;
- return (*cmd->f)(++argv) ;
+ return (*cmd->f)(++argv, &options) ;
}
diff --git a/src/s6-frontend/process_kill.c b/src/s6-frontend/process_kill.c
index 64f7ffb..2a28d8f 100644
--- a/src/s6-frontend/process_kill.c
+++ b/src/s6-frontend/process_kill.c
@@ -4,6 +4,7 @@
#include <signal.h>
#include <unistd.h>
+#include <skalibs/gccattributes.h>
#include <skalibs/uint64.h>
#include <skalibs/posixplz.h>
#include <skalibs/types.h>
@@ -14,21 +15,40 @@
#include <s6/supervise.h>
-#include "s6-internal.h"
+#include "s6f.h"
+#include "s6-frontend-internal.h"
#define USAGE "s6 process kill [ --signal=sig ] services..."
#define dieusage() strerr_dieusage(100, USAGE)
-static int process_kill_hack_kill (int sig, char const *const *argv)
+static void process_kill_hack_kill (int sig, char const *const *argv, size_t argc) gccattr_noreturn ;
+static void process_kill_hack_kill (int sig, char const *const *argv, size_t argc, int dowait, unsigned int timeout)
{
size_t scandirlen = strlen(g->dirs.scan) ;
+ unsigned int m = 0 ;
+ char fmt[UINT_FMT] ;
if (g->verbosity)
{
- char fmt[INT_FMT] ;
- fmt[int_fmt(fmt, sig)] = 0 ;
- strerr_warnw3x("signal ", fmt, " is not natively supported by s6-svc, results may be unreliable") ;
+ fmt[uint_fmt(fmt, (unsigned int)sig)] = 0 ;
+ strerr_warnw3x("signal ", fmt, " is not natively supported by s6-svc, cannot ensure reliability") ;
}
-
+ pid_t pids[argc] ;
+ char const *newargv[5 + argc + (dowait ? 4 + argc + (timeout ? 2 : 0) : 0)] ;
+ char equotestorage[dowait ? s6f_equote_space(argv, argc) : 1] ;
+ if (dowait)
+ {
+ newargv[m++] = S6_EXTBINPREFIX "s6-svlisten" ;
+ newargv[m++] = "-dwD" ;
+ if (timeout)
+ {
+ fmt[uint_fmt(fmt, timeout)] = 0 ;
+ newargv[m++] = "-t" ;
+ newargv[m++] = fmt ;
+ }
+ newargv[m++] = "--" ;
+ m += s6f_equote(newargv + m, argv, argc, equotestorage) ;
+ }
+
for (; *argv ; argv++)
{
s6_svstatus_t status ;
@@ -42,7 +62,7 @@ static int process_kill_hack_kill (int sig, char const *const *argv)
strerr_diefu2sys(111, "read status file for service ", path) ;
if (status.pid && !status.flagfinishing) kill(status.pid, sig) ;
}
- return 0 ;
+ _exit(0) ;
}
@@ -52,18 +72,18 @@ enum gola_e
GOLA_N
} ;
-static gol_arg const rgola[GOLA_N] =
+static gol_arg const rgola[] =
{
{ .so = 's', .lo = "signal", .i = GOLA_SIGNAL },
} ;
-int process_kill (char const *const *argv)
+void process_kill (char const *const *argv, process_options const *options)
{
char const *wgola[GOLA_N] = { 0 } ;
- char const *svcopt = 0 ;
size_t argc ;
int sig = SIGTERM ;
- PROG = "s6 process kill" ;
+ char svcopt[5] = "-!\0\0\0" ;
+ PROG = "s6-frontend: process kill" ;
argv += gol_argv(argv, 0, 0, rgola, GOLA_N, 0, wgola) ;
if (!argv) dieusage() ;
@@ -76,18 +96,20 @@ int process_kill (char const *const *argv)
process_check_services(argv, argc) ;
switch (sig)
{
- case SIGALRM : svcopt = "-a" ; break ;
- case SIGABRT : svcopt = "-b" ; break ;
- case SIGQUIT : svcopt = "-q" ; break ;
- case SIGHUP : svcopt = "-h" ; break ;
- case SIGKILL : svcopt = "-k" ; break ;
- case SIGTERM : svcopt = "-t" ; break ;
- case SIGINT : svcopt = "-i" ; break ;
- case SIGUSR1 : svcopt = "-1" ; break ;
- case SIGUSR2 : svcopt = "-2" ; break ;
- case SIGSTOP : svcopt = "-p" ; break ;
- case SIGCONT : svcopt = "-c" ; break ;
- case SIGWINCH: svcopt = "-y" ; break ;
+ case SIGALRM : svcopt[1] = 'a' ; break ;
+ case SIGABRT : svcopt[1] = 'b' ; break ;
+ case SIGQUIT : svcopt[1] = 'q' ; break ;
+ case SIGHUP : svcopt[1] = 'h' ; break ;
+ case SIGKILL : svcopt[1] = 'k' ; break ;
+ case SIGTERM : svcopt[1] = 't' ; break ;
+ case SIGINT : svcopt[1] = 'i' ; break ;
+ case SIGUSR1 : svcopt[1] = '1' ; break ;
+ case SIGUSR2 : svcopt[1] = '2' ; break ;
+ case SIGSTOP : svcopt[1] = 'p' ; break ;
+ case SIGCONT : svcopt[1] = 'c' ; break ;
+ case SIGWINCH: svcopt[1] = 'y' ; break ;
}
- return svcopt ? process_send_svc(svcopt, argv, argc) : process_kill_hack_kill(sig, argv) ;
+ if (options->flags & 1) { svcopt[2] = 'w' ; svcopt[3] = 'D' ; }
+ if (svcopt[1] != '!') process_send_svc(svcopt, argv, argc, options->timeout) ;
+ else process_kill_hack_kill(sig, argv, argc, options->flags & 1, unsigned int timeout) ;
}
diff --git a/src/s6-frontend/process_restart.c b/src/s6-frontend/process_restart.c
index 73e66f3..6b8f935 100644
--- a/src/s6-frontend/process_restart.c
+++ b/src/s6-frontend/process_restart.c
@@ -7,32 +7,14 @@
#include <skalibs/strerr.h>
#include <skalibs/gol.h>
-#include "s6-internal.h"
+#include "s6-frontend-internal.h"
#define USAGE "s6 process restart [ -W|--nowait ] services..."
#define dieusage() strerr_dieusage(100, USAGE)
-enum golb_e
+void process_restart (char const *const *argv, process_options const *options)
{
- GOLB_WAIT,
- GOLB_N
-} ;
-
-static gol_bool const rgolb[2] =
-{
- { .so = 'W', .lo = "nowait", .clear = 1 << GOLB_WAIT, .set = 0 },
- { .so = 'w', .lo = "wait", .clear = 0, .set = 1 << GOLB_WAIT }
-} ;
-
-int process_restart (char const *const *argv)
-{
- uint64_t wgolb = 1 << GOLB_WAIT ;
- size_t argc ;
- PROG = "s6 process restart" ;
-
- argv += gol_argv(argv, rgolb, 2, 0, 0, &wgolb, 0) ;
- if (!argv) dieusage() ;
- argc = env_len(argv) ;
+ size_t argc = env_len(argv) ;
process_check_services(argv, argc) ;
- return process_send_svc(wgolb & 1 << GOLB_WAIT ? "-rwR" : "-r", argv, argc) ;
+ process_send_svc(options->flags & 1 ? "-rwR" : "-r", argv, argc, options->timeout) ;
}
diff --git a/src/s6-frontend/process_startstop.c b/src/s6-frontend/process_startstop.c
index 8a5089e..9e23680 100644
--- a/src/s6-frontend/process_startstop.c
+++ b/src/s6-frontend/process_startstop.c
@@ -2,44 +2,28 @@
#include <stddef.h>
+#include <skalibs/gccattributes.h>
#include <skalibs/uint64.h>
#include <skalibs/env.h>
#include <skalibs/strerr.h>
#include <skalibs/gol.h>
-#include "s6-internal.h"
+#include "s6-frontend-internal.h"
-enum golb_e
+static void process_startstop (char const *const *argv, process_options const *options, int h) gccattr_noreturn ;
+static void process_startstop (char const *const *argv, process_options const *options, int h)
{
- GOLB_WAIT,
- GOLB_N
-} ;
-
-static gol_bool const rgolb[2] =
-{
- { .so = 'W', .lo = "nowait", .clear = 1 << GOLB_WAIT, .set = 0 },
- { .so = 'w', .lo = "wait", .clear = 0, .set = 1 << GOLB_WAIT }
-} ;
-
-static int process_startstop (char const *const *argv, int h)
-{
- uint64_t wgolb = 1 << GOLB_WAIT ;
- size_t argc ;
- PROG = h ? "s6 process start" : "s6 process stop" ;
-
- argv += gol_argv(argv, rgolb, 2, 0, 0, &wgolb, 0) ;
- if (!argv) strerr_dien(100, 4, PROG, ": usage: ", PROG, " [ -W|--nowait | -w|--wait ] services...") ;
- argc = env_len(argv) ;
+ size_t argc = env_len(argv) ;
process_check_services(argv, argc) ;
- return process_send_svc(wgolb & 1 << GOLB_WAIT ? h ? "-uwU" : "-dwD" : h ? "-u" : "-d", argv, argc) ;
+ process_send_svc(options->flags & 1 ? h ? "-uwU" : "-dwD" : h ? "-u" : "-d", argv, argc, options->timeout) ;
}
-int process_start (char const *const *argv)
+void process_start (char const *const *argv, process_options const *options)
{
- return process_startstop(argv, 1) ;
+ return process_startstop(argv, options, 1) ;
}
-int process_stop (char const *const *argv)
+void process_stop (char const *const *argv, process_options const *options)
{
- return process_startstop(argv, 0) ;
+ return process_startstop(argv, options, 0) ;
}
diff --git a/src/s6-frontend/process_status.c b/src/s6-frontend/process_status.c
index a13938d..96cee95 100644
--- a/src/s6-frontend/process_status.c
+++ b/src/s6-frontend/process_status.c
@@ -15,7 +15,7 @@
#include <s6/config.h>
-#include "s6-internal.h"
+#include "s6-frontend-internal.h"
#define USAGE "s6 process status [ -l|--with-logs ] services..."
#define dieusage() strerr_dieusage(100, USAGE)
diff --git a/src/s6-frontend/s6-internal.h b/src/s6-frontend/s6-frontend-internal.h
index 6ee3939..b935fe2 100644
--- a/src/s6-frontend/s6-internal.h
+++ b/src/s6-frontend/s6-frontend-internal.h
@@ -7,7 +7,10 @@
#include <stdint.h>
#include <stdlib.h>
+#include <skalibs/gccattributes.h>
+#include <skalibs/uint64.h>
#include <skalibs/functypes.h>
+#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
#include <s6-frontend/config.h>
@@ -15,8 +18,7 @@
/* util */
-extern int keycmp (void const *, void const *) ;
-#define BSEARCH(type, key, array) bsearch(key, (array), sizeof(array)/sizeof(type), sizeof(type), &keycmp)
+#define BSEARCH(type, key, array) bsearch(key, (array), sizeof(array)/sizeof(type), sizeof(type), &str_cmp)
/* help */
@@ -29,14 +31,22 @@ extern int help (char const *const *) ;
/* process */
+typedef struct process_options_s process_options, *process_options_ref ;
+struct process_options_s
+{
+ uint64_t flags ;
+ unsigned int timeout ;
+} ;
+#define PROCESS_OPTIONS_ZERO { .flags = 0, .timeout = 0 }
+
extern void process_check_services (char const *const *, size_t) ;
-extern int process_send_svc (char const *, char const *const *, size_t) ;
+extern int process_send_svc (char const *, char const *const *, size_t, unsigned int) gccattr_noreturn ;
-extern int process_kill (char const *const *) ;
-extern int process_restart (char const *const *) ;
-extern int process_start (char const *const *) ;
-extern int process_status (char const *const *) ;
-extern int process_stop (char const *const *) ;
+extern int process_kill (char const *const *, process_options const *) ;
+extern void process_restart (char const *const *, process_options const *) gccattr_noreturn ;
+extern void process_start (char const *const *, process_options const *) gccattr_noreturn ;
+extern void process_stop (char const *const *, process_options const *) gccattr_noreturn ;
+extern int process_status (char const *const *, process_options const *) ;
extern int process (char const *const *) ;
@@ -69,7 +79,7 @@ struct global_s
.scan = S6_FRONTEND_SCANDIR, \
.live = S6_FRONTEND_LIVEDIR, \
.repo = S6_FRONTEND_REPODIR, \
- .boot = S6_FRONTEND_BOOTDIR, \
+ .boot = S6_FRONTEND_BOOTDB, \
.stmp = S6_FRONTEND_STMPDIR, \
}, \
.userstorage = STRALLOC_ZERO, \
@@ -78,6 +88,15 @@ struct global_s
.color = 0 \
}
+struct modif_s
+{
+ char const *s ;
+ size_t len ;
+ unsigned int n ;
+} ;
+
+extern struct modif_s const cleanup_modif ;
+
struct command_s
{
char const *s ;
diff --git a/src/s6-frontend/s6-frontend.c b/src/s6-frontend/s6-frontend.c
index ad55e8d..3148062 100644
--- a/src/s6-frontend/s6-frontend.c
+++ b/src/s6-frontend/s6-frontend.c
@@ -14,11 +14,18 @@
#include <s6-rc/config.h>
#include <s6-frontend/config.h>
-#include "s6-internal.h"
+#include "s6-frontend-internal.h"
-#define USAGE "s6-frontend [ generic options ] command [ command options ] command_arguments... Type \"s6 help\" for details."
+#define USAGE "s6 [ generic options ] command [ command options ] command_arguments... Type \"s6 help\" for details."
#define dieusage() strerr_dieusage(100, USAGE)
+#define CLEANUP_MODIF "EXECLINE_STRICT\0scandir\0livedir\0repodir\0bootdb\0stmpdir\0verbosity"
+struct modif_s const cleanup_modif =
+{
+ .s = CLEANUP_MODIF,
+ .len = sizeof(CLEANUP_MODIF),
+ .n = 7
+} ;
int version (char const *const *argv)
{
@@ -30,10 +37,9 @@ int version (char const *const *argv)
enum golb_e
{
- GOLB_HELP,
- GOLB_VERSION,
- GOLB_USER,
- GOLB_N
+ GOLB_HELP = 0x01,
+ GOLB_VERSION = 0x02,
+ GOLB_USER = 0x04,
} ;
enum gola_e
@@ -41,43 +47,42 @@ enum gola_e
GOLA_SCANDIR,
GOLA_LIVEDIR,
GOLA_REPODIR,
- GOLA_BOOTDIR,
+ GOLA_BOOTDB,
GOLA_STMPDIR,
GOLA_VERBOSITY,
GOLA_COLOR,
GOLA_N
} ;
-static gol_bool const rgolb[GOLB_N] =
-{
- { .so = 'h', .lo = "help", .clear = 0, .set = 1 << GOLB_HELP },
- { .so = 'V', .lo = "version", .clear = 0, .set = 1 << GOLB_VERSION },
- { .so = 0, .lo = "user", .clear = 0, .set = 1 << GOLB_USER }
-} ;
-
-static gol_arg const rgola[GOLA_N] =
-{
- { .so = 's', .lo = "scandir", .i = GOLA_SCANDIR },
- { .so = 'l', .lo = "livedir", .i = GOLA_LIVEDIR },
- { .so = 'r', .lo = "repodir", .i = GOLA_REPODIR },
- { .so = 'b', .lo = "bootdir", .i = GOLA_BOOTDIR },
- { .so = 0, .lo = "stmpdir", .i = GOLA_STMPDIR },
- { .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY },
- { .so = 0, .lo = "color", .i = GOLA_COLOR }
-} ;
-
struct global_s *g ;
-static struct command_s const commands[] =
+int main (int argc, char const *const *argv)
{
- { .s = "help", .f = &help },
- { .s = "process", .f = &process },
- { .s = "service", .f = &service },
- { .s = "version", .f = &version },
-} ;
+ static struct command_s const commands[] =
+ {
+ { .s = "help", .f = &help },
+ { .s = "process", .f = &process },
+ { .s = "service", .f = &service },
+ { .s = "version", .f = &version },
+ } ;
+ static gol_bool const rgolb[] =
+ {
+ { .so = 'h', .lo = "help", .clear = 0, .set = GOLB_HELP },
+ { .so = 'V', .lo = "version", .clear = 0, .set = GOLB_VERSION },
+ { .so = 0, .lo = "user", .clear = 0, .set = GOLB_USER },
+ } ;
+
+ static gol_arg const rgola[] =
+ {
+ { .so = 's', .lo = "scandir", .i = GOLA_SCANDIR },
+ { .so = 'l', .lo = "livedir", .i = GOLA_LIVEDIR },
+ { .so = 'r', .lo = "repodir", .i = GOLA_REPODIR },
+ { .so = 'b', .lo = "bootdb", .i = GOLA_BOOTDB },
+ { .so = 0, .lo = "stmpdir", .i = GOLA_STMPDIR },
+ { .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY },
+ { .so = 0, .lo = "color", .i = GOLA_COLOR },
+ } ;
-int main (int argc, char const *const *argv, char const *const *envp)
-{
struct global_s globals_in_the_stack = GLOBAL_ZERO ;
uint64_t wgolb = 0 ;
unsigned int golc ;
@@ -87,28 +92,28 @@ int main (int argc, char const *const *argv, char const *const *envp)
[GOLA_SCANDIR] = getenv("scandir"),
[GOLA_LIVEDIR] = getenv("livedir"),
[GOLA_REPODIR] = getenv("repodir"),
- [GOLA_BOOTDIR] = getenv("bootdir"),
+ [GOLA_BOOTDB] = getenv("bootdb"),
[GOLA_STMPDIR] = getenv("stmpdir"),
- [GOLA_VERBOSITY] = 0,
+ [GOLA_VERBOSITY] = getenv("verbosity"),
[GOLA_COLOR] = 0
} ;
PROG = "s6-frontend" ;
g = &globals_in_the_stack ;
- golc = gol_main(argc, argv, rgolb, GOLB_N, rgola, GOLA_N, &wgolb, wgola) ;
+ golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ;
argc -= golc ; argv += golc ;
if (wgola[GOLA_VERBOSITY] && !uint0_scan(wgola[GOLA_VERBOSITY], &g->verbosity))
strerr_dief1x(100, "verbosity must be an unsigned integer") ;
- if (wgolb & 1 << GOLB_VERSION) version(argv) ;
- if (wgolb & 1 << GOLB_HELP) help(argv) ;
- if (wgolb & (1 << GOLB_VERSION | 1 << GOLB_HELP)) return 0 ;
+ if (wgolb & GOLB_VERSION) version(argv) ;
+ if (wgolb & GOLB_HELP) help(argv) ;
+ if (wgolb & (GOLB_VERSION | GOLB_HELP)) return 0 ;
if (wgola[GOLA_SCANDIR]) g->dirs.scan = wgola[GOLA_SCANDIR] ;
if (wgola[GOLA_LIVEDIR]) g->dirs.live = wgola[GOLA_LIVEDIR] ;
if (wgola[GOLA_REPODIR]) g->dirs.repo = wgola[GOLA_REPODIR] ;
- if (wgola[GOLA_BOOTDIR]) g->dirs.boot = wgola[GOLA_BOOTDIR] ;
+ if (wgola[GOLA_BOOTDB]) g->dirs.boot = wgola[GOLA_BOOTDB] ;
if (wgola[GOLA_STMPDIR]) g->dirs.stmp = wgola[GOLA_STMPDIR] ;
{
@@ -132,7 +137,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (!force_color) g->color = g->istty ;
}
- g->isuser = !!(wgolb & 1 << GOLB_USER) ;
+ g->isuser = !!(wgolb & GOLB_USER) ;
if (g->isuser) s6f_user_get_confdirs(&g->dirs, &g->userstorage) ;
if (!*argv) dieusage() ;
diff --git a/src/s6-frontend/s6.c b/src/s6-frontend/s6.c
index 9c9de9c..f19fd56 100644
--- a/src/s6-frontend/s6.c
+++ b/src/s6-frontend/s6.c
@@ -12,9 +12,9 @@
int main (int argc, char const *const *argv)
{
- char const *conffile = getenv("S6_FRONTEND_CONFFILE") ;
- PROG = "s6 service" ;
- if (!conffile) conffile = S6_FRONTEND_CONFFILE ;
+ char const *conffile = getenv("S6_FRONTEND_CONF") ;
+ PROG = "s6" ;
+ if (!conffile) conffile = S6_FRONTEND_CONF ;
if (!argc--) strerr_dief1x(103, "invalid argc/argv") ;
argv++ ;
diff --git a/src/s6-frontend/service.c b/src/s6-frontend/service.c
index 5ac453b..ef56339 100644
--- a/src/s6-frontend/service.c
+++ b/src/s6-frontend/service.c
@@ -3,7 +3,7 @@
#include <skalibs/prog.h>
#include <skalibs/strerr.h>
-#include "s6-internal.h"
+#include "s6-frontend-internal.h"
#define USAGE "s6 service [ service options ] subcommand [ subcommand options ] services... Type \"s6 service help\" for details."
#define dieusage() strerr_dieusage(100, USAGE)
@@ -20,7 +20,7 @@ int service (char const *const *argv)
{
struct command_s *cmd ;
- PROG = "s6 service" ;
+ PROG = "s6-frontend: service" ;
if (!*argv) dieusage() ;
cmd = BSEARCH(struct command_s, *argv, service_commands) ;
if (!cmd) dieusage() ;
diff --git a/src/s6-frontend/service_startstop.c b/src/s6-frontend/service_startstop.c
index c4946fc..dee160f 100644
--- a/src/s6-frontend/service_startstop.c
+++ b/src/s6-frontend/service_startstop.c
@@ -15,7 +15,7 @@
#include <s6-rc/config.h>
#include <s6-rc/s6rc-utils.h>
-#include "s6-internal.h"
+#include "s6-frontend-internal.h"
enum golb_e
{
diff --git a/src/s6-frontend/service_status.c b/src/s6-frontend/service_status.c
index 5bf71b5..85ab4b2 100644
--- a/src/s6-frontend/service_status.c
+++ b/src/s6-frontend/service_status.c
@@ -4,7 +4,7 @@
#include <skalibs/strerr.h>
#include <skalibs/gol.h>
-#include "s6-internal.h"
+#include "s6-frontend-internal.h"
#define USAGE "s6 service status services..."
#define dieusage() strerr_dieusage(100, USAGE)