Skip to contentSkip to conversation

New: Using sysvinit inittab and "single" user mode the rcS script still runs

Buildroot bugzilla at busybox.net 1 participant 2 messages May 4, 2016 – May 26, 2016

lore
Share & tools
lore
#0 lore raw

https://bugs.busybox.net/show_bug.cgi?id=8911

Bug ID: 8911
Summary: Using sysvinit inittab and "single" user mode the rcS
script still runs
Product: buildroot
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P5
Component: Other
Assignee: unassigned at buildroot.uclibc.org
Reporter: ckhardin at exablox.com
CC: buildroot at uclibc.org
Target Milestone: ---

Expected single user behavior to NOT run the rcS script when runlevel S is given to sysvinit.

From the busybox code - when going into single user, the logic is conditional to not even parse the inittab and jump into the single user shell.

busybox/init/init.c

        /* Check if we are supposed to be in single user mode */
        if (argv[1]
         && (strcmp(argv[1], "single") == 0 || strcmp(argv[1], "-s") == 0 ||
LONE_CHAR(argv[1], '1'))
        ) {
                /* ??? shouldn't we set RUNLEVEL="b" here? */
                /* Start a shell on console */
                new_init_action(RESPAWN, bb_default_login_shell, "");
        } else {
                /* Not in single user mode - see what inittab says */

                /* NOTE that if CONFIG_FEATURE_USE_INITTAB is NOT defined,
                 * then parse_inittab() simply adds in some default
                 * actions (i.e., INIT_SCRIPT and a pair
                 * of "askfirst" shells) */
                parse_inittab();
        }

However, the sysvinit uses the runlevels and the sysinit action runs before a runlevel has been selected - so, the rcS always runs.

I believe this diff gets what should happen, but their might be a context that I don't know about for not doing this.

package/sysvinit/inittab +1 -1
index 27eb4a6..fad91ea 100644
@@ -10,7 +10,7 @@ si2::sysinit:/bin/mkdir -p /dev/pts
 si3::sysinit:/bin/mkdir -p /dev/shm
 si4::sysinit:/bin/mount -a
 si5::sysinit:/bin/hostname -F /etc/hostname
-si6::sysinit:/etc/init.d/rcS
+rcS:12345:wait:/etc/init.d/rcS
 
 # S0:1:respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL
 
Signature · 2 lines
You are receiving this mail because:
You are on the CC list for the bug.
#1 lore raw

[Buildroot] [Bug 8911] Using sysvinit inittab and "single" user mode the rcS script still runs

https://bugs.busybox.net/show_bug.cgi?id=8911

Peter Korsgaard <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------

             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Peter Korsgaard <[email protected]> --- Fixed on the next branch, thanks:

commit eda809cd052dea73bca02385c7a10a4d7795c912

Author: Charles Hardin <[email protected]>
Date:   Sat May 21 13:11:10 2016 -0700

sysvinit: update the inittab to support "single" from the kernel

Closes #8911

When the kernel passes single in the command line, this translates into an init -s option that is suppose to drop into a shell after the sysinit and before the runlevel.

So, in busybox this is hardcoded - but, in sysvinit using the sysinit action for the rcS means that it will always be executed even when trying to get into single user mode for repair.

This change should run rcS in all of the expected runlevels 1-5 and should achieve the desired result compared to the busybox and still allow a single user shell to get started as expected before running rcS.

Signature · 2 lines
You are receiving this mail because:
You are on the CC list for the bug.