|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
define(`apache_domain', `
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
#This type is for webpages
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
type httpd_$1_content_t, file_type, ifelse($1, sys, `', `$1_file_type, ') httpdcontent, sysadmfile, customizable;
|
|
Chris PeBenito |
0fbfa5 |
ifelse($1, sys, `
|
|
Chris PeBenito |
0fbfa5 |
typealias httpd_sys_content_t alias httpd_sysadm_content_t;
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# This type is used for .htaccess files
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
type httpd_$1_htaccess_t, file_type, sysadmfile;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# This type is used for executable scripts files
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
type httpd_$1_script_exec_t, file_type, sysadmfile, customizable;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Type that CGI scripts run as
|
|
Chris PeBenito |
0fbfa5 |
type httpd_$1_script_t, domain, privmail, nscd_client_domain;
|
|
Chris PeBenito |
0fbfa5 |
role system_r types httpd_$1_script_t;
|
|
Chris PeBenito |
0fbfa5 |
uses_shlib(httpd_$1_script_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
if (httpd_enable_cgi) {
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans(httpd_t, httpd_$1_script_exec_t, httpd_$1_script_t)
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_t httpd_$1_script_t:process { signal sigkill sigstop };
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_t httpd_$1_script_exec_t:dir r_dir_perms;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t httpd_t:fd use;
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t httpd_t:process sigchld;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
can_network(httpd_$1_script_t)
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t { usr_t lib_t }:file { getattr read ioctl };
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t usr_t:lnk_file { getattr read };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t self:process { fork signal_perms };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t devtty_t:chr_file { getattr read write };
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t urandom_device_t:chr_file { getattr read };
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t etc_runtime_t:file { getattr read };
|
|
Chris PeBenito |
0fbfa5 |
read_locale(httpd_$1_script_t)
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t fs_t:filesystem getattr;
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t self:unix_stream_socket create_stream_socket_perms;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t { self proc_t }:file { getattr read };
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t { self proc_t }:dir r_dir_perms;
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t { self proc_t }:lnk_file read;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t device_t:dir { getattr search };
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t null_device_t:chr_file rw_file_perms;
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`ypbind.te', `
|
|
Chris PeBenito |
0fbfa5 |
if (httpd_enable_cgi && allow_ypbind) {
|
|
Chris PeBenito |
0fbfa5 |
uncond_can_ypbind(httpd_$1_script_t)
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
# The following are the only areas that
|
|
Chris PeBenito |
0fbfa5 |
# scripts can read, read/write, or append to
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
type httpd_$1_script_ro_t, file_type, httpdcontent, sysadmfile, customizable;
|
|
Chris PeBenito |
0fbfa5 |
type httpd_$1_script_rw_t, file_type, httpdcontent, sysadmfile, customizable;
|
|
Chris PeBenito |
0fbfa5 |
type httpd_$1_script_ra_t, file_type, httpdcontent, sysadmfile, customizable;
|
|
Chris PeBenito |
0fbfa5 |
file_type_auto_trans(httpd_$1_script_t, tmp_t, httpd_$1_script_rw_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`slocate.te', `
|
|
Chris PeBenito |
0fbfa5 |
ifelse($1, `sys', `', `
|
|
Chris PeBenito |
0fbfa5 |
allow $1_locate_t { httpd_$1_content_t httpd_$1_htaccess_t httpd_$1_script_exec_t httpd_$1_script_ro_t httpd_$1_script_rw_t httpd_$1_script_ra_t }:dir { getattr search };
|
|
Chris PeBenito |
0fbfa5 |
allow $1_locate_t { httpd_$1_content_t httpd_$1_htaccess_t httpd_$1_script_exec_t httpd_$1_script_ro_t httpd_$1_script_rw_t httpd_$1_script_ra_t }:file { getattr read };
|
|
Chris PeBenito |
0fbfa5 |
')dnl end ifelse
|
|
Chris PeBenito |
0fbfa5 |
')dnl end slocate.te
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
#########################################################
|
|
Chris PeBenito |
0fbfa5 |
# Permissions for running child processes and scripts
|
|
Chris PeBenito |
0fbfa5 |
##########################################################
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_suexec_t { httpd_$1_content_t httpd_$1_script_ro_t httpd_$1_script_rw_t httpd_$1_script_exec_t }:dir { getattr search };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans(httpd_suexec_t, httpd_$1_script_exec_t, httpd_$1_script_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t httpd_t:fifo_file write;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t self:fifo_file rw_file_perms;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t { urandom_device_t random_device_t }:chr_file r_file_perms;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# for nscd
|
|
Chris PeBenito |
0fbfa5 |
dontaudit httpd_$1_script_t var_t:dir search;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
###########################################################################
|
|
Chris PeBenito |
0fbfa5 |
# Allow the script interpreters to run the scripts. So
|
|
Chris PeBenito |
0fbfa5 |
# the perl executable will be able to run a perl script
|
|
Chris PeBenito |
0fbfa5 |
#########################################################################
|
|
Chris PeBenito |
0fbfa5 |
can_exec_any(httpd_$1_script_t)
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t etc_t:file { getattr read };
|
|
Chris PeBenito |
0fbfa5 |
dontaudit httpd_$1_script_t selinux_config_t:dir search;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
############################################################################
|
|
Chris PeBenito |
0fbfa5 |
# Allow the script process to search the cgi directory, and users directory
|
|
Chris PeBenito |
0fbfa5 |
##############################################################################
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t httpd_$1_script_exec_t:dir { search getattr };
|
|
Chris PeBenito |
0fbfa5 |
can_exec(httpd_$1_script_t, httpd_$1_script_exec_t)
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t home_root_t:dir { getattr search };
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t httpd_$1_content_t:dir { getattr search };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
#############################################################################
|
|
Chris PeBenito |
0fbfa5 |
# Allow the scripts to read, read/write, append to the specified directories
|
|
Chris PeBenito |
0fbfa5 |
# or files
|
|
Chris PeBenito |
0fbfa5 |
############################################################################
|
|
Chris PeBenito |
0fbfa5 |
r_dir_file(httpd_$1_script_t, fonts_t)
|
|
Chris PeBenito |
0fbfa5 |
r_dir_file(httpd_$1_script_t, httpd_$1_script_ro_t)
|
|
Chris PeBenito |
0fbfa5 |
create_dir_file(httpd_$1_script_t, httpd_$1_script_rw_t)
|
|
Chris PeBenito |
0fbfa5 |
ra_dir_file(httpd_$1_script_t, httpd_$1_script_ra_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
if (httpd_enable_cgi && httpd_unified ifdef(`targeted_policy', ` && ! httpd_disable_trans')) {
|
|
Chris PeBenito |
0fbfa5 |
ifelse($1, sys, `
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans(httpd_t, httpdcontent, httpd_sys_script_t)
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans(httpd_suexec_t, httpdcontent, httpd_sys_script_t)
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans(sysadm_t, httpdcontent, httpd_sys_script_t)
|
|
Chris PeBenito |
0fbfa5 |
create_dir_file(httpd_t, httpdcontent)
|
|
Chris PeBenito |
0fbfa5 |
can_exec(httpd_t, httpdcontent )
|
|
Chris PeBenito |
0fbfa5 |
', `
|
|
Chris PeBenito |
0fbfa5 |
can_exec(httpd_$1_script_t, httpdcontent )
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans($1_t, httpdcontent, httpd_$1_script_t)
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
create_dir_file(httpd_$1_script_t, httpdcontent)
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
ifelse($1, sys, `
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
# If a user starts a script by hand it gets the proper context
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
if (httpd_enable_cgi ifdef(`targeted_policy', ` && ! httpd_disable_trans')) {
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans(sysadm_t, httpd_$1_script_exec_t, httpd_$1_script_t)
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
role sysadm_r types httpd_$1_script_t;
|
|
Chris PeBenito |
0fbfa5 |
', `
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
if (httpd_enable_cgi ifdef(`targeted_policy', ` && ! httpd_disable_trans')) {
|
|
Chris PeBenito |
0fbfa5 |
# If a user starts a script by hand it gets the proper context
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans($1_t, httpd_$1_script_exec_t, httpd_$1_script_t)
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
role $1_r types httpd_$1_script_t;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
#######################################
|
|
Chris PeBenito |
0fbfa5 |
# Allow user to create or edit web content
|
|
Chris PeBenito |
0fbfa5 |
#########################################
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
create_dir_file($1_t, { httpd_$1_content_t httpd_$1_script_exec_t })
|
|
Chris PeBenito |
0fbfa5 |
create_dir_file($1_crond_t, httpd_$1_content_t)
|
|
Chris PeBenito |
0fbfa5 |
allow $1_t { httpd_$1_content_t httpd_$1_script_exec_t }:{ dir file lnk_file } { relabelto relabelfrom };
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`mozilla.te', `
|
|
Chris PeBenito |
0fbfa5 |
r_dir_file($1_mozilla_t, { httpd_$1_script_exec_t httpd_$1_content_t })
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
######################################################################
|
|
Chris PeBenito |
0fbfa5 |
# Allow the user to create htaccess files
|
|
Chris PeBenito |
0fbfa5 |
#####################################################################
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow $1_t httpd_$1_htaccess_t:file { create_file_perms relabelto relabelfrom };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
#########################################################################
|
|
Chris PeBenito |
0fbfa5 |
# Allow user to create files or directories
|
|
Chris PeBenito |
0fbfa5 |
# that scripts are able to read, write, or append to
|
|
Chris PeBenito |
0fbfa5 |
###########################################################################
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
create_dir_file($1_t, { httpd_$1_script_ro_t httpd_$1_script_rw_t httpd_$1_script_ra_t })
|
|
Chris PeBenito |
0fbfa5 |
allow $1_t { httpd_$1_script_ro_t httpd_$1_script_rw_t httpd_$1_script_ra_t }:{ file dir lnk_file } { relabelto relabelfrom };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# allow accessing files/dirs below the users home dir
|
|
Chris PeBenito |
0fbfa5 |
if (httpd_enable_homedirs) {
|
|
Chris PeBenito |
0fbfa5 |
allow { httpd_t httpd_suexec_t httpd_$1_script_t } $1_home_dir_t:dir { getattr search };
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`nfs_home_dirs', `
|
|
Chris PeBenito |
0fbfa5 |
r_dir_file(httpd_$1_script_t, nfs_t)
|
|
Chris PeBenito |
0fbfa5 |
')dnl end if nfs_home_dirs
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
')dnl end ifelse sys
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
dontaudit httpd_$1_script_t sysctl_kernel_t:dir search;
|
|
Chris PeBenito |
0fbfa5 |
dontaudit httpd_$1_script_t sysctl_t:dir search;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
################################################################
|
|
Chris PeBenito |
0fbfa5 |
# Allow the web server to run scripts and serve pages
|
|
Chris PeBenito |
0fbfa5 |
##############################################################
|
|
Chris PeBenito |
0fbfa5 |
r_dir_file(httpd_t, httpd_$1_content_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_t httpd_$1_htaccess_t: file r_file_perms;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
r_dir_file(httpd_t, httpd_$1_script_rw_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
############################################
|
|
Chris PeBenito |
0fbfa5 |
# Allow scripts to append to http logs
|
|
Chris PeBenito |
0fbfa5 |
#########################################
|
|
Chris PeBenito |
0fbfa5 |
allow httpd_$1_script_t httpd_log_t:file { getattr append };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# apache should set close-on-exec
|
|
Chris PeBenito |
0fbfa5 |
dontaudit httpd_$1_script_t httpd_t:unix_stream_socket { read write };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
')
|