aboutsummaryrefslogtreecommitdiff
path: root/src/pies.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-01-08 11:29:13 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-01-08 11:29:13 +0200
commit3325fed2895f079486b88c65409c73153fec306f (patch)
tree65165fde1e48346892cd0c0dfd7f7a4980ba1665 /src/pies.c
parent46b2745b25176c14c42bcc9612b290c310929aa0 (diff)
downloadpies-3325fed2895f079486b88c65409c73153fec306f.tar.gz
pies-3325fed2895f079486b88c65409c73153fec306f.tar.bz2
Enable control socket when run as init process.
* configure.ac (DEFAULT_CONTROL_URL): Rename to DEFAULT_PIES_CONTROL_URL. Change default value. (DEFAULT_INIT_CONTROL_URL): New subst variable. * lib/libpies.h (pies_basic_url_create): New prototype. * lib/url.c (pies_basic_url_create): New function (renamed from pies_url_create). (pies_url_create): Expand variable references in the input string. * src/Makefile.am (AM_CPPFLAGS): Pass DEFAULT_INIT_CONTROL_URL * src/ctl.c (pies_control_url) (ctl_open): Don't exit on errors, return -1 instead. * src/pies.c (default_control_url): New variable. (config_parse): Create default socket url. (pies_control_url): New macro (main): Set environment variable PIES_INSTANCE. Try to open control socket in init process mode as well. * src/pies.h (default_control_url): New extern. (ctl_open): Change prototype. (pies_control_url): Remove. * src/piesctl-cl.opt (parse_options): Set environment variable PIES_INSTANCE. * src/piesctl.c (parse_config): Use pies_url_create and DEFAULT_PIES_CONTROL_URL when falling back to the default socket.
Diffstat (limited to 'src/pies.c')
-rw-r--r--src/pies.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/pies.c b/src/pies.c
index 875684a..09f9fab 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -57,6 +57,11 @@ char *mailer_program = "/usr/sbin/sendmail";
char *mailer_command_line = "/usr/sbin/sendmail -oi -t";
int mailer_argc;
char **mailer_argv;
+
+char *default_control_url[2] = {
+ DEFAULT_PIES_CONTROL_URL,
+ DEFAULT_INIT_CONTROL_URL
+};
struct config_file
{
@@ -1749,6 +1754,18 @@ config_parse (char const *name)
if (grecs_tree_process (tree, pies_keywords))
config_error ();
+
+ if (!control.url)
+ {
+ char const *str = default_control_url[init_process];
+ if (pies_url_create (&control.url, str))
+ {
+ logmsg (LOG_CRIT, _("%s: cannot create control URL: %s"),
+ str, strerror (errno));
+ if (!init_process)
+ exit (EX_OSERR);
+ }
+ }
grecs_tree_free (tree);
}
@@ -1931,6 +1948,8 @@ pies_check_status (pid_t *ppid)
return pies_status_running;
}
+#define pies_control_url() control.url->string
+
void
request_restart_components (size_t cc, char **cv)
{
@@ -2230,7 +2249,7 @@ main (int argc, char **argv)
else
instance++;
}
-
+ setenv ("PIES_INSTANCE", instance, 1);
log_tag = instance;
if (!init_process)
@@ -2371,9 +2390,12 @@ main (int argc, char **argv)
diag_setup (DIAG_TO_SYSLOG);
}
- if (!init_process)
+ if (init_process)
+ ctl_open ();
+ else
{
- ctl_open ();
+ if (ctl_open ())
+ exit (EX_UNAVAILABLE);
create_pidfile (pidfile);
}

Return to:

Send suggestions and report system problems to the System administrator.