aboutsummaryrefslogtreecommitdiff
path: root/src/pies.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-06-24 12:56:24 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-06-24 12:56:24 +0300
commit006bfbc5235c181783445d321ce7a7e3c6d8bd8a (patch)
treef483e0d30c3e801add01b372b24a342281b70b86 /src/pies.c
parentcb90ca582a46ef9f0779837dc4c6fb00656e70c9 (diff)
downloadpies-006bfbc5235c181783445d321ce7a7e3c6d8bd8a.tar.gz
pies-006bfbc5235c181783445d321ce7a7e3c6d8bd8a.tar.bz2
Enable/disable SystemV init code at compile time
* configure.ac: New option --enable-sysvinit. Disable the init code if RUN_LVL is not available. (PIES_SYSVINIT_ENABLED): New configuration define. (PIES_COND_SYSVINIT): New condition Print configuration settings summary. * src/pies.h (is_sysvinit): Check for PIES_SYSVINIT_ENABLED. (SYSVINIT_ACTIVE): New macro. * grecs: Upgrade. * src/Makefile.am: Conditionally link sysvinit-related code. * src/cmdline.opt: Disable the --telinit option if sysvinit support is not available. (parse_options): Use SYSVINIT_ACTIVE in the conditional. * src/comp.c (component_verify): Check if component definition is allowed by the current state of the sysvinit support. * src/ctl.c: Disable the /runlevel entry point if sysvinit support is not compiled. * src/diag.c (stderr_open): Make sure sysvinit-related code is not compiled if the sysvinit support is not available. * src/pies.c (config_syntax_tab): Add entry for CONF_INITTAB only if sysvinit support is available. (_cb_initdefault,_cb_runlevels): Remove. Use cb_initdefault and cb_runlevels instead. (component_keywords): Disable runlevels without sysvinit support. (pies_keywords): Same for initdefault. Use SYSVINIT_ACTIVE to suppress compilation of sysvinit code without sysvinit support. * src/progman.c: Use SYSVINIT_ACTIVE to suppress compilation of sysvinit code without sysvinit support. * src/sysvinit.c (cb_initdefault,cb_runlevels): New functions.
Diffstat (limited to 'src/pies.c')
-rw-r--r--src/pies.c85
1 files changed, 22 insertions, 63 deletions
diff --git a/src/pies.c b/src/pies.c
index 2564af5..75285dc 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -75,7 +75,9 @@ static struct config_syntax config_syntax_tab[] = {
[CONF_PIES] = { "pies" , pies_config_parse },
[CONF_META1] = { "meta1", meta1_config_parse },
[CONF_INETD] = { "inetd", inetd_config_parse },
+#if PIES_SYSVINIT_ENABLED
[CONF_INITTAB] = { "inittab", inittab_parse },
+#endif
};
struct config_file
@@ -1205,56 +1207,6 @@ _cb_flags (enum grecs_callback_command cmd,
return 0;
}
-static int
-_cb_initdefault (enum grecs_callback_command cmd,
- grecs_node_t *node,
- void *varptr, void *cb_data)
-{
- grecs_locus_t *locus = &node->locus;
- grecs_value_t *value = node->v.value;
- int *val = varptr;
-
- if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
- return 1;
- if (strlen (value->v.string) != 1)
- {
- grecs_error (locus, 0, _("argument must be a single character"));
- return 1;
- }
- if (!is_valid_runlevel (value->v.string[0]))
- {
- grecs_error (locus, 0, _("not a valid runlevel"));
- return 1;
- }
- *val = toupper (value->v.string[0]);
- return 0;
-}
-
-static int
-_cb_runlevels (enum grecs_callback_command cmd,
- grecs_node_t *node,
- void *varptr, void *cb_data)
-{
- grecs_locus_t *locus = &node->locus;
- grecs_value_t *value = node->v.value;
- char **sptr = varptr, *p;
-
- if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
- return 1;
- for (p = value->v.string; *p; p++)
- {
- if (!is_valid_runlevel (*p))
- {
- grecs_error (locus, 0, _("not a valid runlevel: %c"), *p);
- return 1;
- }
- }
- *sptr = grecs_strdup (value->v.string);
- for (p = *sptr; *p; p++)
- *p = toupper (*p);
- return 0;
-}
-
struct grecs_keyword component_keywords[] = {
{"mode",
N_("mode"),
@@ -1294,12 +1246,14 @@ struct grecs_keyword component_keywords[] = {
N_("List of flags."),
grecs_type_string, GRECS_LIST, NULL, offsetof (struct component, flags),
_cb_flags },
+#if PIES_SYSVINIT_ENABLED
{"runlevels",
N_("chars"),
N_("Runlevels to start that component in."),
grecs_type_string, GRECS_DFLT,
NULL, offsetof (struct component, runlevels),
- _cb_runlevels },
+ cb_runlevels },
+#endif
{"pass-fd-socket",
N_("name"),
N_("Pass fd through this socket."),
@@ -1722,12 +1676,14 @@ struct grecs_keyword pies_keywords[] = {
grecs_type_string, GRECS_DFLT,
&pies_limits, 0, _cb_limits,
},
+#if PIES_SYSVINIT_ENABLED
{"initdefault",
N_("arg: char"),
N_("Default runlevel"),
grecs_type_string, GRECS_DFLT,
- &initdefault, 0, _cb_initdefault,
+ NULL, 0, cb_initdefault,
},
+#endif
{"shutdown-timeout",
"n",
N_("Wait <n> seconds for all components to shut down."),
@@ -1859,7 +1815,7 @@ pies_read_config (void)
++err;
}
- if (init_process)
+ if (SYSVINIT_ACTIVE)
err = 0;
if (err)
@@ -1898,7 +1854,7 @@ pies_schedule_children (int op)
RETSIGTYPE
sig_handler (int sig)
{
- if (init_process && sysvinit_sigtrans (sig, &action))
+ if (SYSVINIT_ACTIVE && sysvinit_sigtrans (sig, &action))
return;
switch (sig)
{
@@ -2278,7 +2234,7 @@ init_emu (void)
static void
set_conf_file_names (const char *base)
{
- if (init_process)
+ if (SYSVINIT_ACTIVE)
{
config_file_add_type (CONF_INITTAB, "/etc/inittab");
config_file_add_type (CONF_PIES, "/etc/pies.init");
@@ -2338,7 +2294,7 @@ main (int argc, char **argv)
}
/* Set default logging */
- if (init_process)
+ if (SYSVINIT_ACTIVE)
{
log_facility = LOG_DAEMON;
diag_flags = DIAG_TO_STDERR | DIAG_REOPEN_LOG;
@@ -2373,7 +2329,7 @@ main (int argc, char **argv)
set_conf_file_names (instance);
- if (init_process || !DEFAULT_PREPROCESSOR)
+ if (SYSVINIT_ACTIVE || !DEFAULT_PREPROCESSOR)
grecs_preprocessor = NULL;
else
grecs_preprocessor = pp_command_line ();
@@ -2451,7 +2407,7 @@ main (int argc, char **argv)
umask (pies_umask);
}
- if (init_process)
+ if (SYSVINIT_ACTIVE)
{
foreground = 1;
sysvinit_begin ();
@@ -2491,7 +2447,7 @@ main (int argc, char **argv)
logmsg (LOG_INFO, _("%s %s starting"), proginfo.package, proginfo.version);
- if (!init_process)
+ if (!SYSVINIT_ACTIVE)
{
if (ctl_open ())
exit (EX_UNAVAILABLE);
@@ -2516,7 +2472,7 @@ main (int argc, char **argv)
switch (action)
{
case ACTION_RESTART:
- if (pies_master_argv[0][0] != '/' || init_process)
+ if (pies_master_argv[0][0] != '/' || SYSVINIT_ACTIVE)
{
logmsg (LOG_INFO, _("restart command ignored"));
action = ACTION_CONT;
@@ -2532,7 +2488,7 @@ main (int argc, char **argv)
/* fall through */
case ACTION_COMMIT:
component_config_commit ();
- if (init_process)
+ if (SYSVINIT_ACTIVE)
sysvinit_runlevel_setup (PIES_COMP_DEFAULT);
progman_create_sockets ();
progman_start ();
@@ -2542,7 +2498,7 @@ main (int argc, char **argv)
break;
case ACTION_STOP:
- if (init_process)
+ if (SYSVINIT_ACTIVE)
{
debug (1, ("ignoring stop/restart"));
action = ACTION_CONT;
@@ -2551,6 +2507,7 @@ main (int argc, char **argv)
case ACTION_CTRLALTDEL:
debug (1, ("ctrl-alt-del"));
+ if (SYSVINIT_ACTIVE)
sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_ctrlaltdel));
pies_schedule_children (PIES_CHLD_WAKEUP);
action = ACTION_CONT;
@@ -2558,6 +2515,7 @@ main (int argc, char **argv)
case ACTION_KBREQUEST:
debug (1, ("kbrequest"));
+ if (SYSVINIT_ACTIVE)
sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_kbrequest));
pies_schedule_children (PIES_CHLD_WAKEUP);
action = ACTION_CONT;
@@ -2565,6 +2523,7 @@ main (int argc, char **argv)
case ACTION_POWER:
debug (1, ("SIGPWR"));
+ if (SYSVINIT_ACTIVE)
sysvinit_power ();
pies_schedule_children (PIES_CHLD_WAKEUP);
action = ACTION_CONT;
@@ -2582,7 +2541,7 @@ main (int argc, char **argv)
children_op = PIES_CHLD_NONE;
}
}
- while (init_process || action == ACTION_CONT);
+ while (SYSVINIT_ACTIVE || action == ACTION_CONT);
progman_stop ();
remove_pidfile (pidfile);

Return to:

Send suggestions and report system problems to the System administrator.