aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pies.c12
-rw-r--r--src/pies.h11
-rw-r--r--src/progman.c55
-rw-r--r--src/sysvinit.c124
4 files changed, 142 insertions, 60 deletions
diff --git a/src/pies.c b/src/pies.c
index 713ae8e..a2dc5e0 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -959,7 +959,7 @@ _cb_flags (enum grecs_callback_command cmd,
959 return 0; 959 return 0;
960} 960}
961 961
962static const char valid_runlevels[] = "0123456Ss"; 962static const char valid_runlevels[] = "0123456789Ss";
963 963
964static int 964static int
965_cb_initdefault (enum grecs_callback_command cmd, 965_cb_initdefault (enum grecs_callback_command cmd,
@@ -2309,6 +2309,7 @@ main (int argc, char **argv)
2309 { 2309 {
2310 foreground = 1; 2310 foreground = 1;
2311 set_console_dev (); 2311 set_console_dev ();
2312 sysvinit_begin ();
2312 } 2313 }
2313 else 2314 else
2314 switch (pies_check_status (&pid)) 2315 switch (pies_check_status (&pid))
@@ -2360,9 +2361,12 @@ main (int argc, char **argv)
2360 2361
2361 do 2362 do
2362 { 2363 {
2363 if (init_process) 2364 if (init_process && inittrans ())
2364 inittrans (); 2365 {
2365 if (!children_cleanup) 2366 got_alarm = 1;
2367 action = ACTION_CONT;
2368 }
2369 else if (!children_cleanup)
2366 pies_pause (); 2370 pies_pause ();
2367 switch (action) 2371 switch (action)
2368 { 2372 {
diff --git a/src/pies.h b/src/pies.h
index a679afd..fc4f59c 100644
--- a/src/pies.h
+++ b/src/pies.h
@@ -183,8 +183,6 @@ enum pies_comp_mode
183 pies_comp_respawn = pies_comp_exec, 183 pies_comp_respawn = pies_comp_exec,
184 }; 184 };
185 185
186#define is_sysvinit(m) ((m)>=pies_mark_sysvinit)
187
188#define CF_DISABLED 0x001 /* The componenet is disabled */ 186#define CF_DISABLED 0x001 /* The componenet is disabled */
189#define CF_PRECIOUS 0x002 /* The component is precious (should not 187#define CF_PRECIOUS 0x002 /* The component is precious (should not
190 be disabled) */ 188 be disabled) */
@@ -253,6 +251,8 @@ struct component
253 struct action act_temp; /* Auxiliary object used during configuration */ 251 struct action act_temp; /* Auxiliary object used during configuration */
254}; 252};
255 253
254#define is_sysvinit(cp) ((cp)->mode >= pies_mark_sysvinit || (cp)->runlevels)
255
256union pies_sockaddr_storage 256union pies_sockaddr_storage
257{ 257{
258 struct sockaddr s; 258 struct sockaddr s;
@@ -301,6 +301,9 @@ void progman_run_comp (struct component *comp, int fd,
301 301
302void progman_iterate_comp (int (*fun) (struct component *, void *), 302void progman_iterate_comp (int (*fun) (struct component *, void *),
303 void *data); 303 void *data);
304void progman_sysvinit_enable (int (*fun) (struct component *, int, void *),
305 void *data);
306
304void fd_report (int fd, const char *msg); 307void fd_report (int fd, const char *msg);
305 308
306int check_acl (pies_acl_t acl, struct sockaddr *s, socklen_t salen); 309int check_acl (pies_acl_t acl, struct sockaddr *s, socklen_t salen);
@@ -450,8 +453,8 @@ struct inetd_builtin
450struct inetd_builtin *inetd_builtin_lookup (const char *service, int socktype); 453struct inetd_builtin *inetd_builtin_lookup (const char *service, int socktype);
451 454
452/* sysvinit.c */ 455/* sysvinit.c */
453int runlevel_match (struct component *comp); 456void sysvinit_begin (void);
454void inittrans (void); 457int inittrans (void);
455int is_comp_wait (struct component *comp); 458int is_comp_wait (struct component *comp);
456 459
457 460
diff --git a/src/progman.c b/src/progman.c
index f0d0de6..15b8c44 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -106,6 +106,29 @@ progman_iterate_comp (int (*fun) (struct component *, void *), void *data)
106 break; 106 break;
107} 107}
108 108
109void
110progman_sysvinit_enable (int (*fun) (struct component *, int, void *),
111 void *data)
112{
113 struct prog *prog;
114
115 for (prog = proghead; prog; prog = prog->next)
116 if (IS_COMPONENT (prog) && is_sysvinit (prog->v.p.comp))
117 {
118 int rc = fun (prog->v.p.comp, prog->v.p.status == status_finished,
119 data);
120 if (rc < 0)
121 continue;
122 if (rc)
123 prog->v.p.status = status_enabled;
124 else
125 prog->v.p.status = status_disabled;
126 debug (1, ("%s: %s", prog->tag,
127 prog->v.p.status == status_enabled ?
128 "enabled" : "disabled"));
129 }
130}
131
109static struct prog * 132static struct prog *
110prog_lookup_by_pid (pid_t pid) 133prog_lookup_by_pid (pid_t pid)
111{ 134{
@@ -412,7 +435,10 @@ progman_running_p ()
412 { 435 {
413 if (IS_COMPONENT (prog) && is_comp_wait (prog->v.p.comp) && 436 if (IS_COMPONENT (prog) && is_comp_wait (prog->v.p.comp) &&
414 prog->pid > 0) 437 prog->pid > 0)
415 return 1; 438 {
439 debug (1, ("COMP %s still running", prog->tag));
440 return 1;
441 }
416 } 442 }
417 return 0; 443 return 0;
418} 444}
@@ -1185,14 +1211,21 @@ prog_start (struct prog *prog)
1185 if (prog->pid > 0 || !IS_COMPONENT (prog)) 1211 if (prog->pid > 0 || !IS_COMPONENT (prog))
1186 return; 1212 return;
1187 1213
1188 if (is_sysvinit (prog->v.p.comp->mode) && !init_process && 1214 if (is_sysvinit (prog->v.p.comp))
1189 prog->v.p.status != status_disabled)
1190 { 1215 {
1191 logmsg (LOG_NOTICE, "disabling sysvinit component %s", prog->tag); 1216 if (!init_process)
1192 prog->v.p.status = status_disabled; 1217 {
1193 return; 1218 if (prog->v.p.status != status_disabled)
1219 {
1220 logmsg (LOG_NOTICE, "disabling sysvinit component %s",
1221 prog->tag);
1222 prog->v.p.status = status_disabled;
1223 }
1224 return;
1225 }
1226 debug (1, ("ok to start %s", prog->v.p.comp->tag));
1194 } 1227 }
1195 1228
1196 /* This call returns 1 in two cases: Either prog is marked as disabled, 1229 /* This call returns 1 in two cases: Either prog is marked as disabled,
1197 in which case there's nothing more to do, or one or more of its 1230 in which case there's nothing more to do, or one or more of its
1198 prerequisites are in status_stopping. In the latter case either the 1231 prerequisites are in status_stopping. In the latter case either the
@@ -1782,8 +1815,7 @@ progman_start ()
1782 { 1815 {
1783 if (prog->v.p.comp->mode == pies_comp_inetd) 1816 if (prog->v.p.comp->mode == pies_comp_inetd)
1784 { 1817 {
1785 if ((prog->v.p.comp->flags & CF_DISABLED) 1818 if (prog->v.p.comp->flags & CF_DISABLED)
1786 || !runlevel_match (prog->v.p.comp))
1787 disable_socket (prog->v.p.socket); 1819 disable_socket (prog->v.p.socket);
1788 else 1820 else
1789 { 1821 {
@@ -1791,8 +1823,7 @@ progman_start ()
1791 enable_socket (prog->v.p.socket); 1823 enable_socket (prog->v.p.socket);
1792 } 1824 }
1793 } 1825 }
1794 else if ((prog->v.p.status == status_enabled && prog->pid == 0 1826 else if ((prog->v.p.status == status_enabled && prog->pid == 0)
1795 && runlevel_match (prog->v.p.comp))
1796 || prog->v.p.status == status_sleeping) 1827 || prog->v.p.status == status_sleeping)
1797 prog_start (prog); 1828 prog_start (prog);
1798 } 1829 }
@@ -2459,7 +2490,7 @@ progman_cleanup (int expect_term)
2459 if (listener->v.p.comp->flags & CF_WAIT) 2490 if (listener->v.p.comp->flags & CF_WAIT)
2460 enable_socket (listener->v.p.socket); 2491 enable_socket (listener->v.p.socket);
2461 } 2492 }
2462 else if (is_sysvinit(prog->v.p.comp->mode)) 2493 else if (prog->v.p.comp->mode >= pies_mark_sysvinit)
2463 { 2494 {
2464 prog->v.p.status = status_finished; 2495 prog->v.p.status = status_finished;
2465 } 2496 }
diff --git a/src/sysvinit.c b/src/sysvinit.c
index e09802f..5a0d98a 100644
--- a/src/sysvinit.c
+++ b/src/sysvinit.c
@@ -54,7 +54,7 @@ static int boot_trans_tab[max_boot_state][sizeof(valid_runlevels)-1] = {
54}; 54};
55 55
56enum boot_state boot_state; 56enum boot_state boot_state;
57int runlevel; 57int runlevel = 0;
58 58
59int initdefault; /* Default runlevel */ 59int initdefault; /* Default runlevel */
60int dfl_level; 60int dfl_level;
@@ -62,75 +62,104 @@ int dfl_level;
62static int 62static int
63runlevel_index (int n) 63runlevel_index (int n)
64{ 64{
65 char *p = strchr (valid_runlevels, n); 65 char *p;
66
67 if (n == 0)
68 return -1;
69
70 p = strchr (valid_runlevels, n);
66 if (!p) 71 if (!p)
67 return -1; 72 return -1;
68 return p - valid_runlevels; 73 return p - valid_runlevels;
69} 74}
70 75
71int 76static int
72runlevel_match (struct component *comp) 77enablecomp (struct component *comp, int finished, void *data)
73{ 78{
74 if (init_process) 79 int *wait = data;
80 int rc;
81
82 switch (boot_state)
75 { 83 {
76 switch (boot_state) 84