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