summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure4
-rw-r--r--src/include-local/initctl.h12
-rw-r--r--src/init/s6-linux-init-maker.c97
-rw-r--r--src/init/s6-linux-init.c2
-rw-r--r--src/shutdown/s6-linux-init-shutdownd.c1
5 files changed, 57 insertions, 59 deletions
diff --git a/configure b/configure
index 3dac442..47b57b8 100755
--- a/configure
+++ b/configure
@@ -25,6 +25,7 @@ Fine tuning of the installation directories:
--includedir=DIR C header files [PREFIX/include]
--skeldir=DIR script skeleton files [PREFIX/etc/s6-linux-init/skel]
--tmpfsdir=DIR assume the initial tmpfs will be mounted on DIR [/run]
+ --scandir=DIR use tmpfsdir/DIR as the s6-svscan directory [service]
If no --prefix option is given, by default libdir (but not dynlibdir) will be
/usr/lib/$package, and includedir will be /usr/include.
@@ -177,6 +178,7 @@ vpathd=''
build=
skeldir='$prefix/etc/s6-linux-init/skel'
tmpfsdir=/run
+scandir=service
utmps=false
for arg ; do
@@ -212,6 +214,7 @@ for arg ; do
--disable-nsss|--enable-nsss=no) usensss=false ;;
--skeldir=*) skeldir=${arg#*=} ;;
--tmpfsdir=*) tmpfsdir=${arg#*=} ;;
+ --scandir=*) scandir=${arg#*=} ;;
--enable-utmps|--enable-utmps=yes) utmps=true ;;
--disable-utmps|--enable-utmps=no) utmps=false ;;
--enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
@@ -525,6 +528,7 @@ fi
echo "#define ${package_macro_name}_LIBEXECPREFIX \"$libexecdir/\""
echo "#define ${package_macro_name}_SKELDIR \"$skeldir\""
echo "#define ${package_macro_name}_TMPFS \"$tmpfsdir\""
+echo "#define ${package_macro_name}_SCANDIR \"$scandir\""
echo
if $utmps ; then
echo "#define ${package_macro_name}_UTMPD_PATH \"$utmpd_path\""
diff --git a/src/include-local/initctl.h b/src/include-local/initctl.h
index a1be5c8..4e3df00 100644
--- a/src/include-local/initctl.h
+++ b/src/include-local/initctl.h
@@ -5,26 +5,26 @@
#include <s6-linux-init/config.h>
-#define SCANDIR "service"
+#define SCANDIRFULL S6_LINUX_INIT_TMPFS "/" S6_LINUX_INIT_SCANDIR
#define SHUTDOWND_SERVICEDIR "s6-linux-init-shutdownd"
#define SHUTDOWND_FIFO "fifo"
-#define INITCTL S6_LINUX_INIT_TMPFS "/" SCANDIR "/" SHUTDOWND_SERVICEDIR "/" SHUTDOWND_FIFO
+#define INITCTL SCANDIRFULL "/" SHUTDOWND_SERVICEDIR "/" SHUTDOWND_FIFO
#define RUNLEVELD_SERVICEDIR "s6-linux-init-runleveld"
#define RUNLEVELD_SOCKET "s"
-#define RUNLEVELD_PATH S6_LINUX_INIT_TMPFS "/" SCANDIR "/" RUNLEVELD_SERVICEDIR "/" RUNLEVELD_SOCKET
+#define RUNLEVELD_PATH SCANDIRFULL "/" RUNLEVELD_SERVICEDIR "/" RUNLEVELD_SOCKET
#define LOGOUTHOOKD_SERVICEDIR "s6-linux-init-logouthookd"
#define LOGOUTHOOKD_SOCKET "s"
-#define LOGOUTHOOKD_PATH S6_LINUX_INIT_TMPFS "/" SCANDIR "/" LOGOUTHOOKD_SERVICEDIR "/" LOGOUTHOOKD_SOCKET
+#define LOGOUTHOOKD_PATH SCANDIRFULL "/" LOGOUTHOOKD_SERVICEDIR "/" LOGOUTHOOKD_SOCKET
#define LOGGER_SERVICEDIR "s6-svscan-log"
#define LOGGER_FIFO "fifo"
-#define LOGFIFO S6_LINUX_INIT_TMPFS "/" SCANDIR "/" LOGGER_SERVICEDIR "/" LOGGER_FIFO
+#define LOGFIFO SCANDIRFULL "/" LOGGER_SERVICEDIR "/" LOGGER_FIFO
#define EARLYGETTY_SERVICEDIR "s6-linux-init-early-getty"
-#define EARLYGETTY S6_LINUX_INIT_TMPFS "/" SCANDIR "/" EARLYGETTY_SERVICEDIR
+#define EARLYGETTY SCANDIRFULL "/" EARLYGETTY_SERVICEDIR
#define CONTAINER_RESULTS "s6-linux-init-container-results"
diff --git a/src/init/s6-linux-init-maker.c b/src/init/s6-linux-init-maker.c
index f17bc37..840695f 100644
--- a/src/init/s6-linux-init-maker.c
+++ b/src/init/s6-linux-init-maker.c
@@ -316,7 +316,7 @@ static void cleanup (char const *base)
errno = e ;
}
-static void auto_dir_internal (char const *base, char const *dir, uid_t uid, gid_t gid, unsigned int mode, int strict)
+static void auto_dir_internal (char const *base, char const *dir, uid_t uid, gid_t gid, unsigned int mode, unsigned int options)
{
size_t clen = strlen(base) ;
size_t dlen = strlen(dir) ;
@@ -325,9 +325,21 @@ static void auto_dir_internal (char const *base, char const *dir, uid_t uid, gid
fn[clen] = dlen ? '/' : 0 ;
memcpy(fn + clen + 1, dir, dlen + 1) ;
+ if (options & 2)
+ {
+ for (size_t i = clen + 1 ; i < clen + 1 + dlen ; i++) if (fn[i] == '/')
+ {
+ fn[i] = 0 ;
+ if (mkdir(fn, 0755) < 0 && (errno != EEXIST || (options & 1))) goto err ;
+ fn[i] = '/' ;
+ }
+ }
+
+ if (options & 4) return ;
+
if (mkdir(fn, mode) < 0)
{
- if (errno != EEXIST || strict) goto err ;
+ if (errno != EEXIST || (options & 1)) goto err ;
}
else
{
@@ -500,21 +512,6 @@ static void getug (char const *base, char const *s, uid_t *uid, gid_t *gid)
#ifdef S6_LINUX_INIT_UTMPD_PATH
-static inline void auto_basedir (char const *base, char const *dir, uid_t uid, gid_t gid, unsigned int mode)
-{
- size_t n = strlen(dir) ;
- char tmp[n + 1] ;
- for (size_t i = 0 ; i < n ; i++)
- {
- if ((dir[i] == '/') && i)
- {
- tmp[i] = 0 ;
- auto_dir_internal(base, tmp, uid, gid, mode, 0) ;
- }
- tmp[i] = dir[i] ;
- }
-}
-
static int utmpd_script (buffer *b, char const *aux)
{
size_t sabase = satmp.len ;
@@ -544,15 +541,15 @@ static int utmpd_script (buffer *b, char const *aux)
static inline void make_utmps (char const *base)
{
- auto_dir(base, "run-image/" SCANDIR "/utmpd", 0, 0, 0755) ;
- auto_file(base, "run-image/" SCANDIR "/utmpd/notification-fd", "3\n", 2) ;
- auto_script(base, "run-image/" SCANDIR "/utmpd/run", &utmpd_script, 0) ;
+ auto_dir(base, "run-image/" S6_LINUX_INIT_SCANDIR "/utmpd", 0, 0, 0755) ;
+ auto_file(base, "run-image/" S6_LINUX_INIT_SCANDIR "/utmpd/notification-fd", "3\n", 2) ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/utmpd/run", &utmpd_script, 0) ;
{
uid_t uid ;
gid_t gid ;
getug(base, utmp_user, &uid, &gid) ;
auto_dir(base, "run-image/" UTMPS_DIR, uid, gid, 0755) ;
- auto_basedir(base, "run-image/" S6_LINUX_INIT_UTMPD_PATH, uid, gid, 0755) ;
+ auto_dir_internal(base, "run-image/" S6_LINUX_INIT_UTMPD_PATH, uid, gid, 0755, 6) ;
}
}
@@ -560,15 +557,13 @@ static inline void make_utmps (char const *base)
static inline void make_image (char const *base)
{
- auto_dir(base, "run-image", 0, 0, 0755) ;
- auto_dir(base, "run-image/" SCANDIR, 0, 0, 0755) ;
- auto_dir(base, "run-image/" SCANDIR "/.s6-svscan", 0, 0, 0755) ;
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGQUIT", &put_shebang_options, 0) ;
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGINT", &sig_script, "-r") ;
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGUSR1", &sig_script, "-p") ;
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGUSR2", &sig_script, "-h") ;
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGPWR", &sig_script, "-p") ;
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGWINCH", &put_shebang_options, 0) ;
+ auto_dir_internal(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan", 0, 0, 0755, 3) ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan/SIGQUIT", &put_shebang_options, 0) ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan/SIGINT", &sig_script, "-r") ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan/SIGUSR1", &sig_script, "-p") ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan/SIGUSR2", &sig_script, "-h") ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan/SIGPWR", &sig_script, "-p") ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan/SIGWINCH", &put_shebang_options, 0) ;
if (!nologger)
{
@@ -576,45 +571,45 @@ static inline void make_image (char const *base)
gid_t gid ;
getug(base, log_user, &uid, &gid) ;
auto_dir(base, "run-image/" UNCAUGHT_DIR, uid, gid, 02750) ;
- auto_dir(base, "run-image/" SCANDIR "/" LOGGER_SERVICEDIR, 0, 0, 0755) ;
- auto_fifo(base, "run-image/" SCANDIR "/" LOGGER_SERVICEDIR "/" LOGGER_FIFO) ;
- auto_file(base, "run-image/" SCANDIR "/" LOGGER_SERVICEDIR "/notification-fd", "3\n", 2) ;
- auto_script(base, "run-image/" SCANDIR "/" LOGGER_SERVICEDIR "/run", &s6_svscan_log_script, 0) ;
+ auto_dir(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" LOGGER_SERVICEDIR, 0, 0, 0755) ;
+ auto_fifo(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" LOGGER_SERVICEDIR "/" LOGGER_FIFO) ;
+ auto_file(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" LOGGER_SERVICEDIR "/notification-fd", "3\n", 2) ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" LOGGER_SERVICEDIR "/run", &s6_svscan_log_script, 0) ;
}
- auto_dir(base, "run-image/" SCANDIR "/" SHUTDOWND_SERVICEDIR, 0, 0, 0755) ;
- auto_fifo(base, "run-image/" SCANDIR "/" SHUTDOWND_SERVICEDIR "/" SHUTDOWND_FIFO) ;
- auto_script(base, "run-image/" SCANDIR "/" SHUTDOWND_SERVICEDIR "/run", &shutdownd_script, 0) ;
+ auto_dir(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" SHUTDOWND_SERVICEDIR, 0, 0, 0755) ;
+ auto_fifo(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" SHUTDOWND_SERVICEDIR "/" SHUTDOWND_FIFO) ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" SHUTDOWND_SERVICEDIR "/run", &shutdownd_script, 0) ;
if (inns)
{
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGTERM", &sig_script, "-h") ;
- 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_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan/SIGTERM", &sig_script, "-h") ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan/crash", &container_crash_script, 0) ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_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) ;
}
else
{
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGTERM", &put_shebang_options, 0) ;
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/crash", &death_script, "crashed") ;
- auto_script(base, "run-image/" SCANDIR "/.s6-svscan/finish", &death_script, "exited") ;
- auto_dir(base, "run-image/" SCANDIR "/" RUNLEVELD_SERVICEDIR, 0, 0, 0755) ;
- auto_file(base, "run-image/" SCANDIR "/" RUNLEVELD_SERVICEDIR "/notification-fd", "3\n", 2) ;
- auto_script(base, "run-image/" SCANDIR "/" RUNLEVELD_SERVICEDIR "/run", &runleveld_script, 0) ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan/SIGTERM", &put_shebang_options, 0) ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan/crash", &death_script, "crashed") ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/.s6-svscan/finish", &death_script, "exited") ;
+ auto_dir(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" RUNLEVELD_SERVICEDIR, 0, 0, 0755) ;
+ auto_file(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" RUNLEVELD_SERVICEDIR "/notification-fd", "3\n", 2) ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" RUNLEVELD_SERVICEDIR "/run", &runleveld_script, 0) ;
}
if (logouthookd)
{
- auto_dir(base, "run-image/" SCANDIR "/" LOGOUTHOOKD_SERVICEDIR, 0, 0, 0755) ;
- auto_file(base, "run-image/" SCANDIR "/" LOGOUTHOOKD_SERVICEDIR "/notification-fd", "1\n", 2) ;
- auto_script(base, "run-image/" SCANDIR "/" LOGOUTHOOKD_SERVICEDIR "/run", &logouthookd_script, 0) ;
+ auto_dir(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" LOGOUTHOOKD_SERVICEDIR, 0, 0, 0755) ;
+ auto_file(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" LOGOUTHOOKD_SERVICEDIR "/notification-fd", "1\n", 2) ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" LOGOUTHOOKD_SERVICEDIR "/run", &logouthookd_script, 0) ;
}
if (early_getty)
{
- auto_dir(base, "run-image/" SCANDIR "/" EARLYGETTY_SERVICEDIR, 0, 0, 0755) ;
- auto_script(base, "run-image/" SCANDIR "/" EARLYGETTY_SERVICEDIR "/run", &line_script, early_getty) ;
+ auto_dir(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" EARLYGETTY_SERVICEDIR, 0, 0, 0755) ;
+ auto_script(base, "run-image/" S6_LINUX_INIT_SCANDIR "/" EARLYGETTY_SERVICEDIR "/run", &line_script, early_getty) ;
}
#ifdef S6_LINUX_INIT_UTMPD_PATH
diff --git a/src/init/s6-linux-init.c b/src/init/s6-linux-init.c
index d0bb442..d9585d6 100644
--- a/src/init/s6-linux-init.c
+++ b/src/init/s6-linux-init.c
@@ -289,7 +289,7 @@ int main (int argc, char const **argv, char const *const *envp)
char const *newenvp[2] = { 0, 0 } ;
size_t pathlen = path ? strlen(path) : 0 ;
char fmtfd[2 + UINT_FMT] = "-" ;
- char const *newargv[5] = { S6_EXTBINPREFIX "s6-svscan", fmtfd, "--", S6_LINUX_INIT_TMPFS "/" SCANDIR, 0 } ;
+ char const *newargv[5] = { S6_EXTBINPREFIX "s6-svscan", fmtfd, "--", SCANDIRFULL, 0 } ;
char pathvar[6 + pathlen] ;
if (path)
{
diff --git a/src/shutdown/s6-linux-init-shutdownd.c b/src/shutdown/s6-linux-init-shutdownd.c
index ddf5804..ed02721 100644
--- a/src/shutdown/s6-linux-init-shutdownd.c
+++ b/src/shutdown/s6-linux-init-shutdownd.c
@@ -36,7 +36,6 @@
#include "hpr.h"
#define STAGE4_FILE "stage 4"
-#define SCANDIRFULL S6_LINUX_INIT_TMPFS "/" SCANDIR
#define SCANPREFIX SCANDIRFULL "/"
#define SCANPREFIXLEN (sizeof(SCANPREFIX) - 1)
#define DOTPREFIX ".s6-linux-init-shutdownd:"