diff options
| -rw-r--r-- | src/s6-frontend/set.help.txt | 33 | ||||
| -rw-r--r-- | src/s6-frontend/set_apply.c | 12 | ||||
| -rw-r--r-- | src/s6-frontend/set_check.c | 21 | ||||
| -rw-r--r-- | src/s6-frontend/set_commit.c | 11 | ||||
| -rw-r--r-- | src/s6-frontend/set_list.c | 23 |
5 files changed, 49 insertions, 51 deletions
diff --git a/src/s6-frontend/set.help.txt b/src/s6-frontend/set.help.txt index 1da3a8a..8a748f8 100644 --- a/src/s6-frontend/set.help.txt +++ b/src/s6-frontend/set.help.txt @@ -2,31 +2,31 @@ Usage: s6 set subcommand [ options ] [ arguments... ] Subcommands: help this message - copy copy a set to another name (default name is "current") + copy copy a set to another name delete delete one or more sets - list list services in the working set - status list services in the working set with their rx - enable enable services - disable disable services - mask mask services (hide them from the db entirely) - unmask unmask services (equivalent to "disable") - check check working set and fix inconsistencies - commit commit working set (can then be installed) - apply make working set live: commit + live install + live reset + list list services in a set + status list named services in the current set with their rx + enable enable services in the current set + disable disable services in the current set + mask mask services (hide them from the db entirely) in the current set + unmask unmask services (equivalent to "disable") in the current set + check check a set and fix inconsistencies + commit commit a set + apply make a set live: commit + live install + live reset s6 set copy options: -f --force overwrite named set if existing -s6 set delete options: none +s6 set delete options: none, takes a list of set names as arguments -s6 set list options: - -s SET --set=SET show services in set SET (default: current) +s6 set list options: none, takes a set name as an optional argument (default: current) s6 set status options: -E --with-essentials show all services, even essential ones (default) -e --without-essentials don't show essential services -s SET --set=SET show services in set SET (default: current) +Takes a list of services to see the status of as optional arguments (default: all services) s6 set enable|disable|mask|unmask options: -f --ignore-dependencies only change listed services @@ -36,6 +36,7 @@ s6 set enable|disable|mask|unmask options: -P --no-pull-dependencies warn on unlisted dependencies (default) -p --pull-dependencies apply the rx change to unlisted dependencies as well -s SET --set=SET change services in set SET (default: current) +Takes a list of services as mandatory arguments. s6 set check options: -E --no-force-essentials do not allow manual changes to essential services (default) @@ -43,18 +44,18 @@ s6 set check options: -F --fix try to fix inconsistencies automatically -d --down fix by disabling or masking services if necessary (default) -u --up fix by enabling services if necessary - -s SET --set=SET check set SET (default: current) +Takes a set name as an optional argument (default: current) s6 set commit options: -f --force compile db even if up-to-date -K --keep-old keep old db if any, print its path to stdout -D BUN --default-bundle=BUN name of the bundle containing enabled+essential services - -s SET --set=SET commit set SET (default: current) +Takes a set name as an optional argument (default: current) s6 set apply options: -b --block block if another s6-rc is running (default: fail) -D BUN --default-bundle=BUN name of the bundle containing enabled+essential services -f CONVFILE --conversion-file=CONVFILE use CONVFILE when updating the service db (default: none) - -s SET --set=SET apply set SET (default: current) -t TIMEOUT --timeout=TIMEOUT fail after TIMEOUT milliseconds (default: 0 (=infinite)) +Takes a set name as an optional argument (default: current) diff --git a/src/s6-frontend/set_apply.c b/src/s6-frontend/set_apply.c index c250ad5..e88f002 100644 --- a/src/s6-frontend/set_apply.c +++ b/src/s6-frontend/set_apply.c @@ -18,7 +18,6 @@ enum gola_e { GOLA_DEFBUNDLE, GOLA_CONVFILE, - GOLA_SET, GOLA_TIMEOUT, GOLA_N } ; @@ -33,7 +32,6 @@ void set_apply (char const *const *argv) { { .so = 'D', .lo = "default-bundle", .i = GOLA_DEFBUNDLE }, { .so = 'f', .lo = "conversion-file", .i = GOLA_CONVFILE }, - { .so = 's', .lo = "set", .i = GOLA_SET }, { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT }, } ; uint64_t wgolb = 0 ; @@ -43,13 +41,13 @@ void set_apply (char const *const *argv) pid_t pid ; char const *wgola[GOLA_N] = { 0 } ; size_t slen = strlen(g->dirs.scan) ; + char const *set ; char const *newargv[17] ; char fmtv[UINT_FMT] ; char fmtt[UINT_FMT] ; char catchall[slen + 15] ; wgola[GOLA_DEFBUNDLE] = S6_FRONTEND_DEFBUNDLE ; - wgola[GOLA_SET] = "current" ; argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; @@ -59,6 +57,10 @@ void set_apply (char const *const *argv) strerr_dief1x(100, "timeout must be an integer (milliseconds)") ; } + set = *argv ? *argv : "current" ; + if (set[0] == '.' || strchr(set, '/') || strchr(set, '\n')) + strerr_dief(100, "invalid set name: ", set) ; + memcpy(catchall, g->dirs.scan, slen) ; memcpy(catchall + slen, "/s6-svscan-log", 15) ; @@ -82,7 +84,7 @@ void set_apply (char const *const *argv) newargv[m++] = "-L" ; newargv[m++] = catchall ; newargv[m++] = "--" ; - newargv[m++] = wgola[GOLA_SET] ; + newargv[m++] = set ; newargv[m++] = 0 ; pid = main_spawn(newargv) ; @@ -113,7 +115,7 @@ void set_apply (char const *const *argv) newargv[m++] = wgola[GOLA_CONVFILE] ; } newargv[m++] = "--" ; - newargv[m++] = wgola[GOLA_SET] ; + newargv[m++] = set ; newargv[m++] = 0 ; pid = main_spawn(newargv) ; diff --git a/src/s6-frontend/set_check.c b/src/s6-frontend/set_check.c index bbbe6e9..41226e5 100644 --- a/src/s6-frontend/set_check.c +++ b/src/s6-frontend/set_check.c @@ -3,6 +3,7 @@ #include <skalibs/uint64.h> #include <skalibs/types.h> #include <skalibs/gol.h> +#include <skalibs/strerr.h> #include <execline/config.h> @@ -18,12 +19,6 @@ enum golb_e GOLB_FIX = 0x04, } ; -enum gola_e -{ - GOLA_SET, - GOLA_N -} ; - void set_check (char const *const *argv) { static gol_bool const rgolb[] = @@ -34,17 +29,17 @@ void set_check (char const *const *argv) { .so = 'u', .lo = "up", .clear = 0, .set = GOLB_FIXUP }, { .so = 'F', .lo = "fix", .clear = 0, .set = GOLB_FIX }, } ; - static gol_arg const rgola[] = - { - { .so = 's', .lo = "set", .i = GOLA_SET }, - } ; uint64_t wgolb = 0 ; - char const *wgola[GOLA_N] = { [GOLA_SET] = "current" } ; unsigned int m = 0 ; + char const *set ; char const *newargv[11] ; char fmtv[UINT_FMT] ; - argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; + argv += gol_argv(argv, rgolb, sizeof(rgolb)/sizeof(gol_bool), 0, 0, &wgolb, 0) ; + + set = *argv ? *argv : "current" ; + if (set[0] == '.' || strchr(set, '/') || strchr(set, '\n')) + strerr_dief(100, "invalid set name: ", set) ; newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-fix" ; if (g->verbosity != 1) @@ -59,7 +54,7 @@ void set_check (char const *const *argv) newargv[m++] = wgolb & GOLB_FIXUP ? "--fix-up" : "--fix-down" ; if (!(wgolb & GOLB_FIX)) newargv[m++] = "--dry-run" ; newargv[m++] = "--" ; - newargv[m++] = wgola[GOLA_SET] ; + newargv[m++] = set ; newargv[m++] = 0 ; main_exec(newargv) ; diff --git a/src/s6-frontend/set_commit.c b/src/s6-frontend/set_commit.c index 105c012..ec495fc 100644 --- a/src/s6-frontend/set_commit.c +++ b/src/s6-frontend/set_commit.c @@ -3,6 +3,7 @@ #include <skalibs/uint64.h> #include <skalibs/types.h> #include <skalibs/gol.h> +#include <skalibs/strerr.h> #include <s6-rc/config.h> @@ -17,7 +18,6 @@ enum golb_e enum gola_e { GOLA_DEFBUNDLE, - GOLA_SET, GOLA_N } ; @@ -31,21 +31,24 @@ void set_commit (char const *const *argv) static gol_arg const rgola[] = { { .so = 'D', .lo = "default-bundle", .i = GOLA_DEFBUNDLE }, - { .so = 's', .lo = "set", .i = GOLA_SET }, } ; uint64_t wgolb = 0 ; unsigned int m = 0 ; size_t slen = strlen(g->dirs.scan) ; char const *wgola[GOLA_N] = { 0 } ; + char const *set ; char const *newargv[14] ; char fmtv[UINT_FMT] ; char catchall[slen + 15] ; wgola[GOLA_DEFBUNDLE] = S6_FRONTEND_DEFBUNDLE ; - wgola[GOLA_SET] = "current" ; argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; + set = *argv ? *argv : "current" ; + if (set[0] == '.' || strchr(set, '/') || strchr(set, '\n')) + strerr_dief(100, "invalid set name: ", set) ; + memcpy(catchall, g->dirs.scan, slen) ; memcpy(catchall + slen, "/s6-svscan-log", 15) ; @@ -70,7 +73,7 @@ void set_commit (char const *const *argv) newargv[m++] = "-L" ; newargv[m++] = catchall ; newargv[m++] = "--" ; - newargv[m++] = wgola[GOLA_SET] ; + newargv[m++] = set ; newargv[m++] = 0 ; main_exec(newargv) ; } diff --git a/src/s6-frontend/set_list.c b/src/s6-frontend/set_list.c index d1a127f..77df219 100644 --- a/src/s6-frontend/set_list.c +++ b/src/s6-frontend/set_list.c @@ -1,7 +1,9 @@ /* ISC license. */ +#include <skalibs/uint64.h> #include <skalibs/types.h> #include <skalibs/gol.h> +#include <skalibs/strerr.h> #include <execline/config.h> @@ -14,12 +16,6 @@ enum golb_e GOLB_IGNORE_ESSENTIALS = 0x01, } ; -enum gola_e -{ - GOLA_SET, - GOLA_N -} ; - void set_list (char const *const *argv) { static gol_bool const rgolb[] = @@ -27,16 +23,17 @@ void set_list (char const *const *argv) { .so = 'E', .lo = "with-essentials", .clear = GOLB_IGNORE_ESSENTIALS, .set = 0 }, { .so = 'e', .lo = "without-essentials", .clear = 0, .set = GOLB_IGNORE_ESSENTIALS }, } ; - static gol_arg const rgola[] = - { - { .so = 's', .lo = "set", .i = GOLA_SET }, - } ; uint64_t wgolb = 0 ; - char const *wgola[GOLA_N] = { [GOLA_SET] = "current" } ; unsigned int m = 0 ; + char const *set ; char const *newargv[10] ; char fmtv[UINT_FMT] ; - argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; + + argv += gol_argv(argv, rgolb, sizeof(rgolb)/sizeof(gol_bool), 0, 0, &wgolb, 0) ; + + set = *argv ? *argv : "current" ; + if (set[0] == '.' || strchr(set, '/') || strchr(set, '\n')) + strerr_dief(100, "invalid set name: ", set) ; newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-status" ; fmtv[uint_fmt(fmtv, g->verbosity)] = 0 ; @@ -47,7 +44,7 @@ void set_list (char const *const *argv) newargv[m++] = "-L" ; newargv[m++] = wgolb & GOLB_IGNORE_ESSENTIALS ? "--without-essentials" : "--with-essentials" ; newargv[m++] = "--" ; - newargv[m++] = wgola[GOLA_SET] ; + newargv[m++] = set ; newargv[m++] = 0 ; main_exec(newargv) ; } |
