diff --git a/policy/modules/admin/portage.fc b/policy/modules/admin/portage.fc index 5757deaaa7..b1b28f3ee5 100644 --- a/policy/modules/admin/portage.fc +++ b/policy/modules/admin/portage.fc @@ -28,6 +28,7 @@ /var/db/pkg(/.*)? gen_context(system_u:object_r:portage_db_t,s0) /var/db/repos(/.*)? gen_context(system_u:object_r:portage_ebuild_t,s0) /var/cache/binpkgs(/.*)? gen_context(system_u:object_r:portage_ebuild_t,s0) +/var/cache/distfiles(/.*)? gen_context(system_u:object_r:portage_ebuild_t,s0) /var/cache/distfiles/cvs-src(/.*)? gen_context(system_u:object_r:portage_srcrepo_t,s0) /var/cache/distfiles/egit-src(/.*)? gen_context(system_u:object_r:portage_srcrepo_t,s0) /var/cache/distfiles/git[0-9]-src(/.*)? gen_context(system_u:object_r:portage_srcrepo_t,s0) diff --git a/policy/modules/services/xserver.if b/policy/modules/services/xserver.if index baa39ef87f..d5d6c79144 100644 --- a/policy/modules/services/xserver.if +++ b/policy/modules/services/xserver.if @@ -95,6 +95,7 @@ interface(`xserver_restricted_role',` dev_rw_usbfs($2) miscfiles_read_fonts($2) + miscfiles_watch_fonts_dirs($2) xserver_common_x_domain_template(user, $2) #selint-disable:S-004 xserver_domtrans($2) @@ -186,10 +187,13 @@ interface(`xserver_role',` optional_policy(` xdg_manage_all_cache($2) xdg_relabel_all_cache($2) + xdg_watch_all_cache_dirs($2) xdg_manage_all_config($2) xdg_relabel_all_config($2) + xdg_watch_all_config_dirs($2) xdg_manage_all_data($2) xdg_relabel_all_data($2) + xdg_watch_all_data_dirs($2) xdg_generic_user_home_dir_filetrans_cache($2, dir, ".cache") xdg_generic_user_home_dir_filetrans_config($2, dir, ".config") @@ -203,14 +207,19 @@ interface(`xserver_role',` xdg_manage_documents($2) xdg_relabel_documents($2) + xdg_watch_documents_dirs($2) xdg_manage_downloads($2) xdg_relabel_downloads($2) + xdg_watch_downloads_dirs($2) xdg_manage_music($2) xdg_relabel_music($2) + xdg_watch_music_dirs($2) xdg_manage_pictures($2) xdg_relabel_pictures($2) + xdg_watch_pictures_dirs($2) xdg_manage_videos($2) xdg_relabel_videos($2) + xdg_watch_videos_dirs($2) xdg_cache_filetrans($2, mesa_shader_cache_t, dir, "mesa_shader_cache") ') @@ -508,7 +517,7 @@ interface(`xserver_use_user_fonts',` ') # Read per user fonts - allow $1 user_fonts_t:dir list_dir_perms; + allow $1 user_fonts_t:dir { list_dir_perms watch }; allow $1 user_fonts_t:file { map read_file_perms }; # Manipulate the global font cache diff --git a/policy/modules/system/getty.te b/policy/modules/system/getty.te index ce9e4dedba..f9514c7711 100644 --- a/policy/modules/system/getty.te +++ b/policy/modules/system/getty.te @@ -47,6 +47,7 @@ allow getty_t getty_log_t:file { append_file_perms create_file_perms setattr_fil logging_log_filetrans(getty_t, getty_log_t, file) allow getty_t getty_runtime_t:dir watch; +allow getty_t getty_runtime_t:file watch; manage_files_pattern(getty_t, getty_runtime_t, getty_runtime_t) files_runtime_filetrans(getty_t, getty_runtime_t, file) diff --git a/policy/modules/system/init.fc b/policy/modules/system/init.fc index eeeb32bea6..7e13fdc6ed 100644 --- a/policy/modules/system/init.fc +++ b/policy/modules/system/init.fc @@ -99,6 +99,8 @@ ifdef(`distro_gentoo',` # /sbin # /usr/sbin/openrc -- gen_context(system_u:object_r:rc_exec_t,s0) +/usr/sbin/openrc-init -- gen_context(system_u:object_r:init_exec_t,s0) +/usr/sbin/openrc-shutdown -- gen_context(system_u:object_r:init_exec_t,s0) # # /var diff --git a/policy/modules/system/init.te b/policy/modules/system/init.te index b52eaddb16..fe4f837063 100644 --- a/policy/modules/system/init.te +++ b/policy/modules/system/init.te @@ -120,6 +120,7 @@ init_unit_file(systemd_unit_t) ifdef(`distro_gentoo',` type rc_exec_t; domain_entry_file(initrc_t, rc_exec_t) + domtrans_pattern(init_t, rc_exec_t, initrc_t) ') ifdef(`enable_mls',` @@ -755,6 +756,7 @@ fs_unmount_all_fs(initrc_t) fs_remount_all_fs(initrc_t) fs_getattr_all_fs(initrc_t) fs_search_all(initrc_t) +fs_search_all(initrc_state_t) fs_getattr_nfsd_files(initrc_t) # initrc_t needs to do a pidof which requires ptrace diff --git a/policy/modules/system/miscfiles.if b/policy/modules/system/miscfiles.if index a0b13261f1..751b3579d3 100644 --- a/policy/modules/system/miscfiles.if +++ b/policy/modules/system/miscfiles.if @@ -854,6 +854,24 @@ interface(`miscfiles_manage_public_files',` manage_lnk_files_pattern($1, public_content_rw_t, public_content_rw_t) ') +######################################## +## +## Watch public files +## +## +## +## Domain allowed access. +## +## +# +interface(`miscfiles_watch_public_dirs',` + gen_require(` + type public_content_rw_t; + ') + + allow $1 public_content_rw_t:dir watch; +') + ######################################## ## ## Read TeX data diff --git a/policy/modules/system/systemd.te b/policy/modules/system/systemd.te index 74f3fc55df..a08b83d516 100644 --- a/policy/modules/system/systemd.te +++ b/policy/modules/system/systemd.te @@ -1450,4 +1450,6 @@ userdom_manage_user_runtime_dirs(systemd_user_runtime_dir_t) userdom_mounton_user_runtime_dirs(systemd_user_runtime_dir_t) userdom_relabelto_user_runtime_dirs(systemd_user_runtime_dir_t) -dbus_system_bus_client(systemd_user_runtime_dir_t) +optional_policy(` + dbus_system_bus_client(systemd_user_runtime_dir_t) +') diff --git a/policy/modules/system/userdomain.if b/policy/modules/system/userdomain.if index b7fe1a79cb..7ce340dcff 100644 --- a/policy/modules/system/userdomain.if +++ b/policy/modules/system/userdomain.if @@ -289,6 +289,12 @@ interface(`userdom_ro_home_role',` read_sock_files_pattern($2, { user_home_t user_home_dir_t }, user_home_t) files_list_home($2) + allow $2 { user_home_t user_home_dir_t }:dir { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:lnk_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:sock_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:fifo_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + tunable_policy(`use_nfs_home_dirs',` fs_list_nfs($2) fs_read_nfs_files($2) @@ -368,7 +374,11 @@ interface(`userdom_manage_home_role',` # cjp: this should probably be removed: allow $2 user_home_dir_t:dir { manage_dir_perms relabel_dir_perms }; - allow $2 user_home_dir_t:dir watch; + allow $2 { user_home_t user_home_dir_t }:dir { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:lnk_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:sock_file { watch watch_mount watch_sb watch_with_perm watch_reads }; + allow $2 user_home_t:fifo_file { watch watch_mount watch_sb watch_with_perm watch_reads }; userdom_manage_user_certs($2) userdom_user_home_dir_filetrans($2, user_cert_t, dir, ".pki") @@ -631,6 +641,8 @@ template(`userdom_common_user_template',` files_read_var_lib_files($1_t) # Stat lost+found. files_getattr_lost_found_dirs($1_t) + files_watch_etc_dirs($1_t) + files_watch_usr_dirs($1_t) fs_rw_cgroup_files($1_t) @@ -1183,6 +1195,7 @@ template(`userdom_unpriv_user_template', ` files_exec_usr_files($1_t) miscfiles_manage_public_files($1_t) + miscfiles_watch_public_dirs($1_t) tunable_policy(`user_dmesg',` kernel_read_ring_buffer($1_t) diff --git a/policy/modules/system/xdg.if b/policy/modules/system/xdg.if index e94d672067..b7620384ae 100644 --- a/policy/modules/system/xdg.if +++ b/policy/modules/system/xdg.if @@ -83,6 +83,42 @@ interface(`xdg_search_cache_dirs',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg cache home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_cache_dirs',` + gen_require(` + type xdg_cache_t; + ') + + allow $1 xdg_cache_t:dir watch; +') + +######################################## +## +## Watch all the xdg cache home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_all_cache_dirs',` + gen_require(` + attribute xdg_cache_type; + ') + + allow $1 xdg_cache_type:dir watch; +') + ######################################## ## ## Read the xdg cache home files @@ -333,6 +369,42 @@ interface(`xdg_search_config_dirs',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg config home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_config_dirs',` + gen_require(` + type xdg_config_t; + ') + + allow $1 xdg_config_t:dir watch; +') + +######################################## +## +## Watch all the xdg config home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_all_config_dirs',` + gen_require(` + attribute xdg_config_type; + ') + + allow $1 xdg_config_type:dir watch; +') + ######################################## ## ## Read the xdg config home files @@ -563,6 +635,42 @@ interface(`xdg_relabel_all_config',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg data home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_data_dirs',` + gen_require(` + type xdg_data_t; + ') + + allow $1 xdg_data_t:dir watch; +') + +######################################## +## +## Watch all the xdg data home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_all_data_dirs',` + gen_require(` + attribute xdg_data_type; + ') + + allow $1 xdg_data_type:dir watch; +') + ######################################## ## ## Read the xdg data home files @@ -793,6 +901,24 @@ interface(`xdg_relabel_all_data',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg documents home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_documents_dirs',` + gen_require(` + type xdg_documents_t; + ') + + allow $1 xdg_documents_t:dir watch; +') + ######################################## ## ## Create objects in the user home dir with an automatic type transition to @@ -865,6 +991,24 @@ interface(`xdg_relabel_documents',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg downloads home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_downloads_dirs',` + gen_require(` + type xdg_downloads_t; + ') + + allow $1 xdg_downloads_t:dir watch; +') + ######################################### ## ## Read downloaded content @@ -1006,6 +1150,24 @@ interface(`xdg_relabel_downloads',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg pictures home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_pictures_dirs',` + gen_require(` + type xdg_pictures_t; + ') + + allow $1 xdg_pictures_t:dir watch; +') + ######################################### ## ## Read user pictures content @@ -1101,6 +1263,24 @@ interface(`xdg_relabel_pictures',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg music home directories +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_music_dirs',` + gen_require(` + type xdg_music_t; + ') + + allow $1 xdg_music_t:dir watch; +') + ######################################### ## ## Read user music content @@ -1196,6 +1376,24 @@ interface(`xdg_relabel_music',` userdom_search_user_home_dirs($1) ') +######################################## +## +## Watch the xdg video content +## +## +## +## Domain allowed access. +## +## +# +interface(`xdg_watch_videos_dirs',` + gen_require(` + type xdg_videos_t; + ') + + allow $1 xdg_videos_t:dir watch; +') + ######################################### ## ## Read user video content