|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Macros for lpr domains.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Authors: Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# lpr_domain(domain_prefix)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Define a derived domain for the lpr/lpq/lprm programs when executed
|
|
Chris PeBenito |
ab58ad |
# by a user domain.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# The type declaration for the executable type for this program is
|
|
Chris PeBenito |
ab58ad |
# provided separately in domains/program/lpr.te.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
undefine(`lpr_domain')
|
|
Chris PeBenito |
ab58ad |
define(`lpr_domain',`
|
|
Chris PeBenito |
ab58ad |
# Derived domain based on the calling user domain and the program
|
|
Chris PeBenito |
ab58ad |
type $1_lpr_t, domain, privlog, nscd_client_domain;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Transition from the user domain to the derived domain.
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans($1_t, lpr_exec_t, $1_lpr_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_t $1_lpr_t:process signull;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# allow using shared objects, accessing root dir, etc
|
|
Chris PeBenito |
ab58ad |
uses_shlib($1_lpr_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
read_locale($1_lpr_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# The user role is authorized for this domain.
|
|
Chris PeBenito |
ab58ad |
role $1_r types $1_lpr_t;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# This domain is granted permissions common to most domains (including can_net)
|
|
Chris PeBenito |
ab58ad |
can_network_client($1_lpr_t)
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t port_type:tcp_socket name_connect;
|
|
Chris PeBenito |
ab58ad |
can_ypbind($1_lpr_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Use capabilities.
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t self:capability { setuid dac_override net_bind_service chown };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t self:unix_stream_socket create_stream_socket_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for lpd config files (should have a new type)
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1_lpr_t, etc_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for test print
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1_lpr_t, usr_t)
|
|
Chris PeBenito |
ab58ad |
ifdef(`lpd.te', `
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1_lpr_t, printconf_t)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
tmp_domain($1_lpr)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Type for spool files.
|
|
Chris PeBenito |
ab58ad |
type $1_print_spool_t, file_type, sysadmfile;
|
|
Chris PeBenito |
ab58ad |
# Use this type when creating files in /var/spool/lpd and /var/spool/cups.
|
|
Chris PeBenito |
ab58ad |
file_type_auto_trans($1_lpr_t, print_spool_t, $1_print_spool_t, file)
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t var_spool_t:dir search;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for /dev/null
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t device_t:dir search;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Access the terminal.
|
|
Chris PeBenito |
ab58ad |
access_terminal($1_lpr_t, $1)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Inherit and use descriptors from gnome-pty-helper.
|
|
Chris PeBenito |
ab58ad |
ifdef(`gnome-pty-helper.te', `allow $1_lpr_t $1_gph_t:fd use;')
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t privfd:fd use;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read user files.
|
|
Chris PeBenito |
ab58ad |
read_content(sysadm_lpr_t, $1)
|
|
Chris PeBenito |
ab58ad |
read_content($1_lpr_t, $1)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read and write shared files in the spool directory.
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t print_spool_t:file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# lpr can run in lightweight mode, without a local print spooler. If the
|
|
Chris PeBenito |
ab58ad |
# lpd policy is present, grant some permissions for this domain and the lpd
|
|
Chris PeBenito |
ab58ad |
# domain to interact.
|
|
Chris PeBenito |
ab58ad |
ifdef(`lpd.te', `
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t { var_t var_run_t }:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t lpd_var_run_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t lpd_var_run_t:sock_file write;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Allow lpd to read, rename, and unlink spool files.
|
|
Chris PeBenito |
ab58ad |
allow lpd_t $1_print_spool_t:file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow lpd_t $1_print_spool_t:file link_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Connect to lpd via a Unix domain socket.
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t printer_t:sock_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
can_unix_connect($1_lpr_t, lpd_t)
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_lpr_t $1_t:unix_stream_socket { read write };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Connect to lpd via a TCP socket.
|
|
Chris PeBenito |
ab58ad |
can_tcp_connect($1_lpr_t, lpd_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t fs_t:filesystem getattr;
|
|
Chris PeBenito |
ab58ad |
# Send SIGHUP to lpd.
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t lpd_t:process signal;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
')dnl end if lpd.te
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
ifdef(`xdm.te', `
|
|
Chris PeBenito |
ab58ad |
can_pipe_xdm($1_lpr_t)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
ifdef(`cups.te', `
|
|
Chris PeBenito |
ab58ad |
allow { $1_lpr_t $1_t } cupsd_etc_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1_lpr_t { cupsd_etc_t cupsd_rw_etc_t }:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
can_tcp_connect({ $1_lpr_t $1_t }, cupsd_t)
|
|
Chris PeBenito |
ab58ad |
')dnl end ifdef cups.te
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
')dnl end macro definition
|
|
Chris PeBenito |
ab58ad |
|