diff options
-rw-r--r-- | configure.ac | 46 | ||||
m--------- | grecs | 0 | ||||
-rw-r--r-- | src/Makefile.am | 10 | ||||
-rw-r--r-- | src/cmdline.opt | 4 | ||||
-rw-r--r-- | src/comp.c | 3 | ||||
-rw-r--r-- | src/ctl.c | 176 | ||||
-rw-r--r-- | src/diag.c | 2 | ||||
-rw-r--r-- | src/pies.c | 85 | ||||
-rw-r--r-- | src/pies.h | 13 | ||||
-rw-r--r-- | src/progman.c | 15 | ||||
-rw-r--r-- | src/sysvinit.c | 62 |
11 files changed, 250 insertions, 166 deletions
diff --git a/configure.ac b/configure.ac index ae3a9c7..3a23a1a 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -127,2 +127,26 @@ AC_ARG_ENABLE([inetd], | |||
127 | 127 | ||
128 | sysvinit_status=maybe | ||
129 | AC_ARG_ENABLE([sysvinit], | ||
130 | AC_HELP_STRING([--enable-sysvinit], | ||
131 | [compile the SystemV init support]), | ||
132 | [sysvinit_status=$enableval]) | ||
133 | |||
134 | if 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]) | ||
144 | fi | ||
145 | |||
146 | test $sysvinit_status = "no" | ||
147 | PIES_SYSVINIT_ENABLED=$? | ||
148 | AC_DEFINE_UNQUOTED([PIES_SYSVINIT_ENABLED],[$PIES_SYSVINIT_ENABLED], | ||
149 | [whether SystemV init support is compiled]) | ||
150 | AM_CONDITIONAL([PIES_COND_SYSVINIT],[test $sysvinit_status = "yes"]) | ||
151 | |||
128 | AH_BOTTOM([ | 152 | AH_BOTTOM([ |
@@ -149,2 +173,24 @@ AM_MISSING_PROG([AUTOM4TE], [autom4te]) | |||
149 | 173 | ||
174 | AC_CONFIG_COMMANDS([status],[ | ||
175 | cat <<EOF | ||
176 | Configuration summary: | ||
177 | |||
178 | URL of the control API ............................. $control_url | ||
179 | PAM support ........................................ $status_pam | ||
180 | SystemV initialization support ..................... $sysvinit_status | ||
181 | EOF | ||
182 | if test $sysvinit_status = "yes"; then | ||
183 | cat <<EOF | ||
184 | URL of the SystemV init ............................ $sysvinit_control_url | ||
185 | Emergency shell .................................... $emergency_shell | ||
186 | EOF | ||
187 | fi | ||
188 | ], | ||
189 | [sysvinit_status=$sysvinit_status | ||
190 | control_url=`echo "$DEFAULT_PIES_CONTROL_URL" | sed 's/\\\$/\\\\\$/g'` | ||
191 | sysvinit_control_url=$DEFAULT_INIT_CONTROL_URL | ||
192 | emergency_shell=$EMERGENCY_SHELL | ||
193 | status_pam=$status_pam | ||
194 | ]) | ||
195 | |||
150 | AC_CONFIG_FILES([Makefile | 196 | AC_CONFIG_FILES([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 | |||
@@ -32,7 +32,11 @@ pies_SOURCES = \ | |||
32 | socket.c\ | 32 | socket.c\ |
33 | sysdep.c\ | ||
34 | sysvinit.c\ | ||
35 | utmp.c\ | ||
36 | userprivs.c | 33 | userprivs.c |
37 | 34 | ||
35 | if PIES_COND_SYSVINIT | ||
36 | pies_SOURCES += \ | ||
37 | sysvinit.c\ | ||
38 | sysdep.c\ | ||
39 | utmp.c | ||
40 | endif | ||
41 | |||
38 | noinst_HEADERS = \ | 42 | noinst_HEADERS = \ |
diff --git a/src/cmdline.opt b/src/cmdline.opt index d2aaf6d..d9d90e1 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt | |||
@@ -120,2 +120,3 @@ END | |||
120 | 120 | ||
121 | CPP(#if PIES_SYSVINIT_ENABLED) | ||
121 | OPTION(telinit,T,, | 122 | OPTION(telinit,T,, |
@@ -126,2 +127,3 @@ BEGIN | |||
126 | END | 127 | END |
128 | CPP(#endif) | ||
127 | 129 | ||
@@ -222,3 +224,3 @@ parse_options (int *pargc, char ***pargv) | |||
222 | 224 | ||
223 | if (init_process) | 225 | if (SYSVINIT_ACTIVE) |
224 | { | 226 | { |
@@ -676,2 +676,5 @@ component_verify (struct component *comp, grecs_locus_t *locus) | |||
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 */ |
@@ -920,2 +920,6 @@ static void res_programs (struct ctlio *, enum http_method, char const *, | |||
920 | struct json_value *); | 920 | struct json_value *); |
921 | static void res_conf (struct ctlio *, enum http_method, char const *, | ||
922 | struct json_value *); | ||
923 | |||
924 | #if PIES_SYSVINIT_ENABLED | ||
921 | static void res_runlevel (struct ctlio *, enum http_method, char const *, | 925 | static void res_runlevel (struct ctlio *, enum http_method, char const *, |
@@ -924,6 +928,5 @@ static void res_environ (struct ctlio *, enum http_method, char const *, | |||
924 | struct json_value *); | 928 | struct json_value *); |
925 | static void res_conf (struct ctlio *, enum http_method, char const *, | ||
926 | struct json_value *); | ||
927 | |||
928 | static int pred_sysvinit (void); | 929 | static int pred_sysvinit (void); |
930 | #endif | ||
931 | |||
929 | 932 | ||
@@ -945,4 +948,6 @@ static struct ctlio_resource restab[] = { | |||
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 } |
@@ -2119,2 +2124,3 @@ res_programs (struct ctlio *io, enum http_method meth, | |||
2119 | 2124 | ||
2125 | #if PIES_SYSVINIT_ENABLED | ||
2120 | static int | 2126 | static int |
@@ -2166,2 +2172,85 @@ res_runlevel (struct ctlio *io, enum http_method meth, | |||
2166 | 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 | */ | ||
2185 | static void | ||
2186 | env_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 | |||
2205 | static void | ||
2206 | res_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 | ||
2255 | |||
2167 | /* GET /conf/runtime - List configuration | 2256 | /* GET /conf/runtime - List configuration |
@@ -2410,82 +2499 @@ res_conf (struct ctlio *io, enum http_method meth, | |||
2410 | 2499 | ||
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 | */ | ||
2423 | static void | ||
2424 | env_reply (struct ctlio *io, int ok, int rc) | ||
2425 | { | ||
2426 | switch (rc) | ||
2427 | { | ||
2428 | case 0: | ||
2429 | io->code = ok; | ||