1 |
commit: 60d89770b45fce6ae0eefabbbbebd1fbaa717eea |
2 |
Author: David Sugar <dsugar <AT> tresys <DOT> com> |
3 |
AuthorDate: Fri Dec 8 22:30:58 2017 +0000 |
4 |
Commit: Jason Zaman <perfinion <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Dec 12 07:06:27 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=60d89770 |
7 |
|
8 |
label systemd-shutdown so shutdown works |
9 |
|
10 |
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. |
11 |
|
12 |
I was seeing the following log (from systemd) when I enabled systemd debug logging (which was very useful). |
13 |
|
14 |
[ 59.745037] systemd[1]: Starting Final Step. |
15 |
[ 59.746112] systemd[1]: Starting Power-Off... |
16 |
[ 59.776320] systemd[1]: Shutting down. |
17 |
[ 59.783559] systemd[1]: Failed to execute shutdown binary, freezing: Operation not permitted |
18 |
|
19 |
At this point everything locks up instead of actually halting the system. |
20 |
|
21 |
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. |
22 |
|
23 |
Signed-off-by: Dave Sugar <dsugar <AT> tresys.com> |
24 |
|
25 |
policy/modules/system/init.fc | 1 + |
26 |
1 file changed, 1 insertion(+) |
27 |
|
28 |
diff --git a/policy/modules/system/init.fc b/policy/modules/system/init.fc |
29 |
index d029ea30..bf0acaf9 100644 |
30 |
--- a/policy/modules/system/init.fc |
31 |
+++ b/policy/modules/system/init.fc |
32 |
@@ -29,6 +29,7 @@ ifdef(`distro_gentoo',` |
33 |
/usr/bin/upstart -- gen_context(system_u:object_r:init_exec_t,s0) |
34 |
|
35 |
/usr/lib/systemd/systemd -- gen_context(system_u:object_r:init_exec_t,s0) |
36 |
+/usr/lib/systemd/systemd-shutdown -- gen_context(system_u:object_r:init_exec_t,s0) |
37 |
/usr/lib/systemd/system-preset(/.*)? gen_context(system_u:object_r:systemd_unit_t,s0) |
38 |
/usr/lib/systemd/user-preset(/.*)? gen_context(system_u:object_r:systemd_unit_t,s0) |
39 |
/usr/lib/systemd/ntp-units\.d -d gen_context(system_u:object_r:systemd_unit_t,s0) |