Chris PeBenito 31b7c0
#DESC OpenCA - Open Certificate Authority
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Author:  Brian May <bam@snoopy.apana.org.au>
Chris PeBenito 31b7c0
# X-Debian-Packages:
Chris PeBenito 31b7c0
# Depends: apache.te
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# domain for openCA cgi-bin scripts.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Type that system CGI scripts run as
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
type openca_ca_t, domain;
Chris PeBenito 31b7c0
role system_r types openca_ca_t;
Chris PeBenito 31b7c0
uses_shlib(openca_ca_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Types that system CGI scripts on the disk are 
Chris PeBenito 31b7c0
# labeled with
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
type openca_ca_exec_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# When the server starts the script it needs to get the proper context
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
domain_auto_trans(httpd_t, openca_ca_exec_t, openca_ca_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Allow httpd daemon to search /usr/share/openca
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
allow httpd_t openca_usr_share_t:dir { getattr search };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
################################################################
Chris PeBenito 31b7c0
# Allow the web server to run scripts and serve pages
Chris PeBenito 31b7c0
##############################################################
Chris PeBenito 31b7c0
allow httpd_t bin_t:file { read execute }; # execute perl
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow httpd_t openca_ca_exec_t:file {execute getattr read};
Chris PeBenito 31b7c0
allow httpd_t openca_ca_t:process {signal sigkill sigstop};
Chris PeBenito 31b7c0
allow httpd_t openca_ca_t:process transition;
Chris PeBenito 31b7c0
allow httpd_t openca_ca_exec_t:dir r_dir_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##################################################################
Chris PeBenito 31b7c0
# Allow the script to get the file descriptor from the http deamon
Chris PeBenito 31b7c0
# and send sigchild to http deamon
Chris PeBenito 31b7c0
#################################################################
Chris PeBenito 31b7c0
allow openca_ca_t httpd_t:process sigchld;
Chris PeBenito 31b7c0
allow openca_ca_t httpd_t:fd use;
Chris PeBenito 31b7c0
allow openca_ca_t httpd_t:fifo_file {getattr write};
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
############################################
Chris PeBenito 31b7c0
# Allow scripts to append to http logs
Chris PeBenito 31b7c0
#########################################
Chris PeBenito 31b7c0
allow openca_ca_t httpd_log_t:file { append getattr };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#############################################################
Chris PeBenito 31b7c0
# Allow the script access to the library files so it can run
Chris PeBenito 31b7c0
#############################################################
Chris PeBenito 31b7c0
can_exec(openca_ca_t, lib_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
########################################################################
Chris PeBenito 31b7c0
# The script needs to inherit the file descriptor and find the script it
Chris PeBenito 31b7c0
# needs to run
Chris PeBenito 31b7c0
########################################################################
Chris PeBenito 31b7c0
allow openca_ca_t initrc_t:fd use;
Chris PeBenito 31b7c0
allow openca_ca_t init_t:fd use;
Chris PeBenito 31b7c0
allow openca_ca_t default_t:dir r_dir_perms;
Chris PeBenito 31b7c0
allow openca_ca_t random_device_t:chr_file r_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#######################################################################
Chris PeBenito 31b7c0
# Allow the script to return its output
Chris PeBenito 31b7c0
######################################################################
Chris PeBenito 31b7c0
#allow openca_ca_t httpd_var_run_t: file rw_file_perms;
Chris PeBenito 31b7c0
allow openca_ca_t null_device_t: chr_file rw_file_perms;
Chris PeBenito 31b7c0
allow openca_ca_t httpd_cache_t: file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
###########################################################################
Chris PeBenito 31b7c0
# Allow the script interpreters to run the scripts.  So
Chris PeBenito 31b7c0
# the perl executable will be able to run a perl script
Chris PeBenito 31b7c0
#########################################################################
Chris PeBenito 31b7c0
can_exec(openca_ca_t, bin_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
############################################################################
Chris PeBenito 31b7c0
# Allow the script process to search the cgi directory, and users directory
Chris PeBenito 31b7c0
##############################################################################
Chris PeBenito 31b7c0
allow openca_ca_t openca_ca_exec_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Allow access to writeable files under /etc/openca
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
allow openca_ca_t openca_etc_writeable_t:file create_file_perms;
Chris PeBenito 31b7c0
allow openca_ca_t openca_etc_writeable_t:dir create_dir_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Allow access to other files under /etc/openca
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
allow openca_ca_t openca_etc_t:file r_file_perms;
Chris PeBenito 31b7c0
allow openca_ca_t openca_etc_t:dir r_dir_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Allow access to private CA key
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
allow openca_ca_t openca_var_lib_keys_t:file create_file_perms;
Chris PeBenito 31b7c0
allow openca_ca_t openca_var_lib_keys_t:dir create_dir_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Allow access to other /var/lib/openca files
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
allow openca_ca_t openca_var_lib_t:file create_file_perms;
Chris PeBenito 31b7c0
allow openca_ca_t openca_var_lib_t:dir create_dir_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Allow access to other /usr/share/openca files
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
allow openca_ca_t openca_usr_share_t:file r_file_perms;
Chris PeBenito 31b7c0
allow openca_ca_t openca_usr_share_t:lnk_file r_file_perms;
Chris PeBenito 31b7c0
allow openca_ca_t openca_usr_share_t:dir r_dir_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# /etc/openca standard files
Chris PeBenito 31b7c0
type openca_etc_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# /etc/openca template files
Chris PeBenito 31b7c0
type openca_etc_in_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# /etc/openca writeable (from CGI script) files
Chris PeBenito 31b7c0
type openca_etc_writeable_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# /var/lib/openca
Chris PeBenito 31b7c0
type openca_var_lib_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# /var/lib/openca/crypto/keys
Chris PeBenito 31b7c0
type openca_var_lib_keys_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# /usr/share/openca/crypto/keys
Chris PeBenito 31b7c0
type openca_usr_share_t, file_type, sysadmfile;