From: pebenito@ieee.org (Chris PeBenito) Date: Wed, 7 Sep 2016 18:01:03 -0400 Subject: [refpolicy] [PATCH v3] cups: update permissions for HP printers (load firmware) In-Reply-To: <1473266789.11558.6.camel@trentalancia.net> References: <1473185308.11558.1.camel@trentalancia.net> <1473191553.11558.3.camel@trentalancia.net> <1473266789.11558.6.camel@trentalancia.net> Message-ID: To: refpolicy@oss.tresys.com List-Id: refpolicy.oss.tresys.com On 09/07/16 12:46, Guido Trentalancia via refpolicy wrote: > 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. > > 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 | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > --- 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-06 20:03:49.511295021 +0200 > @@ -157,6 +154,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 +301,9 @@ optional_policy(` > ') > > optional_policy(` > + init_dbus_chat_script(cupsd_t) > +') > +optional_policy(` nitpick: Needs a blank line between the blocks. > kerberos_manage_host_rcache(cupsd_t) > kerberos_tmp_filetrans_host_rcache(cupsd_t, file, "host_0") > ') > @@ -608,6 +612,7 @@ 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; > > @@ -635,6 +640,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) > @@ -710,6 +720,11 @@ optional_policy(` > ') > > optional_policy(` > + term_use_generic_ptys(hplip_t) > + term_use_ptmx(hplip_t) > +') It looks like hplip is opening up a pty, so there should be a new pty type (add term_pty()) and use term_create_pty() to get it created with that type. Also, I don't see why this is optional. > +optional_policy(` > udev_read_db(hplip_t) > ') -- Chris PeBenito