diff --git a/refpolicy/Changelog b/refpolicy/Changelog index 643aded..74107e3 100644 --- a/refpolicy/Changelog +++ b/refpolicy/Changelog @@ -2,6 +2,7 @@ or templates on the module page. - Added policies: comsat + dbus * Fri Aug 26 2005 Chris PeBenito - 20050826 - Add Makefile support for building loadable modules. diff --git a/refpolicy/policy/modules/admin/updfstab.te b/refpolicy/policy/modules/admin/updfstab.te index 7b59329..7998aa2 100644 --- a/refpolicy/policy/modules/admin/updfstab.te +++ b/refpolicy/policy/modules/admin/updfstab.te @@ -93,6 +93,10 @@ optional_policy(`authlogin.te',` auth_domtrans_pam_console(updfstab_t) ') +optional_policy(`dbus.te',` + dbus_system_bus_client_template(updfstab,updfstab_t) +') + optional_policy(`modutils.te',` modutils_read_module_conf(updfstab_t) modutils_exec_insmod(updfstab_t) @@ -112,8 +116,5 @@ optional_policy(`udev.te',` ') ifdef(`TODO',` -ifdef(`dbusd.te', ` -dbusd_client(system, updfstab) allow updfstab_t system_dbusd_t:dbus { send_msg }; -') ') dnl end TODO diff --git a/refpolicy/policy/modules/services/dbus.fc b/refpolicy/policy/modules/services/dbus.fc new file mode 100644 index 0000000..1479093 --- /dev/null +++ b/refpolicy/policy/modules/services/dbus.fc @@ -0,0 +1,5 @@ +/etc/dbus-1(/.*)? context_template(system_u:object_r:etc_dbusd_t,s0) + +/usr/bin/dbus-daemon(-1)? -- context_template(system_u:object_r:system_dbusd_exec_t,s0) + +/var/run/dbus(/.*)? context_template(system_u:object_r:system_dbusd_var_run_t,s0) diff --git a/refpolicy/policy/modules/services/dbus.if b/refpolicy/policy/modules/services/dbus.if new file mode 100644 index 0000000..efe31f0 --- /dev/null +++ b/refpolicy/policy/modules/services/dbus.if @@ -0,0 +1,150 @@ +## Desktop messaging bus + +####################################### +## +## The per user domain template for the dbus module. +## +## +##

+## This template creates a derived domain which is +## used for the user dbus. +##

+##

+## This template is invoked automatically for each user, and +## generally does not need to be invoked directly +## by policy writers. +##

+##
+## +## The prefix of the user domain (e.g., user +## is the prefix for user_t). +## +## +## The type of the user domain. +## +## +## The role associated with the user domain. +## +# +template(`dbus_per_userdomain_template',` + ############################## + # + # Delcarations + # + type $1_dbusd_t; + domain_type($1_dbusd_t) + role $3 types $1_dbusd_t; + + type $1_dbusd_tmp_t; + files_tmp_file($1_dbusd_tmp_t) + + ############################## + # + # Local policy + # + + allow $1_dbusd_t self:process { getattr sigkill signal }; + allow $1_dbusd_t self:dbus { send_msg acquire_svc }; + allow $1_dbusd_t self:unix_stream_socket create_stream_socket_perms; + allow $1_dbusd_t self:unix_dgram_socket create_socket_perms; + # Receive notifications of policy reloads and enforcing status changes. + allow $1_dbusd_t self:netlink_selinux_socket { create bind read }; + + allow $1_dbusd_t dbusd_etc_t:dir r_dir_perms; + allow $1_dbusd_t dbusd_etc_t:file r_file_perms; + allow $1_dbusd_t dbusd_etc_t:lnk_file { getattr read }; + + allow $1_dbusd_t $1_dbusd_tmp_t:dir create_dir_perms; + allow $1_dbusd_t $1_dbusd_tmp_t:file create_file_perms; + files_create_tmp_files($1_dbusd_t, $1_dbusd_tmp_t, { file dir }) + + domain_auto_trans($2, system_dbusd_exec_t, $1_dbusd_t) + allow $2 $1_dbusd_t:fd use; + allow $1_dbusd_t $2:fd use; + allow $1_dbusd_t $2:fifo_file rw_file_perms; + allow $1_dbusd_t $2:process sigchld; + + allow $2 $1_dbusd_t:process { sigkill signal }; + + kernel_read_system_state($1_dbusd_t) + kernel_read_kernel_sysctl($1_dbusd_t) + + dev_read_urand($1_dbusd_t) + + selinux_get_fs_mount($1_dbusd_t) + selinux_validate_context($1_dbusd_t) + selinux_compute_access_vector($1_dbusd_t) + selinux_compute_create_context($1_dbusd_t) + selinux_compute_relabel_context($1_dbusd_t) + selinux_compute_user_contexts($1_dbusd_t) + + corecmd_list_bin($1_dbusd_t) + corecmd_read_bin_symlink($1_dbusd_t) + corecmd_read_bin_file($1_dbusd_t) + corecmd_read_bin_pipe($1_dbusd_t) + corecmd_read_bin_socket($1_dbusd_t) + corecmd_list_sbin($1_dbusd_t) + corecmd_read_sbin_symlink($1_dbusd_t) + corecmd_read_sbin_file($1_dbusd_t) + corecmd_read_sbin_pipe($1_dbusd_t) + corecmd_read_sbin_socket($1_dbusd_t) + + files_read_etc_files($1_dbusd_t) + files_list_home($1_dbusd_t) + files_read_usr_files($1_dbusd_t) + files_dontaudit_search_var($1_dbusd_t) + + libs_use_ld_so($1_dbusd_t) + libs_use_shared_libs($1_dbusd_t) + + logging_send_syslog_msg($1_dbusd_t) + + miscfiles_read_localization($1_dbusd_t) + + seutil_read_config($1_dbusd_t) + seutil_read_default_contexts($1_dbusd_t) + + tunable_policy(`read_default_t',` + files_list_default($1_dbusd_t) + files_read_default_files($1_dbusd_t) + files_read_default_symlinks($1_dbusd_t) + files_read_default_sockets($1_dbusd_t) + files_read_default_pipes($1_dbusd_t) + ') + + optional_policy(`authlogin.te',` + auth_read_pam_console_data($1_dbusd_t) + ') + + optional_policy(`nscd.te',` + nscd_use_socket($1_dbusd_t) + ') +') + +####################################### +## +## Template for creating connections to +## the system DBUS. +## +## +## The prefix of the domain (e.g., user +## is the prefix for user_t). +## +## +## The type of the domain. +## +# +template(`dbus_system_bus_client_template',` + + 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; + + # For connecting to the bus + files_search_pids($2) + allow $2 system_dbusd_var_run_t:dir search; + allow $2 system_dbusd_var_run_t:sock_file write; + allow $2 system_dbusd_t:unix_stream_socket connectto; +') diff --git a/refpolicy/policy/modules/services/dbus.te b/refpolicy/policy/modules/services/dbus.te new file mode 100644 index 0000000..f2c4688 --- /dev/null +++ b/refpolicy/policy/modules/services/dbus.te @@ -0,0 +1,134 @@ + +policy_module(dbus,1.0) + +############################## +# +# Delcarations +# + +type dbusd_etc_t alias etc_dbusd_t; +files_type(dbusd_etc_t) + +type system_dbusd_t alias dbusd_t; +type system_dbusd_exec_t; +init_daemon_domain(system_dbusd_t,system_dbusd_exec_t) + +type system_dbusd_tmp_t; +files_tmp_file(system_dbusd_tmp_t) + +type system_dbusd_var_run_t; +files_pid_file(system_dbusd_var_run_t) + +############################## +# +# Local policy +# + +# dac_override: /var/run/dbus is owned by messagebus on Debian +# cjp: dac_override should probably go in a distro_debian +allow system_dbusd_t self:capability { dac_override setgid setuid }; +dontaudit system_dbusd_t self:capability sys_tty_config; +allow system_dbusd_t self:process getattr; +allow system_dbusd_t self:dbus { send_msg acquire_svc }; +allow system_dbusd_t self:unix_stream_socket create_stream_socket_perms; +allow system_dbusd_t self:unix_dgram_socket create_socket_perms; +# Receive notifications of policy reloads and enforcing status changes. +allow system_dbusd_t self:netlink_selinux_socket { create bind read }; + +allow system_dbusd_t dbusd_etc_t:dir r_dir_perms; +allow system_dbusd_t dbusd_etc_t:file r_file_perms; +allow system_dbusd_t dbusd_etc_t:lnk_file { getattr read }; + +allow system_dbusd_t system_dbusd_tmp_t:dir create_dir_perms; +allow system_dbusd_t system_dbusd_tmp_t:file create_file_perms; +files_create_tmp_files(system_dbusd_t, system_dbusd_tmp_t, { file dir }) + +allow system_dbusd_t system_dbusd_var_run_t:file create_file_perms; +allow system_dbusd_t system_dbusd_var_run_t:sock_file create_file_perms; +files_create_pid(system_dbusd_t,system_dbusd_var_run_t) + +kernel_read_system_state(system_dbusd_t) +kernel_read_kernel_sysctl(system_dbusd_t) + +dev_read_urand(system_dbusd_t) +dev_read_sysfs(system_dbusd_t) + +fs_getattr_all_fs(system_dbusd_t) +fs_search_auto_mountpoints(system_dbusd_t) + +selinux_get_fs_mount(system_dbusd_t) +selinux_validate_context(system_dbusd_t) +selinux_compute_access_vector(system_dbusd_t) +selinux_compute_create_context(system_dbusd_t) +selinux_compute_relabel_context(system_dbusd_t) +selinux_compute_user_contexts(system_dbusd_t) + +term_dontaudit_use_console(system_dbusd_t) + +corecmd_list_bin(system_dbusd_t) +corecmd_read_bin_symlink(system_dbusd_t) +corecmd_read_bin_file(system_dbusd_t) +corecmd_read_bin_pipe(system_dbusd_t) +corecmd_read_bin_socket(system_dbusd_t) +corecmd_list_sbin(system_dbusd_t) +corecmd_read_sbin_symlink(system_dbusd_t) +corecmd_read_sbin_file(system_dbusd_t) +corecmd_read_sbin_pipe(system_dbusd_t) +corecmd_read_sbin_socket(system_dbusd_t) + +domain_use_wide_inherit_fd(system_dbusd_t) + +files_read_etc_files(system_dbusd_t) +files_list_home(system_dbusd_t) +files_read_usr_files(system_dbusd_t) + +init_use_fd(system_dbusd_t) +init_use_script_pty(system_dbusd_t) + +libs_use_ld_so(system_dbusd_t) +libs_use_shared_libs(system_dbusd_t) + +logging_send_syslog_msg(system_dbusd_t) + +miscfiles_read_localization(system_dbusd_t) + +seutil_read_config(system_dbusd_t) +seutil_read_default_contexts(system_dbusd_t) +seutil_sigchld_newrole(system_dbusd_t) + +userdom_dontaudit_use_unpriv_user_fd(system_dbusd_t) +userdom_dontaudit_search_sysadm_home_dir(system_dbusd_t) + +ifdef(`targeted_policy', ` + term_dontaudit_use_unallocated_tty(system_dbusd_t) + term_dontaudit_use_generic_pty(system_dbusd_t) + files_dontaudit_read_root_file(system_dbusd_t) +') + +tunable_policy(`read_default_t',` + files_list_default(system_dbusd_t) + files_read_default_files(system_dbusd_t) + files_read_default_symlinks(system_dbusd_t) + files_read_default_sockets(system_dbusd_t) + files_read_default_pipes(system_dbusd_t) +') + +optional_policy(`authlogin.te',` + auth_read_pam_console_data(system_dbusd_t) +') + +optional_policy(`nis.te',` + nis_use_ypbind(system_dbusd_t) +') + +optional_policy(`nscd.te',` + nscd_use_socket(system_dbusd_t) +') + +optional_policy(`rhgb.te',` + rhgb_domain(system_dbusd_t) +') + +optional_policy(`udev.te', ` + udev_read_db(system_dbusd_t) +') diff --git a/refpolicy/policy/modules/system/hotplug.te b/refpolicy/policy/modules/system/hotplug.te index 88b9a5b..6a69a96 100644 --- a/refpolicy/policy/modules/system/hotplug.te +++ b/refpolicy/policy/modules/system/hotplug.te @@ -130,6 +130,10 @@ optional_policy(`consoletype.te',` consoletype_domtrans(hotplug_t) ') +optional_policy(`dbus.te',` + dbus_system_bus_client_template(hotplug,hotplug_t) +') + optional_policy(`fstools.te',` fstools_domtrans(hotplug_t) ') @@ -182,8 +186,6 @@ rhgb_domain(hotplug_t) allow kernel_t hotplug_etc_t:dir search; -dbusd_client(system, hotplug) - # for ps dontaudit hotplug_t domain:dir { getattr search }; dontaudit hotplug_t { init_t kernel_t }:file read; diff --git a/refpolicy/policy/modules/system/init.te b/refpolicy/policy/modules/system/init.te index 0e3d06a..3fa5e6b 100644 --- a/refpolicy/policy/modules/system/init.te +++ b/refpolicy/policy/modules/system/init.te @@ -481,6 +481,8 @@ ifdef(`TODO',` # Set device ownerships/modes. allow initrc_t xconsole_device_t:fifo_file setattr; +allow initrc_t system_dbusd_t:dbus { send_msg acquire_svc }; + # # These rules are here to allow init scripts to su # diff --git a/refpolicy/policy/modules/system/udev.te b/refpolicy/policy/modules/system/udev.te index e0169f3..d4c2038 100644 --- a/refpolicy/policy/modules/system/udev.te +++ b/refpolicy/policy/modules/system/udev.te @@ -148,6 +148,10 @@ optional_policy(`consoletype.te',` consoletype_exec(udev_t) ') +optional_policy(`dbus.te',` + dbus_system_bus_client_template(udev,udev_t) +') + optional_policy(`hotplug.te',` hotplug_read_config(udev_t) ') @@ -166,5 +170,4 @@ optional_policy(`xserver.te',` ifdef(`TODO',` dontaudit udev_t ttyfile:chr_file unlink; -dbusd_client(system, udev) ') dnl endif TODO diff --git a/refpolicy/policy/modules/system/userdomain.if b/refpolicy/policy/modules/system/userdomain.if index b132ba2..9015581 100644 --- a/refpolicy/policy/modules/system/userdomain.if +++ b/refpolicy/policy/modules/system/userdomain.if @@ -240,6 +240,10 @@ template(`base_user_template',` term_getattr_all_user_ttys($1_t) ') + optional_policy(`dbus.te',` + dbus_system_bus_client_template($1,$1_t) + ') + optional_policy(`inetd.te',` inetd_tcp_connect($1_t) ') @@ -345,14 +349,12 @@ template(`base_user_template',` # Grant permissions to access the system DBus ifdef(`dbusd.te', ` - dbusd_client(system, $1) can_network_server_tcp($1_dbusd_t) allow $1_dbusd_t reserved_port_t:tcp_socket name_bind; allow $1_t system_dbusd_t:dbus { send_msg acquire_svc }; dbusd_client($1, $1) allow $1_t $1_dbusd_t:dbus { send_msg acquire_svc }; - dbusd_domain($1) ifdef(`hald.te', ` allow $1_t hald_t:dbus send_msg; allow hald_t $1_t:dbus send_msg;