Skip to contentSkip to conversation

home_domain macro / x_client cleanup patch

PATCH In review Ivan Gyurdiev 1 participant 4 messages Feb 27, 2005 – Mar 1, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 home_domain macro / x_client cleanup patch

This patch attempts to remove the rw_t, ro_t types from x_client_macro, which are the main reason why this macro's not usable for more than the current three domains (games, mozilla, mplayer).

It does this by:
- erasing the rw_t, ro_t types from x_client
- adding a new macro called home_domain, that
allows an application to have its own private domain in $1_home_dir_t. The domain can have both files and subdirectories from all users. It is accessible from $1_t, which can create files in it, relabel to/from.
- converting mplayer, mozilla, xauth, and tvtime to use the new macro.

Points of interest:
- I don't think the tvtime home domain was actually used anywhere before. The type just existed. Now it can create home files/dirs.

- xauth can now make directories, which I thought
isn't bad enough to warrant not changing it

- All javaplugin changes are simply reorganizing the macro to use different arguments.

- All mozilla changes are reorganizing things. The only significant change is that /tmp files are now created in $1_mozilla_tmp_t, lpr can only print those, and only those ones are executable.

- Additional change: getattr /tmp/.X0-lock is now
allowed for all x_client domains.

Future plan:
- Change other HOME_DIR domains to use this macro
- Further change x_client_macro to the point where it's usable by everything. For example, the javaplugin thing has about 50 lines or so that are just duplicating stuff already in x_client_macros.

========
This applies on top of Daniel Walsh's latest policy (which happens to include the read_sysctl patch I sent earlier - no sysctl denials yet that I see)

Signature · 2 lines
Ivan Gyurdiev <[email protected]>
Cornell University
file_contexts/program/mozilla.fc +9 -9
diff -aur policy.old/file_contexts/program/mozilla.fc policy/file_contexts/program/mozilla.fc
@@ -1,13 +1,13 @@
 #  netscape/mozilla
-HOME_DIR/\.galeon(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.netscape(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.mozilla(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.phoenix(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.gconfd(/.*)?		system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.gconf(/.*)?		system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.gnome2/epiphany(/.*)? system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/My.Downloads(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.java(/.*)?		system_u:object_r:ROLE_mozilla_rw_t
+HOME_DIR/\.galeon(/.*)?	system_u:object_r:ROLE_home_mozilla_t
+HOME_DIR/\.netscape(/.*)?	system_u:object_r:ROLE_home_mozilla_t
+HOME_DIR/\.mozilla(/.*)?	system_u:object_r:ROLE_home_mozilla_t
+HOME_DIR/\.phoenix(/.*)?	system_u:object_r:ROLE_home_mozilla_t
+HOME_DIR/\.gconfd(/.*)?		system_u:object_r:ROLE_home_mozilla_t
+HOME_DIR/\.gconf(/.*)?		system_u:object_r:ROLE_home_mozilla_t
+HOME_DIR/\.gnome2/epiphany(/.*)? system_u:object_r:ROLE_home_mozilla_t
+HOME_DIR/My.Downloads(/.*)?	system_u:object_r:ROLE_home_mozilla_t
+HOME_DIR/\.java(/.*)?		system_u:object_r:ROLE_home_mozilla_t
 /usr/bin/netscape	--	system_u:object_r:mozilla_exec_t
 /usr/bin/mozilla	--	system_u:object_r:mozilla_exec_t
 /usr/bin/mozilla-snapshot --	system_u:object_r:mozilla_exec_t
file_contexts/program/mplayer.fc +1 -1
diff -aur policy.old/file_contexts/program/mplayer.fc policy/file_contexts/program/mplayer.fc
@@ -3,4 +3,4 @@
 /usr/bin/mencoder	--	   	system_u:object_r:mencoder_exec_t
 
 /etc/mplayer(/.*)?		system_u:object_r:mplayer_etc_t
-HOME_DIR/\.mplayer(/.*)?        system_u:object_r:ROLE_mplayer_rw_t
+HOME_DIR/\.mplayer(/.*)?        system_u:object_r:ROLE_home_mplayer_t
macros/base_user_macros.te +1 -4
diff -aur policy.old/macros/base_user_macros.te policy/macros/base_user_macros.te
@@ -187,10 +187,7 @@
 ifdef(`using_spamassassin', `spamassassin_domain($1)')
 ifdef(`uml.te', `uml_domain($1)')
 ifdef(`cdrecord.te', `cdrecord_domain($1)')
-ifdef(`mplayer.te', `
-mplayer_domain($1)
-mencoder_domain($1)
-')
+ifdef(`mplayer.te', `mplayer_domains($1)')
 
 # Instantiate a derived domain for user cron jobs.
 ifdef(`crond.te', `crond_domain($1)')
macros/global_macros.te +25 -0
diff -aur policy.old/macros/global_macros.te policy/macros/global_macros.te
@@ -474,6 +474,31 @@
 file_type_auto_trans($1_t, var_lock_t, $1_lock_t, file)
 ')
 
+####################################################################
+# home_domain (prefix, app)
+#
+# Creates a domain in the prefix home where an application can
+# store its settings. It's accessible by the prefix domain.
+#
+
+define(`home_domain', `
+type $1_home_$2_t, file_type, $1_file_type, sysadmfile;
+
+allow $1_$2_t home_root_t:dir search;
+
+if (use_nfs_home_dirs) {
+create_dir_file($1_$2_t, nfs_t)
+}
+if (use_samba_home_dirs) {
+create_dir_file($1_$2_t, cifs_t)
+}
+allow $1_$2_t autofs_t:dir { search getattr };
+
+file_type_auto_trans($1_$2_t, $1_home_dir_t, $1_home_$2_t)
+create_dir_file($1_t, $1_home_$2_t)
+allow $1_t $1_home_$2_t:{ dir file lnk_file } { relabelfrom relabelto };
+')
+
 #######################
 # application_domain(domain_prefix)
 #
macros/program/games_domain.te +3 -3
diff -aur policy.old/macros/program/games_domain.te policy/macros/program/games_domain.te
@@ -11,6 +11,9 @@
 #
 define(`games_domain', `
 x_client_domain($1, `games', `, transitionbool')
+
+allow $1_games_t $1_home_dir_t:dir search;
+
 allow $1_games_t var_t:dir { search getattr };
 rw_dir_create_file($1_games_t, games_data_t)
 allow $1_games_t sound_device_t:chr_file rw_file_perms;
@@ -48,9 +51,6 @@
 # kpat spews errors
 dontaudit $1_games_t bin_t:dir getattr;
 dontaudit $1_games_t var_run_t:dir search;
-ifdef(`xdm.te', `
-dontaudit $1_games_t xdm_xserver_tmp_t:dir getattr;
-')
 
 ')dnl end macro definition
 
macros/program/java_macros.te +62 -63

174 lines not on this page · raw message

macros/program/mozilla_macros.te +33 -33

112 lines not on this page · raw message

macros/program/mplayer_macros.te +17 -13
diff -aur policy.old/macros/program/mplayer_macros.te policy/macros/program/mplayer_macros.te
@@ -6,6 +6,9 @@
 #
 # mplayer_domain(domain_prefix)
 # mencoder_domain(domain_prefix)
+#
+# mplayer_domains(domain_prefix)
+# declares both of them 
 
 ################################################
 #    mplayer_common(prefix, mplayer domain)    #
@@ -13,18 +16,6 @@
 
 define(`mplayer_common',`
 
-# Home directory stuff
-if (use_nfs_home_dirs) {
-create_dir_file($1_$2_t, nfs_t)
-}
-if (use_samba_home_dirs) {
-create_dir_file($1_$2_t, cifs_t)
-}
-allow $1_$2_t autofs_t:dir { search getattr };
-
-# Read local config
-r_dir_file($1_$2_t, $1_mplayer_rw_t)
-
 # Read global config
 r_dir_file($1_$2_t, mplayer_etc_t)
 
@@ -62,7 +53,6 @@
 allow $1_$2_t removable_device_t:blk_file { getattr read };
 allow $1_$2_t v4l_device_t:chr_file { getattr read };
 
-
 # Legacy domain issues
 if (allow_mplayer_execstack) {
 legacy_domain($1_$2)
@@ -116,3 +106,17 @@
 mplayer_common($1, mencoder)
 
 ') dnl end mencoder_domain
+
+###############################
+#  mplayer_domains(prefix)    #
+###############################
+define(`mplayer_domains', `
+
+# Mplayer common configuration here
+home_domain($1, mplayer)
+
+# Invoke both domains
+mplayer_domain($1)
+mencoder_domain($1)
+') dnl end mplayer_domains
+
macros/program/tvtime_macros.te +1 -2
diff -aur policy.old/macros/program/tvtime_macros.te policy/macros/program/tvtime_macros.te
@@ -18,9 +18,8 @@
 undefine(`tvtime_domain')
 ifdef(`tvtime.te', `
 define(`tvtime_domain',`
-# Derived domain based on the calling user domain and the program.
-type $1_home_tvtime_t, file_type, $1_file_type, sysadmfile;
 
+home_domain($1, tvtime)
 x_client_domain($1, tvtime)
 
 allow $1_tvtime_t urandom_device_t:chr_file read;
macros/program/xauth_macros.te +1 -16
diff -aur policy.old/macros/program/xauth_macros.te policy/macros/program/xauth_macros.te
@@ -20,11 +20,10 @@
 define(`xauth_domain',`
 # Derived domain based on the calling user domain and the program.
 type $1_xauth_t, domain;
-type $1_home_xauth_t, file_type, $1_file_type, sysadmfile;
 
 allow $1_xauth_t self:process signal;
 
-allow $1_t $1_home_xauth_t:file { relabelfrom relabelto create_file_perms };
+home_domain($1, xauth)
 
 # Transition from the user domain to this domain.
 domain_auto_trans($1_t, xauth_exec_t, $1_xauth_t)
@@ -72,23 +71,9 @@
 allow $1_xauth_t var_t:dir search;
 allow $1_xauth_t var_run_t:dir search; 
 
-# this is what we are here for
-allow $1_xauth_t home_root_t:dir search;
-file_type_auto_trans($1_xauth_t, $1_home_dir_t, $1_home_xauth_t, file)
-
 tmp_domain($1_xauth)
 allow $1_xauth_t $1_tmp_t:file { getattr ioctl read };
 
-if (use_nfs_home_dirs) {
-allow $1_xauth_t autofs_t:dir { search getattr };
-rw_dir_create_file($1_xauth_t, nfs_t)
-}
-if (use_samba_home_dirs) {
-rw_dir_create_file($1_xauth_t, cifs_t)
-}
-if (use_samba_home_dirs) {
-rw_dir_create_file($1_xauth_t, cifs_t)
-}
 ')dnl end xauth_domain macro
 
 ', `
macros/program/x_client_macros.te +16 -25

81 lines not on this page · raw message

#1 lore raw
Quoted 5 lines

- All mozilla changes are reorganizing things. The only significant change is that /tmp files are now created in $1_mozilla_tmp_t, lpr can only print those, and only those ones are executable.

This broke some things. I also stopped using macros for interaction w/ $1_tmp_t to reduce privileges. Here's a followup patch that addresses some denials.

Applies on top of the latest policy + the home_domain patch I sent.

Signature · 2 lines
Ivan Gyurdiev <[email protected]>
Cornell University
mozilla_macros.new renamed from mozilla_macros.te +2 -2
@@ -74,8 +74,8 @@
 file_type_auto_trans($1_mozilla_t, $1_tmp_t, $1_mozilla_tmp_t)
 can_unix_connect($1_t, $1_mozilla_t)
 allow $1_t $1_mozilla_tmp_t:sock_file write;
-allow $1_mozilla_t $1_tmp_t:file { read write };
-allow $1_mozilla_t $1_tmp_t:sock_file write;
+allow $1_mozilla_t $1_tmp_t:file { read write lock };
+allow $1_mozilla_t $1_tmp_t:sock_file { read write };
 dontaudit $1_mozilla_t $1_tmp_t:dir setattr;
 
 # Allow mozilla to read user home content
#2 lore raw

Here's a new patch, after discussion with Dan. Walsh.

Changes:
- mozilla fixes included into main patch
- naming changed to $1_$2_home_t pattern. This goes against the current pattern, but seems like an improvement.
- since the naming was changed, reduce javaplugin changes to minimum required to support this patch
- add spamassassin to applications using this macro
- restore ro_t type in the form of the home_domain_ro macro. It differs from the one in x_client, since you can't
write to fifo files, but is essentially the same idea (user_t can write to app home file, app can only read)
- add typealias declarations in the macro(s) for backwards compatibility

Home_domain_v4.diff attached.

Quoted 1 line
Signature · 2 lines
Ivan Gyurdiev <[email protected]>
Cornell University
file_contexts/program/mozilla.fc +9 -9
diff -aur policy.old/file_contexts/program/mozilla.fc policy/file_contexts/program/mozilla.fc
@@ -1,13 +1,13 @@
 #  netscape/mozilla
-HOME_DIR/\.galeon(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.netscape(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.mozilla(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.phoenix(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.gconfd(/.*)?		system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.gconf(/.*)?		system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.gnome2/epiphany(/.*)? system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/My.Downloads(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.java(/.*)?		system_u:object_r:ROLE_mozilla_rw_t
+HOME_DIR/\.galeon(/.*)?	system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.netscape(/.*)?	system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.mozilla(/.*)?	system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.phoenix(/.*)?	system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.gconfd(/.*)?		system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.gconf(/.*)?		system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.gnome2/epiphany(/.*)? system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/My.Downloads(/.*)?	system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.java(/.*)?		system_u:object_r:ROLE_mozilla_home_t
 /usr/bin/netscape	--	system_u:object_r:mozilla_exec_t
 /usr/bin/mozilla	--	system_u:object_r:mozilla_exec_t
 /usr/bin/mozilla-snapshot --	system_u:object_r:mozilla_exec_t
file_contexts/program/mplayer.fc +1 -1
diff -aur policy.old/file_contexts/program/mplayer.fc policy/file_contexts/program/mplayer.fc
@@ -3,4 +3,4 @@
 /usr/bin/mencoder	--	   	system_u:object_r:mencoder_exec_t
 
 /etc/mplayer(/.*)?		system_u:object_r:mplayer_etc_t
-HOME_DIR/\.mplayer(/.*)?        system_u:object_r:ROLE_mplayer_rw_t
+HOME_DIR/\.mplayer(/.*)?        system_u:object_r:ROLE_mplayer_home_t
file_contexts/program/spamassassin.fc +1 -1
diff -aur policy.old/file_contexts/program/spamassassin.fc policy/file_contexts/program/spamassassin.fc
@@ -1,3 +1,3 @@
 # spamassasin
 /usr/bin/spamassassin	--	system_u:object_r:spamassassin_exec_t
-HOME_DIR/\.spamassassin(/.*)?	system_u:object_r:ROLE_home_spamassassin_t
+HOME_DIR/\.spamassassin(/.*)?	system_u:object_r:ROLE_spamassassin_home_t
file_contexts/program/xauth.fc +1 -1
diff -aur policy.old/file_contexts/program/xauth.fc policy/file_contexts/program/xauth.fc
@@ -1,3 +1,3 @@
 # xauth
 /usr/X11R6/bin/xauth	--	system_u:object_r:xauth_exec_t
-HOME_DIR/\.Xauthority.* --	system_u:object_r:ROLE_home_xauth_t
+HOME_DIR/\.Xauthority.* --	system_u:object_r:ROLE_xauth_home_t
macros/base_user_macros.te +2 -5
diff -aur policy.old/macros/base_user_macros.te policy/macros/base_user_macros.te
@@ -187,10 +187,7 @@
 ifdef(`using_spamassassin', `spamassassin_domain($1)')
 ifdef(`uml.te', `uml_domain($1)')
 ifdef(`cdrecord.te', `cdrecord_domain($1)')
-ifdef(`mplayer.te', `
-mplayer_domain($1)
-mencoder_domain($1)
-')
+ifdef(`mplayer.te', `mplayer_domains($1)')
 
 # Instantiate a derived domain for user cron jobs.
 ifdef(`crond.te', `crond_domain($1)')
@@ -301,7 +298,7 @@
 allow $1_t xdm_var_lib_t:file { getattr read };
 allow xdm_t $1_home_dir_t:dir getattr;
 ifdef(`xauth.te', `
-file_type_auto_trans(xdm_t, $1_home_dir_t, $1_home_xauth_t, file)
+file_type_auto_trans(xdm_t, $1_home_dir_t, $1_xauth_home_t, file)
 ')
 
 # for shared memory
macros/global_macros.te +56 -0

62 lines not on this page · raw message

macros/program/games_domain.te +3 -3
diff -aur policy.old/macros/program/games_domain.te policy/macros/program/games_domain.te
@@ -11,6 +11,9 @@
 #
 define(`games_domain', `
 x_client_domain($1, `games', `, transitionbool')
+
+allow $1_games_t $1_home_dir_t:dir search;
+
 allow $1_games_t var_t:dir { search getattr };
 rw_dir_create_file($1_games_t, games_data_t)
 allow $1_games_t sound_device_t:chr_file rw_file_perms;
@@ -48,9 +51,6 @@
 # kpat spews errors
 dontaudit $1_games_t bin_t:dir getattr;
 dontaudit $1_games_t var_run_t:dir search;
-ifdef(`xdm.te', `
-dontaudit $1_games_t xdm_xserver_tmp_t:dir getattr;
-')
 
 ')dnl end macro definition
 
macros/program/java_macros.te +4 -4
diff -aur policy.old/macros/program/java_macros.te policy/macros/program/java_macros.te
@@ -105,7 +105,7 @@
 
 uses_shlib($1_javaplugin_t)
 read_locale($1_javaplugin_t)
-rw_dir_file($1_javaplugin_t, $1_rw_t)
+rw_dir_file($1_javaplugin_t, $1_home_t)
 
 if (allow_java_execstack) {
 legacy_domain($1_javaplugin)
@@ -119,8 +119,8 @@
 allow $1_javaplugin_t { random_device_t urandom_device_t }:chr_file ra_file_perms;
 
 allow $1_javaplugin_t home_root_t:dir { getattr search };
-file_type_auto_trans($1_javaplugin_t, $2_home_dir_t, $1_rw_t)
-allow $1_javaplugin_t $2_home_xauth_t:file { getattr read };
+file_type_auto_trans($1_javaplugin_t, $2_home_dir_t, $1_home_t)
+allow $1_javaplugin_t $2_xauth_home_t:file { getattr read };
 allow $1_javaplugin_t $2_tmp_t:sock_file write;
 allow $1_javaplugin_t $2_t:fd use;
 
@@ -131,6 +131,6 @@
 dontaudit $1_javaplugin_t sysadm_devpts_t:chr_file { read write };
 dontaudit $1_javaplugin_t devtty_t:chr_file { read write };
 dontaudit $1_javaplugin_t tmpfs_t:file { execute read write };
-dontaudit $1_javaplugin_t $1_rw_t:file { execute setattr };
+dontaudit $1_javaplugin_t $1_home_t:file { execute setattr };
 
 ')
macros/program/mozilla_macros.te +32 -32

110 lines not on this page · raw message

macros/program/mplayer_macros.te +17 -13
diff -aur policy.old/macros/program/mplayer_macros.te policy/macros/program/mplayer_macros.te
@@ -6,6 +6,9 @@
 #
 # mplayer_domain(domain_prefix)
 # mencoder_domain(domain_prefix)
+#
+# mplayer_domains(domain_prefix)
+# declares both of them 
 
 ################################################
 #    mplayer_common(prefix, mplayer domain)    #
@@ -13,18 +16,6 @@
 
 define(`mplayer_common',`
 
-# Home directory stuff
-if (use_nfs_home_dirs) {
-create_dir_file($1_$2_t, nfs_t)
-}
-if (use_samba_home_dirs) {
-create_dir_file($1_$2_t, cifs_t)
-}
-allow $1_$2_t autofs_t:dir { search getattr };
-
-# Read local config
-r_dir_file($1_$2_t, $1_mplayer_rw_t)
-
 # Read global config
 r_dir_file($1_$2_t, mplayer_etc_t)
 
@@ -62,7 +53,6 @@
 allow $1_$2_t removable_device_t:blk_file { getattr read };
 allow $1_$2_t v4l_device_t:chr_file { getattr read };
 
-
 # Legacy domain issues
 if (allow_mplayer_execstack) {
 legacy_domain($1_$2)
@@ -116,3 +106,17 @@
 mplayer_common($1, mencoder)
 
 ') dnl end mencoder_domain
+
+###############################
+#  mplayer_domains(prefix)    #
+###############################
+define(`mplayer_domains', `
+
+# Mplayer common configuration here
+home_domain($1, mplayer)
+
+# Invoke both domains
+mplayer_domain($1)
+mencoder_domain($1)
+') dnl end mplayer_domains
+
macros/program/spamassassin_macros.te +4 -7
diff -aur policy.old/macros/program/spamassassin_macros.te policy/macros/program/spamassassin_macros.te
@@ -58,8 +58,8 @@
 #
 define(`spamassassin_agent_privs',`
 allow $1 home_root_t:dir r_dir_perms;
-file_type_auto_trans($1, $2_home_dir_t, $2_home_spamassassin_t)
-create_dir_file($1, $2_home_spamassassin_t)
+file_type_auto_trans($1, $2_home_dir_t, $2_spamassassin_home_t)
+create_dir_file($1, $2_spamassassin_home_t)
 
 allow $1 urandom_device_t:chr_file r_file_perms;
 ')
@@ -78,11 +78,8 @@
 dontaudit $1_spamassassin_t proc_t:dir search;
 dontaudit $1_spamassassin_t { sysctl_t sysctl_kernel_t }:dir search;
 
-# The type of ~/.spamassassin
-type $1_home_spamassassin_t, file_type, $1_file_type, sysadmfile;
-create_dir_file($1_t, $1_home_spamassassin_t)
-allow $1_t $1_home_spamassassin_t:notdevfile_class_set { relabelfrom relabelto };
-allow $1_t $1_home_spamassassin_t:dir { relabelfrom relabelto };
+# For ~/.spamassassin
+home_domain($1, spamassassin)
 
 spamassassin_agent_privs($1_spamassassin_t, $1)
 
macros/program/su_macros.te +3 -3
diff -aur policy.old/macros/program/su_macros.te policy/macros/program/su_macros.te
@@ -141,9 +141,9 @@
 
 # Modify .Xauthority file (via xauth program).
 ifdef(`xauth.te', `
-file_type_auto_trans($1_su_t, staff_home_dir_t, staff_home_xauth_t, file)
-file_type_auto_trans($1_su_t, user_home_dir_t, user_home_xauth_t, file)
-file_type_auto_trans($1_su_t, sysadm_home_dir_t, sysadm_home_xauth_t, file)
+file_type_auto_trans($1_su_t, staff_home_dir_t, staff_xauth_home_t, file)
+file_type_auto_trans($1_su_t, user_home_dir_t, user_xauth_home_t, file)
+file_type_auto_trans($1_su_t, sysadm_home_dir_t, sysadm_xauth_home_t, file)
 domain_auto_trans($1_su_t, xauth_exec_t, $1_xauth_t)
 ')
 
macros/program/tvtime_macros.te +1 -2
diff -aur policy.old/macros/program/tvtime_macros.te policy/macros/program/tvtime_macros.te
@@ -18,9 +18,8 @@
 undefine(`tvtime_domain')
 ifdef(`tvtime.te', `
 define(`tvtime_domain',`
-# Derived domain based on the calling user domain and the program.
-type $1_home_tvtime_t, file_type, $1_file_type, sysadmfile;
 
+home_domain($1, tvtime)
 x_client_domain($1, tvtime)
 
 allow $1_tvtime_t urandom_device_t:chr_file read;
macros/program/uml_macros.te +1 -1
diff -aur policy.old/macros/program/uml_macros.te policy/macros/program/uml_macros.te
@@ -103,7 +103,7 @@
 dontaudit $1_uml_t etc_runtime_t:file read;
 can_tcp_connect($1_uml_t, sshd_t)
 ifdef(`xauth.te', `
-allow $1_uml_t $1_home_xauth_t:file { getattr read };
+allow $1_uml_t $1_xauth_home_t:file { getattr read };
 ')
 allow $1_uml_t var_run_t:dir search;
 allow $1_uml_t initrc_var_run_t:file { getattr read };
macros/program/userhelper_macros.te +1 -1
diff -aur policy.old/macros/program/userhelper_macros.te policy/macros/program/userhelper_macros.te
@@ -130,7 +130,7 @@
 
 ifdef(`xauth.te', `
 domain_auto_trans($1_userhelper_t, xauth_exec_t, $1_xauth_t)
-allow $1_userhelper_t $1_home_xauth_t:file { getattr read };
+allow $1_userhelper_t $1_xauth_home_t:file { getattr read };
 ')
 
 ifdef(`pamconsole.te', `
macros/program/xauth_macros.te +1 -16
diff -aur policy.old/macros/program/xauth_macros.te policy/macros/program/xauth_macros.te
@@ -20,11 +20,10 @@
 define(`xauth_domain',`
 # Derived domain based on the calling user domain and the program.
 type $1_xauth_t, domain;
-type $1_home_xauth_t, file_type, $1_file_type, sysadmfile;
 
 allow $1_xauth_t self:process signal;
 
-allow $1_t $1_home_xauth_t:file { relabelfrom relabelto create_file_perms };
+home_domain($1, xauth)
 
 # Transition from the user domain to this domain.
 domain_auto_trans($1_t, xauth_exec_t, $1_xauth_t)
@@ -72,23 +71,9 @@
 allow $1_xauth_t var_t:dir search;
 allow $1_xauth_t var_run_t:dir search; 
 
-# this is what we are here for
-allow $1_xauth_t home_root_t:dir search;
-file_type_auto_trans($1_xauth_t, $1_home_dir_t, $1_home_xauth_t, file)
-
 tmp_domain($1_xauth)
 allow $1_xauth_t $1_tmp_t:file { getattr ioctl read };
 
-if (use_nfs_home_dirs) {
-allow $1_xauth_t autofs_t:dir { search getattr };
-rw_dir_create_file($1_xauth_t, nfs_t)
-}
-if (use_samba_home_dirs) {
-rw_dir_create_file($1_xauth_t, cifs_t)
-}
-if (use_samba_home_dirs) {
-rw_dir_create_file($1_xauth_t, cifs_t)
-}
 ')dnl end xauth_domain macro
 
 ', `
macros/program/x_client_macros.te +17 -26

85 lines not on this page · raw message

macros/program/xserver_macros.te +1 -1
diff -aur policy.old/macros/program/xserver_macros.te policy/macros/program/xserver_macros.te
@@ -97,7 +97,7 @@
 }
 ifdef(`xauth.te', `
 domain_auto_trans($1_xserver_t, xauth_exec_t, $1_xauth_t)
-allow $1_xserver_t $1_home_xauth_t:file { getattr read };
+allow $1_xserver_t $1_xauth_home_t:file { getattr read };
 ', `
 allow $1_xserver_t $1_home_t:file { getattr read };
 ')dnl end ifdef xauth
#3 lore raw

Home_domain_v5 attached.
- corrects bug in home_domain_ro typealias
- adds $1_home_$2_t typealias for home_domain_ro
- adds screen and irc to the list of domains using this. screen uses the ro domain only.
- adds fixes for games_domain denials that I caused

Ok, at this point the only controversial thing that I see left is that home_domain macros allow both directories and files to operated on, and rw macro allows creation of directories. Previously some domains were only given permission to work with files, and some were given permissions to directories, but not to create them. I'm not sure if this is a huge problem.

If there are no objections, please apply.

(other pending patch is security.diff that marks policy_src_t
and policy_config_t as sysadmfile)

Signature · 2 lines
Ivan Gyurdiev <[email protected]>
Cornell University
file_contexts/program/mozilla.fc +9 -9
diff -aru policy.old/file_contexts/program/mozilla.fc policy/file_contexts/program/mozilla.fc
@@ -1,13 +1,13 @@
 #  netscape/mozilla
-HOME_DIR/\.galeon(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.netscape(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.mozilla(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.phoenix(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.gconfd(/.*)?		system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.gconf(/.*)?		system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.gnome2/epiphany(/.*)? system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/My.Downloads(/.*)?	system_u:object_r:ROLE_mozilla_rw_t
-HOME_DIR/\.java(/.*)?		system_u:object_r:ROLE_mozilla_rw_t
+HOME_DIR/\.galeon(/.*)?	system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.netscape(/.*)?	system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.mozilla(/.*)?	system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.phoenix(/.*)?	system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.gconfd(/.*)?		system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.gconf(/.*)?		system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.gnome2/epiphany(/.*)? system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/My.Downloads(/.*)?	system_u:object_r:ROLE_mozilla_home_t
+HOME_DIR/\.java(/.*)?		system_u:object_r:ROLE_mozilla_home_t
 /usr/bin/netscape	--	system_u:object_r:mozilla_exec_t
 /usr/bin/mozilla	--	system_u:object_r:mozilla_exec_t
 /usr/bin/mozilla-snapshot --	system_u:object_r:mozilla_exec_t
file_contexts/program/mplayer.fc +1 -1
diff -aru policy.old/file_contexts/program/mplayer.fc policy/file_contexts/program/mplayer.fc
@@ -3,4 +3,4 @@
 /usr/bin/mencoder	--	   	system_u:object_r:mencoder_exec_t
 
 /etc/mplayer(/.*)?		system_u:object_r:mplayer_etc_t
-HOME_DIR/\.mplayer(/.*)?        system_u:object_r:ROLE_mplayer_rw_t
+HOME_DIR/\.mplayer(/.*)?        system_u:object_r:ROLE_mplayer_home_t
file_contexts/program/screen.fc +1 -1
diff -aru policy.old/file_contexts/program/screen.fc policy/file_contexts/program/screen.fc
@@ -1,5 +1,5 @@
 # screen
 /usr/bin/screen		--	system_u:object_r:screen_exec_t
-HOME_DIR/\.screenrc	--	system_u:object_r:ROLE_home_screen_t
+HOME_DIR/\.screenrc	--	system_u:object_r:ROLE_screen_ro_home_t
 /var/run/screen/S-[^/]+	-d	system_u:object_r:screen_dir_t
 /var/run/screen/S-[^/]+/.*	<<none>>
file_contexts/program/spamassassin.fc +1 -1
diff -aru policy.old/file_contexts/program/spamassassin.fc policy/file_contexts/program/spamassassin.fc
@@ -1,3 +1,3 @@
 # spamassasin
 /usr/bin/spamassassin	--	system_u:object_r:spamassassin_exec_t
-HOME_DIR/\.spamassassin(/.*)?	system_u:object_r:ROLE_home_spamassassin_t
+HOME_DIR/\.spamassassin(/.*)?	system_u:object_r:ROLE_spamassassin_home_t
file_contexts/program/xauth.fc +1 -1
diff -aru policy.old/file_contexts/program/xauth.fc policy/file_contexts/program/xauth.fc
@@ -1,3 +1,3 @@
 # xauth
 /usr/X11R6/bin/xauth	--	system_u:object_r:xauth_exec_t
-HOME_DIR/\.Xauthority.* --	system_u:object_r:ROLE_home_xauth_t
+HOME_DIR/\.Xauthority.* --	system_u:object_r:ROLE_xauth_home_t
macros/base_user_macros.te +2 -5
diff -aru policy.old/macros/base_user_macros.te policy/macros/base_user_macros.te
@@ -187,10 +187,7 @@
 ifdef(`using_spamassassin', `spamassassin_domain($1)')
 ifdef(`uml.te', `uml_domain($1)')
 ifdef(`cdrecord.te', `cdrecord_domain($1)')
-ifdef(`mplayer.te', `
-mplayer_domain($1)
-mencoder_domain($1)
-')
+ifdef(`mplayer.te', `mplayer_domains($1)')
 
 # Instantiate a derived domain for user cron jobs.
 ifdef(`crond.te', `crond_domain($1)')
@@ -301,7 +298,7 @@
 allow $1_t xdm_var_lib_t:file { getattr read };
 allow xdm_t $1_home_dir_t:dir getattr;
 ifdef(`xauth.te', `
-file_type_auto_trans(xdm_t, $1_home_dir_t, $1_home_xauth_t, file)
+file_type_auto_trans(xdm_t, $1_home_dir_t, $1_xauth_home_t, file)
 ')
 
 # for shared memory
macros/global_macros.te +57 -0

63 lines not on this page · raw message

macros/program/games_domain.te +5 -3
diff -aru policy.old/macros/program/games_domain.te policy/macros/program/games_domain.te
@@ -11,13 +11,18 @@
 #
 define(`games_domain', `
 x_client_domain($1, `games', `, transitionbool')
+
 allow $1_games_t var_t:dir { search getattr };
 rw_dir_create_file($1_games_t, games_data_t)
 allow $1_games_t sound_device_t:chr_file rw_file_perms;
 r_dir_file($1_games_t, usr_t)
 can_udp_send($1_games_t, $1_games_t)
 can_tcp_connect($1_games_t, $1_games_t)
+
+# Access /home/user/.gnome2
 create_dir_file($1_games_t, $1_home_t)
+allow $1_games_t $1_home_dir_t:dir search;
+allow $1_games_t $1_home_t:dir { read getattr };
 
 create_dir_file($1_games_t, $1_tmp_t)
 allow $1_games_t $1_tmp_t:sock_file create_file_perms;
@@ -48,9 +53,6 @@
 # kpat spews errors
 dontaudit $1_games_t bin_t:dir getattr;
 dontaudit $1_games_t var_run_t:dir search;
-ifdef(`xdm.te', `
-dontaudit $1_games_t xdm_xserver_tmp_t:dir getattr;
-')
 
 ')dnl end macro definition
 
macros/program/irc_macros.te +5 -6
diff -aru policy.old/macros/program/irc_macros.te policy/macros/program/irc_macros.te
@@ -18,12 +18,15 @@
 undefine(`irc_domain')
 ifdef(`irc.te', `
 define(`irc_domain',`
+
+# Home domain
+home_domain($1, irc)
+
 # Derived domain based on the calling user domain and the program.
 type $1_irc_t, domain;
-type $1_home_irc_t, file_type, $1_file_type, sysadmfile;
 type $1_irc_exec_t, file_type, sysadmfile, $1_file_type;
 
-allow $1_t { $1_home_irc_t $1_irc_exec_t }:file { relabelfrom relabelto create_file_perms };
+allow $1_t $1_irc_exec_t:file { relabelfrom relabelto create_file_perms };
 
 # Transition from the user domain to this domain.
 domain_auto_trans($1_t, { irc_exec_t $1_irc_exec_t }, $1_irc_t)
@@ -65,10 +68,6 @@
 allow $1_irc_t initrc_var_run_t:file read;
 dontaudit $1_irc_t initrc_var_run_t:file lock;
 
-# access config files
-allow $1_irc_t home_root_t:dir search;
-file_type_auto_trans($1_irc_t, $1_home_dir_t, $1_home_irc_t, file)
-
 # access files under /tmp
 file_type_auto_trans($1_irc_t, tmp_t, $1_tmp_t)
 
macros/program/java_macros.te +4 -4
diff -aru policy.old/macros/program/java_macros.te policy/macros/program/java_macros.te
@@ -105,7 +105,7 @@
 
 uses_shlib($1_javaplugin_t)
 read_locale($1_javaplugin_t)
-rw_dir_file($1_javaplugin_t, $1_rw_t)
+rw_dir_file($1_javaplugin_t, $1_home_t)
 
 if (allow_java_execstack) {
 legacy_domain($1_javaplugin)
@@ -119,8 +119,8 @@
 allow $1_javaplugin_t { random_device_t urandom_device_t }:chr_file ra_file_perms;
 
 allow $1_javaplugin_t home_root_t:dir { getattr search };
-file_type_auto_trans($1_javaplugin_t, $2_home_dir_t, $1_rw_t)
-allow $1_javaplugin_t $2_home_xauth_t:file { getattr read };
+file_type_auto_trans($1_javaplugin_t, $2_home_dir_t, $1_home_t)
+allow $1_javaplugin_t $2_xauth_home_t:file { getattr read };
 allow $1_javaplugin_t $2_tmp_t:sock_file write;
 allow $1_javaplugin_t $2_t:fd use;
 
@@ -131,6 +131,6 @@
 dontaudit $1_javaplugin_t sysadm_devpts_t:chr_file { read write };
 dontaudit $1_javaplugin_t devtty_t:chr_file { read write };
 dontaudit $1_javaplugin_t tmpfs_t:file { execute read write };
-dontaudit $1_javaplugin_t $1_rw_t:file { execute setattr };
+dontaudit $1_javaplugin_t $1_home_t:file { execute setattr };
 
 ')
macros/program/mozilla_macros.te +32 -32

110 lines not on this page · raw message

macros/program/mplayer_macros.te +17 -13
diff -aru policy.old/macros/program/mplayer_macros.te policy/macros/program/mplayer_macros.te
@@ -6,6 +6,9 @@
 #
 # mplayer_domain(domain_prefix)
 # mencoder_domain(domain_prefix)
+#
+# mplayer_domains(domain_prefix)
+# declares both of them 
 
 ################################################
 #    mplayer_common(prefix, mplayer domain)    #
@@ -13,18 +16,6 @@
 
 define(`mplayer_common',`
 
-# Home directory stuff
-if (use_nfs_home_dirs) {
-create_dir_file($1_$2_t, nfs_t)
-}
-if (use_samba_home_dirs) {
-create_dir_file($1_$2_t, cifs_t)
-}
-allow $1_$2_t autofs_t:dir { search getattr };
-
-# Read local config
-r_dir_file($1_$2_t, $1_mplayer_rw_t)
-
 # Read global config
 r_dir_file($1_$2_t, mplayer_etc_t)
 
@@ -62,7 +53,6 @@
 allow $1_$2_t removable_device_t:blk_file { getattr read };
 allow $1_$2_t v4l_device_t:chr_file { getattr read };
 
-
 # Legacy domain issues
 if (allow_mplayer_execstack) {
 legacy_domain($1_$2)
@@ -116,3 +106,17 @@
 mplayer_common($1, mencoder)
 
 ') dnl end mencoder_domain
+
+###############################
+#  mplayer_domains(prefix)    #
+###############################
+define(`mplayer_domains', `
+
+# Mplayer common configuration here
+home_domain($1, mplayer)
+
+# Invoke both domains
+mplayer_domain($1)
+mencoder_domain($1)
+') dnl end mplayer_domains
+
macros/program/screen_macros.te +1 -10
diff -aru policy.old/macros/program/screen_macros.te policy/macros/program/screen_macros.te
@@ -22,7 +22,6 @@
 define(`screen_domain',`
 # Derived domain based on the calling user domain and the program.
 type $1_screen_t, domain, privlog, privfd;
-type $1_home_screen_t, file_type, $1_file_type, sysadmfile;
 
 # Transition from the user domain to this domain.
 domain_auto_trans($1_t, screen_exec_t, $1_screen_t)
@@ -50,15 +49,7 @@
 # Inherit and use descriptors from gnome-pty-helper.
 ifdef(`gnome-pty-helper.te', `allow $1_screen_t $1_gph_t:fd use;')
 
-allow $1_screen_t $1_home_screen_t:{ file lnk_file } r_file_perms;
-allow $1_t $1_home_screen_t:file { create_file_perms relabelfrom relabelto };
-allow $1_t $1_home_screen_t:lnk_file { create_lnk_perms relabelfrom relabelto };
-if (use_nfs_home_dirs) {
-r_dir_file($1_screen_t, nfs_t)
-}
-if (use_samba_home_dirs) {
-r_dir_file($1_screen_t, cifs_t)
-}
+home_domain_ro($1, screen)
 
 allow $1_screen_t privfd:fd use;
 
macros/program/spamassassin_macros.te +4 -7
diff -aru policy.old/macros/program/spamassassin_macros.te policy/macros/program/spamassassin_macros.te
@@ -58,8 +58,8 @@
 #
 define(`spamassassin_agent_privs',`
 allow $1 home_root_t:dir r_dir_perms;
-file_type_auto_trans($1, $2_home_dir_t, $2_home_spamassassin_t)
-create_dir_file($1, $2_home_spamassassin_t)
+file_type_auto_trans($1, $2_home_dir_t, $2_spamassassin_home_t)
+create_dir_file($1, $2_spamassassin_home_t)
 
 allow $1 urandom_device_t:chr_file r_file_perms;
 ')
@@ -78,11 +78,8 @@
 dontaudit $1_spamassassin_t proc_t:dir search;
 dontaudit $1_spamassassin_t { sysctl_t sysctl_kernel_t }:dir search;
 
-# The type of ~/.spamassassin
-type $1_home_spamassassin_t, file_type, $1_file_type, sysadmfile;
-create_dir_file($1_t, $1_home_spamassassin_t)
-allow $1_t $1_home_spamassassin_t:notdevfile_class_set { relabelfrom relabelto };
-allow $1_t $1_home_spamassassin_t:dir { relabelfrom relabelto };
+# For ~/.spamassassin
+home_domain($1, spamassassin)
 
 spamassassin_agent_privs($1_spamassassin_t, $1)
 
macros/program/su_macros.te +3 -3
diff -aru policy.old/macros/program/su_macros.te policy/macros/program/su_macros.te
@@ -141,9 +141,9 @@
 
 # Modify .Xauthority file (via xauth program).
 ifdef(`xauth.te', `
-file_type_auto_trans($1_su_t, staff_home_dir_t, staff_home_xauth_t, file)
-file_type_auto_trans($1_su_t, user_home_dir_t, user_home_xauth_t, file)
-file_type_auto_trans($1_su_t, sysadm_home_dir_t, sysadm_home_xauth_t, file)
+file_type_auto_trans($1_su_t, staff_home_dir_t, staff_xauth_home_t, file)
+file_type_auto_trans($1_su_t, user_home_dir_t, user_xauth_home_t, file)
+file_type_auto_trans($1_su_t, sysadm_home_dir_t, sysadm_xauth_home_t, file)
 domain_auto_trans($1_su_t, xauth_exec_t, $1_xauth_t)
 ')
 
macros/program/tvtime_macros.te +1 -2
diff -aru policy.old/macros/program/tvtime_macros.te policy/macros/program/tvtime_macros.te
@@ -18,9 +18,8 @@
 undefine(`tvtime_domain')
 ifdef(`tvtime.te', `
 define(`tvtime_domain',`
-# Derived domain based on the calling user domain and the program.
-type $1_home_tvtime_t, file_type, $1_file_type, sysadmfile;
 
+home_domain($1, tvtime)
 x_client_domain($1, tvtime)
 
 allow $1_tvtime_t urandom_device_t:chr_file read;
macros/program/uml_macros.te +1 -1
diff -aru policy.old/macros/program/uml_macros.te policy/macros/program/uml_macros.te
@@ -103,7 +103,7 @@
 dontaudit $1_uml_t etc_runtime_t:file read;
 can_tcp_connect($1_uml_t, sshd_t)
 ifdef(`xauth.te', `
-allow $1_uml_t $1_home_xauth_t:file { getattr read };
+allow $1_uml_t $1_xauth_home_t:file { getattr read };
 ')
 allow $1_uml_t var_run_t:dir search;
 allow $1_uml_t initrc_var_run_t:file { getattr read };
macros/program/userhelper_macros.te +1 -1
diff -aru policy.old/macros/program/userhelper_macros.te policy/macros/program/userhelper_macros.te
@@ -130,7 +130,7 @@
 
 ifdef(`xauth.te', `
 domain_auto_trans($1_userhelper_t, xauth_exec_t, $1_xauth_t)
-allow $1_userhelper_t $1_home_xauth_t:file { getattr read };
+allow $1_userhelper_t $1_xauth_home_t:file { getattr read };
 ')
 
 ifdef(`pamconsole.te', `
macros/program/xauth_macros.te +1 -16
diff -aru policy.old/macros/program/xauth_macros.te policy/macros/program/xauth_macros.te
@@ -20,11 +20,10 @@
 define(`xauth_domain',`
 # Derived domain based on the calling user domain and the program.
 type $1_xauth_t, domain;
-type $1_home_xauth_t, file_type, $1_file_type, sysadmfile;
 
 allow $1_xauth_t self:process signal;
 
-allow $1_t $1_home_xauth_t:file { relabelfrom relabelto create_file_perms };
+home_domain($1, xauth)
 
 # Transition from the user domain to this domain.
 domain_auto_trans($1_t, xauth_exec_t, $1_xauth_t)
@@ -72,23 +71,9 @@
 allow $1_xauth_t var_t:dir search;
 allow $1_xauth_t var_run_t:dir search; 
 
-# this is what we are here for
-allow $1_xauth_t home_root_t:dir search;
-file_type_auto_trans($1_xauth_t, $1_home_dir_t, $1_home_xauth_t, file)
-
 tmp_domain($1_xauth)
 allow $1_xauth_t $1_tmp_t:file { getattr ioctl read };
 
-if (use_nfs_home_dirs) {
-allow $1_xauth_t autofs_t:dir { search getattr };
-rw_dir_create_file($1_xauth_t, nfs_t)
-}
-if (use_samba_home_dirs) {
-rw_dir_create_file($1_xauth_t, cifs_t)
-}
-if (use_samba_home_dirs) {
-rw_dir_create_file($1_xauth_t, cifs_t)
-}
 ')dnl end xauth_domain macro
 
 ', `
macros/program/x_client_macros.te +17 -26

85 lines not on this page · raw message

macros/program/xserver_macros.te +1 -1
diff -aru policy.old/macros/program/xserver_macros.te policy/macros/program/xserver_macros.te
@@ -97,7 +97,7 @@
 }
 ifdef(`xauth.te', `
 domain_auto_trans($1_xserver_t, xauth_exec_t, $1_xauth_t)
-allow $1_xserver_t $1_home_xauth_t:file { getattr read };
+allow $1_xserver_t $1_xauth_home_t:file { getattr read };
 ', `
 allow $1_xserver_t $1_home_t:file { getattr read };
 ')dnl end ifdef xauth