diff options
-rw-r--r-- | bootstrap.conf | 2 | ||||
-rw-r--r-- | src/pies.c | 51 | ||||
-rw-r--r-- | src/pies.h | 7 | ||||
-rw-r--r-- | src/progman.c | 8 |
4 files changed, 52 insertions, 16 deletions
diff --git a/bootstrap.conf b/bootstrap.conf index 5cf5980..d965892 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -1,4 +1,4 @@ -# Bootstrap configuration for GNU Pies. +# Bootstrap configuration for GNU Pies. -*- shell-script -*- # Copyright (C) 2008, 2009 Sergey Poznyakoff # # GNU Pies is free software; you can redistribute it and/or modify @@ -756,6 +756,41 @@ _cb_limits (enum grecs_callback_command cmd, return 0; } +static int +_cb_bitmask (enum grecs_callback_command cmd, + grecs_locus_t *locus, + int *fptr, grecs_value_t *value, int mask) +{ + int arg; + + if (assert_scalar_stmt (locus, cmd) + || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING) + || grecs_string_convert (&arg, grecs_type_bool, value->v.string, + locus)) + return 1; + if (arg) + *fptr |= mask; + else + *fptr &= ~mask; + return 0; +} + +static int +_cb_precious (enum grecs_callback_command cmd, + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) +{ + return _cb_bitmask (cmd, locus, varptr, value, CF_PRECIOUS); +} + +static int +_cb_disabled (enum grecs_callback_command cmd, + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) +{ + return _cb_bitmask (cmd, locus, varptr, value, CF_DISABLED); +} + struct grecs_keyword component_keywords[] = { {"mode", /* TRANSLATORS: The words between '{' and '}' are keywords, do not @@ -791,12 +826,6 @@ struct grecs_keyword component_keywords[] = { grecs_type_string | GRECS_LIST, NULL, offsetof (struct component, depend), NULL, }, - {"disable", - NULL, - N_("Disable this entry."), - grecs_type_bool, NULL, offsetof (struct component, disabled), - NULL, - }, {"pass-fd-timeout", NULL, N_("Time to wait for pass-fd socket to become available."), @@ -804,12 +833,18 @@ struct grecs_keyword component_keywords[] = { offsetof (struct component, pass_fd_timeout), NULL, }, + {"disable", + NULL, + N_("Disable this entry."), + grecs_type_bool, NULL, offsetof (struct component, flags), + _cb_disabled, + }, {"precious", NULL, N_("Mark this entry as precious."), grecs_type_bool, NULL, - offsetof (struct component, precious), - NULL, + offsetof (struct component, flags), + _cb_precious, }, {"socket", N_("url: string"), @@ -136,6 +136,9 @@ enum pies_comp_mode pies_comp_pass_fd }; +#define CF_DISABLED 0x01 /* The componenet is disabled */ +#define CF_PRECIOUS 0x02 /* The component is precious (cannot be disabled) */ + struct component { enum pies_comp_mode mode; @@ -147,9 +150,7 @@ struct component char *dir; /* Working directory */ gl_list_t prereq; /* Prerequisites */ gl_list_t depend; /* Dependency targets */ - /* FIXME: disabled and precious can be encoded as bits in mode */ - int disabled; /* The componenet is disabled */ - int precious; /* The component is precious (cannot be disabled) */ + int flags; /* CF_ bitmask */ char *rmfile; /* Try to remove this file before starting */ struct pies_privs privs; /* UID/GIDS+groups to run under */ mode_t umask; /* Umask to install before starting */ diff --git a/src/progman.c b/src/progman.c index f241915..801a75c 100644 --- a/src/progman.c +++ b/src/progman.c @@ -259,7 +259,7 @@ register_prog0 (struct component *comp, unsigned index) newp->v.p.comp = comp; newp->v.p.idx = index; newp->v.p.socket = -1; - if (comp->disabled) + if (comp->flags & CF_DISABLED) newp->v.p.status = status_disabled; else if (comp->mode == pies_comp_inetd) newp->v.p.status = status_listener; @@ -995,7 +995,7 @@ progman_dump_depmap () { prog = prog_lookup_by_idx (i); if (prog) - printf ("%2d: %s\n", (unsigned long)i, prog->tag); + printf ("%2lu: %s\n", (unsigned long)i, prog->tag); } } @@ -1199,7 +1199,7 @@ prog_start_prerequisites (struct prog *prog) struct prog *dp = prog_lookup_by_tag (prog->prereq[i]); if (!IS_COMPONENT (dp)) /* Skip redirectors */ continue; - if (prog->v.p.comp->precious) + if (prog->v.p.comp->flags & CF_PRECIOUS) continue; switch (dp->v.p.status) { @@ -1796,7 +1796,7 @@ progman_stop_component (const char *name) break; case status_disabled: - if (!prog->v.p.comp->disabled) + if (!(prog->v.p.comp->flags & CF_DISABLED)) prog->v.p.status = status_enabled; break; |