Skip to contentSkip to conversation

another systemd misc patch

PATCH In review Russell Coker 3 participants 5 messages Feb 3, 2021 – Feb 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 another systemd misc patch

Lots of littls changes related to systemd.

policy/modules/system/systemd.if +75 -1
Index: refpolicy-2.20210203/policy/modules/system/systemd.if
===================================================================
@@ -84,6 +84,8 @@ template(`systemd_role_template',`
 	seutil_read_file_contexts($1_systemd_t)
 	seutil_search_default_contexts($1_systemd_t)
 
+	userdom_search_user_home_dirs($1_systemd_t)
+
 	# for machinectl shell
 	term_user_pty($1_systemd_t, user_devpts_t)
 	allow $1_systemd_t user_devpts_t:chr_file rw_file_perms;
@@ -296,6 +298,24 @@ interface(`systemd_write_logind_runtime_
 
 ######################################
 ## <summary>
+##     Watch systemd-logind runtime dirs
+## </summary>
+## <param name="domain">
+##     <summary>
+##     Domain allowed access.
+##     </summary>
+## </param>
+#
+interface(`systemd_watch_logind_runtime_dir',`
+	gen_require(`
+		type systemd_logind_runtime_t;
+	')
+
+	allow $1 systemd_logind_runtime_t:dir watch;
+')
+
+######################################
+## <summary>
 ##   Use inherited systemd
 ##   logind file descriptors.
 ## </summary>
@@ -356,6 +376,24 @@ interface(`systemd_write_inherited_login
 
 ######################################
 ## <summary>
+##      Watch logind sessions dirs.
+## </summary>
+## <param name="domain">
+##      <summary>
+##      Domain allowed access.
+##      </summary>
+## </param>
+#
+interface(`systemd_watch_logind_sessions_dir',`
+	gen_require(`
+		type systemd_sessions_runtime_t;
+	')
+
+	allow $1 systemd_sessions_runtime_t:dir watch;
+')
+
+######################################
+## <summary>
 ##      Write inherited logind inhibit pipes.
 ## </summary>
 ## <param name="domain">
@@ -528,6 +566,24 @@ interface(`systemd_connect_machined',`
 
 ########################################
 ## <summary>
+##	Allow watching /run/systemd/machines
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain that can watch the machines files
+##	</summary>
+## </param>
+#
+interface(`systemd_watch_machines_dir',`
+	gen_require(`
+		type systemd_machined_runtime_t;
+	')
+
+	allow $1 systemd_machined_runtime_t:dir watch;
+')
+
+########################################
+## <summary>
 ##   Send and receive messages from
 ##   systemd hostnamed over dbus.
 ## </summary>
@@ -585,7 +641,7 @@ interface(`systemd_run_passwd_agent',`
 		type systemd_passwd_agent_t, systemd_passwd_agent_exec_t;
 	')
 
-	domtrans_pattern($1, systemd_passwd_agent_exec_t, systemd_passwd_agent_t)
+	domain_auto_transition_pattern($1, systemd_passwd_agent_exec_t, systemd_passwd_agent_t)
 	allow systemd_passwd_agent_t $1:fd use;
 	role $2 types systemd_passwd_agent_t;
 ')
@@ -673,6 +729,24 @@ interface(`systemd_manage_passwd_runtime
 ')
 
 ########################################
+## <summary>
+##      watch systemd_passwd_runtime_t dirs
+## </summary>
+## <param name="domain">
+##  <summary>
+##  Domain allowed access.
+##  </summary>
+## </param>
+#
+interface(`systemd_watch_passwd_runtime_dirs',`
+	gen_require(`
+		type systemd_passwd_runtime_t;
+	')
+
+	allow $1 systemd_passwd_runtime_t:dir watch;
+')
+
+########################################
 ## <summary>
 ##      manage systemd unit dirs and the files in them  (Deprecated)
 ## </summary>
policy/modules/system/systemd.te +120 -5

361 lines not on this page · raw message

policy/modules/admin/dpkg.if +37 -0
Index: refpolicy-2.20210203/policy/modules/admin/dpkg.if
===================================================================
@@ -356,3 +356,40 @@ interface(`dpkg_read_script_tmp_symlinks
 
 	allow $1 dpkg_script_tmp_t:lnk_file read_lnk_file_perms;
 ')
+
+########################################
+## <summary>
+##	send dbus messages to dpkg_t
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`dpkg_dbus_chat',`
+	gen_require(`
+		type dpkg_t;
+	')
+
+	allow $1 dpkg_t:dbus send_msg;
+')
+
+########################################
+## <summary>
+##	read dpkg_t process state
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`dpkg_read_state',`
+	gen_require(`
+		type dpkg_t;
+	')
+
+	allow $1 dpkg_t:dir search;
+	allow $1 dpkg_t:file read_file_perms;
+')
policy/modules/roles/sysadm.te +3 -0
Index: refpolicy-2.20210203/policy/modules/roles/sysadm.te
===================================================================
@@ -95,6 +95,9 @@ ifdef(`init_systemd',`
 	# Allow sysadm to resolve the username of dynamic users by calling
 	# LookupDynamicUserByUID on org.freedesktop.systemd1.
 	init_dbus_chat(sysadm_t)
+
+	systemd_run_passwd_agent(sysadm_t, sysadm_r)
+	systemd_watch_passwd_runtime_dirs(sysadm_t)
 ')
 
 tunable_policy(`allow_ptrace',`
policy/modules/services/networkmanager.te +3 -0
Index: refpolicy-2.20210203/policy/modules/services/networkmanager.te
===================================================================
@@ -340,6 +340,9 @@ optional_policy(`
 optional_policy(`
 	systemd_read_logind_runtime_files(NetworkManager_t)
 	systemd_read_logind_sessions_files(NetworkManager_t)
+	systemd_watch_logind_runtime_dir(NetworkManager_t)
+	systemd_watch_logind_sessions_dir(NetworkManager_t)
+	systemd_watch_machines_dir(NetworkManager_t)
 	systemd_write_inherited_logind_inhibit_pipes(NetworkManager_t)
 ')
 
policy/modules/services/policykit.te +3 -0
Index: refpolicy-2.20210203/policy/modules/services/policykit.te
===================================================================
@@ -134,12 +134,15 @@ optional_policy(`
 optional_policy(`
 	# for /run/systemd/machines
 	systemd_read_machines(policykit_t)
+	systemd_watch_machines_dir(policykit_t)
 
 	# for /run/systemd/seats/seat*
 	systemd_read_logind_sessions_files(policykit_t)
+	systemd_watch_logind_sessions_dir(policykit_t)
 
 	# for /run/systemd/users/*
 	systemd_read_logind_runtime_files(policykit_t)
+	systemd_watch_logind_runtime_dir(policykit_t)
 ')
 
 ########################################
#1 lore raw
Quoted 8 lines · Russell Coker

Lots of littls changes related to systemd.

policy/modules/system/systemd.if +0 -0
@@ -296,6 +298,24 @@ interface(`systemd_write_logind_runtime_
 
  ######################################

policy/modules/system/systemd.if interface(`systemd_write_logind_runtime_ · line 309

Quoted 10 lines
policy/modules/system/systemd.if +9 -0
  ## <summary>
+##     Watch systemd-logind runtime dirs
+## </summary>
+## <param name="domain">
+##     <summary>
+##     Domain allowed access.
+##     </summary>
+## </param>
+#
+interface(`systemd_watch_logind_runtime_dir',`

systemd_watch_logind_runtime_dirs (plural)

Quoted 15 lines
policy/modules/system/systemd.if +9 -0
+	gen_require(`
+		type systemd_logind_runtime_t;
+	')
+
+	allow $1 systemd_logind_runtime_t:dir watch;
+')
+
+######################################
+## <summary>
  ##   Use inherited systemd
  ##   logind file descriptors.
  ## </summary>
@@ -356,6 +376,24 @@ interface(`systemd_write_inherited_login
 
  ######################################

policy/modules/system/systemd.if interface(`systemd_write_inherited_login · line 387

Quoted 10 lines
policy/modules/system/systemd.if +9 -0
  ## <summary>
+##      Watch logind sessions dirs.
+## </summary>
+## <param name="domain">
+##      <summary>
+##      Domain allowed access.
+##      </summary>
+## </param>
+#
+interface(`systemd_watch_logind_sessions_dir',`

systemd_watch_logind_sessions_dirs (plural)

Quoted 15 lines
policy/modules/system/systemd.if +9 -0
+	gen_require(`
+		type systemd_sessions_runtime_t;
+	')
+
+	allow $1 systemd_sessions_runtime_t:dir watch;
+')
+
+######################################
+## <summary>
  ##      Write inherited logind inhibit pipes.
  ## </summary>
  ## <param name="domain">
@@ -528,6 +566,24 @@ interface(`systemd_connect_machined',`
 
  ########################################

policy/modules/system/systemd.if interface(`systemd_connect_machined',` · line 577

Quoted 10 lines
policy/modules/system/systemd.if +9 -0
  ## <summary>
+##	Allow watching /run/systemd/machines
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain that can watch the machines files
+##	</summary>
+## </param>
+#
+interface(`systemd_watch_machines_dir',`

systemd_watch_machines_dirs (plural)

Quoted 13 lines
policy/modules/system/systemd.if +9 -0
+	gen_require(`
+		type systemd_machined_runtime_t;
+	')
+
+	allow $1 systemd_machined_runtime_t:dir watch;
+')
+
+########################################
+## <summary>
  ##   Send and receive messages from
  ##   systemd hostnamed over dbus.
  ## </summary>

policy/modules/system/systemd.if interface(`systemd_run_passwd_agent',` · line 644

Quoted 5 lines
policy/modules/system/systemd.if +1 -1
@@ -585,7 +641,7 @@ interface(`systemd_run_passwd_agent',`
  		type systemd_passwd_agent_t, systemd_passwd_agent_exec_t;
  	')
 
-	domtrans_pattern($1, systemd_passwd_agent_exec_t, systemd_passwd_agent_t)
+	domain_auto_transition_pattern($1, systemd_passwd_agent_exec_t, systemd_passwd_agent_t)

domtrans_pattern() is the standard pattern. This change has no effect.

Quoted 22 lines

Index: refpolicy-2.20210203/policy/modules/system/systemd.te
===================================================================

policy/modules/system/systemd.te +3 -0
@@ -129,6 +129,7 @@ type systemd_logind_t;
  type systemd_logind_exec_t;
  init_daemon_domain(systemd_logind_t, systemd_logind_exec_t)
  init_named_socket_activation(systemd_logind_t, systemd_logind_runtime_t)
+init_stream_connect(systemd_logind_t)
 
  type systemd_logind_inhibit_runtime_t alias systemd_logind_inhibit_var_run_t;
  files_runtime_file(systemd_logind_inhibit_runtime_t)
@@ -295,6 +296,8 @@ allow systemd_backlight_t systemd_backli
  init_var_lib_filetrans(systemd_backlight_t, systemd_backlight_var_lib_t, dir)
  manage_files_pattern(systemd_backlight_t, systemd_backlight_var_lib_t, systemd_backlight_var_lib_t)
 
+kernel_read_kernel_sysctls(systemd_backlight_t)
+
  systemd_log_parse_environment(systemd_backlight_t)
 
  # Allow systemd-backlight to write to /sys/class/backlight/*/brightness

policy/modules/system/systemd.te ifdef(`enable_mls',` · line 365

Quoted 6 lines
policy/modules/system/systemd.te +2 -1
@@ -358,13 +361,15 @@ ifdef(`enable_mls',`
  #
 
  allow systemd_coredump_t self:unix_dgram_socket { create write connect getopt setopt };
-allow systemd_coredump_t self:capability { dac_override dac_read_search setgid setuid setpcap sys_ptrace };
+allow systemd_coredump_t self:unix_stream_socket connectto;
+allow systemd_coredump_t self:capability { dac_override dac_read_search setgid setuid setpcap net_admin sys_ptrace };

net_admin? That doesn't seem necessary for core dumping.

[...]

Quoted 19 lines
policy/modules/system/systemd.te +15 -0
@@ -393,6 +403,32 @@ logging_send_syslog_msg(systemd_coredump
 
  seutil_search_default_contexts(systemd_coredump_t)
 
+allow systemd_generator_t self:fifo_file rw_file_perms;
+allow systemd_generator_t self:process setfscreate;
+
+allow systemd_generator_t self:capability dac_override;
+allow systemd_generator_t self:tcp_socket create;
+allow systemd_generator_t self:netlink_route_socket { create read bind getattr write nlmsg_read };
+
+corecmd_exec_bin(systemd_generator_t)
+corecmd_exec_shell(systemd_generator_t)
+files_exec_etc_files(systemd_generator_t)
+fs_getattr_cgroup(systemd_generator_t)
+fs_getattr_tmpfs(systemd_generator_t)
+fs_rw_tmpfs_files(systemd_generator_t)
+miscfiles_read_localization(systemd_generator_t)
+

policy/modules/system/systemd.te logging_send_syslog_msg(systemd_coredump · line 430

Quoted 10 lines
policy/modules/system/systemd.te +10 -0
+optional_policy(`
+	# for /lib/systemd/system-generators/openvpn-generator
+	openvpn_read_config(systemd_generator_t)
+')
+
+optional_policy(`
+	# it runs postconf
+	# maybe /lib/systemd/system-generators/postfix-instance-generator
+	postfix_read_config(systemd_generator_t)
+')

The systemd_generator_t rules need to move to proper places.

policy/modules/system/systemd.te allow systemd_logind_t systemd_sessions_ · line 645

Quoted 5 lines
policy/modules/system/systemd.te +1 -0
@@ -583,6 +642,8 @@ allow systemd_logind_t systemd_sessions_
 
  kernel_read_kernel_sysctls(systemd_logind_t)
 
+auth_read_shadow(systemd_logind_t)

If this is necessary, it seems Debian specific.

[...]

Quoted 5 lines
policy/modules/system/systemd.te +1 -0
@@ -925,14 +1001,26 @@ allow systemd_nspawn_t systemd_nspawn_tm
  # for /run/systemd/nspawn/incoming in chroot
  allow systemd_nspawn_t systemd_nspawn_runtime_t:dir mounton;
 
+kernel_getattr_core_if(systemd_nspawn_t)

policy/modules/system/systemd.te allow systemd_nspawn_t systemd_nspawn_tm · line 1014

Quoted 10 lines
policy/modules/system/systemd.te +5 -0
+kernel_getattr_proc(systemd_nspawn_t)
+kernel_getattr_unlabeled_dirs(systemd_nspawn_t)
+
  kernel_mount_proc(systemd_nspawn_t)
  kernel_mounton_sysctl_dirs(systemd_nspawn_t)
  kernel_mounton_kernel_sysctl_files(systemd_nspawn_t)
  kernel_mounton_message_if(systemd_nspawn_t)
  kernel_mounton_proc(systemd_nspawn_t)
+kernel_mounton_sysctl_files(systemd_nspawn_t)
+kernel_mounton_unlabeled_dirs(systemd_nspawn_t)

With all of the mounting, perhaps we should consider coalescing on allowing it to mount an all init_mountpoint_types.

[..]

policy/modules/system/systemd.te term_mount_devpts(systemd_nspawn_t) · line 1070

Quoted 5 lines
policy/modules/system/systemd.te +1 -0
@@ -972,6 +1067,7 @@ term_mount_devpts(systemd_nspawn_t)
  term_search_ptys(systemd_nspawn_t)
  term_setattr_generic_ptys(systemd_nspawn_t)
  term_use_ptmx(systemd_nspawn_t)
+term_use_generic_ptys(systemd_nspawn_t)

Perhaps this should have a pty type?

policy/modules/system/systemd.te seutil_libselinux_linked(systemd_user_se · line 1630

Quoted 6 lines
policy/modules/system/systemd.te +1 -1
@@ -1519,11 +1627,15 @@ seutil_libselinux_linked(systemd_user_se
  # systemd-user-runtime-dir local policy
  #
 
-allow systemd_user_runtime_dir_t self:capability { fowner chown sys_admin dac_read_search dac_override };
+allow systemd_user_runtime_dir_t self:capability { chown dac_override dac_read_search dac_override fowner sys_admin mknod };

sys_admin and mknod? What is sys_admin used for; also, I don't see any rules for creating devices.

Quoted 38 lines
policy/modules/system/systemd.te +7 -0
  allow systemd_user_runtime_dir_t self:process setfscreate;
 
  domain_obj_id_change_exemption(systemd_user_runtime_dir_t)
 
+allow systemd_user_runtime_dir_t systemd_user_runtime_t:dir manage_dir_perms;
+allow systemd_user_runtime_dir_t systemd_user_runtime_t:sock_file unlink;
+allow systemd_user_runtime_dir_t systemd_user_runtime_notify_t:sock_file unlink;
+
  files_read_etc_files(systemd_user_runtime_dir_t)
 
  fs_mount_tmpfs(systemd_user_runtime_dir_t)
@@ -1543,7 +1655,10 @@ seutil_read_file_contexts(systemd_user_r
  seutil_libselinux_linked(systemd_user_runtime_dir_t)
 
  userdom_delete_user_tmp_dirs(systemd_user_runtime_dir_t)
+userdom_delete_user_tmp_files(systemd_user_runtime_dir_t)
  userdom_delete_user_tmp_named_pipes(systemd_user_runtime_dir_t)
+userdom_delete_user_tmp_named_sockets(systemd_user_runtime_dir_t)
+userdom_list_user_tmp(systemd_user_runtime_dir_t)
  userdom_search_user_runtime_root(systemd_user_runtime_dir_t)
  userdom_user_runtime_root_filetrans_user_runtime(systemd_user_runtime_dir_t, dir)
  userdom_manage_user_runtime_dirs(systemd_user_runtime_dir_t)

Index: refpolicy-2.20210203/policy/modules/admin/dpkg.if
===================================================================

policy/modules/admin/dpkg.if +8 -0
@@ -356,3 +356,40 @@ interface(`dpkg_read_script_tmp_symlinks
 
  	allow $1 dpkg_script_tmp_t:lnk_file read_lnk_file_perms;
  ')
+
+########################################
+## <summary>
+##	send dbus messages to dpkg_t
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.

policy/modules/admin/dpkg.if interface(`dpkg_read_script_tmp_symlinks · line 376

Quoted 10 lines
policy/modules/admin/dpkg.if +10 -0
+##	</summary>
+## </param>
+#
+interface(`dpkg_dbus_chat',`
+	gen_require(`
+		type dpkg_t;
+	')
+
+	allow $1 dpkg_t:dbus send_msg;
+')

I'd prefer that the dbus chat interfaces are provided by the server process' domain.

Signature · 1 line
Chris PeBenito
#2 lore raw
Quoted 161 lines · Chris PeBenito
Quoted 6 lines · Russell Coker

Lots of littls changes related to systemd.

policy/modules/system/systemd.if +0 -0
@@ -296,6 +298,24 @@ interface(`systemd_write_logind_runtime_
    ######################################

policy/modules/system/systemd.if interface(`systemd_write_logind_runtime_ · line 308

Quoted 10 lines
policy/modules/system/systemd.if +9 -0
  ## <summary>
+##     Watch systemd-logind runtime dirs
+## </summary>
+## <param name="domain">
+##     <summary>
+##     Domain allowed access.
+##     </summary>
+## </param>
+#
+interface(`systemd_watch_logind_runtime_dir',`

systemd_watch_logind_runtime_dirs (plural)

Quoted 14 lines
policy/modules/system/systemd.if +9 -0
+	gen_require(`
+		type systemd_logind_runtime_t;
+	')
+
+	allow $1 systemd_logind_runtime_t:dir watch;
+')
+
+######################################
+## <summary>
  ##   Use inherited systemd
  ##   logind file descriptors.
  ## </summary>
@@ -356,6 +376,24 @@ interface(`systemd_write_inherited_login
    ######################################

policy/modules/system/systemd.if interface(`systemd_write_inherited_login · line 386

Quoted 10 lines
policy/modules/system/systemd.if +9 -0
  ## <summary>
+##      Watch logind sessions dirs.
+## </summary>
+## <param name="domain">
+##      <summary>
+##      Domain allowed access.
+##      </summary>
+## </param>
+#
+interface(`systemd_watch_logind_sessions_dir',`

systemd_watch_logind_sessions_dirs (plural)

Quoted 14 lines
policy/modules/system/systemd.if +9 -0
+	gen_require(`
+		type systemd_sessions_runtime_t;
+	')
+
+	allow $1 systemd_sessions_runtime_t:dir watch;
+')
+
+######################################
+## <summary>
  ##      Write inherited logind inhibit pipes.
  ## </summary>
  ## <param name="domain">
@@ -528,6 +566,24 @@ interface(`systemd_connect_machined',`
    ########################################

policy/modules/system/systemd.if interface(`systemd_connect_machined',` · line 576

Quoted 10 lines
policy/modules/system/systemd.if +9 -0
  ## <summary>
+##	Allow watching /run/systemd/machines
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain that can watch the machines files
+##	</summary>
+## </param>
+#
+interface(`systemd_watch_machines_dir',`

systemd_watch_machines_dirs (plural)

Quoted 13 lines
policy/modules/system/systemd.if +9 -0
+	gen_require(`
+		type systemd_machined_runtime_t;
+	')
+
+	allow $1 systemd_machined_runtime_t:dir watch;
+')
+
+########################################
+## <summary>
  ##   Send and receive messages from
  ##   systemd hostnamed over dbus.
  ## </summary>

policy/modules/system/systemd.if interface(`systemd_run_passwd_agent',` · line 645

Quoted 5 lines
policy/modules/system/systemd.if +1 -0
@@ -585,7 +641,7 @@ interface(`systemd_run_passwd_agent',`
  		type systemd_passwd_agent_t, systemd_passwd_agent_exec_t;
  	')
  -	domtrans_pattern($1, systemd_passwd_agent_exec_t,
 systemd_passwd_agent_t)
+	domain_auto_transition_pattern($1, systemd_passwd_agent_exec_t, systemd_passwd_agent_t)

domtrans_pattern() is the standard pattern. This change has no effect.

Quoted 21 lines

Index: refpolicy-2.20210203/policy/modules/system/systemd.te
===================================================================

policy/modules/system/systemd.te +2 -0
@@ -129,6 +129,7 @@ type systemd_logind_t;
  type systemd_logind_exec_t;
  init_daemon_domain(systemd_logind_t, systemd_logind_exec_t)
  init_named_socket_activation(systemd_logind_t, systemd_logind_runtime_t)
+init_stream_connect(systemd_logind_t)
    type systemd_logind_inhibit_runtime_t alias
 systemd_logind_inhibit_var_run_t;
  files_runtime_file(systemd_logind_inhibit_runtime_t)
@@ -295,6 +296,8 @@ allow systemd_backlight_t systemd_backli
  init_var_lib_filetrans(systemd_backlight_t, systemd_backlight_var_lib_t, dir)
  manage_files_pattern(systemd_backlight_t, systemd_backlight_var_lib_t, systemd_backlight_var_lib_t)
  +kernel_read_kernel_sysctls(systemd_backlight_t)
+
  systemd_log_parse_environment(systemd_backlight_t)
    # Allow systemd-backlight to write to

/sys/class/backlight/*/brightness

policy/modules/system/systemd.te ifdef(`enable_mls',` · line 365

Quoted 6 lines
policy/modules/system/systemd.te +2 -1
@@ -358,13 +361,15 @@ ifdef(`enable_mls',`
  #
    allow systemd_coredump_t self:unix_dgram_socket { create write
 connect getopt setopt };
-allow systemd_coredump_t self:capability { dac_override dac_read_search setgid setuid setpcap sys_ptrace };
+allow systemd_coredump_t self:unix_stream_socket connectto;
+allow systemd_coredump_t self:capability { dac_override dac_read_search setgid setuid setpcap net_admin sys_ptrace };

net_admin? That doesn't seem necessary for core dumping.

[...]

Quoted 17 lines
policy/modules/system/systemd.te +14 -0
@@ -393,6 +403,32 @@ logging_send_syslog_msg(systemd_coredump
    seutil_search_default_contexts(systemd_coredump_t)
  +allow systemd_generator_t self:fifo_file rw_file_perms;
+allow systemd_generator_t self:process setfscreate;
+
+allow systemd_generator_t self:capability dac_override;
+allow systemd_generator_t self:tcp_socket create;
+allow systemd_generator_t self:netlink_route_socket { create read bind getattr write nlmsg_read };
+
+corecmd_exec_bin(systemd_generator_t)
+corecmd_exec_shell(systemd_generator_t)
+files_exec_etc_files(systemd_generator_t)
+fs_getattr_cgroup(systemd_generator_t)
+fs_getattr_tmpfs(systemd_generator_t)
+fs_rw_tmpfs_files(systemd_generator_t)
+miscfiles_read_localization(systemd_generator_t)
+

policy/modules/system/systemd.te logging_send_syslog_msg(systemd_coredump · line 428

Quoted 10 lines
policy/modules/system/systemd.te +10 -0
+optional_policy(`
+	# for /lib/systemd/system-generators/openvpn-generator
+	openvpn_read_config(systemd_generator_t)
+')
+
+optional_policy(`
+	# it runs postconf
+	# maybe /lib/systemd/system-generators/postfix-instance-generator
+	postfix_read_config(systemd_generator_t)
+')

The systemd_generator_t rules need to move to proper places.

Quoted 5 lines

policy/modules/system/systemd.te allow systemd_logind_t systemd_sessions_ · line 643

Quoted 3 lines
policy/modules/system/systemd.te +0 -0
@@ -583,6 +642,8 @@ allow systemd_logind_t systemd_sessions_
    kernel_read_kernel_sysctls(systemd_logind_t)
  +auth_read_shadow(systemd_logind_t)

If this is necessary, it seems Debian specific.

This also happens on fedora (not sure why)

Quoted 11 lines

[...]

Quoted 9 lines
policy/modules/system/systemd.te +3 -0
@@ -925,14 +1001,26 @@ allow systemd_nspawn_t systemd_nspawn_tm
  # for /run/systemd/nspawn/incoming in chroot
  allow systemd_nspawn_t systemd_nspawn_runtime_t:dir mounton;
  +kernel_getattr_core_if(systemd_nspawn_t)
+kernel_getattr_proc(systemd_nspawn_t)
+kernel_getattr_unlabeled_dirs(systemd_nspawn_t)
+
  kernel_mount_proc(systemd_nspawn_t)
  kernel_mounton_sysctl_dirs(systemd_nspawn_t)
Quoted 8 lines

policy/modules/system/systemd.te allow systemd_nspawn_t systemd_nspawn_tm · line 1014

Quoted 5 lines
policy/modules/system/systemd.te +2 -0
  kernel_mounton_kernel_sysctl_files(systemd_nspawn_t)
  kernel_mounton_message_if(systemd_nspawn_t)
  kernel_mounton_proc(systemd_nspawn_t)
+kernel_mounton_sysctl_files(systemd_nspawn_t)
+kernel_mounton_unlabeled_dirs(systemd_nspawn_t)

With all of the mounting, perhaps we should consider coalescing on allowing it to mount an all init_mountpoint_types.

mounton unlabeled dirs indicates that something is unlabeled/mislabeled though. Wouldnt allow that.

Quoted 9 lines

[..]

policy/modules/system/systemd.te term_mount_devpts(systemd_nspawn_t) · line 1070

Quoted 5 lines
policy/modules/system/systemd.te +1 -0
@@ -972,6 +1067,7 @@ term_mount_devpts(systemd_nspawn_t)
  term_search_ptys(systemd_nspawn_t)
  term_setattr_generic_ptys(systemd_nspawn_t)
  term_use_ptmx(systemd_nspawn_t)
+term_use_generic_ptys(systemd_nspawn_t)

Perhaps this should have a pty type?

Agree

Quoted 12 lines

policy/modules/system/systemd.te seutil_libselinux_linked(systemd_user_se · line 1632

Quoted 9 lines
policy/modules/system/systemd.te +1 -0
@@ -1519,11 +1627,15 @@ seutil_libselinux_linked(systemd_user_se
  # systemd-user-runtime-dir local policy
  #
  -allow systemd_user_runtime_dir_t self:capability { fowner chown
 sys_admin dac_read_search dac_override };
+allow systemd_user_runtime_dir_t self:capability { chown
 dac_override dac_read_search dac_override fowner sys_admin mknod };

sys_admin and mknod? What is sys_admin used for; also, I don't see any rules for creating devices.

its probably old systemd stuff (fixed in more recent version): ie /run/user/UID/inaccessible/blk

should be able to ignore this

Quoted 47 lines
Quoted 35 lines
policy/modules/system/systemd.te +6 -0
  allow systemd_user_runtime_dir_t self:process setfscreate;
    domain_obj_id_change_exemption(systemd_user_runtime_dir_t)
  +allow systemd_user_runtime_dir_t systemd_user_runtime_t:dir
 manage_dir_perms;
+allow systemd_user_runtime_dir_t systemd_user_runtime_t:sock_file unlink;
+allow systemd_user_runtime_dir_t systemd_user_runtime_notify_t:sock_file unlink;
+
  files_read_etc_files(systemd_user_runtime_dir_t)
    fs_mount_tmpfs(systemd_user_runtime_dir_t)
@@ -1543,7 +1655,10 @@ seutil_read_file_contexts(systemd_user_r
  seutil_libselinux_linked(systemd_user_runtime_dir_t)
    userdom_delete_user_tmp_dirs(systemd_user_runtime_dir_t)
+userdom_delete_user_tmp_files(systemd_user_runtime_dir_t)
  userdom_delete_user_tmp_named_pipes(systemd_user_runtime_dir_t)
+userdom_delete_user_tmp_named_sockets(systemd_user_runtime_dir_t)
+userdom_list_user_tmp(systemd_user_runtime_dir_t)
  userdom_search_user_runtime_root(systemd_user_runtime_dir_t)
  userdom_user_runtime_root_filetrans_user_runtime(systemd_user_runtime_dir_t, dir)
  userdom_manage_user_runtime_dirs(systemd_user_runtime_dir_t)

Index: refpolicy-2.20210203/policy/modules/admin/dpkg.if
===================================================================

policy/modules/admin/dpkg.if +8 -0
@@ -356,3 +356,40 @@ interface(`dpkg_read_script_tmp_symlinks
    	allow $1 dpkg_script_tmp_t:lnk_file read_lnk_file_perms;
  ')
+
+########################################
+## <summary>
+##	send dbus messages to dpkg_t
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.

policy/modules/admin/dpkg.if interface(`dpkg_read_script_tmp_symlinks · line 375

Quoted 10 lines
policy/modules/admin/dpkg.if +10 -0
+##	</summary>
+## </param>
+#
+interface(`dpkg_dbus_chat',`
+	gen_require(`
+		type dpkg_t;
+	')
+
+	allow $1 dpkg_t:dbus send_msg;
+')

I'd prefer that the dbus chat interfaces are provided by the server process' domain.

Signature · 4 lines
gpg --locate-keys [email protected]
Key fingerprint = FCD2 3660 5D6B 9D27 7FC6  E0FF DA7E 521F 10F6 4098
https://sks-keyservers.net/pks/lookup?op=get&search=0xDA7E521F10F64098
Dominick Grift
#3 lore raw
Quoted 23 lines · Dominick Grift
Quoted 13 lines · Chris PeBenito
Quoted 12 lines · Russell Coker

Lots of littls changes related to systemd.

policy/modules/system/systemd.te +3 -0
@@ -925,14 +1001,26 @@ allow systemd_nspawn_t systemd_nspawn_tm
   # for /run/systemd/nspawn/incoming in chroot
   allow systemd_nspawn_t systemd_nspawn_runtime_t:dir mounton;
   +kernel_getattr_core_if(systemd_nspawn_t)
+kernel_getattr_proc(systemd_nspawn_t)
+kernel_getattr_unlabeled_dirs(systemd_nspawn_t)
+
   kernel_mount_proc(systemd_nspawn_t)
   kernel_mounton_sysctl_dirs(systemd_nspawn_t)
Quoted 8 lines

policy/modules/system/systemd.te allow systemd_nspawn_t systemd_nspawn_tm · line 1014

Quoted 5 lines
policy/modules/system/systemd.te +2 -0
   kernel_mounton_kernel_sysctl_files(systemd_nspawn_t)
   kernel_mounton_message_if(systemd_nspawn_t)
   kernel_mounton_proc(systemd_nspawn_t)
+kernel_mounton_sysctl_files(systemd_nspawn_t)
+kernel_mounton_unlabeled_dirs(systemd_nspawn_t)

With all of the mounting, perhaps we should consider coalescing on allowing it to mount an all init_mountpoint_types.

Quoted 2 lines

mounton unlabeled dirs indicates that something is unlabeled/mislabeled though. Wouldnt allow that.

Yes I agree. I noticed all the mountons but didn't notice this specific one.

Signature · 1 line
Chris PeBenito
#4 lore raw
Quoted 24 lines · Chris PeBenito
Quoted 23 lines · Dominick Grift
Quoted 21 lines · Chris PeBenito
Quoted 7 lines · Russell Coker

Lots of littls changes related to systemd.

policy/modules/system/systemd.te +0 -0
@@ -925,14 +1001,26 @@ allow systemd_nspawn_t systemd_nspawn_tm
    # for /run/systemd/nspawn/incoming in chroot
    allow systemd_nspawn_t systemd_nspawn_runtime_t:dir mounton;
    +kernel_getattr_core_if(systemd_nspawn_t)

policy/modules/system/systemd.te allow systemd_nspawn_t systemd_nspawn_tm · line 1013

Quoted 10 lines
policy/modules/system/systemd.te +5 -0
+kernel_getattr_proc(systemd_nspawn_t)
+kernel_getattr_unlabeled_dirs(systemd_nspawn_t)
+
    kernel_mount_proc(systemd_nspawn_t)
    kernel_mounton_sysctl_dirs(systemd_nspawn_t)
    kernel_mounton_kernel_sysctl_files(systemd_nspawn_t)
    kernel_mounton_message_if(systemd_nspawn_t)
    kernel_mounton_proc(systemd_nspawn_t)
+kernel_mounton_sysctl_files(systemd_nspawn_t)
+kernel_mounton_unlabeled_dirs(systemd_nspawn_t)

With all of the mounting, perhaps we should consider coalescing on allowing it to mount an all init_mountpoint_types.

Quoted 6 lines
Quoted 2 lines

mounton unlabeled dirs indicates that something is unlabeled/mislabeled though. Wouldnt allow that.

Yes I agree.  I noticed all the mountons but didn't notice this specific one.

I know how that goes, i probably "reviewed" this patch and overlooked this wrole wtuff ...

Quoted 1 line