Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 617746 - rc-update add without runlevel adds to sysinit runlevel
Summary: rc-update add without runlevel adds to sysinit runlevel
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-07 16:48 UTC by Robert Bridge
Modified: 2017-11-17 23:51 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Bridge 2017-05-07 16:48:23 UTC
While installing gentoo into a VM, I observed the following behaviour:
(chroot) livecd init.d # rc-update add net.eth0 
 * service net.eth0 added to runlevel sysinit

For reference the version of openrc in the instance was:
(chroot) livecd init.d # emerge -pv openrc

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] sys-apps/openrc-0.24.2::gentoo  USE="ncurses netifrc pam unicode -audit -debug -newnet (-prefix) (-selinux) -static-libs" 208 KiB

Total: 1 package (1 reinstall), Size of downloads: 208 KiB

I would expect in the absence of a runlevel being specified the service to be added to the default runlevel, or the command to fail with a message saying to specify the runlevel. The current behaviour is, in my opinion, a violation of the principle of least surprise, and counter-intuitive.
Comment 1 Robert Bridge 2017-05-07 17:13:51 UTC
Further testing shows that following the reboot to complete the install, the rc-update add service adds the service to the default runlevel.
Comment 2 Adam Feldman gentoo-dev 2017-05-11 12:33:58 UTC
From the manpage:

     add service             Add the service to the runlevel or the current
                             one if none given.  Services added to the boot
                             runlevel must exist in /etc/init.d.


Presuming that since you booted with a livecd and then chrooted it, it fellback on sysinit as the "current", but I'll bring the openrc devs in for confirmation.
Comment 3 dwfreed 2017-05-13 16:07:52 UTC
(In reply to NP-Hardass from comment #2)
> Presuming that since you booted with a livecd and then chrooted it, it
> fellback on sysinit as the "current", but I'll bring the openrc devs in for
> confirmation.

This is correct.  rc-update simply uses rc_runlevel_get() to get the current runlevel. 
 On Linux systems, OpenRC uses /run/openrc/softlevel to record the current runlevel.  This file does not exist during very early boot, so the function defaults to the sysinit runlevel, as most of the other consumers of the function rely on this behavior.

The only way to fix this would be to make rc-update explicitly check for the existence of the runlevel file, and fail if it does not exist.  Relatedly, OpenRC doesn't have a concept of a "default runlevel."  Yes, there's a runlevel named "default" in the standard configuration, but OpenRC will only enter this runlevel (or really, any runlevel) if explicitly told to do so (which is what Gentoo's default /etc/inittab does), so the name is kind of confusing.
Comment 4 William Hubbs gentoo-dev 2017-11-17 23:51:21 UTC
There has been no activity on this bug in a while.

If we were to make the existance of the softlevel file a requirement for
rc-update, that might cause breakage for other consumers. You should
always be able to specify which runlevel you want to add a service to,
for example:

# rc-update add foobar default

This should add foobar to the default runlevel.

Feel free to re-open this bug if you feel that we should fail instead of
treating sysinit as the default runlevel if one can't be determined.