Chris PeBenito ab58ad
#DESC Cups - Common Unix Printing System
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Created cups policy from lpd policy: Russell Coker <russell@coker.com.au>
Chris PeBenito ab58ad
# X-Debian-Packages: cupsys cupsys-client cupsys-bsd
Chris PeBenito ab58ad
# Depends: lpd.te lpr.te
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Rules for the cupsd_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# cupsd_t is the domain of cupsd.
Chris PeBenito ab58ad
# cupsd_exec_t is the type of the cupsd executable.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
daemon_domain(cupsd, `, auth_chkpwd, nscd_client_domain')
Chris PeBenito ab58ad
etcdir_domain(cupsd)
Chris PeBenito ab58ad
type cupsd_rw_etc_t, file_type, sysadmfile, usercanread;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_network(cupsd_t)
Chris PeBenito ab58ad
allow cupsd_t port_type:tcp_socket name_connect;
Chris PeBenito ab58ad
logdir_domain(cupsd)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
tmp_domain(cupsd, `', { file dir fifo_file })
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_t devpts_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_t device_t:lnk_file read;
Chris PeBenito ab58ad
allow cupsd_t printer_device_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
allow cupsd_t urandom_device_t:chr_file { getattr read };
Chris PeBenito ab58ad
dontaudit cupsd_t random_device_t:chr_file ioctl;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# temporary solution, we need something better
Chris PeBenito ab58ad
allow cupsd_t serial_device:chr_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
r_dir_file(cupsd_t, usbdevfs_t)
Chris PeBenito ab58ad
r_dir_file(cupsd_t, usbfs_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`logrotate.te', `
Chris PeBenito ab58ad
domain_auto_trans(logrotate_t, cupsd_exec_t, cupsd_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`inetd.te', `
Chris PeBenito ab58ad
allow inetd_t printer_port_t:tcp_socket name_bind;
Chris PeBenito ab58ad
domain_auto_trans(inetd_t, cupsd_exec_t, cupsd_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# write to spool
Chris PeBenito ab58ad
allow cupsd_t var_spool_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# this is not ideal, and allowing setattr access to cupsd_etc_t is wrong
Chris PeBenito ab58ad
file_type_auto_trans(cupsd_t, cupsd_etc_t, cupsd_rw_etc_t, file)
Chris PeBenito ab58ad
file_type_auto_trans(cupsd_t, var_t, cupsd_rw_etc_t, { dir file })
Chris PeBenito ab58ad
allow cupsd_t cupsd_rw_etc_t:dir { setattr rw_dir_perms };
Chris PeBenito ab58ad
allow cupsd_t cupsd_etc_t:file setattr;
Chris PeBenito ab58ad
allow cupsd_t cupsd_etc_t:dir setattr;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_t { etc_t etc_runtime_t }:file { getattr read ioctl };
Chris PeBenito ab58ad
can_exec(cupsd_t, initrc_exec_t)
Chris PeBenito ab58ad
allow cupsd_t proc_t:file r_file_perms;
Chris PeBenito ab58ad
allow cupsd_t proc_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow cupsd_t self:file { getattr read };
Chris PeBenito ab58ad
read_sysctl(cupsd_t)
Chris PeBenito ab58ad
allow cupsd_t sysctl_dev_t:dir search;
Chris PeBenito ab58ad
allow cupsd_t sysctl_dev_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for /etc/printcap
Chris PeBenito ab58ad
dontaudit cupsd_t etc_t:file write;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# allow cups to execute its backend scripts
Chris PeBenito ab58ad
can_exec(cupsd_t, cupsd_exec_t)
Chris PeBenito ab58ad
allow cupsd_t cupsd_exec_t:dir search;
Chris PeBenito ab58ad
allow cupsd_t cupsd_exec_t:lnk_file read;
Chris PeBenito ab58ad
allow cupsd_t reserved_port_t:tcp_socket name_bind;
Chris PeBenito ab58ad
dontaudit cupsd_t reserved_port_type:tcp_socket name_bind;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_t self:unix_stream_socket create_socket_perms;
Chris PeBenito ab58ad
allow cupsd_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow cupsd_t self:fifo_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use capabilities.
Chris PeBenito ab58ad
allow cupsd_t self:capability { dac_read_search kill setgid setuid fsetid net_bind_service fowner chown dac_override sys_tty_config audit_write };
Chris PeBenito ab58ad
dontaudit cupsd_t self:capability net_admin;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# /usr/lib/cups/backend/serial needs sys_admin
Chris PeBenito ab58ad
# Need new context to run under???
Chris PeBenito ab58ad
allow cupsd_t self:capability sys_admin;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_t self:process setsched;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for /var/lib/defoma
Chris PeBenito ab58ad
allow cupsd_t var_lib_t:dir search;
Chris PeBenito ab58ad
r_dir_file(cupsd_t, readable_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Bind to the cups/ipp port (631).
Chris PeBenito ab58ad
allow cupsd_t ipp_port_t:{ udp_socket tcp_socket } name_bind;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_tcp_connect(web_client_domain, cupsd_t)
Chris PeBenito ab58ad
can_tcp_connect(cupsd_t, cupsd_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Send to portmap.
Chris PeBenito ab58ad
ifdef(`portmap.te', `
Chris PeBenito ab58ad
can_udp_send(cupsd_t, portmap_t)
Chris PeBenito ab58ad
can_udp_send(portmap_t, cupsd_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Write to /var/spool/cups.
Chris PeBenito ab58ad
allow cupsd_t print_spool_t:dir { setattr rw_dir_perms };
Chris PeBenito ab58ad
allow cupsd_t print_spool_t:file create_file_perms;
Chris PeBenito ab58ad
allow cupsd_t print_spool_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Filter scripts may be shell scripts, and may invoke progs like /bin/mktemp
Chris PeBenito ab58ad
allow cupsd_t { bin_t sbin_t }:dir { search getattr };
Chris PeBenito ab58ad
allow cupsd_t bin_t:lnk_file read;
Chris PeBenito ab58ad
can_exec(cupsd_t, { shell_exec_t bin_t sbin_t })
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# They will also invoke ghostscript, which needs to read fonts
Chris PeBenito ab58ad
read_fonts(cupsd_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read /usr/lib/gconv/gconv-modules.* and /usr/lib/python2.2/.*
Chris PeBenito ab58ad
allow cupsd_t lib_t:file { read getattr };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# read python modules
Chris PeBenito ab58ad
allow cupsd_t usr_t:{ file lnk_file } { read getattr ioctl };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# lots of errors generated requiring the following
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow cupsd_t self:netlink_audit_socket { create_netlink_socket_perms nlmsg_relay };
Chris PeBenito ab58ad
allow cupsd_t self:netlink_route_socket { r_netlink_socket_perms };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Satisfy readahead
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow initrc_t cupsd_log_t:file { getattr read };
Chris PeBenito ab58ad
r_dir_file(cupsd_t, var_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
r_dir_file(cupsd_t, usercanread)
Chris PeBenito ab58ad
ifdef(`samba.te', `
Chris PeBenito ab58ad
rw_dir_file(cupsd_t, samba_var_t)
Chris PeBenito ab58ad
allow smbd_t cupsd_etc_t:dir search;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`pam.te', `
Chris PeBenito ab58ad
dontaudit cupsd_t pam_var_run_t:file { getattr read };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
dontaudit cupsd_t { sysadm_home_dir_t staff_home_dir_t }:dir { getattr search };
Chris PeBenito ab58ad
# PTAL
Chris PeBenito ab58ad
daemon_domain(ptal)
Chris PeBenito ab58ad
etcdir_domain(ptal)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
file_type_auto_trans(ptal_t, var_run_t, ptal_var_run_t)
Chris PeBenito ab58ad
allow ptal_t self:capability { chown sys_rawio };
Chris PeBenito ab58ad
allow ptal_t self:{ unix_dgram_socket unix_stream_socket } create_socket_perms;
Chris PeBenito ab58ad
allow ptal_t self:unix_stream_socket { listen accept };
Chris PeBenito ab58ad
can_network_server_tcp(ptal_t)
Chris PeBenito ab58ad
allow ptal_t ptal_port_t:tcp_socket name_bind;
Chris PeBenito ab58ad
allow userdomain ptal_t:unix_stream_socket connectto;
Chris PeBenito ab58ad
allow userdomain ptal_var_run_t:sock_file write;
Chris PeBenito ab58ad
allow userdomain ptal_var_run_t:dir search;
Chris PeBenito ab58ad
allow ptal_t self:fifo_file rw_file_perms;
Chris PeBenito ab58ad
allow ptal_t device_t:dir read;
Chris PeBenito ab58ad
allow ptal_t printer_device_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
allow initrc_t printer_device_t:chr_file getattr;
Chris PeBenito ab58ad
allow ptal_t { etc_t etc_runtime_t }:file { getattr read };
Chris PeBenito ab58ad
r_dir_file(ptal_t, usbdevfs_t)
Chris PeBenito ab58ad
rw_dir_file(ptal_t, usbfs_t)
Chris PeBenito ab58ad
allow cupsd_t ptal_var_run_t:sock_file { write setattr };
Chris PeBenito ab58ad
allow cupsd_t ptal_t:unix_stream_socket connectto;
Chris PeBenito ab58ad
allow cupsd_t ptal_var_run_t:dir search;
Chris PeBenito ab58ad
dontaudit ptal_t { sysadm_home_dir_t staff_home_dir_t }:dir { getattr search };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow initrc_t ptal_var_run_t:dir rmdir;
Chris PeBenito ab58ad
allow initrc_t ptal_var_run_t:fifo_file unlink;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# HPLIP
Chris PeBenito ab58ad
daemon_domain(hplip)
Chris PeBenito ab58ad
etcdir_domain(hplip)
Chris PeBenito ab58ad
allow hplip_t etc_t:file r_file_perms;
Chris PeBenito ab58ad
allow hplip_t etc_runtime_t:file { read getattr };
Chris PeBenito ab58ad
allow hplip_t printer_device_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
allow cupsd_t hplip_var_run_t:file { read getattr };
Chris PeBenito ab58ad
allow hplip_t cupsd_etc_t:dir search;
Chris PeBenito ab58ad
can_network(hplip_t)
Chris PeBenito ab58ad
allow hplip_t { hplip_port_t ipp_port_t }:tcp_socket name_connect;
Chris PeBenito ab58ad
allow hplip_t hplip_port_t:tcp_socket name_bind;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Uses networking to talk to the daemons
Chris PeBenito ab58ad
allow hplip_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow hplip_t self:unix_stream_socket create_socket_perms;
Chris PeBenito ab58ad
allow hplip_t self:rawip_socket create_socket_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for python
Chris PeBenito ab58ad
can_exec(hplip_t, bin_t)
Chris PeBenito ab58ad
allow hplip_t { sbin_t bin_t }:dir search;
Chris PeBenito ab58ad
allow hplip_t self:file { getattr read };
Chris PeBenito ab58ad
allow hplip_t proc_t:file r_file_perms;
Chris PeBenito ab58ad
allow hplip_t urandom_device_t:chr_file { getattr read };
Chris PeBenito ab58ad
allow hplip_t usr_t:{ file lnk_file } r_file_perms;
Chris PeBenito ab58ad
allow hplip_t devpts_t:dir search;
Chris PeBenito ab58ad
allow hplip_t devpts_t:chr_file { getattr ioctl };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
dontaudit cupsd_t selinux_config_t:dir search;
Chris PeBenito ab58ad
dontaudit cupsd_t selinux_config_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_t printconf_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`dbusd.te', `
Chris PeBenito ab58ad
dbusd_client(system, cupsd)
Chris PeBenito ab58ad
allow cupsd_t system_dbusd_t:dbus send_msg;
Chris PeBenito ab58ad
allow cupsd_t userdomain:dbus send_msg;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# CUPS configuration daemon
Chris PeBenito ab58ad
daemon_domain(cupsd_config, `, nscd_client_domain')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_config_t devpts_t:dir search;
Chris PeBenito ab58ad
allow cupsd_config_t devpts_t:chr_file { getattr ioctl };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`distro_redhat', `
Chris PeBenito ab58ad
ifdef(`rpm.te', `
Chris PeBenito ab58ad
allow cupsd_config_t rpm_var_lib_t:dir { getattr search };
Chris PeBenito ab58ad
allow cupsd_config_t rpm_var_lib_t:file { getattr read };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
allow cupsd_config_t initrc_exec_t:file getattr;
Chris PeBenito ab58ad
')dnl end distro_redhat
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_config_t { etc_t etc_runtime_t net_conf_t }:file { getattr read };
Chris PeBenito ab58ad
allow cupsd_config_t self:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_config_t proc_t:file { getattr read };
Chris PeBenito ab58ad
allow cupsd_config_t cupsd_var_run_t:file { getattr read };
Chris PeBenito ab58ad
allow cupsd_config_t cupsd_t:process { signal };
Chris PeBenito ab58ad
allow cupsd_config_t cupsd_t:{ file lnk_file } { getattr read };
Chris PeBenito ab58ad
can_ps(cupsd_config_t, cupsd_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_config_t self:capability { chown sys_tty_config };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
rw_dir_create_file(cupsd_config_t, cupsd_etc_t)
Chris PeBenito ab58ad
rw_dir_create_file(cupsd_config_t, cupsd_rw_etc_t)
Chris PeBenito ab58ad
file_type_auto_trans(cupsd_config_t, cupsd_etc_t, cupsd_rw_etc_t, file)
Chris PeBenito ab58ad
file_type_auto_trans(cupsd_config_t, var_t, cupsd_rw_etc_t, file)
Chris PeBenito ab58ad
allow cupsd_config_t var_t:lnk_file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_network_tcp(cupsd_config_t)
Chris PeBenito ab58ad
can_ypbind(cupsd_config_t)
Chris PeBenito ab58ad
allow cupsd_config_t port_type:tcp_socket name_connect;
Chris PeBenito ab58ad
can_tcp_connect(cupsd_config_t, cupsd_t)
Chris PeBenito ab58ad
allow cupsd_config_t self:fifo_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_config_t self:unix_stream_socket create_socket_perms;
Chris PeBenito ab58ad
allow cupsd_config_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
ifdef(`dbusd.te', `
Chris PeBenito ab58ad
dbusd_client(system, cupsd_config)
Chris PeBenito ab58ad
allow cupsd_config_t userdomain:dbus send_msg;
Chris PeBenito ab58ad
allow cupsd_config_t system_dbusd_t:dbus { send_msg acquire_svc };
Chris PeBenito ab58ad
allow userdomain cupsd_config_t:dbus send_msg;
Chris PeBenito ab58ad
')dnl end if dbusd.te
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`hald.te', `
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`dbusd.te', `
Chris PeBenito ab58ad
allow { cupsd_t cupsd_config_t } hald_t:dbus send_msg;
Chris PeBenito ab58ad
allow hald_t { cupsd_t cupsd_config_t }:dbus send_msg;
Chris PeBenito ab58ad
')dnl end if dbusd.te
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow hald_t cupsd_config_t:process signal;
Chris PeBenito ab58ad
domain_auto_trans(hald_t, cupsd_config_exec_t, cupsd_config_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
') dnl end if hald.te
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_exec(cupsd_config_t, { bin_t sbin_t shell_exec_t })
Chris PeBenito ab58ad
ifdef(`hostname.te', `
Chris PeBenito ab58ad
can_exec(cupsd_t, hostname_exec_t)
Chris PeBenito ab58ad
can_exec(cupsd_config_t, hostname_exec_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
allow cupsd_config_t { bin_t sbin_t }:dir { search getattr };
Chris PeBenito ab58ad
allow cupsd_config_t { bin_t sbin_t }:lnk_file read;
Chris PeBenito ab58ad
# killall causes the following
Chris PeBenito ab58ad
dontaudit cupsd_config_t domain:dir { getattr search };
Chris PeBenito ab58ad
dontaudit cupsd_config_t selinux_config_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_exec(cupsd_config_t, cupsd_config_exec_t) 
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_config_t usr_t:file { getattr read };
Chris PeBenito ab58ad
allow cupsd_config_t var_lib_t:dir { getattr search };
Chris PeBenito ab58ad
allow cupsd_config_t rpm_var_lib_t:file { getattr read };
Chris PeBenito ab58ad
allow cupsd_config_t printconf_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow cupsd_config_t urandom_device_t:chr_file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`logrotate.te', `
Chris PeBenito ab58ad
allow cupsd_config_t logrotate_t:fd use;
Chris PeBenito ab58ad
')dnl end if logrotate.te
Chris PeBenito ab58ad
allow cupsd_config_t system_crond_t:fd use;
Chris PeBenito ab58ad
allow cupsd_config_t crond_t:fifo_file r_file_perms;
Chris PeBenito ab58ad
allow cupsd_t crond_t:fifo_file read;
Chris PeBenito ab58ad
allow cupsd_t crond_t:fd use;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Alternatives asks for this
Chris PeBenito ab58ad
allow cupsd_config_t initrc_exec_t:file getattr;
Chris PeBenito ab58ad
ifdef(`targeted_policy', `
Chris PeBenito ab58ad
can_unix_connect(cupsd_t, initrc_t)
Chris PeBenito ab58ad
allow cupsd_t initrc_t:dbus send_msg;
Chris PeBenito ab58ad
allow initrc_t cupsd_t:dbus send_msg;
Chris PeBenito ab58ad
allow { cupsd_config_t cupsd_t } unconfined_t:dbus send_msg;
Chris PeBenito ab58ad
allow unconfined_t cupsd_config_t:dbus send_msg;
Chris PeBenito ab58ad
allow { cupsd_t cupsd_config_t } unconfined_t:fifo_file read;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
typealias printer_port_t alias cupsd_lpd_port_t;
Chris PeBenito ab58ad
inetd_child_domain(cupsd_lpd)
Chris PeBenito ab58ad
allow inetd_t printer_port_t:tcp_socket name_bind;
Chris PeBenito ab58ad
r_dir_file(cupsd_lpd_t, cupsd_etc_t)
Chris PeBenito ab58ad
r_dir_file(cupsd_lpd_t, cupsd_rw_etc_t)
Chris PeBenito ab58ad
allow cupsd_lpd_t ipp_port_t:tcp_socket name_connect;
Chris PeBenito ab58ad
ifdef(`use_mcs', `
Chris PeBenito ab58ad
range_transition initrc_t cupsd_exec_t s0 - s0:c0.c255;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad