aboutsummaryrefslogtreecommitdiffstats
path: root/src/s6/s6.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-06-14 13:32:49 +0000
committerLaurent Bercot <ska@appnovation.com>2025-06-14 13:32:49 +0000
commit331d019eeb1104d4baa6af1d11ad228793b8d97f (patch)
tree7a9c8142d587844f23a1bde3432a4f7d57ecd2df /src/s6/s6.c
parent7d717a323bbc1558ee7710b3598c681388748652 (diff)
downloads6-frontend-331d019eeb1104d4baa6af1d11ad228793b8d97f.tar.gz
Set up configurable policy infrastructure
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/s6/s6.c')
-rw-r--r--src/s6/s6.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/s6/s6.c b/src/s6/s6.c
index 9b6b88a..8d5295c 100644
--- a/src/s6/s6.c
+++ b/src/s6/s6.c
@@ -32,6 +32,7 @@ enum main_golb_e
{
MAIN_GOLB_HELP,
MAIN_GOLB_VERSION,
+ MAIN_GOLB_USER,
MAIN_GOLB_N
} ;
@@ -40,6 +41,7 @@ enum main_gola_e
MAIN_GOLA_SCANDIR,
MAIN_GOLA_LIVEDIR,
MAIN_GOLA_REPODIR,
+ MAIN_GOLA_BOOTDIR,
MAIN_GOLA_VERBOSITY,
MAIN_GOLA_COLOR,
MAIN_GOLA_N
@@ -48,7 +50,8 @@ enum main_gola_e
static gol_bool const main_golb[MAIN_GOLB_N] =
{
{ .so = 'h', .lo = "help", .set = 1, .mask = 1 << MAIN_GOLB_HELP },
- { .so = 'V', .lo = "version", .set = 1, .mask = 1 << MAIN_GOLB_VERSION }
+ { .so = 'V', .lo = "version", .set = 1, .mask = 1 << MAIN_GOLB_VERSION },
+ { .so = 0, .lo = "user", .set = 1, .mask = 1 << MAIN_GOLB_USER }
} ;
static gol_arg const main_gola[MAIN_GOLA_N] =
@@ -56,6 +59,7 @@ static gol_arg const main_gola[MAIN_GOLA_N] =
{ .so = 's', .lo = "scandir", .i = MAIN_GOLA_SCANDIR },
{ .so = 'l', .lo = "livedir", .i = MAIN_GOLA_LIVEDIR },
{ .so = 'r', .lo = "repodir", .i = MAIN_GOLA_REPODIR },
+ { .so = 'b', .lo = "bootdir", .i = MAIN_GOLA_BOOTDIR },
{ .so = 'v', .lo = "verbosity", .i = MAIN_GOLA_VERBOSITY },
{ .so = 0, .lo = "color", .i = MAIN_GOLA_COLOR }
} ;
@@ -86,13 +90,14 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (gola[MAIN_GOLA_VERBOSITY] && !uint0_scan(gola[MAIN_GOLA_VERBOSITY], &g->verbosity))
strerr_dief1x(100, "verbosity must be an unsigned integer") ;
- if (golb & (1 << MAIN_GOLB_VERSION)) version(argv) ;
- if (golb & (1 << MAIN_GOLB_HELP)) help(argv) ;
- if (golb & ((1 << MAIN_GOLB_VERSION) | (1 << MAIN_GOLB_HELP))) return 0 ;
+ if (golb & 1 << MAIN_GOLB_VERSION) version(argv) ;
+ if (golb & 1 << MAIN_GOLB_HELP) help(argv) ;
+ if (golb & (1 << MAIN_GOLB_VERSION | 1 << MAIN_GOLB_HELP)) return 0 ;
- if (gola[MAIN_GOLA_SCANDIR]) g->scandir = gola[MAIN_GOLA_SCANDIR] ;
- if (gola[MAIN_GOLA_LIVEDIR]) g->livedir = gola[MAIN_GOLA_LIVEDIR] ;
- if (gola[MAIN_GOLA_REPODIR]) g->repodir = gola[MAIN_GOLA_REPODIR] ;
+ if (gola[MAIN_GOLA_SCANDIR]) g->dirs.scan = gola[MAIN_GOLA_SCANDIR] ;
+ if (gola[MAIN_GOLA_LIVEDIR]) g->dirs.live = gola[MAIN_GOLA_LIVEDIR] ;
+ if (gola[MAIN_GOLA_REPODIR]) g->dirs.repo = gola[MAIN_GOLA_REPODIR] ;
+ if (gola[MAIN_GOLA_BOOTDIR]) g->dirs.boot = gola[MAIN_GOLA_BOOTDIR] ;
{
int force_color = 0 ;
@@ -115,6 +120,9 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (!force_color) g->color = g->istty ;
}
+ g->isuser = !!(golb & 1 << MAIN_GOLB_USER) ;
+ if (g->isuser) s6f_user_get_confdirs(&g->dirs, &g->userstorage) ;
+
if (!*argv) dieusage() ;
cmd = BSEARCH(struct command_s, *argv, main_commands) ;
if (!cmd) dieusage() ;