diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2015-12-20 00:50:52 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2015-12-20 00:59:25 +0200 |
commit | d479bd2f63445524253e16d8575a0592c266908d (patch) | |
tree | aae2188767328ee7dac100e14ad58ec75eeb35e5 /src/pies.c | |
parent | 84e4b3d5274c599ed30482bfe2ca8af080d936af (diff) | |
download | pies-d479bd2f63445524253e16d8575a0592c266908d.tar.gz pies-d479bd2f63445524253e16d8575a0592c266908d.tar.bz2 |
Bugfixes in init mode
* src/ctl.c (ctl_open): Add missing return.
* src/pies.c (config_parse): Return if tree is null.
(main) [INIT_EMU]: Print more info. Override default init_fifo.
Don't use syslog and control socket if running as init process.
* src/pies.h (init_fifo): New extern.
* src/progman.c (open_redirector): Return -1 if running as init process.
(prog_start): Always initialize redir[].
* src/sysvinit.c (init_fifo): New variable. Use it instead if the
INIT_FIFO macro.
(inittrans): Call create_fifo once, when transiting from boot to
normal state.
Diffstat (limited to 'src/pies.c')
-rw-r--r-- | src/pies.c | 44 |
1 files changed, 35 insertions, 9 deletions
@@ -22,7 +22,7 @@ int preprocess_only; /* Preprocess config, do nothing more */ int lint_mode; /* Test configuration syntax and exit */ -int log_to_stderr_only; /* Use only stderr for logging */ +int log_to_stderr_only; /* Use only stderr for logging */ int log_facility = LOG_USER; char *log_tag; struct pies_privs pies_privs; @@ -1816,9 +1816,13 @@ config_parse (char const *name) { struct grecs_node *node; struct grecs_node *tree = grecs_parse (name); - if (!tree) - config_error (); + if (!tree) + { + config_error (); + return; + } + for (node = tree; node; node = node->next) { node = grecs_find_node (node, "identity-provider"); @@ -2305,7 +2309,8 @@ main (int argc, char **argv) pid_t pid; extern char **environ; struct grecs_list_entry *ep; - + int diag_flags; + set_program_name (argv[0]); #ifdef ENABLE_NLS setlocale (LC_ALL, ""); @@ -2322,14 +2327,29 @@ main (int argc, char **argv) # warning "pies compiled with init emulation code" if (!init_process) { - fprintf (stderr, "%s: to enable init emulation code,\n", program_name); - fprintf (stderr, "%s: define environment variable INIT_EMU=<inittab>[:<pies_init_file>]\n", program_name); init_process = getenv ("INIT_EMU") != NULL; + if (init_process) + fprintf (stderr, "%s: running in init emulation mode\n", program_name); + else + { + fprintf (stderr, + "%s: to enable init emulation code,\n", program_name); + fprintf (stderr, + "%s: define environment variable INIT_EMU=<inittab>[:<pies_init_file>]\n", program_name); + fprintf (stderr, + "%s: define variable INIT_FIFO=<pathname> to override the default FIFO name\n", + program_name); + } } #endif /* Set default logging */ - diag_setup (DIAG_TO_SYSLOG | (stderr_closed_p () ? 0 : DIAG_TO_STDERR)); + if (init_process) + diag_flags = DIAG_TO_STDERR; + else + diag_flags = DIAG_TO_SYSLOG | (stderr_closed_p () ? 0 : DIAG_TO_STDERR); + + diag_setup (diag_flags); config_init (); if (init_process) @@ -2342,6 +2362,10 @@ main (int argc, char **argv) char *piesinit = strtok (NULL, ":"); add_config (CONF_INITTAB, inittab); add_config (CONF_PIES, piesinit ? piesinit : "/etc/pies.init"); + + init_fifo = getenv ("INIT_FIFO"); + if (!init_fifo) + init_fifo = "/tmp/initctl"; } else { @@ -2517,9 +2541,11 @@ main (int argc, char **argv) diag_setup (DIAG_TO_SYSLOG); } - ctl_open (); if (!init_process) - create_pidfile (pidfile); + { + ctl_open (); + create_pidfile (pidfile); + } if (argv[0][0] != '/') logmsg (LOG_NOTICE, |