diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-12-30 15:36:56 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-01-04 12:29:27 +0200 |
commit | cf14c349fad774e477a80d1c5e6572f21f17ced1 (patch) | |
tree | d8d73b072902cadc5aea5583119ec9e4e8ced2bc | |
parent | 64c343ff8f11c8379ec21916ba915a2894495797 (diff) | |
download | pies-cf14c349fad774e477a80d1c5e6572f21f17ced1.tar.gz pies-cf14c349fad774e477a80d1c5e6572f21f17ced1.tar.bz2 |
Initial support for running as init process.
* grecs: Upgrade.
* lib/Makefile.am: Use AM_CPPFLAGS instead of INCLUDES.
* src/Makefile.am: Likewise.
* src/acl.c: Update grecs_keyword definitions.
* src/inetd.c (inetd_conf_file): Bugfix. The ws structure could
be free'd prior to initialization.
* src/pies.c: Update grecs_keyword definitions.
(init_process,initdefault,dfl_level): New globals.
(modetab) <once>: New keyword.
(component_keywords)<runlevels,initdefault>: New keywords.
(main): Initial support for init(8) mode.
* src/pies.h (pies_comp_mode) <pies_comp_exec_once>: New constant.
(component)<runlevels>: New member.
(init_process,console_device,initdefault): New externs.
* src/progman.c (prog_status)<status_finished>: New status.
(prog)<runlevels>: New member.
(progman_running_p): New function.
(prog_start): Special handling for init process mode.
(progman_start): Likewise. Take into account runlevels.
(progman_dump_stats): New flag 'f' for status_finished.
m--------- | grecs | 0 | ||||
-rw-r--r-- | lib/Makefile.am | 2 | ||||
-rw-r--r-- | src/Makefile.am | 10 | ||||
-rw-r--r-- | src/acl.c | 4 | ||||
-rw-r--r-- | src/inetd.c | 13 | ||||
-rw-r--r-- | src/pies.c | 509 | ||||
-rw-r--r-- | src/pies.h | 53 | ||||
-rw-r--r-- | src/progman.c | 185 |
8 files changed, 567 insertions, 209 deletions
diff --git a/grecs b/grecs | |||
Subproject a52ab6c6c38e1dca047ada4d60249fb323942f0 | Subproject 5596f7cdcdc1983021185c5e0900d5fcba7f328 | ||
diff --git a/lib/Makefile.am b/lib/Makefile.am index 2569bd1..5883021 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am | |||
@@ -25,5 +25,5 @@ libpies_a_SOURCES=\ | |||
25 | 25 | ||
26 | libpies_a_LIBADD=$(LIBOBJS) | 26 | libpies_a_LIBADD=$(LIBOBJS) |
27 | 27 | ||
28 | INCLUDES = -I$(top_srcdir)/gnu -I../gnu | 28 | AM_CPPFLAGS = -I$(top_srcdir)/gnu -I../gnu |
29 | 29 | ||
diff --git a/src/Makefile.am b/src/Makefile.am index 455b2c2..44e0a8d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -54,12 +54,6 @@ SUFFIXES=.opt .c .h | |||
54 | 54 | ||
55 | cmdline.h: cmdline.opt | 55 | cmdline.h: cmdline.opt |
56 | 56 | ||
57 | INCLUDES = \ | ||
58 | -I$(top_srcdir)/lib\ | ||
59 | -I$(top_srcdir)/gnu\ | ||
60 | -I$(top_builddir)/gnu\ | ||
61 | @GRECS_INCLUDES@ | ||
62 | |||
63 | LDADD = \ | 57 | LDADD = \ |
64 | ../lib/libpies.a\ | 58 | ../lib/libpies.a\ |
65 | @GRECS_LDADD@\ | 59 | @GRECS_LDADD@\ |
@@ -69,6 +63,10 @@ LDADD = \ | |||
69 | pkgstatedir=$(localstatedir)/pies | 63 | pkgstatedir=$(localstatedir)/pies |
70 | 64 | ||
71 | AM_CPPFLAGS=\ | 65 | AM_CPPFLAGS=\ |
66 | -I$(top_srcdir)/lib\ | ||
67 | -I$(top_srcdir)/gnu\ | ||
68 | -I$(top_builddir)/gnu\ | ||
69 | @GRECS_INCLUDES@\ | ||
72 | -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)"\ | 70 | -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)"\ |
73 | -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\ | 71 | -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\ |
74 | -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\ | 72 | -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\ |
@@ -482,12 +482,12 @@ struct grecs_keyword acl_keywords[] = { | |||
482 | /* TRANSLATORS: only words within angle brackets are translatable */ | 482 | /* TRANSLATORS: only words within angle brackets are translatable */ |
483 | { "allow", N_("[all|authenticated|group <grp: list>] [from <addr: list>]"), | 483 | { "allow", N_("[all|authenticated|group <grp: list>] [from <addr: list>]"), |
484 | N_("Allow access"), | 484 | N_("Allow access"), |
485 | grecs_type_string, NULL, 0, | 485 | grecs_type_string, GRECS_MULT, NULL, 0, |
486 | allow_cb }, | 486 | allow_cb }, |
487 | /* TRANSLATORS: only words within angle brackets are translatable */ | 487 | /* TRANSLATORS: only words within angle brackets are translatable */ |
488 | { "deny", N_("[all|authenticated|group <grp: list>] [from <addr: list>]"), | 488 | { "deny", N_("[all|authenticated|group <grp: list>] [from <addr: list>]"), |
489 | N_("Deny access"), | 489 | N_("Deny access"), |
490 | grecs_type_string, NULL, 0, | 490 | grecs_type_string, GRECS_MULT, NULL, 0, |
491 | deny_cb }, | 491 | deny_cb }, |
492 | { NULL } | 492 | { NULL } |
493 | }; | 493 | }; |
diff --git a/src/inetd.c b/src/inetd.c index 1d7798d..febd84e 100644 --- a/src/inetd.c +++ b/src/inetd.c | |||
@@ -84,6 +84,7 @@ inetd_conf_file (const char *file) | |||
84 | size_t line_no = 0; | 84 | size_t line_no = 0; |
85 | struct wordsplit ws; | 85 | struct wordsplit ws; |
86 | char *dfl_address = NULL; | 86 | char *dfl_address = NULL; |
87 | int wsflags; | ||
87 | 88 | ||
88 | fp = fopen (file, "r"); | 89 | fp = fopen (file, "r"); |
89 | if (!fp) | 90 | if (!fp) |
@@ -94,6 +95,7 @@ inetd_conf_file (const char *file) | |||
94 | return 1; | 95 | return 1; |
95 | } | 96 | } |
96 | 97 | ||
98 | wsflags = WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_WS | WRDSF_SQUEEZE_DELIMS; | ||
97 | while (getline (&buf, &size, fp) >= 0) | 99 | while (getline (&buf, &size, fp) >= 0) |
98 | { | 100 | { |
99 | char *p; | 101 | char *p; |
@@ -111,9 +113,6 @@ inetd_conf_file (const char *file) | |||
111 | struct inetd_builtin *builtin; | 113 | struct inetd_builtin *builtin; |
112 | char *tag; | 114 | char *tag; |
113 | 115 | ||
114 | if (line_no) | ||
115 | wordsplit_free (&ws); | ||
116 | |||
117 | line_no++; | 116 | line_no++; |
118 | for (p = buf; *p && c_isblank (*p); p++) | 117 | for (p = buf; *p && c_isblank (*p); p++) |
119 | ; | 118 | ; |
@@ -121,14 +120,12 @@ inetd_conf_file (const char *file) | |||
121 | if (!p || *p == '\n' || *p == '#') | 120 | if (!p || *p == '\n' || *p == '#') |
122 | continue; | 121 | continue; |
123 | 122 | ||
124 | if (wordsplit (p, &ws, | 123 | if (wordsplit (p, &ws, wsflags)) |
125 | WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_WS | | ||
126 | WRDSF_SQUEEZE_DELIMS)) | ||
127 | { | 124 | { |
128 | logmsg (LOG_ERR, "wordsplit: %s", strerror (errno)); | 125 | logmsg (LOG_ERR, "wordsplit: %s", strerror (errno)); |
129 | continue; | 126 | continue; |
130 | } | 127 | } |
131 | 128 | wsflags |= WRDSF_REUSE; | |
132 | if (ws.ws_wordc == 1) | 129 | if (ws.ws_wordc == 1) |
133 | { | 130 | { |
134 | size_t len = strlen (ws.ws_wordv[IFLD_SERVICE]); | 131 | size_t len = strlen (ws.ws_wordv[IFLD_SERVICE]); |
@@ -308,7 +305,7 @@ inetd_conf_file (const char *file) | |||
308 | register_prog (comp); | 305 | register_prog (comp); |
309 | } | 306 | } |
310 | 307 | ||
311 | if (line_no) | 308 | if (wsflags & WRDSF_REUSE) |
312 | wordsplit_free (&ws); | 309 | wordsplit_free (&ws); |
313 | free (dfl_address); | 310 | free (dfl_address); |
314 | free (buf); | 311 | free (buf); |
@@ -26,6 +26,7 @@ int log_facility = LOG_USER; | |||
26 | char *log_tag; | 26 | char *log_tag; |
27 | struct pies_privs pies_privs; | 27 | struct pies_privs pies_privs; |
28 | int foreground; | 28 | int foreground; |
29 | int init_process; | ||
29 | 30 | ||
30 | enum pies_command { | 31 | enum pies_command { |
31 | COM_START, | 32 | COM_START, |
@@ -38,6 +39,8 @@ enum pies_command { | |||
38 | }; | 39 | }; |
39 | 40 | ||
40 | enum pies_command command; | 41 | enum pies_command command; |
42 | int initdefault; /* Default runlevel */ | ||
43 | int dfl_level; | ||
41 | char *statedir = DEFAULT_STATE_DIR; | 44 | char *statedir = DEFAULT_STATE_DIR; |
42 | char *instance; | 45 | char *instance; |
43 | char *pidfile; | 46 | char *pidfile; |
@@ -95,8 +98,8 @@ str_to_config_syntax (const char *str, enum config_syntax *psynt) | |||
95 | for (p = config_syntax_tab; p->name; p++) | 98 | for (p = config_syntax_tab; p->name; p++) |
96 | if (strcmp (p->name, str) == 0) | 99 | if (strcmp (p->name, str) == 0) |
97 | { | 100 | { |
98 | *psynt = p->type; | 101 | *psynt = p->type; |
99 | return 0; | 102 | return 0; |
100 | } | 103 | } |
101 | return 1; | 104 | return 1; |
102 | } | 105 | } |
@@ -131,7 +134,7 @@ add_pp_option (const char *opt, const char *arg) | |||
131 | { | 134 | { |
132 | char *qarg; | 135 | char *qarg; |
133 | size_t qlen; | 136 | size_t qlen; |
134 | 137 | ||
135 | if (!pp_qopt) | 138 | if (!pp_qopt) |
136 | { | 139 | { |
137 | pp_qopt = clone_quoting_options (NULL); | 140 | pp_qopt = clone_quoting_options (NULL); |
@@ -158,19 +161,19 @@ stderr_closed_p () | |||
158 | 161 | ||
159 | int | 162 | int |
160 | assert_grecs_value_type (grecs_locus_t *locus, | 163 | assert_grecs_value_type (grecs_locus_t *locus, |
161 | const grecs_value_t *value, int type) | 164 | const grecs_value_t *value, int type) |
162 | { | 165 | { |
163 | if (GRECS_VALUE_EMPTY_P (value)) | 166 | if (GRECS_VALUE_EMPTY_P (value)) |
164 | { | 167 | { |
165 | grecs_error (locus, 0, _("expected %s"), | 168 | grecs_error (locus, 0, _("expected %s"), |
166 | grecs_data_type_string (type)); | 169 | grecs_data_type_string (type)); |
167 | return 1; | 170 | return 1; |
168 | } | 171 | } |
169 | if (value->type != type) | 172 | if (value->type != type) |
170 | { | 173 | { |
171 | grecs_error (locus, 0, _("expected %s, but found %s"), | 174 | grecs_error (locus, 0, _("expected %s, but found %s"), |
172 | grecs_data_type_string (type), | 175 | grecs_data_type_string (type), |
173 | grecs_data_type_string (value->type)); | 176 | grecs_data_type_string (value->type)); |
174 | return 1; | 177 | return 1; |
175 | } | 178 | } |
176 | return 0; | 179 | return 0; |
@@ -190,8 +193,8 @@ assert_scalar_stmt (grecs_locus_t *locus, enum grecs_callback_command cmd) | |||
190 | 193 | ||
191 | static int | 194 | static int |
192 | _cb_action (enum grecs_callback_command cmd, | 195 | _cb_action (enum grecs_callback_command cmd, |
193 | grecs_locus_t *locus, | 196 | grecs_locus_t *locus, |
194 | void *varptr, grecs_value_t *value, void *cb_data) | 197 | void *varptr, grecs_value_t *value, void *cb_data) |
195 | { | 198 | { |
196 | enum return_action *pact = varptr; | 199 | enum return_action *pact = varptr; |
197 | static struct tokendef actab[] = { | 200 | static struct tokendef actab[] = { |
@@ -219,24 +222,27 @@ struct grecs_keyword return_code_keywords[] = { | |||
219 | N_("arg: {disable | restart}"), | 222 | N_("arg: {disable | restart}"), |
220 | N_("Specifies action to take when a component finishes with this " | 223 | N_("Specifies action to take when a component finishes with this " |
221 | "return code."), | 224 | "return code."), |
222 | grecs_type_string, NULL, offsetof (struct component, act_temp.act), | 225 | grecs_type_string, GRECS_DFLT, |
226 | NULL, offsetof (struct component, act_temp.act), | ||
223 | _cb_action, | 227 | _cb_action, |
224 | }, | 228 | }, |
225 | {"notify", | 229 | {"notify", |
226 | N_("arg: emails"), | 230 | N_("arg: emails"), |
227 | N_("Notify this address when a component terminates."), | 231 | N_("Notify this address when a component terminates."), |