aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-02-22 12:31:56 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-02-22 12:33:46 +0200
commitbfa3617a79292e3569587c65cd218b69bdfd28a2 (patch)
tree8b094ec15dbb50be7324b3aa2f0d7486146a04d3
parenta9bd91de478ab29fa7bac2093479a1ccee1bbd87 (diff)
downloadpies-bfa3617a79292e3569587c65cd218b69bdfd28a2.tar.gz
pies-bfa3617a79292e3569587c65cd218b69bdfd28a2.tar.bz2
Provide a default single-user entry in init mode
This complements 6aac230c. The entry is created unless a component for runlevel S already exists. * src/comp.c (component_foreach): New function. * src/pies.h: Likewise. * src/sysvinit.c (inittab_parse): Provide default S entry unless one is already defined.
-rw-r--r--src/comp.c17
-rw-r--r--src/pies.h2
-rw-r--r--src/sysvinit.c14
3 files changed, 29 insertions, 4 deletions
diff --git a/src/comp.c b/src/comp.c
index 38e440e..43772c2 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -812,6 +812,23 @@ component_depmap_next (pies_depmap_pos_t pos)
return NULL;
return comp_array[n];
}
+
+int
+component_foreach (int (*filter) (struct component *, void *), void *data)
+{
+ struct component *comp;
+ int rc = 0;
+ struct complist *list = &comp_list[cur];
+
+ for (comp = list->head; comp; )
+ {
+ struct component *next = comp->next;
+ if ((rc = filter (comp, data)) != 0)
+ break;
+ comp = next;
+ }
+ return rc;
+}
diff --git a/src/pies.h b/src/pies.h
index 939bd4c..d4b5c6a 100644
--- a/src/pies.h
+++ b/src/pies.h
@@ -406,6 +406,8 @@ int component_is_active (struct component *comp);
void component_finish (struct component *comp, grecs_locus_t *locus);
struct grecs_keyword *find_component_keyword (const char *ident);
+int component_foreach (int (*filter) (struct component *, void *),
+ void *data);
void components_dump_depmap (void);
void components_trace (char **argv, enum pies_depmap_direction dir);
diff --git a/src/sysvinit.c b/src/sysvinit.c
index 695a22a..cc26fa9 100644
--- a/src/sysvinit.c
+++ b/src/sysvinit.c
@@ -1092,6 +1092,13 @@ inittab_parse_line (struct inittab_ctx *ctx)
return inittab_ok;
}
+/* Return true if we hit a single-user component */
+static int
+is_single_user (struct component *comp, void *data)
+{
+ return is_sysvinit (comp) && comp->runlevels && strchr (comp->runlevels, 'S');
+}
+
int
inittab_parse (const char *file)
{
@@ -1125,13 +1132,12 @@ inittab_parse (const char *file)
err = 1;
}
- if (component_list_is_empty ())
+ if (!component_foreach (is_single_user, 0))
{
- /* Provide default inittab entry */
+ /* Provide single-user entry */
ctx.file = __FILE__;
ctx.line_no = __LINE__;
- grecs_asprintf (&ctx.buf, &ctx.size, "~~:%s:wait:%s\n",
- valid_runlevels, emergency_shell);
+ grecs_asprintf (&ctx.buf, &ctx.size, "~~:S:wait:%s\n", emergency_shell);
inittab_parse_line (&ctx);
}

Return to:

Send suggestions and report system problems to the System administrator.