Skip to contentSkip to conversation

Allow ntpd to read unit files

PATCH In review Sugar, David 2 participants 2 messages Mar 26, 2019 – Mar 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow ntpd to read unit files

Adding missing documenation (sorry about that).

type=AVC msg=audit(1553013917.359:9935): avc:  denied  { read } for  pid=16326 comm="systemd-timedat" name="50-chronyd.list" dev="dm-1" ino=4870675 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:ntpd_unit_t:s0 tclass=file permissive=1
type=AVC msg=audit(1553013917.359:9935): avc:  denied  { open } for  pid=16326 comm="systemd-timedat" path="/usr/lib/systemd/ntp-units.d/50-chronyd.list" dev="dm-1" ino=4870675 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:ntpd_unit_t:s0 tclass=file permissive=1
type=AVC msg=audit(1553013917.359:9936): avc:  denied  { getattr } for  pid=16326 comm="systemd-timedat" path="/usr/lib/systemd/ntp-units.d/50-chronyd.list" dev="dm-1" ino=4870675 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:ntpd_unit_t:s0 tclass=file permissive=1
type=AVC msg=audit(1553013821.622:9902): avc:  denied  { getattr } for  pid=16281 comm="systemd-timedat" path="/usr/lib/systemd/ntp-units.d" dev="dm-1" ino=4700094 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:systemd_unit_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1553013821.622:9903): avc:  denied  { read } for  pid=16281 comm="systemd-timedat" name="ntp-units.d" dev="dm-1" ino=4700094 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:systemd_unit_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1553013821.622:9903): avc:  denied  { open } for  pid=16281 comm="systemd-timedat" path="/usr/lib/systemd/ntp-units.d" dev="dm-1" ino=4700094 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:systemd_unit_t:s0 tclass=dir permissive=1
---
 policy/modules/services/ntp.te |  3 +++
 policy/modules/system/init.if  | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+)
policy/modules/services/ntp.te +3 -0
index a95bf21d..982d6a4c 100644
@@ -138,10 +138,13 @@ userdom_dontaudit_use_unpriv_user_fds(ntpd_t)
 userdom_list_user_home_dirs(ntpd_t)
 
 ifdef(`init_systemd',`
+	allow ntpd_t ntpd_unit_t:file read_file_perms;
+
 	dbus_system_bus_client(ntpd_t)
 	dbus_connect_system_bus(ntpd_t)
 	init_dbus_chat(ntpd_t)
 	init_get_system_status(ntpd_t)
+	init_list_unit_dirs(ntpd_t)
 	# for /var/lib/systemd/timesync
 	init_read_var_lib_links(ntpd_t)
 	allow ntpd_t self:capability { fowner setpcap };
policy/modules/system/init.if +20 -0
index 2a17910e..be2c0a70 100644
@@ -2960,6 +2960,26 @@ interface(`init_search_units',`
 	fs_search_tmpfs($1)
 ')
 
+######################################
+## <summary>
+##	List systemd unit dirs.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`init_list_unit_dirs',`
+	gen_require(`
+		type systemd_unit_t;
+	')
+
+	allow $1 systemd_unit_t:dir list_dir_perms;
+
+	init_search_units($1)
+')
+
 ########################################
 ## <summary>
 ##	Read systemd unit links
Signature · 1 line
2.20.1
#1 lore raw
Quoted 55 lines · David

Adding missing documenation (sorry about that).

type=AVC msg=audit(1553013917.359:9935): avc:  denied  { read } for  pid=16326 comm="systemd-timedat" name="50-chronyd.list" dev="dm-1" ino=4870675 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:ntpd_unit_t:s0 tclass=file permissive=1
type=AVC msg=audit(1553013917.359:9935): avc:  denied  { open } for  pid=16326 comm="systemd-timedat" path="/usr/lib/systemd/ntp-units.d/50-chronyd.list" dev="dm-1" ino=4870675 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:ntpd_unit_t:s0 tclass=file permissive=1
type=AVC msg=audit(1553013917.359:9936): avc:  denied  { getattr } for  pid=16326 comm="systemd-timedat" path="/usr/lib/systemd/ntp-units.d/50-chronyd.list" dev="dm-1" ino=4870675 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:ntpd_unit_t:s0 tclass=file permissive=1
type=AVC msg=audit(1553013821.622:9902): avc:  denied  { getattr } for  pid=16281 comm="systemd-timedat" path="/usr/lib/systemd/ntp-units.d" dev="dm-1" ino=4700094 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:systemd_unit_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1553013821.622:9903): avc:  denied  { read } for  pid=16281 comm="systemd-timedat" name="ntp-units.d" dev="dm-1" ino=4700094 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:systemd_unit_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1553013821.622:9903): avc:  denied  { open } for  pid=16281 comm="systemd-timedat" path="/usr/lib/systemd/ntp-units.d" dev="dm-1" ino=4700094 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:systemd_unit_t:s0 tclass=dir permissive=1
---
  policy/modules/services/ntp.te |  3 +++
  policy/modules/system/init.if  | 20 ++++++++++++++++++++
  2 files changed, 23 insertions(+)
policy/modules/services/ntp.te +3 -0
index a95bf21d..982d6a4c 100644
@@ -138,10 +138,13 @@ userdom_dontaudit_use_unpriv_user_fds(ntpd_t)
  userdom_list_user_home_dirs(ntpd_t)
 
  ifdef(`init_systemd',`
+	allow ntpd_t ntpd_unit_t:file read_file_perms;
+
  	dbus_system_bus_client(ntpd_t)
  	dbus_connect_system_bus(ntpd_t)
  	init_dbus_chat(ntpd_t)
  	init_get_system_status(ntpd_t)
+	init_list_unit_dirs(ntpd_t)
  	# for /var/lib/systemd/timesync
  	init_read_var_lib_links(ntpd_t)
  	allow ntpd_t self:capability { fowner setpcap };
policy/modules/system/init.if +13 -0
index 2a17910e..be2c0a70 100644
@@ -2960,6 +2960,26 @@ interface(`init_search_units',`
  	fs_search_tmpfs($1)
  ')
 
+######################################
+## <summary>
+##	List systemd unit dirs.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`init_list_unit_dirs',`
+	gen_require(`
+		type systemd_unit_t;

policy/modules/system/init.if interface(`init_search_units',` · line 2985

Quoted 10 lines
policy/modules/system/init.if +7 -0
+	')
+
+	allow $1 systemd_unit_t:dir list_dir_perms;
+
+	init_search_units($1)
+')
+
  ########################################
  ## <summary>
  ##	Read systemd unit links

Merged.

Signature · 1 line
Chris PeBenito