policy_module(dpkg,1.1.2) ######################################## # # Declarations # type dpkg_t; type dpkg_exec_t; # dpkg can start/stop services init_system_domain(dpkg_t,dpkg_exec_t) # dpkg can change file labels, roles, IO domain_obj_id_change_exemption(dpkg_t) domain_role_change_exemption(dpkg_t) domain_system_change_exemption(dpkg_t) domain_interactive_fd(dpkg_t) role system_r types dpkg_t; # lockfile type dpkg_lock_t; files_type(dpkg_lock_t) type dpkg_tmp_t; files_tmp_file(dpkg_tmp_t) type dpkg_tmpfs_t; files_tmpfs_file(dpkg_tmpfs_t) # status files type dpkg_var_lib_t alias var_lib_dpkg_t; files_type(dpkg_var_lib_t) # package scripts type dpkg_script_t; domain_type(dpkg_script_t) domain_entry_file(dpkg_t, dpkg_var_lib_t) corecmd_shell_entry_type(dpkg_script_t) domain_obj_id_change_exemption(dpkg_script_t) domain_system_change_exemption(dpkg_script_t) domain_interactive_fd(dpkg_script_t) role system_r types dpkg_script_t; type dpkg_script_tmp_t; files_tmp_file(dpkg_script_tmp_t) type dpkg_script_tmpfs_t; files_tmpfs_file(dpkg_script_tmpfs_t) ######################################## # # dpkg Local policy # allow dpkg_t self:capability { chown dac_override fowner fsetid setgid setuid kill sys_tty_config sys_nice sys_resource mknod linux_immutable }; allow dpkg_t self:process { setpgid fork getsched setfscreate }; allow dpkg_t self:fd use; allow dpkg_t self:fifo_file rw_fifo_file_perms; allow dpkg_t self:unix_dgram_socket create_socket_perms; allow dpkg_t self:unix_stream_socket rw_stream_socket_perms; allow dpkg_t self:unix_dgram_socket sendto; allow dpkg_t self:unix_stream_socket connectto; allow dpkg_t self:udp_socket { connect create_socket_perms }; allow dpkg_t self:tcp_socket create_stream_socket_perms; allow dpkg_t self:shm create_shm_perms; allow dpkg_t self:sem create_sem_perms; allow dpkg_t self:msgq create_msgq_perms; allow dpkg_t self:msg { send receive }; allow dpkg_t dpkg_lock_t:file manage_file_perms; manage_dirs_pattern(dpkg_t,dpkg_tmp_t,dpkg_tmp_t) manage_files_pattern(dpkg_t,dpkg_tmp_t,dpkg_tmp_t) files_tmp_filetrans(dpkg_t, dpkg_tmp_t, { file dir }) manage_dirs_pattern(dpkg_t,dpkg_tmpfs_t,dpkg_tmpfs_t) manage_files_pattern(dpkg_t,dpkg_tmpfs_t,dpkg_tmpfs_t) manage_lnk_files_pattern(dpkg_t,dpkg_tmpfs_t,dpkg_tmpfs_t) manage_sock_files_pattern(dpkg_t,dpkg_tmpfs_t,dpkg_tmpfs_t) manage_fifo_files_pattern(dpkg_t,dpkg_tmpfs_t,dpkg_tmpfs_t) fs_tmpfs_filetrans(dpkg_t,dpkg_tmpfs_t,{ dir file lnk_file sock_file fifo_file }) # Access /var/lib/dpkg files manage_files_pattern(dpkg_t,dpkg_var_lib_t,dpkg_var_lib_t) files_var_lib_filetrans(dpkg_t,dpkg_var_lib_t,dir) kernel_read_system_state(dpkg_t) kernel_read_kernel_sysctls(dpkg_t) corecmd_exec_all_executables(dpkg_t) # TODO: do we really need all networking? corenet_all_recvfrom_unlabeled(dpkg_t) corenet_all_recvfrom_netlabel(dpkg_t) corenet_tcp_sendrecv_all_if(dpkg_t) corenet_raw_sendrecv_all_if(dpkg_t) corenet_udp_sendrecv_all_if(dpkg_t) corenet_tcp_sendrecv_all_nodes(dpkg_t) corenet_raw_sendrecv_all_nodes(dpkg_t) corenet_udp_sendrecv_all_nodes(dpkg_t) corenet_tcp_sendrecv_all_ports(dpkg_t) corenet_udp_sendrecv_all_ports(dpkg_t) corenet_tcp_connect_all_ports(dpkg_t) corenet_sendrecv_all_client_packets(dpkg_t) dev_list_sysfs(dpkg_t) dev_list_usbfs(dpkg_t) dev_read_urand(dpkg_t) #devices_manage_all_device_types(dpkg_t) domain_read_all_domains_state(dpkg_t) domain_getattr_all_domains(dpkg_t) domain_dontaudit_ptrace_all_domains(dpkg_t) domain_use_interactive_fds(dpkg_t) domain_dontaudit_getattr_all_pipes(dpkg_t) domain_dontaudit_getattr_all_tcp_sockets(dpkg_t) domain_dontaudit_getattr_all_udp_sockets(dpkg_t) domain_dontaudit_getattr_all_packet_sockets(dpkg_t) domain_dontaudit_getattr_all_raw_sockets(dpkg_t) domain_dontaudit_getattr_all_stream_sockets(dpkg_t) domain_dontaudit_getattr_all_dgram_sockets(dpkg_t) fs_manage_nfs_dirs(dpkg_t) fs_manage_nfs_files(dpkg_t) fs_manage_nfs_symlinks(dpkg_t) fs_getattr_all_fs(dpkg_t) fs_search_auto_mountpoints(dpkg_t) mls_file_read_up(dpkg_t) mls_file_write_down(dpkg_t) mls_file_upgrade(dpkg_t) selinux_get_fs_mount(dpkg_t) selinux_validate_context(dpkg_t) selinux_compute_access_vector(dpkg_t) selinux_compute_create_context(dpkg_t) selinux_compute_relabel_context(dpkg_t) selinux_compute_user_contexts(dpkg_t) storage_raw_write_fixed_disk(dpkg_t) # for installing kernel packages storage_raw_read_fixed_disk(dpkg_t) term_list_ptys(dpkg_t) auth_relabel_all_files_except_shadow(dpkg_t) auth_manage_all_files_except_shadow(dpkg_t) auth_dontaudit_read_shadow(dpkg_t) files_exec_etc_files(dpkg_t) init_domtrans_script(dpkg_t) libs_use_ld_so(dpkg_t) libs_use_shared_libs(dpkg_t) libs_exec_ld_so(dpkg_t) libs_exec_lib_files(dpkg_t) libs_domtrans_ldconfig(dpkg_t) logging_send_syslog_msg(dpkg_t) # allow compiling and loading new policy seutil_manage_src_policy(dpkg_t) seutil_manage_bin_policy(dpkg_t) sysnet_read_config(dpkg_t) userdom_use_unpriv_users_fds(dpkg_t) # transition to dpkg script: dpkg_domtrans_script(dpkg_t) # since the scripts aren't labeled correctly yet... allow dpkg_t dpkg_var_lib_t:file execute; ifdef(`targeted_policy',` unconfined_domain(dpkg_t) ') # TODO: allow? #optional_policy(` # cron_system_entry(dpkg_t,dpkg_exec_t) #') optional_policy(` nis_use_ypbind(dpkg_t) ') # TODO: the following was copied from dpkg_script_t, and could probably # be removed again when dpkg_script_t is actually used... domain_signal_all_domains(dpkg_t) domain_signull_all_domains(dpkg_t) files_read_etc_runtime_files(dpkg_t) files_exec_usr_files(dpkg_t) miscfiles_read_localization(dpkg_t) modutils_domtrans_depmod(dpkg_t) modutils_domtrans_insmod(dpkg_t) seutil_domtrans_loadpolicy(dpkg_t) seutil_domtrans_setfiles(dpkg_t) userdom_use_all_users_fds(dpkg_t) optional_policy(` mta_send_mail(dpkg_t) ') optional_policy(` usermanage_domtrans_groupadd(dpkg_t) usermanage_domtrans_useradd(dpkg_t) ') ######################################## # # dpkg-script Local policy # # TODO: actually use dpkg_script_t allow dpkg_script_t self:capability { chown dac_override dac_read_search fowner fsetid setgid setuid ipc_lock sys_chroot sys_nice mknod kill }; allow dpkg_script_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap }; allow dpkg_script_t self:fd use; allow dpkg_script_t self:fifo_file rw_file_perms; allow dpkg_script_t self:unix_dgram_socket create_socket_perms; allow dpkg_script_t self:unix_stream_socket rw_stream_socket_perms; allow dpkg_script_t self:unix_dgram_socket sendto; allow dpkg_script_t self:unix_stream_socket connectto; allow dpkg_script_t self:shm create_shm_perms; allow dpkg_script_t self:sem create_sem_perms; allow dpkg_script_t self:msgq create_msgq_perms; allow dpkg_script_t self:msg { send receive }; allow dpkg_script_t dpkg_tmp_t:file r_file_perms; allow dpkg_script_t dpkg_script_tmp_t:dir { manage_dir_perms mounton }; allow dpkg_script_t dpkg_script_tmp_t:file manage_file_perms; files_tmp_filetrans(dpkg_script_t, dpkg_script_tmp_t, { file dir }) allow dpkg_script_t dpkg_script_tmpfs_t:dir manage_dir_perms; allow dpkg_script_t dpkg_script_tmpfs_t:file manage_file_perms; allow dpkg_script_t dpkg_script_tmpfs_t:lnk_file create_lnk_perms; allow dpkg_script_t dpkg_script_tmpfs_t:sock_file manage_file_perms; allow dpkg_script_t dpkg_script_tmpfs_t:fifo_file manage_file_perms; fs_tmpfs_filetrans(dpkg_script_t,dpkg_script_tmpfs_t,{ dir file lnk_file sock_file fifo_file }) kernel_read_kernel_sysctls(dpkg_script_t) kernel_read_system_state(dpkg_script_t) corecmd_exec_all_executables(dpkg_script_t) dev_list_sysfs(dpkg_script_t) # ideally we would not need this dev_manage_generic_blk_files(dpkg_script_t) dev_manage_generic_chr_files(dpkg_script_t) dev_manage_all_blk_files(dpkg_script_t) dev_manage_all_chr_files(dpkg_script_t) domain_read_all_domains_state(dpkg_script_t) domain_getattr_all_domains(dpkg_script_t) domain_dontaudit_ptrace_all_domains(dpkg_script_t) domain_use_interactive_fds(dpkg_script_t) domain_signal_all_domains(dpkg_script_t) domain_signull_all_domains(dpkg_script_t) files_exec_etc_files(dpkg_script_t) files_read_etc_runtime_files(dpkg_script_t) files_exec_usr_files(dpkg_script_t) fs_manage_nfs_files(dpkg_script_t) fs_getattr_nfs(dpkg_script_t) # why is this not using mount? fs_getattr_xattr_fs(dpkg_script_t) fs_mount_xattr_fs(dpkg_script_t) fs_unmount_xattr_fs(dpkg_script_t) fs_search_auto_mountpoints(dpkg_script_t) mls_file_read_up(dpkg_script_t) mls_file_write_down(dpkg_script_t) selinux_get_fs_mount(dpkg_script_t) selinux_validate_context(dpkg_script_t) selinux_compute_access_vector(dpkg_script_t) selinux_compute_create_context(dpkg_script_t) selinux_compute_relabel_context(dpkg_script_t) selinux_compute_user_contexts(dpkg_script_t) storage_raw_read_fixed_disk(dpkg_script_t) storage_raw_write_fixed_disk(dpkg_script_t) term_getattr_unallocated_ttys(dpkg_script_t) term_list_ptys(dpkg_script_t) 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_shadow(dpkg_script_t) init_domtrans_script(dpkg_script_t) libs_use_ld_so(dpkg_script_t) libs_use_shared_libs(dpkg_script_t) libs_exec_ld_so(dpkg_script_t) libs_exec_lib_files(dpkg_script_t) libs_domtrans_ldconfig(dpkg_script_t) logging_send_syslog_msg(dpkg_script_t) miscfiles_read_localization(dpkg_script_t) modutils_domtrans_depmod(dpkg_script_t) modutils_domtrans_insmod(dpkg_script_t) seutil_domtrans_loadpolicy(dpkg_script_t) seutil_domtrans_setfiles(dpkg_script_t) userdom_use_all_users_fds(dpkg_script_t) ifdef(`distro_redhat',` unconfined_domain(dpkg_script_t) ') ifdef(`targeted_policy',` unconfined_domain(dpkg_script_t) ',` optional_policy(` bootloader_domtrans(dpkg_script_t) ') ') tunable_policy(`allow_execmem',` allow dpkg_script_t self:process execmem; ') optional_policy(` mta_send_mail(dpkg_script_t) ') optional_policy(` nis_use_ypbind(dpkg_script_t) ') optional_policy(` usermanage_domtrans_groupadd(dpkg_script_t) usermanage_domtrans_useradd(dpkg_script_t) ')