summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--configure.ac46
m---------grecs0
-rw-r--r--src/Makefile.am10
-rw-r--r--src/cmdline.opt4
-rw-r--r--src/comp.c3
-rw-r--r--src/ctl.c176
-rw-r--r--src/diag.c2
-rw-r--r--src/pies.c91
-rw-r--r--src/pies.h13
-rw-r--r--src/progman.c15
-rw-r--r--src/sysvinit.c64
11 files changed, 254 insertions, 170 deletions
diff --git a/configure.ac b/configure.ac
index ae3a9c7..3a23a1a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,6 +125,30 @@ AC_ARG_ENABLE([inetd],
125 no) ;; 125 no) ;;
126 esac]) 126 esac])
127 127
128sysvinit_status=maybe
129AC_ARG_ENABLE([sysvinit],
130 AC_HELP_STRING([--enable-sysvinit],
131 [compile the SystemV init support]),
132 [sysvinit_status=$enableval])
133
134if test $sysvinit_status = "maybe"; then
135 AC_TRY_COMPILE([#ifdef HAVE_UTMPX_H
136# include <utmpx.h>
137#else
138# include <utmp.h>
139#endif
140],
141[int x = RUN_LVL;],
142[sysvinit_status=yes],
143[sysvinit_status=no])
144fi
145
146test $sysvinit_status = "no"
147PIES_SYSVINIT_ENABLED=$?
148AC_DEFINE_UNQUOTED([PIES_SYSVINIT_ENABLED],[$PIES_SYSVINIT_ENABLED],
149 [whether SystemV init support is compiled])
150AM_CONDITIONAL([PIES_COND_SYSVINIT],[test $sysvinit_status = "yes"])
151
128AH_BOTTOM([ 152AH_BOTTOM([
129# ifndef ATTRIBUTE_NORETURN 153# ifndef ATTRIBUTE_NORETURN
130# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) 154# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
@@ -147,6 +171,28 @@ AC_CONFIG_TESTDIR(tests)
147AC_CONFIG_FILES([tests/Makefile tests/atlocal]) 171AC_CONFIG_FILES([tests/Makefile tests/atlocal])
148AM_MISSING_PROG([AUTOM4TE], [autom4te]) 172AM_MISSING_PROG([AUTOM4TE], [autom4te])
149 173
174AC_CONFIG_COMMANDS([status],[
175cat <<EOF
176Configuration summary:
177
178URL of the control API ............................. $control_url
179PAM support ........................................ $status_pam
180SystemV initialization support ..................... $sysvinit_status
181EOF
182if test $sysvinit_status = "yes"; then
183 cat <<EOF
184URL of the SystemV init ............................ $sysvinit_control_url
185Emergency shell .................................... $emergency_shell
186EOF
187fi
188],
189[sysvinit_status=$sysvinit_status
190control_url=`echo "$DEFAULT_PIES_CONTROL_URL" | sed 's/\\\$/\\\\\$/g'`
191sysvinit_control_url=$DEFAULT_INIT_CONTROL_URL
192emergency_shell=$EMERGENCY_SHELL
193status_pam=$status_pam
194])
195
150AC_CONFIG_FILES([Makefile 196AC_CONFIG_FILES([Makefile
151 gnu/Makefile 197 gnu/Makefile
152 lib/Makefile 198 lib/Makefile
diff --git a/grecs b/grecs
Subproject 12304127b52650588877f00b0c4b32dae083e85 Subproject ee35adccec058a5a8cc62f5030b9a925168236d
diff --git a/src/Makefile.am b/src/Makefile.am
index 16f8a75..925da88 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,11 +30,15 @@ pies_SOURCES = \
30 pies.c\ 30 pies.c\
31 progman.c\ 31 progman.c\
32 socket.c\ 32 socket.c\
33 sysdep.c\
34 sysvinit.c\
35 utmp.c\
36 userprivs.c 33 userprivs.c
37 34
35if PIES_COND_SYSVINIT
36pies_SOURCES += \
37 sysvinit.c\
38 sysdep.c\
39 utmp.c
40endif
41
38noinst_HEADERS = \ 42noinst_HEADERS = \
39 acl.h\ 43 acl.h\
40 cmdline.h\ 44 cmdline.h\
diff --git a/src/cmdline.opt b/src/cmdline.opt
index d2aaf6d..d9d90e1 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -118,12 +118,14 @@ BEGIN
118 lint_mode = 1; 118 lint_mode = 1;
119END 119END
120 120
121CPP(#if PIES_SYSVINIT_ENABLED)
121OPTION(telinit,T,, 122OPTION(telinit,T,,
122 [<telinit command: run "pies -T --help" for help>]) 123 [<telinit command: run "pies -T --help" for help>])
123BEGIN 124BEGIN
124 log_to_stderr_only = 1; 125 log_to_stderr_only = 1;
125 exit (telinit (argc - (optind - 1), argv + (optind - 1))); 126 exit (telinit (argc - (optind - 1), argv + (optind - 1)));
126END 127END
128CPP(#endif)
127 129
128GROUP(Preprocessor) 130GROUP(Preprocessor)
129 131
@@ -220,7 +222,7 @@ parse_options (int *pargc, char ***pargv)
220 char **argv = *pargv; 222 char **argv = *pargv;
221 int index; 223 int index;
222 224
223 if (init_process) 225 if (SYSVINIT_ACTIVE)
224 { 226 {
225 sysvinit_parse_argv (argc, argv); 227 sysvinit_parse_argv (argc, argv);
226 index = argc; 228 index = argc;
diff --git a/src/comp.c b/src/comp.c
index 6eeeeed..7b2b373 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -674,6 +674,9 @@ component_verify (struct component *comp, grecs_locus_t *locus)
674 return 1; 674 return 1;
675 } 675 }
676 default: 676 default:
677 if (PIES_SYSVINIT_ENABLED && comp->mode >= pies_mark_sysvinit)
678 COMPERR (grecs_error,
679 "%s", _("SystemV init support is not compiled in"));
677 /* FIXME: more checks perhaps */ 680 /* FIXME: more checks perhaps */
678 break; 681 break;
679 } 682 }
diff --git a/src/ctl.c b/src/ctl.c
index d9a8998..5609f19 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -918,14 +918,17 @@ static void res_instance (struct ctlio *, enum http_method, char const *,
918 struct json_value *); 918 struct json_value *);
919static void res_programs (struct ctlio *, enum http_method, char const *, 919static void res_programs (struct ctlio *, enum http_method, char const *,
920 struct json_value *); 920 struct json_value *);
921static void res_conf (struct ctlio *, enum http_method, char const *,
922 struct json_value *);
923
924#if PIES_SYSVINIT_ENABLED
921static void res_runlevel (struct ctlio *, enum http_method, char const *, 925static void res_runlevel (struct ctlio *, enum http_method, char const *,
922 struct json_value *); 926 struct json_value *);
923static void res_environ (struct ctlio *, enum http_method, char const *, 927static void res_environ (struct ctlio *, enum http_method, char const *,
924 struct json_value *); 928 struct json_value *);
925static void res_conf (struct ctlio *, enum http_method, char const *,
926 struct json_value *);
927
928static int pred_sysvinit (void); 929static int pred_sysvinit (void);
930#endif
931
929 932
930struct ctlio_resource 933struct ctlio_resource
931{ 934{
@@ -943,8 +946,10 @@ static struct ctlio_resource restab[] = {
943 { S(/conf), CTL_ADMIN_STATE, NULL, res_conf }, 946 { S(/conf), CTL_ADMIN_STATE, NULL, res_conf },
944 { S(/programs), CTL_ADMIN_STATE|CTL_USER_STATE, NULL, 947 { S(/programs), CTL_ADMIN_STATE|CTL_USER_STATE, NULL,
945 res_programs }, 948 res_programs },
949#if PIES_SYSVINIT_ENABLED
946 { S(/runlevel), CTL_ADMIN_STATE, pred_sysvinit, res_runlevel }, 950 { S(/runlevel), CTL_ADMIN_STATE, pred_sysvinit, res_runlevel },
947 { S(/environ), CTL_ADMIN_STATE, pred_sysvinit, res_environ }, 951 { S(/environ), CTL_ADMIN_STATE, pred_sysvinit, res_environ },
952#endif
948 { NULL } 953 { NULL }
949#undef S 954#undef S
950}; 955};
@@ -2117,6 +2122,7 @@ res_programs (struct ctlio *io, enum http_method meth,
2117 res_programs_select (io, meth, uri, json); 2122 res_programs_select (io, meth, uri, json);
2118} 2123}
2119 2124
2125#if PIES_SYSVINIT_ENABLED
2120static int 2126static int
2121pred_sysvinit (void) 2127pred_sysvinit (void)
2122{ 2128{
@@ -2163,6 +2169,89 @@ res_runlevel (struct ctlio *io, enum http_method meth,
2163 else 2169 else
2164 ctlio_reply (io, 405, NULL); 2170 ctlio_reply (io, 405, NULL);
2165} 2171}
2172
2173/* GET /environ - List entire environment
2174 * ["RUNLEVEL=3", "CONSOLE=/dev/tty", ...]
2175 * GET /environ/NAME - Get value of variable NAME
2176 * { "status":"OK", "value":"..." }
2177 * { "status":"ER", "error_message":"..." }
2178 * DELETE /environ/NAME - Unset variable
2179 * { "status":"OK" }
2180 * { "status":"ER", "error_message":"..." }
2181 * PUT /environ/NAME=VALUE - Set variable
2182 * { "status":"OK" }
2183 * { "status":"ER", "error_message":"..." }
2184 */
2185static void
2186env_reply (struct ctlio *io, int ok, int rc)
2187{
2188 switch (rc)
2189 {
2190 case 0:
2191 io->code = ok;
2192 io->output.reply = json_reply_create ();
2193 json_object_set_string (io->output.reply, "status", "OK");
2194 break;
2195
2196 case 1:
2197 ctlio_reply (io, 403, NULL);
2198 break;
2199
2200 case -1:
2201 ctlio_reply (io, 404, NULL);
2202 }
2203}
2204
2205static void
2206res_environ (struct ctlio *io, enum http_method meth,
2207 char const *uri, struct json_value *json)
2208{
2209 if (meth == METH_GET)
2210 {
2211 if (uri && uri[1])
2212 {
2213 char *value;
2214
2215 if (sysvinit_envlocate (uri + 1, &value) == -1)
2216 ctlio_reply (io, 404, NULL);
2217 else
2218 {
2219 env_reply (io, 200, 0);
2220 json_object_set_string (io->output.reply, "value", "%s", value);
2221 }
2222 }
2223 else
2224 {
2225 size_t i;
2226
2227 io->output.reply = json_new_array ();
2228 io->code = 200;
2229 for (i = 0; sysvinit_environ_hint[i]; i++)
2230 {
2231 json_array_append (io->output.reply,
2232 json_new_string (sysvinit_environ_hint[i]));
2233 }
2234 }
2235 }
2236 else if (meth == METH_DELETE)
2237 {
2238 if (!(uri && uri[0]))
2239 ctlio_reply (io, 400, NULL);
2240 else
2241 env_reply (io, 200, sysvinit_envupdate (uri + 1));
2242 }
2243 else if (meth == METH_PUT)
2244 {
2245 if (!(uri && uri[0]))
2246 ctlio_reply (io, 400, NULL);
2247 else
2248 env_reply (io, 201, sysvinit_envupdate (uri + 1));
2249 }
2250 else
2251 ctlio_reply (io, 405, NULL);
2252
2253}
2254#endif
2166 2255
2167/* GET /conf/runtime - List configuration 2256/* GET /conf/runtime - List configuration
2168 * PUT /conf/runtime - Reload configuration 2257 * PUT /conf/runtime - Reload configuration
@@ -2407,85 +2496,4 @@ res_conf (struct ctlio *io, enum http_method meth,
2407 else 2496 else
2408 ctlio_reply (io, 404, NULL); 2497 ctlio_reply (io, 404, NULL);
2409} 2498}
2410
2411/* GET /environ - List entire environment
2412 * ["RUNLEVEL=3", "CONSOLE=/dev/tty", ...]
2413 * GET /environ/NAME - Get value of variable NAME
2414 * { "status":"OK", "value":"..." }
2415 * { "status":"ER", "error_message":"..." }
2416 * DELETE /environ/NAME - Unset variable
2417 * { "status":"OK" }
2418 * { "status":"ER", "error_message":"..." }
2419 * PUT /environ/NAME=VALUE - Set variable
2420 * { "status":"OK" }
2421 * { "status":"ER", "error_message":"..." }
2422 */
2423static void
2424env_reply (struct ctlio *io, int ok, int rc)
2425{
2426 switch (rc)
2427 {
2428 case 0:
2429 io->code = ok;
2430 io->output.reply = json_reply_create ();
2431 json_object_set_string (io->output.reply, "status", "OK");
2432 break;
2433 2499
2434 case 1:
2435 ctlio_reply (io, 403, NULL);
2436 break;
2437
2438 case -1:
2439 ctlio_reply (io, 404, NULL);
2440 }
2441}
2442
2443static void
2444res_environ (struct ctlio *io, enum http_method meth,
2445 char const *uri, struct json_value *json)
2446{
2447 if (meth == METH_GET)
2448 {
2449 if (uri && uri[1])
2450 {
2451 char *value;
2452
2453 if (sysvinit_envlocate (uri + 1, &value) == -1)
2454 ctlio_reply (io, 404, NULL);
2455 else
2456 {
2457 env_reply (io, 200, 0);
2458 json_object_set_string (io->output.reply, "value", "%s", value);
2459 }
2460 }
2461 else
2462 {
2463 size_t i;
2464
2465 io->output.reply = json_new_array ();
2466 io->code = 200;
2467 for (i = 0; sysvinit_environ_hint[i]; i++)
2468 {
2469 json_array_append (io->output.reply,
2470 json_new_string (sysvinit_environ_hint[i]));
2471 }
2472 }
2473 }
2474 else if (meth == METH_DELETE)
2475 {
2476 if (!(uri && uri[0]))
2477 ctlio_reply (io, 400, NULL);
2478 else
2479 env_reply (io, 200, sysvinit_envupdate (uri + 1));
2480 }
2481 else if (meth == METH_PUT)
2482 {
2483 if (!(uri && uri[0]))
2484 ctlio_reply (io, 400, NULL);
2485 else
2486 env_reply (io, 201, sysvinit_envupdate (uri + 1));
2487 }
2488 else
2489 ctlio_reply (io, 405, NULL);
2490
2491}
diff --git a/src/diag.c b/src/diag.c
index 78e2741..bd5eff2 100644
--- a/src/diag.c
+++ b/src/diag.c
@@ -73,7 +73,7 @@ stderr_printer (LOGSTREAM *str, int prio, const char *fmt, va_list ap)
73static int 73static int
74stderr_open (int logf, LOGSTREAM *str) 74stderr_open (int logf, LOGSTREAM *str)
75{ 75{
76 if (logf & DIAG_REOPEN_LOG) 76 if (PIES_SYSVINIT_ENABLED && (logf & DIAG_REOPEN_LOG))
77 { 77 {
78 int fd = console_open (O_WRONLY|O_NOCTTY|O_NDELAY); 78 int fd = console_open (O_WRONLY|O_NOCTTY|O_NDELAY);
79 if (fd == -1) 79 if (fd == -1)
diff --git a/src/pies.c b/src/pies.c
index 2564af5..75285dc 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -75,7 +75,9 @@ static struct config_syntax config_syntax_tab[] = {
75 [CONF_PIES] = { "pies" , pies_config_parse }, 75 [CONF_PIES] = { "pies" , pies_config_parse },
76 [CONF_META1] = { "meta1", meta1_config_parse }, 76 [CONF_META1] = { "meta1", meta1_config_parse },
77 [CONF_INETD] = { "inetd", inetd_config_parse }, 77 [CONF_INETD] = { "inetd", inetd_config_parse },
78#if PIES_SYSVINIT_ENABLED
78 [CONF_INITTAB] = { "inittab", inittab_parse }, 79 [CONF_INITTAB] = { "inittab", inittab_parse },
80#endif
79}; 81};
80 82
81struct config_file 83struct config_file
@@ -1205,56 +1207,6 @@ _cb_flags (enum grecs_callback_command cmd,
1205 return 0; 1207 return 0;
1206} 1208}
1207 1209
1208static int
1209_cb_initdefault (enum grecs_callback_command cmd,
1210 grecs_node_t *node,
1211 void *varptr, void *cb_data)
1212{
1213 grecs_locus_t *locus = &node->locus;
1214 grecs_value_t *value = node->v.value;
1215 int *val = varptr;
1216
1217 if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
1218 return 1;
1219 if (strlen (value->v.string) != 1)
1220 {
1221 grecs_error (locus, 0, _("argument must be a single character"));
1222 return 1;
1223 }
1224 if (!is_valid_runlevel (value->v.string[0]))
1225 {
1226 grecs_error (locus, 0, _("not a valid runlevel"));
1227 return 1;
1228 }
1229 *val = toupper (value->v.string[0]);
1230 return 0;
1231}
1232
1233static int
1234_cb_runlevels (enum grecs_callback_command cmd,
1235 grecs_node_t *node,
1236 void *varptr, void *cb_data)
1237{
1238 grecs_locus_t *locus = &node->locus;
1239 grecs_value_t *value = node->v.value;
1240 char **sptr = varptr, *p;
1241
1242 if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
1243 return 1;
1244 for (p = value->v.string; *p; p++)
1245 {
1246 if (!is_valid_runlevel (*p))
1247 {
1248 grecs_error (locus, 0, _("not a valid runlevel: %c"), *p);
1249 return 1;
1250 }
1251 }
1252 *sptr = grecs_strdup (value->v.string);
1253 for (p = *sptr; *p; p++)
1254 *p = toupper (*p);
1255 return 0;
1256}
1257
1258struct grecs_keyword component_keywords[] = { 1210struct grecs_keyword component_keywords[] = {
1259 {"mode", 1211 {"mode",
1260 N_("mode"), 1212 N_("mode"),
@@ -1294,12 +1246,14 @@ struct grecs_keyword component_keywords[] = {
1294 N_("List of flags."), 1246 N_("List of flags."),
1295 grecs_type_string, GRECS_LIST, NULL, offsetof (struct component, flags), 1247 grecs_type_string, GRECS_LIST, NULL, offsetof (struct component, flags),
1296 _cb_flags }, 1248 _cb_flags },
1249#if PIES_SYSVINIT_ENABLED
1297 {"runlevels", 1250 {"runlevels",
1298 N_("chars"), 1251 N_("chars"),
1299 N_("Runlevels to start that component in."), 1252 N_("Runlevels to start that component in."),
1300 grecs_type_string, GRECS_DFLT, 1253 grecs_type_string, GRECS_DFLT,
1301 NULL, offsetof (struct component, runlevels), 1254 NULL, offsetof (struct component, runlevels),
1302 _cb_runlevels }, 1255 cb_runlevels },
1256#endif
1303 {"pass-fd-socket", 1257 {"pass-fd-socket",
1304 N_("name"), 1258 N_("name"),
1305 N_("Pass fd through this socket."), 1259 N_("Pass fd through this socket."),
@@ -1722,12 +1676,14 @@ struct grecs_keyword pies_keywords[] = {
1722 grecs_type_string, GRECS_DFLT, 1676 grecs_type_string, GRECS_DFLT,
1723 &pies_limits, 0, _cb_limits, 1677 &pies_limits, 0, _cb_limits,
1724 }, 1678 },
1679#if PIES_SYSVINIT_ENABLED
1725 {"initdefault", 1680 {"initdefault",
1726 N_("arg: char"), 1681 N_("arg: char"),
1727 N_("Default runlevel"), 1682 N_("Default runlevel"),
1728 grecs_type_string, GRECS_DFLT, 1683 grecs_type_string, GRECS_DFLT,
1729 &initdefault, 0, _cb_initdefault, 1684 NULL, 0, cb_initdefault,
1730 }, 1685 },
1686#endif
1731 {"shutdown-timeout", 1687 {"shutdown-timeout",
1732 "n", 1688 "n",
1733 N_("Wait <n> seconds for all components to shut down."), 1689 N_("Wait <n> seconds for all components to shut down."),
@@ -1859,7 +1815,7 @@ pies_read_config (void)
1859 ++err; 1815 ++err;
1860 } 1816 }
1861 1817
1862 if (init_process) 1818 if (SYSVINIT_ACTIVE)
1863 err = 0; 1819 err = 0;
1864 1820
1865 if (err) 1821 if (err)
@@ -1898,7 +1854,7 @@ pies_schedule_children (int op)
1898RETSIGTYPE 1854RETSIGTYPE
1899sig_handler (int sig) 1855sig_handler (int sig)
1900{ 1856{
1901 if (init_process && sysvinit_sigtrans (sig, &action)) 1857 if (SYSVINIT_ACTIVE && sysvinit_sigtrans (sig, &action))
1902 return; 1858 return;
1903 switch (sig) 1859 switch (sig)
1904 { 1860 {
@@ -2278,7 +2234,7 @@ init_emu (void)
2278static void 2234static void
2279set_conf_file_names (const char *base) 2235set_conf_file_names (const char *base)
2280{ 2236{
2281 if (init_process) 2237 if (SYSVINIT_ACTIVE)
2282 { 2238 {
2283 config_file_add_type (CONF_INITTAB, "/etc/inittab"); 2239 config_file_add_type (CONF_INITTAB, "/etc/inittab");
2284 config_file_add_type (CONF_PIES, "/etc/pies.init"); 2240 config_file_add_type (CONF_PIES, "/etc/pies.init");
@@ -2338,7 +2294,7 @@ main (int argc, char **argv)
2338 } 2294 }
2339 2295
2340 /* Set default logging */ 2296 /* Set default logging */
2341 if (init_process) 2297 if (SYSVINIT_ACTIVE)
2342 { 2298 {
2343 log_facility = LOG_DAEMON; 2299 log_facility = LOG_DAEMON;
2344 diag_flags = DIAG_TO_STDERR | DIAG_REOPEN_LOG; 2300 diag_flags = DIAG_TO_STDERR | DIAG_REOPEN_LOG;
@@ -2373,7 +2329,7 @@ main (int argc, char **argv)
2373 2329
2374 set_conf_file_names (instance); 2330 set_conf_file_names (instance);
2375 2331
2376 if (init_process || !DEFAULT_PREPROCESSOR) 2332 if (SYSVINIT_ACTIVE || !DEFAULT_PREPROCESSOR)
2377 grecs_preprocessor = NULL; 2333 grecs_preprocessor = NULL;
2378 else 2334 else
2379 grecs_preprocessor = pp_command_line (); 2335 grecs_preprocessor = pp_command_line ();
@@ -2451,7 +2407,7 @@ main (int argc, char **argv)
2451 umask (pies_umask); 2407 umask (pies_umask);
2452 } 2408 }
2453 2409
2454 if (init_process) 2410 if (SYSVINIT_ACTIVE)
2455 { 2411 {
2456 foreground = 1; 2412 foreground = 1;
2457 sysvinit_begin (); 2413 sysvinit_begin ();
@@ -2491,7 +2447,7 @@ main (int argc, char **argv)
2491 2447
2492 logmsg (LOG_INFO, _("%s %s starting"), proginfo.package, proginfo.version); 2448 logmsg (LOG_INFO, _("%s %s starting"), proginfo.package, proginfo.version);
2493 2449
2494 if (!init_process) 2450 if (!SYSVINIT_ACTIVE)
2495 { 2451 {
2496 if (ctl_open ()) 2452 if (ctl_open ())
2497 exit (EX_UNAVAILABLE); 2453 exit (EX_UNAVAILABLE);
@@ -2516,7 +2472,7 @@ main (int argc, char **argv)
2516 switch (action) 2472 switch (action)
2517 { 2473 {
2518 case ACTION_RESTART: 2474 case ACTION_RESTART:
2519 if (pies_master_argv[0][0] != '/' || init_process) 2475 if (pies_master_argv[0][0] != '/' || SYSVINIT_ACTIVE)
2520 { 2476 {
2521 logmsg (LOG_INFO, _("restart command ignored")); 2477 logmsg (LOG_INFO, _("restart command ignored"));
2522 action = ACTION_CONT; 2478 action = ACTION_CONT;
@@ -2532,7 +2488,7 @@ main (int argc, char **argv)
2532 /* fall through */ 2488 /* fall through */
2533 case ACTION_COMMIT: 2489 case ACTION_COMMIT:
2534 component_config_commit (); 2490 component_config_commit ();
2535 if (init_process) 2491 if (SYSVINIT_ACTIVE)
2536 sysvinit_runlevel_setup (PIES_COMP_DEFAULT); 2492 sysvinit_runlevel_setup (PIES_COMP_DEFAULT);
2537 progman_create_sockets (); 2493 progman_create_sockets ();
2538 progman_start (); 2494 progman_start ();
@@ -2542,7 +2498,7 @@ main (int argc, char **argv)
2542 break; 2498 break;
2543 2499
2544 case ACTION_STOP: 2500 case ACTION_STOP:
2545 if (init_process) 2501 if (SYSVINIT_ACTIVE)
2546 { 2502 {
2547 debug (1, ("ignoring stop/restart")); 2503 debug (1, ("ignoring stop/restart"));
2548 action = ACTION_CONT; 2504 action = ACTION_CONT;
@@ -2551,21 +2507,24 @@ main (int argc, char **argv)
2551 2507
2552 case ACTION_CTRLALTDEL: 2508 case ACTION_CTRLALTDEL:
2553 debug (1, ("ctrl-alt-del")); 2509 debug (1, ("ctrl-alt-del"));
2554 sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_ctrlaltdel)); 2510 if (SYSVINIT_ACTIVE)
2511 sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_ctrlaltdel));
2555 pies_schedule_children (PIES_CHLD_WAKEUP); 2512 pies_schedule_children (PIES_CHLD_WAKEUP);
2556 action = ACTION_CONT; 2513 action = ACTION_CONT;
2557 break; 2514 break;
2558 2515
2559 case ACTION_KBREQUEST: 2516 case ACTION_KBREQUEST:
2560 debug (1, ("kbrequest")); 2517 debug (1, ("kbrequest"));
2561 sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_kbrequest)); 2518 if (SYSVINIT_ACTIVE)
2519 sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_kbrequest));
2562 pies_schedule_children (PIES_CHLD_WAKEUP); 2520 pies_schedule_children (PIES_CHLD_WAKEUP);
2563 action = ACTION_CONT; 2521 action = ACTION_CONT;
2564 break; 2522 break;
2565 2523
2566 case ACTION_POWER: 2524 case ACTION_POWER:
2567 debug (1, ("SIGPWR")); 2525 debug (1, ("SIGPWR"));
2568 sysvinit_power (); 2526 if (SYSVINIT_ACTIVE)
2527 sysvinit_power ();
2569 pies_schedule_children (PIES_CHLD_WAKEUP); 2528 pies_schedule_children (PIES_CHLD_WAKEUP);
2570 action = ACTION_CONT; 2529 action = ACTION_CONT;
2571 } 2530 }
@@ -2582,7 +2541,7 @@ main (int argc, char **argv)
2582 children_op = PIES_CHLD_NONE; 2541 children_op = PIES_CHLD_NONE;
2583 } 2542 }
2584 } 2543 }
2585 while (init_process || action == ACTION_CONT); 2544 while (SYSVINIT_ACTIVE || action == ACTION_CONT);
2586 2545
2587 progman_stop (); 2546 progman_stop ();
2588 remove_pidfile (pidfile); 2547 remove_pidfile (pidfile);
diff --git a/src/pies.h b/src/pies.h
index 4d52ce4..201a719 100644
--- a/src/pies.h
+++ b/src/pies.h
@@ -276,7 +276,11 @@ struct component
276 pies_acl_t adm_acl; /* Administrative ACL (stop, start, etc.) */ 276 pies_acl_t adm_acl; /* Administrative ACL (stop, start, etc.) */
277}; 277};
278 278
279#define is_sysvinit(cp) ((cp)->mode >= pies_mark_sysvinit || (cp)->runlevels) 279#define is_sysvinit(cp) \
280 (PIES_SYSVINIT_ENABLED \
281 && ((cp)->mode >= pies_mark_sysvinit || (cp)->runlevels))
282
283#define SYSVINIT_ACTIVE (PIES_SYSVINIT_ENABLED && init_process)
280 284
281enum pies_action { 285enum pies_action {
282 ACTION_CONT, 286 ACTION_CONT,
@@ -565,6 +569,13 @@ int sysvinit_envlocate (char const *name, char **value);
565int sysvinit_envdelete (char const *name); 569int sysvinit_envdelete (char const *name);
566int sysvinit_envupdate (char const *var); 570int sysvinit_envupdate (char const *var);
567 571
572int cb_initdefault (enum grecs_callback_command cmd,
573 grecs_node_t *node,
574 void *varptr, void *cb_data);
575int cb_runlevels (enum grecs_callback_command cmd,
576 grecs_node_t *node,
577 void *varptr, void *cb_data);
578
568extern char *sysvinit_environ_hint[]; 579extern char *sysvinit_environ_hint[];
569extern char *init_fifo; 580extern char *init_fifo;
570 581
diff --git a/src/progman.c b/src/progman.c
index 88f9afa..70ebf68 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -824,7 +824,7 @@ prog_start_prologue (struct prog *prog)
824 environ_unset (prog->v.p.env, sockenv_var[i], NULL); 824 environ_unset (prog->v.p.env, sockenv_var[i], NULL);
825 } 825 }
826 envop_exec (prog->v.p.comp->envop, prog->v.p.env); 826 envop_exec (prog->v.p.comp->envop, prog->v.p.env);
827 if (init_process) 827 if (SYSVINIT_ACTIVE)
828 { 828 {
829 size_t i; 829 size_t i;
830 for (i = 0; sysvinit_environ_hint[i]; i++) 830 for (i = 0; sysvinit_environ_hint[i]; i++)
@@ -899,7 +899,7 @@ prog_start (struct prog *prog)
899 899
900 if (is_sysvinit (prog->v.p.comp)) 900 if (is_sysvinit (prog->v.p.comp))
901 { 901 {
902 if (!init_process) 902 if (!SYSVINIT_ACTIVE)
903 { 903 {
904 if (prog->active) 904 if (prog->active)
905 { 905 {
@@ -995,7 +995,7 @@ prog_start (struct prog *prog)
995 break; 995 break;
996 996
997 default: 997 default:
998 if (init_process) 998 if (SYSVINIT_ACTIVE)
999 { 999 {
1000 int fd = console_open (O_RDWR|O_NOCTTY); 1000 int fd = console_open (O_RDWR|O_NOCTTY);
1001 if (fd < 0) 1001 if (fd < 0)
@@ -1037,7 +1037,7 @@ prog_start (struct prog *prog)
1037 break; 1037 break;
1038 } 1038 }
1039 1039
1040 if (!init_process) 1040 if (!SYSVINIT_ACTIVE)
1041 { 1041 {
1042 if (redir[RETR_ERR] == -1) 1042 if (redir[RETR_ERR] == -1)
1043 { 1043 {
@@ -1600,7 +1600,7 @@ print_status (const char *tag, pid_t pid, int status, int expect_term)
1600{ 1600{
1601 int prio; 1601 int prio;
1602 1602
1603 if (init_process) 1603 if (SYSVINIT_ACTIVE)
1604 { 1604 {
1605 if (debug_level <= 1) 1605 if (debug_level <= 1)
1606 return; 1606 return;
@@ -2147,7 +2147,8 @@ progman_cleanup (int expect_term)
2147 } 2147 }
2148 else 2148 else
2149 { 2149 {
2150 if (prog->v.p.comp->mode >= pies_mark_sysvinit 2150 if (PIES_SYSVINIT_ENABLED
2151 && prog->v.p.comp->mode >= pies_mark_sysvinit
2151 && prog->v.p.comp->mode != pies_comp_ondemand) 2152 && prog->v.p.comp->mode != pies_comp_ondemand)
2152 { 2153 {
2153 sysvinit_acct (SYSV_ACCT_PROC_STOP, "", prog_tag (prog), 2154 sysvinit_acct (SYSV_ACCT_PROC_STOP, "", prog_tag (prog),
@@ -2303,7 +2304,7 @@ prog_to_stop (struct prog *prog)
2303} 2304}
2304 2305
2305#define DIAG_CON \ 2306#define DIAG_CON \
2306 (init_process ? (DIAG_TO_STDERR|DIAG_REOPEN_LOG) : diag_output) 2307 (SYSVINIT_ACTIVE ? (DIAG_TO_STDERR|DIAG_REOPEN_LOG) : diag_output)
2307 2308
2308/* Stop all program components marked for termination. Wait at most 2309/* Stop all program components marked for termination. Wait at most
2309 2*shutdown_timeout seconds. */ 2310 2*shutdown_timeout seconds. */
diff --git a/src/sysvinit.c b/src/sysvinit.c
index 3ba986b..c5d25da 100644
--- a/src/sysvinit.c
+++ b/src/sysvinit.c
@@ -55,13 +55,13 @@ static int boot_trans_tab[max_boot_state][sizeof(valid_runlevels)-1] = {
55}; 55};
56 56
57enum boot_state boot_state; 57enum boot_state boot_state;
58int runlevel = 0; 58static int runlevel = 0;
59int prevlevel = 'N'; 59static int prevlevel = 'N';
60 60
61int initdefault; /* Default runlevel */ 61int initdefault;
62int dfl_level; 62static int dfl_level;
63char *emergency_shell = EMERGENCY_SHELL; 63static char *emergency_shell = EMERGENCY_SHELL;
64int emergency; 64static int emergency;
65 65
66static int inittrans (void); 66static int inittrans (void);
67 67
@@ -340,7 +340,7 @@ is_valid_runlevel (int c)
340{ 340{
341 return !!strchr (valid_runlevel_arg, c); 341 return !!strchr (valid_runlevel_arg, c);
342} 342}
343 343
344#define ENVAR_CONSOLE "CONSOLE=" 344#define ENVAR_CONSOLE "CONSOLE="
345#define ENVTMPL_CONSOLE "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 345#define ENVTMPL_CONSOLE "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
346 346
@@ -1283,3 +1283,53 @@ sysvinit_parse_argv (int argc, char **argv)
1283 dfl_level = c; 1283 dfl_level = c;
1284 } 1284 }
1285} 1285}
1286
1287int
1288cb_initdefault (enum grecs_callback_command cmd,
1289 grecs_node_t *node,
1290 void *varptr, void *cb_data)
1291{
1292 grecs_locus_t *locus = &node->locus;
1293 grecs_value_t *value = node->v.value;
1294
1295 if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
1296 return 1;
1297 if (strlen (value->v.string) != 1)
1298 {
1299 grecs_error (locus, 0, _("argument must be a single character"));
1300 return 1;
1301 }
1302 if (!is_valid_runlevel (value->v.string[0]))
1303 {
1304 grecs_error (locus, 0, _("not a valid runlevel"));
1305 return 1;
1306 }
1307 initdefault = toupper (value->v.string[0]);
1308 return 0;
1309}
1310
1311int
1312cb_runlevels (enum grecs_callback_command cmd,
1313 grecs_node_t *node,
1314 void *varptr, void *cb_data)
1315{
1316 grecs_locus_t *locus = &node->locus;
1317 grecs_value_t *value = node->v.value;
1318 char **sptr = varptr, *p;
1319
1320 if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
1321 return 1;
1322 for (p = value->v.string; *p; p++)
1323 {
1324 if (!is_valid_runlevel (*p))
1325 {
1326 grecs_error (locus, 0, _("not a valid runlevel: %c"), *p);
1327 return 1;
1328 }
1329 }
1330 *sptr = grecs_strdup (value->v.string);
1331 for (p = *sptr; *p; p++)
1332 *p = toupper (*p);
1333 return 0;
1334}
1335

Return to:

Send suggestions and report system problems to the System administrator.