Bug 158613

Summary: switching runlevels kills daemons started in boot.d
Product: [openSUSE] SUSE Linux 10.1 Reporter: Stefan Scheler <sscheler>
Component: AppArmorAssignee: Jesse Michael <jmichael>
Status: RESOLVED FIXED QA Contact: Dominic W Reynolds <dreynolds>
Severity: Critical    
Priority: P5 - None CC: fmfischer, hare, ro, suse-beta, werner
Version: Beta 7   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on:    
Bug Blocks: 157246    

Description Stefan Scheler 2006-03-16 12:54:12 UTC
switching to runlevel 1 and then back to 3 or 5 doesn't restart udev which leaves the system in a bad shape. For example wlan might not work because no firmware uploads without udev etc. This affects not also udev but most likely some other stuff in /etc/init.d/boot.*.
Comment 1 Dr. Werner Fink 2006-03-16 13:11:35 UTC
Not my problem: Do NEVER start daemons during hardware initialization.
All stuff in /etc/init.d/boot.*. has to run only once at startup and
maybe if someone does a cold boot into single user mode.  Last case
is done by /etc/init.d/rc.

I'm not willingly to run all boot scripts after a warm single user
mode (warm == init 1). This would e.g. run fsck on rw mounted file
systems and unmounting all file systems is not an option.
Comment 2 Kay Sievers 2006-03-16 16:19:12 UTC
Well the udev daemon _is_ the hardware initialization, so "NEVER" will not really work :) Next udev will skip "boot.udev stop".
Comment 3 Dr. Werner Fink 2006-03-16 16:28:39 UTC
Does not help, because /etc/init.d/single has to have terminate
or kill all processes.  After `init 1' the single user mode will
not have any process beside init its self.  And this is essential
for a single user mode.
Comment 4 Kay Sievers 2006-03-16 16:31:33 UTC
So, what to do then?
Comment 5 Kay Sievers 2006-03-16 16:43:13 UTC
Will: 
  # Default-Start:     B 2 3 5
instead of:
  # Default-Start:     B
do the trick?
Comment 6 Dr. Werner Fink 2006-03-16 16:59:20 UTC
Two solutions possible: first a script in all runlevels to check if
a udev is active and if not start it again ... or a two lines in
/etc/init.d/rc in the test case of a cold boot into single user
mode.  This would be the else tree for warm change into single user
mode with one line

       /etc/init.d/boot.d/S*boot.udev start

or something similar. Would be a change of aaa_base, there add
Rudi to CC.
Comment 7 Dr. Werner Fink 2006-03-16 17:01:02 UTC
Hmmm  ... the default start works only if you check in your boot
script if udev is already done.
Comment 8 Dr. Werner Fink 2006-03-16 17:05:12 UTC
Just noted that cold boot into single user mode and following
init 3/5 does not work for all cases.
Comment 9 Dr. Werner Fink 2006-03-16 17:53:00 UTC
-------------------------------------------------------------------
Thu Mar 16 18:50:27 CET 2006 - werner@suse.de

- Make cold boot into single user work even for `s'
- Restart udev after warm reached single user mode (bug #158613)

-------------------------------------------------------------------
Comment 10 Christian Zoz 2006-03-17 10:12:03 UTC
Afaik there are some other daemons started in boot.d e.g. subdomein (AppArmor), which seems not to be started in ordinary runlevels.
Comment 11 Christian Zoz 2006-03-17 10:15:52 UTC
*** Bug 157246 has been marked as a duplicate of this bug. ***
Comment 12 Dr. Werner Fink 2006-03-17 10:21:28 UTC
As I already stated: daemons should not be started
during boot time. This is for HW initialization only.

Afters system initialization is finished the runlevels
with their daemons and other services are started.
Comment 13 Dr. Werner Fink 2006-03-17 10:41:38 UTC
Please move boot.apparmor to apparmor and change the Default-Start to `2 3 5'
... beside the auditd service script should use also Default-Start `2 3 5'
because we've also a runlevel 2 not only 3 and 5.
Comment 14 Dominic W Reynolds 2006-03-21 06:39:03 UTC
Jesse can you look at this issue as steve is out? If we move to a standard runlevel managed startup can we ensure that apparmor starts early enough to confine the early services that we do now? From looking at /etc/rc.d/boot.d its looks like now we start before:

S07boot.clock
S07boot.klog
S07boot.loadmodules
S07boot.scpm
S07boot.udev_retry
S07boot.videobios
S08boot.crypto
S09boot.preload
S09boot.swap

Moving to a runlevel based startup would make us unable to confine these later services - from our current profile set I would guess this impacts klogd (which we ship a profile for).
Comment 15 Jesse Michael 2006-03-21 06:48:59 UTC
I'd rather we split things back out like we used to and have the boot.apparmor init script load the module and security policy and have a secondary init script that starts up the event daemon if necessary.
Comment 16 Dominic W Reynolds 2006-03-21 07:14:16 UTC
Also just to clarify as this bug is a little confusing - an apparmor change won't effect udev startup. Do we need two separate bugs here? one for udev and one against apparmor for violating the property that boot services are all hardware related?
Comment 17 Christian Zoz 2006-03-21 09:52:19 UTC
udev and apparmor are independant here. They just had the same problem, namely staring daemons in boot.d. The udev part is fixed.
Yes would have been better to have two bug reports, but it's the same problem.
Comment 18 Dominic W Reynolds 2006-03-22 05:16:14 UTC
Ok. So what remains is the changes to apparmor. Jesse what do you think about this? Can we change and test this week? 
Comment 19 Dr. Werner Fink 2006-03-22 10:12:54 UTC
And please do not forget to set Default-Start to `2 3 5' for
/etc/init.d/apparmor _and_ /etc/init.d/auditd
Comment 20 Dominic W Reynolds 2006-03-26 19:54:47 UTC
I don't think that there is the bandwidth here to correct and test this fix before  the GM candidate without stopping other critical work. What is the impact for not correcting this for 10.1? If the udev issue is fixed what is the impact of not moving to a standard service for apparmor?
Comment 21 Christian Zoz 2006-03-27 06:35:54 UTC
The problem is that you may lose apparmor protection when switching to runlevel 1 and back (e.g. for maintenance). And maybe you don't even notice it. So this is kind of securiry problem. But IMHO it is not critical.
Comment 22 Dominic W Reynolds 2006-03-30 22:39:32 UTC
Changes have been made for beta9 to split out part of this service to its own init script (starting the aa-eventd daemon).

This process should remain as a boot script and will only load policy (there is no userspace daemon running after this script is completed).

This allows the policy to load as early as possible in the boot process (apparmor policy being allowed to load early means we can confine programs that start in the boot process)