selinux-refpolicy/policy/modules/system/init.fc
David Sugar 8a7a8bd8c8 label systemd-shutdown so shutdown works
I am seeing (on RHEL 7.4 w/systemd) that halting the system doesn't work.  It took me a long time (and a lot of help from Steve L.) to figure out what was going on.  It turns out in refpolicy the default label for /usr/lib/systemd/systemd-shutdown is bin_t.  But when systemd tried to execve systemd-shutdown it fails because init_t isn't allowed file entrypoint for bin_t.  When I labeled systemd-shutdown as init_exec_t shutting down the system works.

I was seeing the following log (from systemd) when I enabled systemd debug logging (which was very useful).

[   59.745037] systemd[1]: Starting Final Step.
[   59.746112] systemd[1]: Starting Power-Off...
[   59.776320] systemd[1]: Shutting down.
[   59.783559] systemd[1]: Failed to execute shutdown binary, freezing: Operation not permitted

At this point everything locks up instead of actually halting the system.

This is a patch to change the label for systemd-shutdown which solves the problem.  I'm happy to go through and make a distinct type of systemd-shutdown if someone doesn't think it is a good idea to share the type with systemd.  But based on what is going on, this might be reasonable.

Signed-off-by: Dave Sugar <dsugar@tresys.com>
2017-12-10 14:45:35 -05:00

89 lines
3.7 KiB
Plaintext

#
# /etc
#
/etc/rc\.d/rc -- gen_context(system_u:object_r:initrc_exec_t,s0)
/etc/rc\.d/rc\.[^/]+ -- gen_context(system_u:object_r:initrc_exec_t,s0)
/etc/rc\.d/init\.d/.* -- gen_context(system_u:object_r:initrc_exec_t,s0)
/etc/sysconfig/network-scripts/ifup-ipsec -- gen_context(system_u:object_r:initrc_exec_t,s0)
/etc/X11/prefdm -- gen_context(system_u:object_r:initrc_exec_t,s0)
ifdef(`distro_gentoo',`
/etc/vmware/init\.d/vmware -- gen_context(system_u:object_r:initrc_exec_t,s0)
/etc/x11/startDM\.sh -- gen_context(system_u:object_r:initrc_exec_t,s0)
')
#
# /dev
#
/dev/initctl -p gen_context(system_u:object_r:initctl_t,s0)
#
# /usr
#
/usr/bin/init(ng)? -- gen_context(system_u:object_r:init_exec_t,s0)
/usr/bin/open_init_pty -- gen_context(system_u:object_r:initrc_exec_t,s0)
/usr/bin/sepg_ctl -- gen_context(system_u:object_r:initrc_exec_t,s0)
/usr/bin/systemd -- gen_context(system_u:object_r:init_exec_t,s0)
/usr/bin/upstart -- gen_context(system_u:object_r:init_exec_t,s0)
/usr/lib/systemd/systemd -- gen_context(system_u:object_r:init_exec_t,s0)
/usr/lib/systemd/systemd-shutdown -- gen_context(system_u:object_r:init_exec_t,s0)
/usr/lib/systemd/system-preset(/.*)? gen_context(system_u:object_r:systemd_unit_t,s0)
/usr/lib/systemd/user-preset(/.*)? gen_context(system_u:object_r:systemd_unit_t,s0)
/usr/lib/systemd/ntp-units\.d -d gen_context(system_u:object_r:systemd_unit_t,s0)
/usr/lib/systemd/system(/.*)? gen_context(system_u:object_r:systemd_unit_t,s0)
/usr/libexec/dcc/start-.* -- gen_context(system_u:object_r:initrc_exec_t,s0)
/usr/libexec/dcc/stop-.* -- gen_context(system_u:object_r:initrc_exec_t,s0)
/usr/sbin/init(ng)? -- gen_context(system_u:object_r:init_exec_t,s0)
/usr/sbin/open_init_pty -- gen_context(system_u:object_r:initrc_exec_t,s0)
/usr/sbin/upstart -- gen_context(system_u:object_r:init_exec_t,s0)
ifdef(`distro_gentoo', `
/usr/lib/rc/init\.d(/.*)? gen_context(system_u:object_r:initrc_state_t,s0)
/usr/sbin/rc -- gen_context(system_u:object_r:rc_exec_t,s0)
')
ifdef(`distro_redhat',`
/usr/lib/systemd/rhel[^/]* -- gen_context(system_u:object_r:initrc_exec_t,s0)
')
#
# /var
#
/var/lib/systemd(/.*)? gen_context(system_u:object_r:init_var_lib_t,s0)
/run/initctl -p gen_context(system_u:object_r:initctl_t,s0)
/run/kerneloops\.pid -- gen_context(system_u:object_r:initrc_var_run_t,s0)
/run/utmp -- gen_context(system_u:object_r:initrc_var_run_t,s0)
/run/runlevel\.dir gen_context(system_u:object_r:initrc_var_run_t,s0)
/run/random-seed -- gen_context(system_u:object_r:initrc_var_run_t,s0)
/run/setmixer_flag -- gen_context(system_u:object_r:initrc_var_run_t,s0)
/run/systemd(/.*)? gen_context(system_u:object_r:init_var_run_t,s0)
/run/wd_keepalive\.pid -- gen_context(system_u:object_r:initrc_var_run_t,s0)
ifdef(`distro_debian',`
/run/hotkey-setup -- gen_context(system_u:object_r:initrc_var_run_t,s0)
/run/kdm/.* -- gen_context(system_u:object_r:initrc_var_run_t,s0)
/etc/network/if-pre-up\.d/.* -- gen_context(system_u:object_r:initrc_exec_t,s0)
/etc/network/if-up\.d/.* -- gen_context(system_u:object_r:initrc_exec_t,s0)
/etc/network/if-down\.d/.* -- gen_context(system_u:object_r:initrc_exec_t,s0)
/etc/network/if-post-down\.d/.* -- gen_context(system_u:object_r:initrc_exec_t,s0)
')
ifdef(`distro_gentoo', `
/var/lib/init\.d(/.*)? gen_context(system_u:object_r:initrc_state_t,s0)
/run/svscan\.pid -- gen_context(system_u:object_r:initrc_var_run_t,s0)
')
ifdef(`distro_suse', `
/run/bootsplashctl -p gen_context(system_u:object_r:initrc_var_run_t,s0)
/run/keymap -- gen_context(system_u:object_r:initrc_var_run_t,s0)
/run/numlock-on -- gen_context(system_u:object_r:initrc_var_run_t,s0)
/run/setleds-on -- gen_context(system_u:object_r:initrc_var_run_t,s0)
/run/sysconfig(/.*)? gen_context(system_u:object_r:initrc_var_run_t,s0)
')