summaryrefslogtreecommitdiffabout
path: root/src/ctl.c
authorSergey Poznyakoff <gray@gnu.org.ua>2016-01-08 09:29:13 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-01-08 09:29:13 (GMT)
commit3325fed2895f079486b88c65409c73153fec306f (patch) (side-by-side diff)
tree65165fde1e48346892cd0c0dfd7f7a4980ba1665 /src/ctl.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/ctl.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/ctl.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/ctl.c b/src/ctl.c
index 78490cb..46038a2 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -1233,45 +1233,29 @@ ctl_accept (int socket, void *data)
return 0;
}
-char const *
-pies_control_url (void)
-{
- if (!control.url)
- {
- char *str = xasprintf (DEFAULT_CONTROL_URL, instance);
- if (pies_url_create (&control.url, str))
- {
- logmsg (LOG_CRIT, _("%s: cannot create URL: %s"),
- str, strerror (errno));
- exit (EX_OSERR);
- }
- free (str);
- }
- return control.url->string;
-}
-
-void
-ctl_open ()
+int
+ctl_open (void)
{
int fd;
- pies_control_url ();
fd = create_socket (control.url, SOCK_STREAM, NULL, 077);
if (fd == -1)
{
logmsg (LOG_CRIT, _("can't create control socket %s"),
control.url->string);
- exit (EX_UNAVAILABLE);
+ return -1;
}
if (listen (fd, 8))
{
logmsg (LOG_CRIT, _("can't listen on control socket %s: %s"),
control.url->string, strerror (errno));
- exit (EX_UNAVAILABLE);
+ return -1;
}
register_socket (fd, ctl_accept, NULL, NULL, NULL);
+
+ return 0;
}
static void

Return to:

Send suggestions and report system problems to the System administrator.