Skip to contentSkip to conversation

This patch removes use of auth*files_except_auth_files in order to shrink size of policy.

refpolicy Daniel J Walsh 2 participants 2 messages Aug 26, 2011 – Sep 9, 2011

lore
Share & tools
lore
#1 lore raw
Quoted 351 lines · Daniel J Walsh
policy/modules/admin/dpkg.te +3 -3
index 633d2fc..8d62407 100644
@@ -140,8 +140,8 @@ storage_raw_write_fixed_disk(dpkg_t)
 # for installing kernel packages
 storage_raw_read_fixed_disk(dpkg_t)
 
-auth_relabel_all_files_except_auth_files(dpkg_t)
-auth_manage_all_files_except_auth_files(dpkg_t)
+files_relabel_non_security_files(dpkg_t)
+files_manage_non_security_files(dpkg_t)
 auth_dontaudit_read_shadow(dpkg_t)
 
 files_exec_etc_files(dpkg_t)
@@ -286,7 +286,7 @@ term_use_all_terms(dpkg_script_t)
 
 auth_dontaudit_getattr_shadow(dpkg_script_t)
 # ideally we would not need this
-auth_manage_all_files_except_auth_files(dpkg_script_t)
+files_manage_non_security_files(dpkg_script_t)
 
 init_domtrans_script(dpkg_script_t)
 init_use_script_fds(dpkg_script_t)
policy/modules/admin/rpm.te +4 -4
index 7d964bf..ba6e400 100644
@@ -154,8 +154,8 @@ storage_raw_read_fixed_disk(rpm_t)
 
 term_list_ptys(rpm_t)
 
-auth_relabel_all_files_except_auth_files(rpm_t)
-auth_manage_all_files_except_auth_files(rpm_t)
+files_relabel_all_files(rpm_t)
+files_manage_all_files(rpm_t)
 auth_dontaudit_read_shadow(rpm_t)
 auth_use_nsswitch(rpm_t)
 
@@ -304,8 +304,8 @@ term_use_all_terms(rpm_script_t)
 auth_dontaudit_getattr_shadow(rpm_script_t)
 auth_use_nsswitch(rpm_script_t)
 # ideally we would not need this
-auth_manage_all_files_except_auth_files(rpm_script_t)
-auth_relabel_shadow(rpm_script_t)
+files_manage_all_files(rpm_script_t)
+files_relabel_all_files(rpm_script_t)
 
 corecmd_exec_all_executables(rpm_script_t)
 
policy/modules/admin/sosreport.te +1 -1
index ebaff2f..de6b197 100644
@@ -80,7 +80,7 @@ fs_list_inotifyfs(sosreport_t)
 
 # some config files do not have configfile attribute
 # sosreport needs to read various files on system
-auth_read_all_files_except_auth_files(sosreport_t)
+files_read_non_security_files(sosreport_t)
 auth_use_nsswitch(sosreport_t)
 
 init_domtrans_script(sosreport_t)
policy/modules/admin/sxid.te +1 -1
index 045fb86..a51a92d 100644
@@ -66,7 +66,7 @@ fs_list_all(sxid_t)
 
 term_dontaudit_use_console(sxid_t)
 
-auth_read_all_files_except_auth_files(sxid_t)
+files_read_non_security_files(sxid_t)
 auth_dontaudit_getattr_shadow(sxid_t)
 
 init_use_fds(sxid_t)
policy/modules/kernel/files.if +56 -5
index deb24b4..225c263 100644
@@ -663,12 +663,63 @@ interface(`files_read_non_security_files',`
 		attribute non_security_file_type;
 	')
 
+	list_dirs_pattern($1, non_security_file_type, non_security_file_type)
 	read_files_pattern($1, non_security_file_type, non_security_file_type)
 	read_lnk_files_pattern($1, non_security_file_type, non_security_file_type)
 ')
 
 ########################################
 ## <summary>
+##	Manage all non-security files.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`files_manage_non_security_files',`
+	gen_require(`
+		attribute non_security_file_type;
+	')
+
+	manage_files_pattern($1, non_security_file_type, non_security_file_type)
+	manage_lnk_files_pattern($1, non_security_file_type, non_security_file_type)
+')
+
+########################################
+## <summary>
+##	Relabel all non-security files.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`files_relabel_non_security_files',`
+	gen_require(`
+		attribute non_security_file_type;
+	')
+
+	relabel_files_pattern($1, non_security_file_type, non_security_file_type)
+	allow $1 { non_security_file_type }:dir list_dir_perms;
+	relabel_dirs_pattern($1, { non_security_file_type }, { non_security_file_type })
+	relabel_files_pattern($1, { non_security_file_type }, { non_security_file_type })
+	relabel_lnk_files_pattern($1, { non_security_file_type }, { non_security_file_type })
+	relabel_fifo_files_pattern($1, { non_security_file_type }, { non_security_file_type })
+	relabel_sock_files_pattern($1, { non_security_file_type }, { non_security_file_type })
+	relabel_blk_files_pattern($1, { non_security_file_type }, { non_security_file_type })
+	relabel_chr_files_pattern($1, { non_security_file_type }, { non_security_file_type })
+
+	# satisfy the assertions:
+	seutil_relabelto_bin_policy($1)
+')
+
+########################################
+## <summary>
 ##	Read all directories on the filesystem, except
 ##	the listed exceptions.
 ## </summary>
@@ -2451,7 +2502,7 @@ interface(`files_read_etc_files',`
 ## </summary>
 ## <param name="domain">
 ##	<summary>
-##	Domain allowed access.
+##	Domain to not audit.
 ##	</summary>
 ## </param>
 #
@@ -3945,7 +3996,7 @@ interface(`files_getattr_tmp_dirs',`
 ## </summary>
 ## <param name="domain">
 ##	<summary>
-##	Domain allowed access.
+##	Domain to not audit.
 ##	</summary>
 ## </param>
 #
@@ -4017,7 +4068,7 @@ interface(`files_list_tmp',`
 ## </summary>
 ## <param name="domain">
 ##	<summary>
-##	Domain not to audit.
+##	Domain to not audit.
 ##	</summary>
 ## </param>
 #
@@ -4202,7 +4253,7 @@ interface(`files_relabel_all_tmp_dirs',`
 ## </summary>
 ## <param name="domain">
 ##	<summary>
-##	Domain not to audit.
+##	Domain to not audit.
 ##	</summary>
 ## </param>
 #
@@ -4262,7 +4313,7 @@ interface(`files_relabel_all_tmp_files',`
 ## </summary>
 ## <param name="domain">
 ##	<summary>
-##	Domain not to audit.
+##	Domain to not audit.
 ##	</summary>
 ## </param>
 #
policy/modules/kernel/kernel.te +2 -2
index eac9961..797f131 100644
@@ -336,7 +336,7 @@ optional_policy(`
 		fs_read_noxattr_fs_symlinks(kernel_t)
 
 		auth_read_all_dirs_except_auth_files(kernel_t)
-		auth_read_all_files_except_auth_files(kernel_t)
+		files_read_non_security_files(kernel_t)
 		auth_read_all_symlinks_except_auth_files(kernel_t)
 	')
 
@@ -346,7 +346,7 @@ optional_policy(`
 		fs_read_noxattr_fs_files(kernel_t)
 		fs_read_noxattr_fs_symlinks(kernel_t)
 
-		auth_manage_all_files_except_auth_files(kernel_t)
+		files_manage_non_security_files(kernel_t)
 	')
 ')
 
policy/modules/roles/secadm.te +1 -1
index 89ddeaa..4b5119b 100644
@@ -30,7 +30,7 @@ mls_file_upgrade(secadm_t)
 mls_file_downgrade(secadm_t)
 
 auth_role(secadm_r, secadm_t)
-auth_relabel_all_files_except_auth_files(secadm_t)
+files_relabel_non_security_files(secadm_t)
 auth_relabel_shadow(secadm_t)
 
 init_exec(secadm_t)
policy/modules/services/ftp.te +2 -2
index 02ffdfb..69c2d2c 100644
@@ -261,7 +261,7 @@ tunable_policy(`allow_ftpd_use_nfs && allow_ftpd_anon_write',`
 
 tunable_policy(`allow_ftpd_full_access',`
 	allow ftpd_t self:capability { dac_override dac_read_search };
-	auth_manage_all_files_except_auth_files(ftpd_t)
+	files_manage_non_security_files(ftpd_t)
 ')
 
 tunable_policy(`ftp_home_dir',`
@@ -394,7 +394,7 @@ tunable_policy(`sftpd_enable_homedirs && use_samba_home_dirs',`
 tunable_policy(`sftpd_full_access',`
 	allow sftpd_t self:capability { dac_override dac_read_search };
 	fs_read_noxattr_fs_files(sftpd_t)
-	auth_manage_all_files_except_auth_files(sftpd_t)
+	files_manage_non_security_files(sftpd_t)
 ')
 
 tunable_policy(`use_samba_home_dirs',`
policy/modules/services/puppet.te +1 -1
index 941f6e1..68985da 100644
@@ -134,7 +134,7 @@ sysnet_dns_name_resolve(puppet_t)
 sysnet_run_ifconfig(puppet_t, system_r)
 
 tunable_policy(`puppet_manage_all_files',`
-	auth_manage_all_files_except_auth_files(puppet_t)
+	files_manage_non_security_files(puppet_t)
 ')
 
 optional_policy(`
policy/modules/services/rgmanager.te +1 -1
index c537000..52ec13b 100644
@@ -92,7 +92,7 @@ term_getattr_pty_fs(rgmanager_t)
 #term_use_ptmx(rgmanager_t)
 
 # needed by resources scripts
-auth_read_all_files_except_auth_files(rgmanager_t)
+files_read_non_security_files(rgmanager_t)
 auth_dontaudit_getattr_shadow(rgmanager_t)
 auth_use_nsswitch(rgmanager_t)
 
policy/modules/services/rpc.te +2 -2
index 62fca97..6c6d18b 100644
@@ -158,7 +158,7 @@ tunable_policy(`nfs_export_all_rw',`
 	dev_getattr_all_chr_files(nfsd_t)
 
 	fs_read_noxattr_fs_files(nfsd_t)
-	auth_manage_all_files_except_auth_files(nfsd_t)
+	files_manage_non_security_files(nfsd_t)
 ')
 
 tunable_policy(`nfs_export_all_ro',`
@@ -171,7 +171,7 @@ tunable_policy(`nfs_export_all_ro',`
 	fs_read_noxattr_fs_files(nfsd_t)
 
 	auth_read_all_dirs_except_auth_files(nfsd_t)
-	auth_read_all_files_except_auth_files(nfsd_t)
+	files_read_non_security_files(nfsd_t)
 ')
 
 ########################################
policy/modules/services/rsync.te +1 -1
index 1c381e1..51cedbd 100644
@@ -126,7 +126,7 @@ tunable_policy(`rsync_export_all_ro',`
 	fs_read_nfs_files(rsync_t)
 	fs_read_cifs_files(rsync_t)
 	auth_read_all_dirs_except_auth_files(rsync_t)
-	auth_read_all_files_except_auth_files(rsync_t)
+	files_read_non_security_files(rsync_t)
 	auth_read_all_symlinks_except_auth_files(rsync_t)
 	auth_tunable_read_shadow(rsync_t)
 ')
policy/modules/services/samba.te +4 -4
index df830cf..d1f1a15 100644
@@ -451,17 +451,17 @@ tunable_policy(`samba_create_home_dirs',`
 tunable_policy(`samba_export_all_ro',`
 	fs_read_noxattr_fs_files(smbd_t) 
 	auth_read_all_dirs_except_auth_files(smbd_t)
-	auth_read_all_files_except_auth_files(smbd_t)
+	files_read_non_security_files(smbd_t)
 	fs_read_noxattr_fs_files(nmbd_t) 
 	auth_read_all_dirs_except_auth_files(nmbd_t)
-	auth_read_all_files_except_auth_files(nmbd_t)
+	files_read_non_security_files(nmbd_t)
 ')
 
 tunable_policy(`samba_export_all_rw',`
 	fs_read_noxattr_fs_files(smbd_t) 
-	auth_manage_all_files_except_auth_files(smbd_t)
+	files_manage_non_security_files(smbd_t)
 	fs_read_noxattr_fs_files(nmbd_t) 
-	auth_manage_all_files_except_auth_files(nmbd_t)
+	files_manage_non_security_files(nmbd_t)
 	userdom_user_home_dir_filetrans_user_home_content(nmbd_t, { file dir })
 ')
 
policy/modules/system/mount.te +1 -1
index 94e49e8..fd331b9 100644
@@ -143,7 +143,7 @@ ifdef(`distro_ubuntu',`
 
 tunable_policy(`allow_mount_anyfile',`
 	auth_read_all_dirs_except_auth_files(mount_t)
-	auth_read_all_files_except_auth_files(mount_t)
+	files_read_non_security_files(mount_t)
 	files_mounton_non_security(mount_t)
 ')
 
policy/modules/system/selinuxutil.te +0 -0
index 508b206..52a5442 100644

policy/modules/system/selinuxutil.te selinux_compute_create_context(restorecond_t) · line 334

Quoted 10 lines
policy/modules/system/selinuxutil.te +2 -2
@@ -327,8 +327,8 @@ selinux_compute_create_context(restorecond_t)
 selinux_compute_relabel_context(restorecond_t)
 selinux_compute_user_contexts(restorecond_t)
 
-auth_relabel_all_files_except_auth_files(restorecond_t )
-auth_read_all_files_except_auth_files(restorecond_t)
+files_relabel_non_security_files(restorecond_t )
+files_read_non_security_files(restorecond_t)
 auth_use_nsswitch(restorecond_t)
 
 locallogin_dontaudit_use_fds(restorecond_t)

Generally speaking, I'm fine with this. However, I'm looking closely to make sure the new calls that are being made are the right ones.

Signature · 3 lines
Chris PeBenito
Tresys Technology, LLC
www.tresys.com | oss.tresys.com