From: guido@trentalancia.net (Guido Trentalancia) Date: Fri, 09 Sep 2016 14:11:16 +0200 Subject: [refpolicy] [PATCH v5] cups: update permissions for HP printers (load firmware) In-Reply-To: References: <1473185308.11558.1.camel@trentalancia.net> <1473191553.11558.3.camel@trentalancia.net> <1473266789.11558.6.camel@trentalancia.net> <1473351558.2887.6.camel@trentalancia.net> Message-ID: <1473423076.23131.5.camel@trentalancia.net> To: refpolicy@oss.tresys.com List-Id: refpolicy.oss.tresys.com Update the cups module with some permissions needed to run HP printers (in particular to be able to load firmware on those printers that need it every time they are connected). The permission to execute shell scripts has been removed in this new version, as this is not required. Compared to previous versions, this new version creates a specific hplip pty (as suggested by Christopher PeBenito). Here is the list of printers that require firmware loading: HP LaserJet 1000 HP LaserJet 1005 series HP LaserJet 1018 HP LaserJet 1020 HP LaserJet p1005 HP LaserJet p1006 HP LaserJet p1007 HP LaserJet p1008 HP LaserJet p1009 HP LaserJet p1505 HP LaserJet Professional p1102 HP LaserJet Professional p1102w HP LaserJet Professional p1566 Signed-off-by: Guido Trentalancia --- policy/modules/contrib/cups.te | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) --- refpolicy-git-06082016-orig/policy/modules/contrib/cups.te 2016-08-07 23:05:57.061018507 +0200 +++ refpolicy-git-06082016/policy/modules/contrib/cups.te 2016-09-09 14:01:19.182918381 +0200 @@ -71,6 +68,9 @@ type hplip_exec_t; init_daemon_domain(hplip_t, hplip_exec_t) cups_backend(hplip_t, hplip_exec_t) +type hplip_devpts_t; +term_pty(hplip_devpts_t) + type hplip_etc_t; files_config_file(hplip_etc_t) @@ -157,6 +157,10 @@ read_files_pattern(cupsd_t, hplip_etc_t, allow cupsd_t hplip_var_run_t:file read_file_perms; +# hpcups +read_files_pattern(cupsd_t, hplip_var_lib_t, hplip_var_lib_t) +read_lnk_files_pattern(cupsd_t, hplip_var_lib_t, hplip_var_lib_t) + stream_connect_pattern(cupsd_t, ptal_var_run_t, ptal_var_run_t, ptal_t) allow cupsd_t ptal_var_run_t:sock_file setattr_sock_file_perms; @@ -300,6 +304,10 @@ optional_policy(` ') optional_policy(` + init_dbus_chat_script(cupsd_t) +') + +optional_policy(` kerberos_manage_host_rcache(cupsd_t) kerberos_tmp_filetrans_host_rcache(cupsd_t, file, "host_0") ') @@ -426,6 +434,8 @@ miscfiles_read_hwdata(cupsd_config_t) seutil_dontaudit_search_config(cupsd_config_t) +term_use_generic_ptys(cupsd_config_t) + userdom_dontaudit_use_unpriv_user_fds(cupsd_config_t) userdom_dontaudit_search_user_home_dirs(cupsd_config_t) userdom_read_all_users_state(cupsd_config_t) @@ -433,10 +443,6 @@ userdom_read_user_tmp_symlinks(cupsd_con userdom_rw_user_tmp_files(cupsd_config_t) optional_policy(` - term_use_generic_ptys(cupsd_config_t) -') - -optional_policy(` cron_system_entry(cupsd_config_t, cupsd_config_exec_t) ') @@ -608,9 +614,12 @@ allow hplip_t self:capability { dac_over dontaudit hplip_t self:capability sys_tty_config; allow hplip_t self:fifo_file rw_fifo_file_perms; allow hplip_t self:process signal_perms; +allow hplip_t self:netlink_kobject_uevent_socket create_socket_perms; allow hplip_t self:tcp_socket { accept listen }; allow hplip_t self:rawip_socket create_socket_perms; +allow hplip_t hplip_devpts_t:chr_file { rw_chr_file_perms setattr_chr_file_perms }; + allow hplip_t cupsd_etc_t:dir search_dir_perms; manage_dirs_pattern(hplip_t, cupsd_tmp_t, cupsd_tmp_t) @@ -635,6 +644,9 @@ stream_connect_pattern(hplip_t, cupsd_va kernel_read_system_state(hplip_t) kernel_read_kernel_sysctls(hplip_t) +# e.g. execute python script to load the firmware +can_exec(hplip_t, hplip_exec_t) + corenet_all_recvfrom_unlabeled(hplip_t) corenet_all_recvfrom_netlabel(hplip_t) corenet_tcp_sendrecv_generic_if(hplip_t) @@ -684,6 +696,10 @@ miscfiles_read_localization(hplip_t) sysnet_dns_name_resolve(hplip_t) +term_create_pty(hplip_t, hplip_devpts_t) +term_use_generic_ptys(hplip_t) +term_use_ptmx(hplip_t) + userdom_dontaudit_use_unpriv_user_fds(hplip_t) userdom_dontaudit_search_user_home_dirs(hplip_t) userdom_dontaudit_search_user_home_content(hplip_t)