diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-22 12:31:56 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-22 12:33:46 +0200 |
commit | bfa3617a79292e3569587c65cd218b69bdfd28a2 (patch) | |
tree | 8b094ec15dbb50be7324b3aa2f0d7486146a04d3 /src/sysvinit.c | |
parent | a9bd91de478ab29fa7bac2093479a1ccee1bbd87 (diff) | |
download | pies-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.
Diffstat (limited to 'src/sysvinit.c')
-rw-r--r-- | src/sysvinit.c | 14 |
1 files changed, 10 insertions, 4 deletions
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); } |