1 |
commit: d124bc67058d9f7913289dec07b0b4cb27e25acf |
2 |
Author: Dave Sugar <dsugar <AT> tresys <DOT> com> |
3 |
AuthorDate: Mon Mar 5 14:03:01 2018 +0000 |
4 |
Commit: Sven Vermeulen <swift <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Mar 25 09:31:07 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=d124bc67 |
7 |
|
8 |
Policy for chronyc - it was running in init_t domain |
9 |
|
10 |
This patch is creating a new domain for /usr/bin/chronyc. This is a cli program that talks to a running chronyd process. chronyc is used by chrony-wait.service and I was seeing chronyc running in the init_t domain when started this way. |
11 |
|
12 |
Interface name updated based on suggestions. |
13 |
|
14 |
Signed-off-by: Dave Sugar <dsugar <AT> tresys.com> |
15 |
|
16 |
policy/modules/contrib/chronyd.fc | 1 + |
17 |
policy/modules/contrib/chronyd.if | 20 +++++++++++++++++ |
18 |
policy/modules/contrib/chronyd.te | 46 +++++++++++++++++++++++++++++++++++++-- |
19 |
3 files changed, 65 insertions(+), 2 deletions(-) |
20 |
|
21 |
diff --git a/policy/modules/contrib/chronyd.fc b/policy/modules/contrib/chronyd.fc |
22 |
index 445f3749..7153deee 100644 |
23 |
--- a/policy/modules/contrib/chronyd.fc |
24 |
+++ b/policy/modules/contrib/chronyd.fc |
25 |
@@ -9,6 +9,7 @@ |
26 |
/usr/lib/systemd/system/[^/]*chrony-wait.* -- gen_context(system_u:object_r:chronyd_unit_t,s0) |
27 |
/usr/lib/systemd/system/[^/]*chronyd.* -- gen_context(system_u:object_r:chronyd_unit_t,s0) |
28 |
|
29 |
+/usr/bin/chronyc -- gen_context(system_u:object_r:chronyc_exec_t,s0) |
30 |
/usr/sbin/chronyd -- gen_context(system_u:object_r:chronyd_exec_t,s0) |
31 |
|
32 |
/var/lib/chrony(/.*)? gen_context(system_u:object_r:chronyd_var_lib_t,s0) |
33 |
|
34 |
diff --git a/policy/modules/contrib/chronyd.if b/policy/modules/contrib/chronyd.if |
35 |
index a42bc4f4..32988914 100644 |
36 |
--- a/policy/modules/contrib/chronyd.if |
37 |
+++ b/policy/modules/contrib/chronyd.if |
38 |
@@ -252,6 +252,26 @@ interface(`chronyd_status',` |
39 |
allow $1 chronyd_unit_t:service status; |
40 |
') |
41 |
|
42 |
+######################################## |
43 |
+## <summary> |
44 |
+## Send to chronyd command line interface using a unix domain |
45 |
+## datagram socket. |
46 |
+## </summary> |
47 |
+## <param name="domain"> |
48 |
+## <summary> |
49 |
+## Domain allowed access. |
50 |
+## </summary> |
51 |
+## </param> |
52 |
+# |
53 |
+interface(`chronyd_dgram_send_cli',` |
54 |
+ gen_require(` |
55 |
+ type chronyc_t, chronyd_var_run_t; |
56 |
+ ') |
57 |
+ |
58 |
+ files_search_pids($1) |
59 |
+ dgram_send_pattern($1, chronyd_var_run_t, chronyd_var_run_t, chronyc_t) |
60 |
+') |
61 |
+ |
62 |
#################################### |
63 |
## <summary> |
64 |
## All of the rules required to |
65 |
|
66 |
diff --git a/policy/modules/contrib/chronyd.te b/policy/modules/contrib/chronyd.te |
67 |
index f28dd5e6..0634548d 100644 |
68 |
--- a/policy/modules/contrib/chronyd.te |
69 |
+++ b/policy/modules/contrib/chronyd.te |
70 |
@@ -9,6 +9,10 @@ type chronyd_t; |
71 |
type chronyd_exec_t; |
72 |
init_daemon_domain(chronyd_t, chronyd_exec_t) |
73 |
|
74 |
+type chronyc_t; |
75 |
+type chronyc_exec_t; |
76 |
+init_daemon_domain(chronyc_t, chronyc_exec_t) |
77 |
+ |
78 |
type chronyd_conf_t; |
79 |
files_config_file(chronyd_conf_t) |
80 |
|
81 |
@@ -35,10 +39,10 @@ init_daemon_pid_file(chronyd_var_run_t, dir, "chrony") |
82 |
|
83 |
######################################## |
84 |
# |
85 |
-# Local policy |
86 |
+# chronyd local policy |
87 |
# |
88 |
|
89 |
-allow chronyd_t self:capability { dac_override ipc_lock setgid setuid sys_resource sys_time }; |
90 |
+allow chronyd_t self:capability { chown dac_override ipc_lock setgid setuid sys_resource sys_time }; |
91 |
allow chronyd_t self:process { getcap setcap setrlimit signal }; |
92 |
allow chronyd_t self:shm create_shm_perms; |
93 |
allow chronyd_t self:fifo_file rw_fifo_file_perms; |
94 |
@@ -91,6 +95,7 @@ logging_send_syslog_msg(chronyd_t) |
95 |
|
96 |
miscfiles_read_localization(chronyd_t) |
97 |
|
98 |
+chronyd_dgram_send_cli(chronyd_t) |
99 |
chronyd_read_config(chronyd_t) |
100 |
|
101 |
optional_policy(` |
102 |
@@ -100,3 +105,40 @@ optional_policy(` |
103 |
optional_policy(` |
104 |
mta_send_mail(chronyd_t) |
105 |
') |
106 |
+ |
107 |
+######################################## |
108 |
+# |
109 |
+# chronyc local policy |
110 |
+# |
111 |
+ |
112 |
+allow chronyc_t self:capability { dac_override }; |
113 |
+allow chronyc_t self:process { signal }; |
114 |
+allow chronyc_t self:udp_socket create_socket_perms; |
115 |
+allow chronyc_t self:netlink_route_socket create_netlink_socket_perms; |
116 |
+ |
117 |
+manage_dirs_pattern(chronyc_t, chronyd_var_run_t, chronyd_var_run_t) |
118 |
+manage_files_pattern(chronyc_t, chronyd_var_run_t, chronyd_var_run_t) |
119 |
+manage_sock_files_pattern(chronyc_t, chronyd_var_run_t, chronyd_var_run_t) |
120 |
+files_pid_filetrans(chronyc_t, chronyd_var_run_t, { dir file sock_file }) |
121 |
+ |
122 |
+corenet_all_recvfrom_unlabeled(chronyc_t) |
123 |
+corenet_all_recvfrom_netlabel(chronyc_t) |
124 |
+corenet_udp_sendrecv_generic_if(chronyc_t) |
125 |
+corenet_udp_sendrecv_generic_node(chronyc_t) |
126 |
+ |
127 |
+corenet_sendrecv_chronyd_client_packets(chronyc_t) |
128 |
+corenet_udp_sendrecv_chronyd_port(chronyc_t) |
129 |
+ |
130 |
+files_read_etc_files(chronyc_t) |
131 |
+files_read_usr_files(chronyc_t) |
132 |
+ |
133 |
+logging_send_syslog_msg(chronyc_t) |
134 |
+ |
135 |
+sysnet_read_config(chronyc_t) |
136 |
+sysnet_dns_name_resolve(chronyc_t) |
137 |
+ |
138 |
+miscfiles_read_localization(chronyc_t) |
139 |
+ |
140 |
+chronyd_dgram_send(chronyc_t) |
141 |
+chronyd_read_config(chronyc_t) |
142 |
+ |