--- nsaserefpolicy/policy/modules/services/dbus.fc	2008-08-07 11:15:11.000000000 -0400
+++ serefpolicy-3.5.5/policy/modules/services/dbus.fc	2008-08-14 13:53:54.000000000 -0400
@@ -4,6 +4,9 @@
 /usr/bin/dbus-daemon(-1)? --	gen_context(system_u:object_r:system_dbusd_exec_t,s0)
 /bin/dbus-daemon 	--	gen_context(system_u:object_r:system_dbusd_exec_t,s0)
 
+/lib/dbus-1/dbus-daemon-launch-helper 	--	gen_context(system_u:object_r:system_dbusd_exec_t,s0)
+/lib64/dbus-1/dbus-daemon-launch-helper 	--	gen_context(system_u:object_r:system_dbusd_exec_t,s0)
+
 /var/lib/dbus(/.*)?		gen_context(system_u:object_r:system_dbusd_var_lib_t,s0)
 
 /var/run/dbus(/.*)?		gen_context(system_u:object_r:system_dbusd_var_run_t,s0)
--- nsaserefpolicy/policy/modules/services/dbus.if	2008-08-07 11:15:11.000000000 -0400
+++ serefpolicy-3.5.5/policy/modules/services/dbus.if	2008-08-14 13:53:54.000000000 -0400
@@ -53,6 +53,7 @@
 	gen_require(`
 		type system_dbusd_exec_t, system_dbusd_t, dbusd_etc_t;
 		class dbus { send_msg acquire_svc };
+		attribute dbusd_unconfined;
 	')
 
 	##############################
@@ -64,8 +65,6 @@
 	domain_entry_file($1_dbusd_t, system_dbusd_exec_t)
 	role $3 types $1_dbusd_t;
 
-	type $1_dbusd_$1_t;
-
 	type $1_dbusd_tmp_t;
 	files_tmp_file($1_dbusd_tmp_t)
 
@@ -84,14 +83,18 @@
 	allow $1_dbusd_t self:tcp_socket create_stream_socket_perms;
 	allow $1_dbusd_t self:netlink_selinux_socket create_socket_perms;
 
+	allow dbusd_unconfined  $1_dbusd_t:dbus { send_msg acquire_svc };
+	allow $1_dbusd_t dbusd_unconfined:dbus send_msg;
+
 	# For connecting to the bus
-	allow $2 $1_dbusd_t:unix_stream_socket connectto;
-	type_change $2 $1_dbusd_t:dbus $1_dbusd_$1_t;
+	allow $2 $1_dbusd_t:unix_stream_socket { getattr connectto };
+	allow $2 $1_dbusd_t:unix_dgram_socket getattr;
 
 	# SE-DBus specific permissions
-	allow $1_dbusd_$1_t { $1_dbusd_t self }:dbus send_msg;
 	allow $2 $1_dbusd_t:dbus { send_msg acquire_svc };
-	allow $1_t system_dbusd_t:dbus { send_msg acquire_svc };
+	allow $1_dbusd_t $2:dbus send_msg;
+	allow $2 $2:dbus send_msg;
+	allow $2 system_dbusd_t:dbus { send_msg acquire_svc };
 
 	allow $1_dbusd_t dbusd_etc_t:dir list_dir_perms;
 	read_files_pattern($1_dbusd_t, dbusd_etc_t, dbusd_etc_t)
@@ -102,10 +105,9 @@
 	files_tmp_filetrans($1_dbusd_t, $1_dbusd_tmp_t, { file dir })
 
 	domtrans_pattern($2, system_dbusd_exec_t, $1_dbusd_t)
-	allow $2 $1_dbusd_t:process { sigkill signal };
+	allow $2 $1_dbusd_t:process { getattr ptrace signal_perms };
 
-	# cjp: this seems very broken
-	corecmd_bin_domtrans($1_dbusd_t, $2)
+	corecmd_bin_domtrans($1_dbusd_t, $1_t)
 	allow $1_dbusd_t $2:process sigkill;
 	allow $2 $1_dbusd_t:fd use;
 	allow $2 $1_dbusd_t:fifo_file rw_fifo_file_perms;
@@ -115,8 +117,8 @@
 	kernel_read_kernel_sysctls($1_dbusd_t)
 
 	corecmd_list_bin($1_dbusd_t)
-	corecmd_read_bin_symlinks($1_dbusd_t)
 	corecmd_read_bin_files($1_dbusd_t)
+	corecmd_read_bin_symlinks($1_dbusd_t)
 	corecmd_read_bin_pipes($1_dbusd_t)
 	corecmd_read_bin_sockets($1_dbusd_t)
 
@@ -139,6 +141,7 @@
 
 	fs_getattr_romfs($1_dbusd_t)
 	fs_getattr_xattr_fs($1_dbusd_t)
+	fs_list_inotifyfs($1_dbusd_t)
 
 	selinux_get_fs_mount($1_dbusd_t)
 	selinux_validate_context($1_dbusd_t)
@@ -161,12 +164,24 @@
 	seutil_read_config($1_dbusd_t)
 	seutil_read_default_contexts($1_dbusd_t)
 
-	userdom_read_user_home_content_files($1, $1_dbusd_t)
+	sysadm_dontaudit_search_home_dirs($1_dbusd_t)
+	unprivuser_read_home_content_files($1_dbusd_t)
+	unprivuser_dontaudit_append_home_content_files($1_dbusd_t)
+	term_dontaudit_use_all_user_ptys($1_dbusd_t)
+	term_dontaudit_use_all_user_ttys($1_dbusd_t)
 
 	ifdef(`hide_broken_symptoms', `
 		dontaudit $2 $1_dbusd_t:netlink_selinux_socket { read write };
 	')
 
+	tunable_policy(`use_nfs_home_dirs',`
+		fs_read_nfs_files($1_dbusd_t)
+	')
+
+	tunable_policy(`use_samba_home_dirs',`
+		fs_read_cifs_files($1_dbusd_t)
+	')
+
 	tunable_policy(`read_default_t',`
 		files_list_default($1_dbusd_t)
 		files_read_default_files($1_dbusd_t)
@@ -180,8 +195,15 @@
 	')
 
 	optional_policy(`
+		gnome_read_gnome_config($1, $1_dbusd_t)
+		gnome_read_gconf_home_files($1_dbusd_t)
+	')
+
+	optional_policy(`
 		xserver_use_xdm_fds($1_dbusd_t)
 		xserver_rw_xdm_pipes($1_dbusd_t)
+		xserver_dontaudit_xdm_lib_search($1_dbusd_t)
+		xserver_rw_xdm_home_files($1_dbusd_t)
 	')
 ')
 
@@ -207,14 +229,12 @@
 		type system_dbusd_t, system_dbusd_t;
 		type system_dbusd_var_run_t, system_dbusd_var_lib_t;
 		class dbus send_msg;
+		attribute dbusd_unconfined;
 	')
 
-#	type $1_dbusd_system_t;
-#	type_change $2 system_dbusd_t:dbus $1_dbusd_system_t;
-
 	# SE-DBus specific permissions
-#	allow $1_dbusd_system_t { system_dbusd_t self }:dbus send_msg;
-	allow $2 { system_dbusd_t self }:dbus send_msg;
+	allow $2 { system_dbusd_t $2 dbusd_unconfined }:dbus send_msg;
+	allow { system_dbusd_t dbusd_unconfined } $2:dbus send_msg;
 
 	read_files_pattern($2, system_dbusd_var_lib_t, system_dbusd_var_lib_t)
 	files_search_var_lib($2)
@@ -223,6 +243,10 @@
 	files_search_pids($2)
 	stream_connect_pattern($2, system_dbusd_var_run_t, system_dbusd_var_run_t, system_dbusd_t)
 	dbus_read_config($2)
+
+	optional_policy(`
+		rpm_script_dbus_chat($2)
+	')
 ')
 
 #######################################
@@ -251,18 +275,16 @@
 template(`dbus_user_bus_client_template',`
 	gen_require(`
 		type $1_dbusd_t;
+		attribute dbusd_unconfined;
 		class dbus send_msg;
 	')
 
-#	type $2_dbusd_$1_t;
-#	type_change $3 $1_dbusd_t:dbus $2_dbusd_$1_t;
-
 	# SE-DBus specific permissions
-#	allow $2_dbusd_$1_t { $1_dbusd_t self }:dbus send_msg;
 	allow $3 { $1_dbusd_t self }:dbus send_msg;
 
 	# For connecting to the bus
 	allow $3 $1_dbusd_t:unix_stream_socket connectto;
+	allow dbusd_unconfined $1_dbusd_t:dbus *;
 ')
 
 ########################################
@@ -292,6 +314,55 @@
 
 ########################################
 ## <summary>
+##	connectto a message on user/application specific DBUS.
+## </summary>
+## <param name="domain_prefix">
+##	<summary>
+##	The prefix of the domain (e.g., user
+##	is the prefix for user_t).
+##	</summary>
+## </param>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+template(`dbus_connectto_user_bus',`
+	allow $2 $1_dbusd_t:unix_stream_socket connectto;
+')
+
+########################################
+## <summary>
+##	Chat on user/application specific DBUS.
+## </summary>
+## <param name="domain_prefix">
+##	<summary>
+##	The prefix of the domain (e.g., user
+##	is the prefix for user_t).
+##	</summary>
+## </param>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+template(`dbus_chat_user_bus',`
+	gen_require(`
+		type $1_t;
+		type $1_dbusd_t;
+		class dbus send_msg;
+	')
+
+	allow $2 $1_dbusd_t:dbus send_msg;
+	allow $1_dbusd_t $2:dbus send_msg;
+	allow $2 $1_t:dbus send_msg;
+	allow $1_t $2:dbus send_msg;
+')
+
+########################################
+## <summary>
 ##	Read dbus configuration.
 ## </summary>
 ## <param name="domain">
@@ -366,3 +437,75 @@
 
 	allow $1 system_dbusd_t:dbus *;
 ')
+
+########################################
+## <summary>
+##	Allow unconfined access to the system DBUS.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`dbus_unconfined',`
+	gen_require(`
+		attribute dbusd_unconfined;
+	')
+
+	typeattribute $1 dbusd_unconfined;
+')
+
+########################################
+## <summary>
+##	Create a domain for processes
+##	which can be started by the system dbus
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Type to be used as a domain.
+##	</summary>
+## </param>
+## <param name="entry_point">
+##	<summary>
+##	Type of the program to be used as an entry point to this domain.
+##	</summary>
+## </param>
+#
+interface(`dbus_system_domain',`
+	gen_require(`
+		type system_dbusd_t;
+		role system_r;
+
+	')
+
+	domain_type($1)
+	domain_entry_file($1, $2)
+
+	role system_r types $1;
+
+	domtrans_pattern(system_dbusd_t, $2, $1)
+
+	dbus_system_bus_client_template($1, $1)
+	dbus_connect_system_bus($1)
+
+')
+
+########################################
+## <summary>
+##	Dontaudit Read, and write system dbus TCP sockets.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`dbus_dontaudit_system_bus_rw_tcp_sockets',`
+	gen_require(`
+		type system_dbusd_t;
+	')
+
+	allow $1 system_dbusd_t:tcp_socket { read write };
+	allow $1 system_dbusd_t:fd use;
+')
--- nsaserefpolicy/policy/modules/services/dbus.te	2008-08-07 11:15:11.000000000 -0400
+++ serefpolicy-3.5.5/policy/modules/services/dbus.te	2008-08-14 13:53:54.000000000 -0400
@@ -9,9 +9,10 @@
 #
 # Delcarations
 #
+attribute dbusd_unconfined;
 
 type dbusd_etc_t alias etc_dbusd_t;
-files_type(dbusd_etc_t)
+files_config_file(dbusd_etc_t)
 
 type system_dbusd_t alias dbusd_t;
 type system_dbusd_exec_t;
@@ -21,11 +22,23 @@
 files_tmp_file(system_dbusd_tmp_t)
 
 type system_dbusd_var_lib_t;
-files_pid_file(system_dbusd_var_lib_t)
+files_type(system_dbusd_var_lib_t)
 
 type system_dbusd_var_run_t;
 files_pid_file(system_dbusd_var_run_t)
 
+ifdef(`enable_mcs',`
+	init_ranged_daemon_domain(system_dbusd_t, system_dbusd_exec_t,s0 - mcs_systemhigh)
+')
+
+ifdef(`enable_mls',`
+	init_ranged_daemon_domain(system_dbusd_t, system_dbusd_exec_t,s0 - mls_systemhigh)
+	mls_fd_use_all_levels(system_dbusd_t)
+	mls_rangetrans_target(system_dbusd_t)
+	mls_file_read_all_levels(system_dbusd_t)
+	mls_socket_write_all_levels(system_dbusd_t)
+')
+
 ##############################
 #
 # Local policy
@@ -35,7 +48,7 @@
 # cjp: dac_override should probably go in a distro_debian
 allow system_dbusd_t self:capability { dac_override setgid setpcap setuid };
 dontaudit system_dbusd_t self:capability sys_tty_config;
-allow system_dbusd_t self:process { getattr signal_perms setcap };
+allow system_dbusd_t self:process { getattr signal_perms setpgid getcap setcap };
 allow system_dbusd_t self:fifo_file { read write };
 allow system_dbusd_t self:dbus { send_msg acquire_svc };
 allow system_dbusd_t self:unix_stream_socket { connectto create_stream_socket_perms connectto };
@@ -43,6 +56,8 @@
 # Receive notifications of policy reloads and enforcing status changes.
 allow system_dbusd_t self:netlink_selinux_socket { create bind read };
 
+can_exec(system_dbusd_t, system_dbusd_exec_t)
+
 allow system_dbusd_t dbusd_etc_t:dir list_dir_perms;
 read_files_pattern(system_dbusd_t, dbusd_etc_t, dbusd_etc_t)
 read_lnk_files_pattern(system_dbusd_t, dbusd_etc_t, dbusd_etc_t)
@@ -65,6 +80,8 @@
 
 fs_getattr_all_fs(system_dbusd_t)
 fs_search_auto_mountpoints(system_dbusd_t)
+fs_list_inotifyfs(system_dbusd_t)
+fs_dontaudit_list_nfs(system_dbusd_t)
 
 selinux_get_fs_mount(system_dbusd_t)
 selinux_validate_context(system_dbusd_t)
@@ -81,7 +98,6 @@
 corecmd_list_bin(system_dbusd_t)
 corecmd_read_bin_pipes(system_dbusd_t)
 corecmd_read_bin_sockets(system_dbusd_t)
-corecmd_exec_bin(system_dbusd_t)
 
 domain_use_interactive_fds(system_dbusd_t)
 
@@ -91,6 +107,8 @@
 
 init_use_fds(system_dbusd_t)
 init_use_script_ptys(system_dbusd_t)
+init_dbus_chat_script(system_dbusd_t)
+init_bin_domtrans_spec(system_dbusd_t)
 
 libs_use_ld_so(system_dbusd_t)
 libs_use_shared_libs(system_dbusd_t)
@@ -122,9 +140,38 @@
 ')
 
 optional_policy(`
+	gnome_exec_gconf(system_dbusd_t)
+')
+
+optional_policy(`
+	networkmanager_init_script_domtrans_spec(system_dbusd_t)
+')
+
+optional_policy(`
+	polkit_domtrans_auth(system_dbusd_t)
+	polkit_search_lib(system_dbusd_t)
+')
+
+optional_policy(`
 	sysnet_domtrans_dhcpc(system_dbusd_t)
 ')
 
 optional_policy(`
 	udev_read_db(system_dbusd_t)
 ')
+
+optional_policy(`
+	consolekit_dbus_chat(system_dbusd_t)
+')
+
+optional_policy(`
+	gen_require(`
+		type unconfined_dbusd_t;
+	')
+	unconfined_domain(unconfined_dbusd_t)
+	unconfined_execmem_domtrans(unconfined_dbusd_t)
+
+	optional_policy(`
+		xserver_xdm_rw_shm(unconfined_dbusd_t)
+	')
+')
