aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--configure.ac7
-rw-r--r--lib/libpies.h1
-rw-r--r--lib/url.c19
-rw-r--r--po/.gitignore1
-rw-r--r--src/Makefile.am3
-rw-r--r--src/ctl.c28
-rw-r--r--src/pies.c28
-rw-r--r--src/pies.h4
-rw-r--r--src/piesctl-cl.opt1
-rw-r--r--src/piesctl.c11
11 files changed, 64 insertions, 40 deletions
diff --git a/.gitignore b/.gitignore
index f7b417d..216d2e5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
1/ABOUT-NLS~
1*.a 2*.a
2*.la 3*.la
3*.lo 4*.lo
diff --git a/configure.ac b/configure.ac
index 3b34059..d6d4e4f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,8 +129,11 @@ AH_BOTTOM([
129# endif 129# endif
130]) 130])
131 131
132AC_SUBST([DEFAULT_CONTROL_URL],[unix:///tmp/%s.ctl]) 132AC_SUBST([DEFAULT_PIES_CONTROL_URL],['unix:///tmp/$${PIES_INSTANCE}.ctl'])
133AC_ARG_VAR([DEFAULT_CONTROL_URL], 133AC_ARG_VAR([DEFAULT_PIES_CONTROL_URL],
134 [URL of the default control socket])
135AC_SUBST([DEFAULT_INIT_CONTROL_URL],['unix:///dev/init.ctl'])
136AC_ARG_VAR([DEFAULT_INIT_CONTROL_URL],
134 [URL of the default control socket]) 137 [URL of the default control socket])
135 138
136IMPRIMATUR_INIT 139IMPRIMATUR_INIT
diff --git a/lib/libpies.h b/lib/libpies.h
index b04182e..1c83b8e 100644
--- a/lib/libpies.h
+++ b/lib/libpies.h
@@ -71,6 +71,7 @@ struct pies_url
71 char **argv; 71 char **argv;
72}; 72};
73 73
74int pies_basic_url_create (struct pies_url **purl, const char *str);
74int pies_url_create (struct pies_url **purl, const char *str); 75int pies_url_create (struct pies_url **purl, const char *str);
75void pies_url_destroy (struct pies_url **purl); 76void pies_url_destroy (struct pies_url **purl);
76const char *pies_url_get_arg (struct pies_url *url, const char *argname); 77const char *pies_url_get_arg (struct pies_url *url, const char *argname);
diff --git a/lib/url.c b/lib/url.c
index 41f5c04..11d220d 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -325,7 +325,7 @@ pies_url_copy (struct pies_url **purl, struct pies_url *src)
325} 325}
326 326
327int 327int
328pies_url_create (struct pies_url **purl, const char *str) 328pies_basic_url_create (struct pies_url **purl, const char *str)
329{ 329{
330 int rc; 330 int rc;
331 struct pies_url *url; 331 struct pies_url *url;
@@ -344,6 +344,23 @@ pies_url_create (struct pies_url **purl, const char *str)
344 } 344 }
345 return rc; 345 return rc;
346} 346}
347
348extern char **environ;
349
350int
351pies_url_create (struct pies_url **purl, const char *str)
352{
353 struct wordsplit ws;
354 int rc;
355
356 ws.ws_env = (const char**) environ;
357 if (wordsplit (str, &ws,
358 WRDSF_NOCMD | WRDSF_QUOTE | WRDSF_NOSPLIT | WRDSF_ENV))
359 return -1;
360 rc = pies_basic_url_create (purl, ws.ws_wordv[0]);
361 wordsplit_free (&ws);
362 return rc;
363}
347 364
348const char * 365const char *
349pies_url_get_arg (struct pies_url *url, const char *argname) 366pies_url_get_arg (struct pies_url *url, const char *argname)
diff --git a/po/.gitignore b/po/.gitignore
index d00dd8d..b45a955 100644
--- a/po/.gitignore
+++ b/po/.gitignore
@@ -1,3 +1,4 @@
1/Rules-quot~
1/Makevars.template~ 2/Makevars.template~
2/Makefile.in.in~ 3/Makefile.in.in~
3*.gmo 4*.gmo
diff --git a/src/Makefile.am b/src/Makefile.am
index 9fb29d2..01149c6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -87,7 +87,8 @@ AM_CPPFLAGS=\
87 -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\ 87 -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\
88 -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\ 88 -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\
89 -DDEFAULT_STATE_DIR=\"$(pkgstatedir)\"\ 89 -DDEFAULT_STATE_DIR=\"$(pkgstatedir)\"\
90 -DDEFAULT_CONTROL_URL=\"$(DEFAULT_CONTROL_URL)\" 90 -DDEFAULT_PIES_CONTROL_URL='"$(DEFAULT_PIES_CONTROL_URL)"'\
91 -DDEFAULT_INIT_CONTROL_URL='"$(DEFAULT_INIT_CONTROL_URL)"'
91 92
92AM_YFLAGS=-dvt -pmeta1 93AM_YFLAGS=-dvt -pmeta1
93AM_LFLAGS=-dvp -Pmeta1 -olex.yy.c 94AM_LFLAGS=-dvp -Pmeta1 -olex.yy.c
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)
1233 return 0; 1233 return 0;
1234} 1234}
1235 1235
1236char const * 1236int
1237pies_control_url (void) 1237ctl_open (void)
1238{
1239 if (!control.url)
1240 {
1241 char *str = xasprintf (DEFAULT_CONTROL_URL, instance);
1242 if (pies_url_create (&control.url, str))
1243 {
1244 logmsg (LOG_CRIT, _("%s: cannot create URL: %s"),
1245 str, strerror (errno));
1246 exit (EX_OSERR);
1247 }
1248 free (str);
1249 }
1250 return control.url->string;
1251}
1252
1253void
1254ctl_open ()
1255{ 1238{
1256 int fd; 1239 int fd;
1257 1240
1258 pies_control_url ();
1259 fd = create_socket (control.url, SOCK_STREAM, NULL, 077); 1241 fd = create_socket (control.url, SOCK_STREAM, NULL, 077);
1260 if (fd == -1) 1242 if (fd == -1)
1261 { 1243 {
1262 logmsg (LOG_CRIT, _("can't create control socket %s"), 1244 logmsg (LOG_CRIT, _("can't create control socket %s"),
1263 control.url->string); 1245 control.url->string);
1264 exit (EX_UNAVAILABLE); 1246 return -1;
1265 } 1247 }
1266 1248
1267 if (listen (fd, 8)) 1249 if (listen (fd, 8))
1268 { 1250 {
1269 logmsg (LOG_CRIT, _("can't listen on control socket %s: %s"), 1251 logmsg (LOG_CRIT, _("can't listen on control socket %s: %s"),
1270 control.url->string, strerror (errno)); 1252 control.url->string, strerror (errno));
1271 exit (EX_UNAVAILABLE); 1253 return -1;
1272 } 1254 }
1273 1255
1274 register_socket (fd, ctl_accept, NULL, NULL, NULL); 1256 register_socket (fd, ctl_accept, NULL, NULL, NULL);
1257
1258 return 0;
1275} 1259}
1276 1260
1277static void 1261static void
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";
57char *mailer_command_line = "/usr/sbin/sendmail -oi -t"; 57char *mailer_command_line = "/usr/sbin/sendmail -oi -t";
58int mailer_argc; 58int mailer_argc;
59char **mailer_argv; 59char **mailer_argv;
60
61char *default_control_url[2] = {
62 DEFAULT_PIES_CONTROL_URL,
63 DEFAULT_INIT_CONTROL_URL
64};
60 65
61struct config_file 66struct config_file
62{ 67{
@@ -1749,6 +1754,18 @@ config_parse (char const *name)
1749 1754
1750 if (grecs_tree_process (tree, pies_keywords)) 1755 if (grecs_tree_process (tree, pies_keywords))
1751 config_error (); 1756 config_error ();
1757
1758 if (!control.url)
1759 {
1760 char const *str = default_control_url[init_process];
1761 if (pies_url_create (&control.url, str))
1762 {
1763 logmsg (LOG_CRIT, _("%s: cannot create control URL: %s"),
1764 str, strerror (errno));
1765 if (!init_process)
1766 exit (EX_OSERR);
1767 }
1768 }
1752 1769
1753 grecs_tree_free (tree); 1770 grecs_tree_free (tree);
1754} 1771}
@@ -1931,6 +1948,8 @@ pies_check_status (pid_t *ppid)
1931 return pies_status_running; 1948 return pies_status_running;
1932} 1949}
1933 1950
1951#define pies_control_url() control.url->string
1952
1934void 1953void
1935request_restart_components (size_t cc, char **cv) 1954request_restart_components (size_t cc, char **cv)
1936{ 1955{
@@ -2230,7 +2249,7 @@ main (int argc, char **argv)
2230 else 2249 else
2231 instance++; 2250 instance++;
2232 } 2251 }
2233 2252 setenv ("PIES_INSTANCE", instance, 1);
2234 log_tag = instance; 2253 log_tag = instance;
2235 2254
2236 if (!init_process) 2255 if (!init_process)
@@ -2371,9 +2390,12 @@ main (int argc, char **argv)
2371 diag_setup (DIAG_TO_SYSLOG); 2390 diag_setup (DIAG_TO_SYSLOG);
2372 } 2391 }
2373 2392
2374 if (!init_process) 2393 if (init_process)
2394 ctl_open ();
2395 else
2375 { 2396 {
2376 ctl_open (); 2397 if (ctl_open ())
2398 exit (EX_UNAVAILABLE);
2377 create_pidfile (pidfile); 2399 create_pidfile (pidfile);
2378 } 2400 }
2379 2401
diff --git a/src/pies.h b/src/pies.h
index f69c512..f22ccb2 100644
--- a/src/pies.h
+++ b/src/pies.h
@@ -292,6 +292,7 @@ extern int dfl_level;
292 292
293extern size_t pies_master_argc; 293extern size_t pies_master_argc;
294extern char **pies_master_argv; 294extern char **pies_master_argv;