summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/s6-rc/s6-rc-compile.c36
-rw-r--r--src/s6-rc/s6-rc-compile.h4
-rw-r--r--src/s6-rc/s6-rc.c29
3 files changed, 26 insertions, 43 deletions
diff --git a/src/s6-rc/s6-rc-compile.c b/src/s6-rc/s6-rc-compile.c
index ab79463..87808ef 100644
--- a/src/s6-rc/s6-rc-compile.c
+++ b/src/s6-rc/s6-rc-compile.c
@@ -20,9 +20,10 @@
#include <skalibs/skamisc.h>
#include <skalibs/avltree.h>
#include <skalibs/unix-transactional.h>
+#include <execline/config.h>
#include <execline/execline.h>
+#include <s6/config.h>
#include <s6-rc/s6rc.h>
-#include "s6-rc-compile.h"
#ifdef DEBUG
# include <skalibs/lolstdio.h>
@@ -35,6 +36,15 @@
#define dieusage() strerr_dieusage(100, USAGE)
#define dienomem() strerr_dief1x(111, "out of memory") ;
+#define S6RC_ONESHOT_RUNNER_RUNSCRIPT \
+"#!" EXECLINE_EXTBINPREFIX "execlineb -P\n" \
+EXECLINE_EXTBINPREFIX "fdmove -c 2 1\n" \
+S6_EXTBINPREFIX "s6-ipcserver-socketbinder -- s\n" \
+S6_EXTBINPREFIX "s6-notifywhenup -f --\n" \
+S6_EXTBINPREFIX "s6-ipcserverd -1 --\n" \
+S6_EXTBINPREFIX "s6-ipcserver-access -E -l0 -i data/rules --\n" \
+S6_EXTBINPREFIX "s6-sudod -t 2000 --\n"
+
static unsigned int verbosity = 1 ;
static stralloc keep = STRALLOC_ZERO ;
static stralloc data = STRALLOC_ZERO ;
@@ -235,7 +245,7 @@ static inline void add_specials (before_t *be)
.logrelated = 0,
.logtype = 0
} ;
- add_name(be, "(s6-rc-compile internals)", SPECIAL_NAME, SVTYPE_LONGRUN, &service.common.name, &service.common.kname) ;
+ add_name(be, "(s6-rc-compile internals)", S6RC_ONESHOT_RUNNER, SVTYPE_LONGRUN, &service.common.name, &service.common.kname) ;
if (!stralloc_cats(&keep, data.s + service.common.name)
|| !stralloc_0(&keep)) dienomem() ;
if (!genalloc_append(longrun_t, &be->longruns, &service)) dienomem() ;
@@ -364,7 +374,7 @@ static inline void add_oneshot (before_t *be, int dirfd, char const *srcdir, cha
service.common.ndeps++ ;
}
else if (verbosity)
- strerr_warnw6x(srcdir, "/", name, "/dependencies", " explicitly lists ", SPECIAL_NAME) ;
+ strerr_warnw6x(srcdir, "/", name, "/dependencies", " explicitly lists ", S6RC_ONESHOT_RUNNER) ;
if (verbosity >= 4)
{
unsigned int i = service.common.ndeps ;
@@ -838,16 +848,16 @@ static inline void write_sizes (char const *compiled, s6rc_db_t const *db)
static inline void write_specials (char const *compiled)
{
- auto_dir(compiled, "servicedirs/" SPECIAL_NAME) ;
- auto_dir(compiled, "servicedirs/" SPECIAL_NAME "/data") ;
- auto_dir(compiled, "servicedirs/" SPECIAL_NAME "/data/rules") ;
- auto_dir(compiled, "servicedirs/" SPECIAL_NAME "/data/rules/uid") ;
- auto_dir(compiled, "servicedirs/" SPECIAL_NAME "/data/rules/uid/default") ;
- auto_file(compiled, "servicedirs/" SPECIAL_NAME "/data/rules/uid/default/deny", "", 0) ;
- auto_dir(compiled, "servicedirs/" SPECIAL_NAME "/data/rules/uid/0") ;
- auto_file(compiled, "servicedirs/" SPECIAL_NAME "/data/rules/uid/0/allow", "", 0) ;
- auto_file(compiled, "servicedirs/" SPECIAL_NAME "/run", SPECIAL_RUNSCRIPT, sizeof(SPECIAL_RUNSCRIPT) - 1) ;
- auto_rights(compiled, "servicedirs/" SPECIAL_NAME "/run", 0755) ;
+ auto_dir(compiled, "servicedirs/" S6RC_ONESHOT_RUNNER) ;
+ auto_dir(compiled, "servicedirs/" S6RC_ONESHOT_RUNNER "/data") ;
+ auto_dir(compiled, "servicedirs/" S6RC_ONESHOT_RUNNER "/data/rules") ;
+ auto_dir(compiled, "servicedirs/" S6RC_ONESHOT_RUNNER "/data/rules/uid") ;
+ auto_dir(compiled, "servicedirs/" S6RC_ONESHOT_RUNNER "/data/rules/uid/default") ;
+ auto_file(compiled, "servicedirs/" S6RC_ONESHOT_RUNNER "/data/rules/uid/default/deny", "", 0) ;
+ auto_dir(compiled, "servicedirs/" S6RC_ONESHOT_RUNNER "/data/rules/uid/0") ;
+ auto_file(compiled, "servicedirs/" S6RC_ONESHOT_RUNNER "/data/rules/uid/0/allow", "", 0) ;
+ auto_file(compiled, "servicedirs/" S6RC_ONESHOT_RUNNER "/run", S6RC_ONESHOT_RUNNER_RUNSCRIPT, sizeof(S6RC_ONESHOT_RUNNER_RUNSCRIPT) - 1) ;
+ auto_rights(compiled, "servicedirs/" S6RC_ONESHOT_RUNNER "/run", 0755) ;
}
static inline void write_resolve (char const *compiled, s6rc_db_t const *db, bundle_t const *bundles, unsigned int nbundles, uint32 const *bdeps)
diff --git a/src/s6-rc/s6-rc-compile.h b/src/s6-rc/s6-rc-compile.h
index 7d2bc19..6529af1 100644
--- a/src/s6-rc/s6-rc-compile.h
+++ b/src/s6-rc/s6-rc-compile.h
@@ -6,9 +6,7 @@
#include <execline/config.h>
#include <s6/config.h>
-#define SPECIAL_NAME "s6-oneshot-runner"
-
-#define SPECIAL_RUNSCRIPT \
+#define S6RC_ONESHOT_RUNNER_RUNSCRIPT \
"#!" EXECLINE_EXTBINPREFIX "execlineb -P\n" \
EXECLINE_EXTBINPREFIX "fdmove -c 2 1\n" \
S6_EXTBINPREFIX "s6-ipcserver-socketbinder -- s\n" \
diff --git a/src/s6-rc/s6-rc.c b/src/s6-rc/s6-rc.c
index 65516df..dc92d49 100644
--- a/src/s6-rc/s6-rc.c
+++ b/src/s6-rc/s6-rc.c
@@ -220,7 +220,7 @@ static void on_success (unsigned int i, int h)
if (h) state[i] |= 1 ; else state[i] &= 254 ;
announce() ;
if (verbosity >= 2)
- strerr_warni4x("service ", db->string + db->services[i].name, h ? "started" : "stopped", " successfully") ;
+ strerr_warni4x("service ", db->string + db->services[i].name, h ? " started" : " stopped", " successfully") ;
broadcast_success(i, h) ;
}
@@ -230,7 +230,7 @@ static void on_failure (unsigned int i, int h, int crashed, unsigned int code)
{
char fmt[UINT_FMT] ;
fmt[uint_fmt(fmt, code)] = 0 ;
- strerr_warnw7x("service ", db->string + db->services[i].name, h ? "started" : "stopped", " unsuccessfully", ": ", crashed ? " crashed with signal " : " exited ", fmt) ;
+ strerr_warnw6x("service ", db->string + db->services[i].name, h ? " started" : " stopped", " unsuccessfully: ", crashed ? "crashed with signal " : "exited ", fmt) ;
}
}
@@ -312,10 +312,6 @@ static int doit (int spfd, int h)
static void invert_selection (void)
{
register unsigned int i = n ;
-
- if (verbosity >= 3)
- strerr_warni1x("inverting the selection") ;
-
while (i--) state[i] ^= 2 ;
}
@@ -369,8 +365,6 @@ int main (int argc, char const *const *argv)
s6rc_db_t dbblob ;
char dbfn[livelen + 10] ;
db = &dbblob ;
- if (verbosity >= 3)
- strerr_warni3x("reading services database in ", live, "/compiled") ;
/* Take the live lock */
@@ -422,9 +416,6 @@ int main (int argc, char const *const *argv)
if (what.check)
{
unsigned int problem, w ;
- if (verbosity >= 3)
- strerr_warni1x("checking database consistency") ;
-
if (!s6rc_db_check_revdeps(&dbblob))
strerr_dief3x(4, "invalid service database in ", dbfn, ": direct and reverse dependencies are mismatched") ;
w = s6rc_db_check_depcycles(&dbblob, 1, &problem) ;
@@ -435,9 +426,6 @@ int main (int argc, char const *const *argv)
/* Resolve the args and add them to the selection */
- if (verbosity >= 3)
- strerr_warni1x("resolving command line arguments") ;
-
{
cdb_t c = CDB_ZERO ;
int fd = open_readatb(fdcompiled, "resolve.cdb") ;
@@ -448,7 +436,6 @@ int main (int argc, char const *const *argv)
{
unsigned int len ;
register int r ;
- if (verbosity >= 4) strerr_warnt2x("looking up ", *argv) ;
r = cdb_find(&c, *argv, str_len(*argv)) ;
if (r < 0) strerr_diefu3sys(111, "read ", dbfn, "/resolve.cdb") ;
if (!r)
@@ -470,12 +457,6 @@ int main (int argc, char const *const *argv)
if (x >= n)
strerr_dief3x(4, "invalid resolve database in ", dbfn, "/resolve.cdb") ;
state[x] |= 2 ;
- if (verbosity >= 4)
- {
- char fmt[UINT32_FMT] ;
- fmt[uint32_fmt(fmt, x)] = 0 ;
- strerr_warnt2x("adding service ", fmt) ;
- }
}
}
}
@@ -487,9 +468,6 @@ int main (int argc, char const *const *argv)
/* Read live state in bit 0 of state */
- if (verbosity >= 3)
- strerr_warni2x("reading current state in ", live) ;
-
byte_copy(dbfn + livelen + 1, 6, "state") ;
{
char tmpstate[n] ;
@@ -518,9 +496,6 @@ int main (int argc, char const *const *argv)
/* Compute the closure */
- if (verbosity >= 3)
- strerr_warni1x("computing the final set of services") ;
-
s6rc_graph_closure(db, state, 1, what.up) ;