Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Macros for gnome-pty-helper domains.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Authors:  Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser 
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# gph_domain(domain_prefix, role_prefix)
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Define a derived domain for the gnome-pty-helper program when
Chris PeBenito 0fbfa5
# executed by a user domain.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# The type declaration for the executable type for this program is
Chris PeBenito 0fbfa5
# provided separately in domains/program/gnome-pty-helper.te. 
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# The *_gph_t domains are for the gnome_pty_helper program.
Chris PeBenito 0fbfa5
# This program is executed by gnome-terminal to handle
Chris PeBenito 0fbfa5
# updates to utmp and wtmp.  In this regard, it is similar
Chris PeBenito 0fbfa5
# to utempter.  However, unlike utempter, gnome-pty-helper
Chris PeBenito 0fbfa5
# also creates the pty file for the terminal program.
Chris PeBenito 0fbfa5
# There is one *_gph_t domain for each user domain.  
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
undefine(`gph_domain')
Chris PeBenito 0fbfa5
define(`gph_domain',`
Chris PeBenito 0fbfa5
# Derived domain based on the calling user domain and the program.
Chris PeBenito 0fbfa5
type $1_gph_t, domain, gphdomain, nscd_client_domain;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Transition from the user domain to the derived domain.
Chris PeBenito 0fbfa5
domain_auto_trans($1_t, gph_exec_t, $1_gph_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# The user role is authorized for this domain.
Chris PeBenito 0fbfa5
role $2_r types $1_gph_t;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# This domain is granted permissions common to most domains.
Chris PeBenito 0fbfa5
uses_shlib($1_gph_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Use capabilities.
Chris PeBenito 0fbfa5
allow $1_gph_t self:capability { chown fsetid setgid setuid };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Update /var/run/utmp and /var/log/wtmp.
Chris PeBenito 0fbfa5
allow $1_gph_t { var_t var_run_t }:dir search;
Chris PeBenito 0fbfa5
allow $1_gph_t initrc_var_run_t:file rw_file_perms;
Chris PeBenito 0fbfa5
allow $1_gph_t wtmp_t:file rw_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Allow gph to rw to stream sockets of appropriate user type.
Chris PeBenito 0fbfa5
# (Need this so gnome-pty-helper can pass pty fd to parent 
Chris PeBenito 0fbfa5
#  gnome-terminal which is running in a user domain.)
Chris PeBenito 0fbfa5
allow $1_gph_t $1_t:unix_stream_socket rw_stream_socket_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_gph_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Allow user domain to use pty fd from gnome-pty-helper.
Chris PeBenito 0fbfa5
allow $1_t $1_gph_t:fd use;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Use the network, e.g. for NIS lookups.
Chris PeBenito 0fbfa5
can_resolve($1_gph_t)
Chris PeBenito 0fbfa5
can_ypbind($1_gph_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_gph_t etc_t:file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Added by David A. Wheeler:
Chris PeBenito 0fbfa5
# Allow gnome-pty-helper to update /var/log/lastlog
Chris PeBenito 0fbfa5
# (the gnome-pty-helper in Red Hat Linux 7.1 does this):
Chris PeBenito 0fbfa5
allow $1_gph_t lastlog_t:file rw_file_perms;
Chris PeBenito 0fbfa5
allow $1_gph_t var_log_t:dir search;
Chris PeBenito 0fbfa5
allow $1_t $1_gph_t:process signal;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifelse($2, `system', `
Chris PeBenito 0fbfa5
# Create ptys for the system
Chris PeBenito 0fbfa5
can_create_other_pty($1_gph, initrc)
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
# Create ptys for the user domain.
Chris PeBenito 0fbfa5
can_create_other_pty($1_gph, $1)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Read and write the users tty.
Chris PeBenito 0fbfa5
allow $1_gph_t $1_tty_device_t:chr_file rw_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Allow gnome-pty-helper to write the .xsession-errors file.
Chris PeBenito 0fbfa5
allow $1_gph_t home_root_t:dir search;
Chris PeBenito 0fbfa5
allow $1_gph_t $1_home_t:dir { search add_name };
Chris PeBenito 0fbfa5
allow $1_gph_t $1_home_t:file { create write };
Chris PeBenito 0fbfa5
')dnl end ifelse system
Chris PeBenito 0fbfa5
')dnl end macro