another systemd misc patch
PATCH 1/1 another systemd misc patch
Here's the latest version of this patch with the previous issues addressed.
policy/modules/system/systemd.if +102 -0
@@ -102,6 +102,8 @@ template(`systemd_role_template',` seutil_search_default_contexts($1_systemd_t) seutil_read_file_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;
@@ -169,6 +171,10 @@ template(`systemd_role_template',` systemd_watch_passwd_runtime_dirs($3) optional_policy(` + dirmngr_tmp_dir_search($1_systemd_t) + ') + + optional_policy(` xdg_config_filetrans($1_systemd_t, systemd_conf_home_t, dir, "systemd") xdg_data_filetrans($1_systemd_t, systemd_data_home_t, dir, "systemd") xdg_read_config_files($1_systemd_t)
@@ -791,6 +797,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_dirs',` + gen_require(` + type systemd_logind_runtime_t; + ') + + allow $1 systemd_logind_runtime_t:dir watch; +') + +###################################### +## <summary> ## Use inherited systemd ## logind file descriptors. ## </summary>
@@ -851,6 +875,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_dirs',` + 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">
@@ -1023,6 +1065,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_dirs',` + 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>
@@ -1911,3 +1971,45 @@ interface(`systemd_use_inherited_machine allow $1 systemd_machined_t:fd use; allow $1 systemd_machined_devpts_t:chr_file rw_inherited_term_perms; ') + +######################################## +## <summary> +## run systemd-nspawn in systemd_nspawn_t domain +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +## <param name="role"> +## <summary> +## The role of the object to create. +## </summary> +## </param> +# +interface(`systemd_run_nspawn', ` + gen_require(` + type systemd_nspawn_t, systemd_nspawn_exec_t; + ') + + role $2 types systemd_nspawn_t; + domtrans_pattern($1, systemd_nspawn_exec_t, systemd_nspawn_t) +') + +######################################## +## <summary> +## send datagrams to systemd_nspawn_t +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`systemd_dgram_nspawn', ` + gen_require(` + type systemd_nspawn_t, systemd_nspawn_var_run_t; + ') + + dgram_send_pattern($1, systemd_nspawn_var_run_t, systemd_nspawn_var_run_t, systemd_nspawn_t) +')
policy/modules/system/systemd.te +148 -16
433 lines not on this page · raw message
policy/modules/admin/dpkg.if +37 -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. +## </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 +4 -0
@@ -99,6 +99,10 @@ ifdef(`init_systemd',` # LookupDynamicUserByUID on org.freedesktop.systemd1. init_dbus_chat(sysadm_t) + systemd_run_nspawn(sysadm_t, sysadm_r) + systemd_run_passwd_agent(sysadm_t, sysadm_r) + + # Allow sysadm to get the status of and set properties of other users, # sessions, and seats on the system. systemd_dbus_chat_logind(sysadm_t)
policy/modules/services/networkmanager.te +3 -0
@@ -332,6 +332,9 @@ optional_policy(` optional_policy(` systemd_read_logind_runtime_files(NetworkManager_t) systemd_read_logind_sessions_files(NetworkManager_t) + systemd_watch_logind_runtime_dirs(NetworkManager_t) + systemd_watch_logind_sessions_dirs(NetworkManager_t) + systemd_watch_machines_dirs(NetworkManager_t) systemd_write_inherited_logind_inhibit_pipes(NetworkManager_t) ')
policy/modules/services/policykit.te +3 -0
@@ -134,12 +134,15 @@ optional_policy(` optional_policy(` # for /run/systemd/machines systemd_read_machines(policykit_t) + systemd_watch_machines_dirs(policykit_t) # for /run/systemd/seats/seat* systemd_read_logind_sessions_files(policykit_t) + systemd_watch_logind_sessions_dirs(policykit_t) # for /run/systemd/users/* systemd_read_logind_runtime_files(policykit_t) + systemd_watch_logind_runtime_dirs(policykit_t) ') ########################################
policy/modules/services/devicekit.te +6 -0
@@ -195,6 +195,12 @@ optional_policy(` ') optional_policy(` + systemd_read_logind_sessions_files(devicekit_disk_t) + systemd_use_logind_fds(devicekit_disk_t) + systemd_write_inherited_logind_inhibit_pipes(devicekit_disk_t) +') + +optional_policy(` udev_domtrans_udevadm(devicekit_disk_t) udev_read_runtime_files(devicekit_disk_t) ')
policy/modules/services/ssh.te +1 -0
@@ -270,6 +270,7 @@ ifdef(`init_systemd',` auth_use_pam_systemd(sshd_t) init_dbus_chat(sshd_t) init_rw_stream_sockets(sshd_t) + systemd_dgram_nspawn(sshd_t) systemd_write_inherited_logind_sessions_pipes(sshd_t) ')
policy/modules/apps/gpg.if +18 -0
@@ -274,6 +274,24 @@ interface(`gpg_agent_tmp_filetrans',` ######################################## ## <summary> +## unlink gpg_agent_tmp_t sock_file +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`gpg_agent_tmp_unlink_sock',` + gen_require(` + type gpg_agent_tmp_t; + ') + + allow $1 gpg_agent_tmp_t:sock_file unlink; +') + +######################################## +## <summary> ## filetrans in gpg_runtime_t dirs ## </summary> ## <param name="domain">
policy/modules/services/dirmngr.if +36 -0
@@ -34,6 +34,24 @@ interface(`dirmngr_role',` allow $2 dirmngr_tmp_t:sock_file { manage_sock_file_perms relabel_sock_file_perms }; ') +############################################################ +## <summary> +## unlink dirmngr_tmp_t sock_file +## </summary> +## <param name="domain"> +## <summary> +## domain allowed access +## </summary> +## </param> +# +interface(`dirmngr_unlink_tmp_sock',` + gen_require(` + type dirmngr_tmp_t; + ') + + allow $1 dirmngr_tmp_t:sock_file unlink; +') + ######################################## ## <summary> ## Execute dirmngr in the dirmngr domain.
@@ -95,6 +113,24 @@ interface(`dirmngr_stream_connect',` ') ######################################## +## <summary> +## Search dirmngr_tmp_t dirs +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`dirmngr_tmp_dir_search',` + gen_require(` + type dirmngr_tmp_t; + ') + + allow $1 dirmngr_tmp_t:dir search_dir_perms; +') + +######################################## ## <summary> ## All of the rules required to ## administrate an dirmngr environment.
policy/modules/system/logging.te +1 -0
@@ -555,6 +555,7 @@ ifdef(`init_systemd',` logging_send_syslog_msg(syslogd_t) systemd_manage_journal_files(syslogd_t) + systemd_search_user_runtime(syslogd_t) udev_read_runtime_files(syslogd_t)
policy/modules/services/colord.if +19 -0
@@ -58,3 +58,22 @@ interface(`colord_read_lib_files',` files_search_var_lib($1) read_files_pattern($1, colord_var_lib_t, colord_var_lib_t) ') + +###################################### +## <summary> +## relabel colord lib files and dirs. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`colord_relabel_lib',` + gen_require(` + type colord_var_lib_t; + ') + + allow $1 colord_var_lib_t:dir { list_dir_perms relabelfrom relabelto }; + allow $1 colord_var_lib_t:file { relabelfrom relabelto }; +')
policy/modules/system/userdomain.if +19 -0
@@ -4539,6 +4539,25 @@ interface(`userdom_dontaudit_write_user_ ######################################## ## <summary> +## Delete user_tmp_t device nodes (probably should not have been +## created in the first place) +## </summary> +## <param name="domain"> +## <summary> +## Domain to allow deleting +## </summary> +## </param> +# +interface(`userdom_unlink_user_tmp_devices',` + gen_require(` + type user_tmp_t; + ') + + allow $1 user_tmp_t:{ chr_file blk_file } unlink; +') + +######################################## +## <summary> ## Do not audit attempts to use user ttys. ## </summary> ## <param name="domain">
Quoted 26 lines · Russell Coker
Here's the latest version of this patch with the previous issues addressed.
Signed-off-by Russell Coker <[email protected]>Index: refpolicy-2.20210908/policy/modules/system/systemd.if
===================================================================policy/modules/system/systemd.if +14
-0@@ -1911,3 +1971,45 @@ interface(`systemd_use_inherited_machine allow $1 systemd_machined_t:fd use; allow $1 systemd_machined_devpts_t:chr_file rw_inherited_term_perms; ') + +######################################## +## <summary> +## run systemd-nspawn in systemd_nspawn_t domain +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +## <param name="role"> +## <summary> +## The role of the object to create. +## </summary>
policy/modules/system/systemd.if interface(`systemd_use_inherited_machine · line 1997
Quoted 10 lines
policy/modules/system/systemd.if +10
-0+## </param> +# +interface(`systemd_run_nspawn', ` + gen_require(` + type systemd_nspawn_t, systemd_nspawn_exec_t; + ') + + role $2 types systemd_nspawn_t; + domtrans_pattern($1, systemd_nspawn_exec_t, systemd_nspawn_t) +')
What is the use case? I see it later in the patch run by sysadm_t, but I don't understand why sysadm would run it directly, instead of using the systemctl.
policy/modules/system/systemd.te logging_send_syslog_msg(systemd_coredump · line 451
Quoted 12 lines
Index: refpolicy-2.20210908/policy/modules/system/systemd.te
===================================================================policy/modules/system/systemd.te +1
-0@@ -427,6 +445,7 @@ logging_send_syslog_msg(systemd_coredump seutil_search_default_contexts(systemd_coredump_t) + ####################################### # # Systemd generator local policy
Please remove the extra endline.
policy/modules/system/systemd.te allow systemd_generator_t self:fifo_file · line 459
Quoted 6 lines
policy/modules/system/systemd.te +2
-0@@ -436,26 +455,44 @@ allow systemd_generator_t self:fifo_file allow systemd_generator_t self:capability dac_override; allow systemd_generator_t self:process setfscreate; +allow systemd_generator_t self:tcp_socket create; +allow systemd_generator_t self:udp_socket create;
Create sockets but do nothing with them? i.e. read/write/ioctl
Quoted 13 lines
policy/modules/system/systemd.te +10
-0+allow systemd_generator_t self:netlink_route_socket { create read bind getattr write nlmsg_read }; + allow systemd_generator_t systemd_unit_t:file getattr; +kernel_dontaudit_getattr_proc(systemd_generator_t) +kernel_read_kernel_sysctls(systemd_generator_t) +kernel_read_network_state(systemd_generator_t) +kernel_read_system_state(systemd_generator_t) +kernel_search_network_sysctl(systemd_generator_t) +kernel_use_fds(systemd_generator_t) + +corecmd_exec_bin(systemd_generator_t) corecmd_exec_shell(systemd_generator_t)
policy/modules/system/systemd.te allow systemd_generator_t self:fifo_file · line 480
Quoted 10 lines
policy/modules/system/systemd.te +3
-2-corecmd_getattr_bin_files(systemd_generator_t) dev_read_sysfs(systemd_generator_t) +dev_read_urand(systemd_generator_t) dev_write_kmsg(systemd_generator_t) dev_write_sysfs_dirs(systemd_generator_t) -files_read_etc_files(systemd_generator_t) +application_exec(systemd_generator_t) +domain_read_all_entry_files(systemd_generator_t)
These last two could use blank lines for separation.
[...]
policy/modules/system/systemd.te allow systemd_nspawn_t systemd_nspawn_tm · line 1051
Quoted 6 lines
policy/modules/system/systemd.te +2
-0@@ -974,14 +1047,29 @@ allow systemd_nspawn_t systemd_nspawn_tm # for /run/systemd/nspawn/incoming in chroot allow systemd_nspawn_t systemd_nspawn_runtime_t:dir mounton; +term_create_pty(systemd_nspawn_t, systemd_nspawn_devpts_t) +allow systemd_nspawn_t systemd_nspawn_devpts_t:chr_file manage_chr_file_perms;
Please move these up after the self block of rules.
Quoted 10 lines
policy/modules/system/systemd.te +5
-0+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) 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)
policy/modules/system/systemd.te allow systemd_nspawn_t systemd_nspawn_tm · line 1072
Quoted 10 lines
policy/modules/system/systemd.te +7
-0+kernel_mounton_unlabeled_dirs(systemd_nspawn_t) + +kernel_read_irq_sysctls(systemd_nspawn_t) +kernel_read_network_state(systemd_nspawn_t) kernel_read_kernel_sysctls(systemd_nspawn_t) +kernel_read_sysctl(systemd_nspawn_t) kernel_read_system_state(systemd_nspawn_t) kernel_remount_proc(systemd_nspawn_t) +kernel_request_load_module(systemd_nspawn_t) +kernel_search_network_sysctl(systemd_nspawn_t)
Please remove the extra newlines.
Quoted 39 lines
policy/modules/system/systemd.te +9
-1corecmd_exec_shell(systemd_nspawn_t) corecmd_search_bin(systemd_nspawn_t)@@ -998,6 +1086,7 @@ dev_read_sysfs(systemd_nspawn_t) dev_read_rand(systemd_nspawn_t) dev_read_urand(systemd_nspawn_t) +files_getattr_default_dirs(systemd_nspawn_t) files_getattr_tmp_dirs(systemd_nspawn_t) files_manage_etc_files(systemd_nspawn_t) files_manage_mnt_dirs(systemd_nspawn_t)@@ -1009,11 +1098,17 @@ files_setattr_runtime_dirs(systemd_nspaw fs_getattr_cgroup(systemd_nspawn_t) fs_getattr_tmpfs(systemd_nspawn_t) +fs_getattr_xattr_fs(systemd_nspawn_t) +fs_manage_cgroup_dirs(systemd_nspawn_t) +fs_manage_cgroup_files(systemd_nspawn_t) +fs_manage_tmpfs_blk_files(systemd_nspawn_t) fs_manage_tmpfs_chr_files(systemd_nspawn_t) +fs_mount_cgroup(systemd_nspawn_t) fs_mount_tmpfs(systemd_nspawn_t) +fs_mounton_cgroup(systemd_nspawn_t) +fs_read_nsfs_files(systemd_nspawn_t) fs_remount_tmpfs(systemd_nspawn_t) fs_remount_xattr_fs(systemd_nspawn_t) -fs_read_cgroup_files(systemd_nspawn_t) term_getattr_generic_ptys(systemd_nspawn_t) term_getattr_pty_fs(systemd_nspawn_t)@@ -1021,6 +1116,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) init_domtrans_script(systemd_nspawn_t) init_getrlimit(systemd_nspawn_t)@@ -1031,8 +1127,12 @@ init_write_runtime_socket(systemd_nspawn init_spec_domtrans_script(systemd_nspawn_t)
policy/modules/system/systemd.te init_write_runtime_socket(systemd_nspawn · line 1137
Quoted 10 lines
policy/modules/system/systemd.te +4
-0miscfiles_manage_localization(systemd_nspawn_t) +mount_exec(systemd_nspawn_t) + udev_read_runtime_files(systemd_nspawn_t) +sysnet_exec_ifconfig(systemd_nspawn_t) + # for writing inside chroot sysnet_manage_config(systemd_nspawn_t)
With all the mountons, it seems to make sense to switch it to mount on init_mountpoint_type. See init.te:262, which is what we have for systemd.
[...]
policy/modules/system/systemd.te tunable_policy(`systemd_tmpfilesd_factor · line 1604
Quoted 7 lines
policy/modules/system/systemd.te +3
-0@@ -1491,6 +1599,11 @@ tunable_policy(`systemd_tmpfilesd_factor ') optional_policy(` + colord_read_lib_files(systemd_tmpfiles_t) + colord_relabel_lib(systemd_tmpfiles_t) +')
Instead of new interfaces and calling here, you should add systemd_tmpfilesd_managed(colord_var_lib_t) in colord.te.
policy/modules/services/ssh.te ifdef(`init_systemd',` · line 275
Quoted 11 lines
Index: refpolicy-2.20210908/policy/modules/services/ssh.te
===================================================================policy/modules/services/ssh.te +1
-0@@ -270,6 +270,7 @@ ifdef(`init_systemd',` auth_use_pam_systemd(sshd_t) init_dbus_chat(sshd_t) init_rw_stream_sockets(sshd_t) + systemd_dgram_nspawn(sshd_t) systemd_write_inherited_logind_sessions_pipes(sshd_t) ')
Is this sshd running inside a namespace started by nspawn?
Signature · 1 line
Chris PeBenito