Skip to contentSkip to conversation

Allow init_t to read net_conf_t

PATCH In review Sugar, David 2 participants 4 messages Feb 18, 2019 – Feb 20, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow init_t to read net_conf_t

init (systemd) needs to read /etc/hostname during boot to retreive the hostname to apply to the system.

Feb 06 18:37:06 localhost.localdomain kernel: type=1400 audit(1549478223.842:3): avc:  denied  { read } for  pid=1 comm="systemd" name="hostname" dev="dm-1" ino=1262975 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:net_conf_t:s0 tclass=file permissive=0
---
 policy/modules/system/init.te | 2 ++
 1 file changed, 2 insertions(+)
policy/modules/system/init.te +2 -0
index eabba1ed..735a3b81 100644
@@ -409,6 +409,8 @@ ifdef(`init_systemd',`
 	# lvm2-activation-generator checks file labels
 	seutil_read_file_contexts(init_t)
 
+	sysnet_read_config(init_t)
+
 	systemd_getattr_updated_runtime(init_t)
 	systemd_manage_passwd_runtime_symlinks(init_t)
 	systemd_use_passwd_agent(init_t)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 Allow systemd-hostnamed to set the hostname

When calling hostnamectl to set the hostname it needs sys_admin capability to actually set the hostname.

Feb 13 11:47:14 localhost.localdomain systemd-hostnamed[7221]: Failed to set host name: Operation not permitted

type=AVC msg=audit(1550058524.656:1988): avc: denied { sys_admin } for pid=7873 comm="systemd-hostnam" capability=21 scontext=system_u:system_r:systemd_hostnamed_t:s0 tcontext=system_u:system_r:systemd_hostnamed_t:s0 tclass=capability permissive=0

---
 policy/modules/system/systemd.te | 2 ++
 1 file changed, 2 insertions(+)
policy/modules/system/systemd.te +2 -0
index 2b25a7d5..b88bf232 100644
@@ -331,6 +331,8 @@ seutil_search_default_contexts(systemd_coredump_t)
 # Hostnamed policy
 #
 
+allow systemd_hostnamed_t self:capability { sys_admin };
+
 kernel_read_kernel_sysctls(systemd_hostnamed_t)
 
 dev_read_sysfs(systemd_hostnamed_t)
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH] Allow systemd-hostnamed to set the hostname

Quoted 30 lines · David

When calling hostnamectl to set the hostname it needs sys_admin capability to actually set the hostname.

Feb 13 11:47:14 localhost.localdomain systemd-hostnamed[7221]: Failed

to set host name: Operation not permitted
type=AVC msg=audit(1550058524.656:1988): avc: denied { sys_admin } for pid=7873 comm="systemd-hostnam"
capability=21 scontext=system_u:system_r:systemd_hostnamed_t:s0 tcontext=system_u:system_r:systemd_hostnamed_t:s0 tclass=capability permissive=0

---
 policy/modules/system/systemd.te | 2 ++
 1 file changed, 2 insertions(+)
policy/modules/system/systemd.te +2 -0
index 2b25a7d5..b88bf232 100644
@@ -331,6 +331,8 @@
 seutil_search_default_contexts(systemd_coredump_t)
 # Hostnamed policy
 #
 
+allow systemd_hostnamed_t self:capability { sys_admin };
+
 kernel_read_kernel_sysctls(systemd_hostnamed_t)
 
Quoted 1 line

dev_read_sysfs(systemd_hostnamed_t)

Merged.

Signature · 1 line
Chris PeBenito
#3 lore raw
In reply to Sugar, David
Quoted 20 lines · David

init (systemd) needs to read /etc/hostname during boot to retreive the hostname to apply to the system.

Feb 06 18:37:06 localhost.localdomain kernel: type=1400

audit(1549478223.842:3): avc: denied { read } for pid=1 comm="systemd" name="hostname" dev="dm-1" ino=1262975 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:net_conf_t:s0 tclass=file permissive=0

---
 policy/modules/system/init.te | 2 ++
 1 file changed, 2 insertions(+)
policy/modules/system/init.te +0 -0
index eabba1ed..735a3b81 100644

policy/modules/system/init.te ifdef(`init_systemd',` · line 416

Quoted 8 lines
policy/modules/system/init.te +2 -0
@@ -409,6 +409,8 @@ ifdef(`init_systemd',`
 	# lvm2-activation-generator checks file labels
 	seutil_read_file_contexts(init_t)
 
+	sysnet_read_config(init_t)
+
 	systemd_getattr_updated_runtime(init_t)
 	systemd_manage_passwd_runtime_symlinks(init_t)
 	systemd_use_passwd_agent(init_t)

Merged.

Signature · 1 line
Chris PeBenito