Chris PeBenito a996bd
Chris PeBenito 2b3c99
policy_module(apache,1.3.0)
Chris PeBenito a996bd
Chris PeBenito a996bd
#
Chris PeBenito a996bd
# NOTES: 
Chris PeBenito a996bd
#  This policy will work with SUEXEC enabled as part of the Apache
Chris PeBenito a996bd
#  configuration. However, the user CGI scripts will run under the
Chris PeBenito a996bd
#  system_u:system_r:httpd_$1_script_t domain where $1 is the domain of the
Chris PeBenito a996bd
#  of the creating user.
Chris PeBenito a996bd
#
Chris PeBenito a996bd
#  The user CGI scripts must be labeled with the httpd_$1_script_exec_t
Chris PeBenito a996bd
#  type, and the directory containing the scripts should also be labeled
Chris PeBenito a996bd
#  with these types. This policy allows user_r role to perform that 
Chris PeBenito a996bd
#  relabeling. If it is desired that only sysadm_r should be able to relabel
Chris PeBenito a996bd
#  the user CGI scripts, then relabel rule for user_r should be removed.
Chris PeBenito a996bd
#
Chris PeBenito a996bd
Chris PeBenito a996bd
########################################
Chris PeBenito a996bd
#
Chris PeBenito a996bd
# Declarations
Chris PeBenito a996bd
#
Chris PeBenito a996bd
Chris PeBenito a996bd
attribute httpdcontent;
Chris PeBenito a996bd
Chris PeBenito e749cd
# domains that can exec all users scripts
Chris PeBenito e749cd
attribute httpd_exec_scripts;
Chris PeBenito e749cd
Chris PeBenito e749cd
# user script domains
Chris PeBenito e749cd
attribute httpd_script_domains;
Chris PeBenito e749cd
Chris PeBenito a996bd
type httpd_t;
Chris PeBenito a996bd
type httpd_exec_t;
Chris PeBenito a996bd
init_daemon_domain(httpd_t,httpd_exec_t)
Chris PeBenito e749cd
role system_r types httpd_t;
Chris PeBenito a996bd
Chris PeBenito a996bd
# httpd_cache_t is the type given to the /var/cache/httpd
Chris PeBenito a996bd
# directory and the files under that directory
Chris PeBenito a996bd
type httpd_cache_t;
Chris PeBenito a996bd
files_type(httpd_cache_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
# httpd_config_t is the type given to the configuration files
Chris PeBenito a996bd
type httpd_config_t;
Chris PeBenito a996bd
files_type(httpd_config_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_helper_t;
Chris PeBenito a996bd
type httpd_helper_exec_t;
Chris PeBenito e749cd
domain_type(httpd_helper_t)
Chris PeBenito a996bd
domain_entry_file(httpd_helper_t,httpd_helper_exec_t)
Chris PeBenito e749cd
role system_r types httpd_helper_t;
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_lock_t;
Chris PeBenito a996bd
files_lock_file(httpd_lock_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_log_t;
Chris PeBenito a996bd
logging_log_file(httpd_log_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
# httpd_modules_t is the type given to module files (libraries) 
Chris PeBenito a996bd
# that come with Apache /etc/httpd/modules and /usr/lib/apache
Chris PeBenito a996bd
type httpd_modules_t;
Chris PeBenito a996bd
files_type(httpd_modules_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_php_t;
Chris PeBenito a996bd
type httpd_php_exec_t;
Chris PeBenito e749cd
domain_type(httpd_php_t)
Chris PeBenito a996bd
domain_entry_file(httpd_php_t,httpd_php_exec_t)
Chris PeBenito e749cd
role system_r types httpd_php_t;
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_php_tmp_t;
Chris PeBenito a996bd
files_tmp_file(httpd_php_tmp_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_squirrelmail_t;
Chris PeBenito a996bd
files_type(httpd_squirrelmail_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
# SUEXEC runs user scripts as their own user ID
Chris PeBenito a996bd
type httpd_suexec_t; #, daemon;
Chris PeBenito a996bd
type httpd_suexec_exec_t;
Chris PeBenito e749cd
domain_type(httpd_suexec_t)
Chris PeBenito a996bd
domain_entry_file(httpd_suexec_t,httpd_suexec_exec_t)
Chris PeBenito e749cd
role system_r types httpd_suexec_t;
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_suexec_tmp_t;
Chris PeBenito a996bd
files_tmp_file(httpd_suexec_tmp_t)
Chris PeBenito a996bd
Chris PeBenito c2b18f
# setup the system domain for system CGI scripts
Chris PeBenito c2b18f
apache_content_template(sys)
Chris PeBenito c2b18f
Chris PeBenito a996bd
type httpd_tmp_t;
Chris PeBenito a996bd
files_tmp_file(httpd_tmp_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_tmpfs_t;
Chris PeBenito a996bd
files_tmpfs_file(httpd_tmpfs_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
# Unconfined domain for apache scripts.
Chris PeBenito a996bd
# Only to be used as a last resort
Chris PeBenito a996bd
type httpd_unconfined_script_t;
Chris PeBenito e749cd
type httpd_unconfined_script_exec_t; # customizable
Chris PeBenito a996bd
domain_type(httpd_unconfined_script_t)
Chris PeBenito e749cd
domain_entry_file(httpd_unconfined_script_t,httpd_unconfined_script_exec_t)
Chris PeBenito a996bd
role system_r types httpd_unconfined_script_t;
Chris PeBenito a996bd
Chris PeBenito a996bd
# for apache2 memory mapped files
Chris PeBenito a996bd
type httpd_var_lib_t;
Chris PeBenito a996bd
files_type(httpd_var_lib_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_var_run_t;
Chris PeBenito a996bd
files_pid_file(httpd_var_run_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
# File Type of squirrelmail attachments
Chris PeBenito a996bd
type squirrelmail_spool_t;
Chris PeBenito a996bd
files_tmp_file(squirrelmail_spool_t)
Chris PeBenito a996bd
Chris PeBenito 6e99a6
# mod_jk2 creates /var/log/httpd/jk2.shm to communicate with tomcat
Chris PeBenito 6e99a6
# This is a bug but it still exists in FC2
Chris PeBenito 6e99a6
# cjp: probably can remove this
Chris PeBenito 6e99a6
ifdef(`distro_redhat',`
Chris PeBenito 6e99a6
	typealias httpd_log_t alias httpd_runtime_t;
Chris PeBenito 9ca7e7
	dontaudit httpd_t httpd_runtime_t:file ioctl;
Chris PeBenito 6e99a6
')
Chris PeBenito 6e99a6
Chris PeBenito c2b18f
ifdef(`targeted_policy',`
Chris PeBenito c2b18f
	typealias httpd_sys_content_t alias httpd_user_content_t;
Chris PeBenito c2b18f
	typealias httpd_sys_script_exec_t alias httpd_user_script_exec_t;
Chris PeBenito c2b18f
')
Chris PeBenito c2b18f
Chris PeBenito 2c2435
optional_policy(`prelink',`
Chris PeBenito 2c2435
	prelink_object_file(httpd_modules_t)
Chris PeBenito 2c2435
')
Chris PeBenito 2c2435
Chris PeBenito a996bd
########################################
Chris PeBenito a996bd
#
Chris PeBenito a996bd
# Apache server local policy
Chris PeBenito a996bd
#
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t self:capability { chown dac_override kill setgid setuid sys_tty_config };
Chris PeBenito a996bd
dontaudit httpd_t self:capability { net_admin sys_tty_config };
Chris PeBenito a996bd
allow httpd_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
Chris PeBenito a996bd
allow httpd_t self:fd use;
Chris PeBenito 0500e0
allow httpd_t self:sock_file r_file_perms;
Chris PeBenito a996bd
allow httpd_t self:fifo_file rw_file_perms;
Chris PeBenito a996bd
allow httpd_t self:shm create_shm_perms;
Chris PeBenito a996bd
allow httpd_t self:sem create_sem_perms;
Chris PeBenito a996bd
allow httpd_t self:msgq create_msgq_perms;
Chris PeBenito a996bd
allow httpd_t self:msg { send receive };
Chris PeBenito a996bd
allow httpd_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito a996bd
allow httpd_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito a996bd
allow httpd_t self:unix_dgram_socket sendto;
Chris PeBenito a996bd
allow httpd_t self:unix_stream_socket connectto;
Chris PeBenito a996bd
allow httpd_t self:netlink_route_socket { bind create getattr nlmsg_read read write };
Chris PeBenito a996bd
allow httpd_t self:tcp_socket { acceptfrom connectto recvfrom };
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito a996bd
allow httpd_t self:udp_socket { connect };
Chris PeBenito a996bd
allow httpd_t self:tcp_socket connected_socket_perms;
Chris PeBenito a996bd
allow httpd_t self:udp_socket connected_socket_perms;
Chris PeBenito a996bd
Chris PeBenito a996bd
# Allow httpd_t to put files in /var/cache/httpd etc
Chris PeBenito a996bd
allow httpd_t httpd_cache_t:dir create_dir_perms;
Chris PeBenito a996bd
allow httpd_t httpd_cache_t:file create_file_perms;
Chris PeBenito a996bd
allow httpd_t httpd_cache_t:lnk_file create_lnk_perms;
Chris PeBenito a996bd
Chris PeBenito a996bd
# Allow the httpd_t to read the web servers config files
Chris PeBenito a996bd
allow httpd_t httpd_config_t:dir r_dir_perms;
Chris PeBenito a996bd
allow httpd_t httpd_config_t:file r_file_perms;
Chris PeBenito a996bd
allow httpd_t httpd_config_t:lnk_file { getattr read };
Chris PeBenito a996bd
Chris PeBenito a996bd
can_exec(httpd_t, httpd_exec_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t httpd_lock_t:file create_file_perms;
Chris PeBenito 1c1ac6
files_lock_filetrans(httpd_t,httpd_lock_t,file)
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t httpd_log_t:dir { setattr rw_dir_perms };
Chris PeBenito a996bd
allow httpd_t httpd_log_t:file { create ra_file_perms };
Chris PeBenito a996bd
allow httpd_t httpd_log_t:lnk_file read;
Chris PeBenito c2b18f
# cjp: need to refine create interfaces to
Chris PeBenito c2b18f
# cut this back to add_name only
Chris PeBenito 1c1ac6
logging_log_filetrans(httpd_t,httpd_log_t,file)
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t httpd_modules_t:file rx_file_perms;
Chris PeBenito a996bd
allow httpd_t httpd_modules_t:dir r_dir_perms;
Chris PeBenito a996bd
allow httpd_t httpd_modules_t:lnk_file r_file_perms;
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t httpd_squirrelmail_t:dir create_dir_perms;
Chris PeBenito a996bd
allow httpd_t httpd_squirrelmail_t:lnk_file create_lnk_perms;
Chris PeBenito a996bd
allow httpd_t httpd_squirrelmail_t:file create_file_perms;
Chris PeBenito a996bd
Chris PeBenito 725926
allow httpd_t httpd_suexec_exec_t:file { getattr read };
Chris PeBenito 725926
Don Miner 3d37bc
allow httpd_t httpd_sys_content_t:dir r_dir_perms;
Don Miner f470a1
allow httpd_t httpd_sys_content_t:file r_file_perms;
Don Miner 3d37bc
Chris PeBenito a996bd
allow httpd_t httpd_tmp_t:dir create_dir_perms;
Chris PeBenito a996bd
allow httpd_t httpd_tmp_t:file create_file_perms;
Chris PeBenito 103fe2
files_tmp_filetrans(httpd_t, httpd_tmp_t, { file dir })
Chris PeBenito a996bd
Chris PeBenito e749cd
allow httpd_t httpd_tmpfs_t:dir create_dir_perms;
Chris PeBenito e749cd
allow httpd_t httpd_tmpfs_t:file create_file_perms;
Chris PeBenito e749cd
allow httpd_t httpd_tmpfs_t:lnk_file create_lnk_perms;
Chris PeBenito e749cd
allow httpd_t httpd_tmpfs_t:sock_file create_file_perms;
Chris PeBenito e749cd
allow httpd_t httpd_tmpfs_t:fifo_file create_file_perms;
Chris PeBenito 103fe2
fs_tmpfs_filetrans(httpd_t,httpd_tmpfs_t,{ dir file lnk_file sock_file fifo_file })
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t httpd_var_lib_t:file create_file_perms;
Chris PeBenito e749cd
allow httpd_t httpd_var_lib_t:dir rw_dir_perms;
Chris PeBenito 1c1ac6
files_var_lib_filetrans(httpd_t,httpd_var_lib_t,file)
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t httpd_var_run_t:file create_file_perms;
Chris PeBenito a996bd
allow httpd_t httpd_var_run_t:sock_file create_file_perms;
Chris PeBenito a996bd
allow httpd_t httpd_var_run_t:dir rw_dir_perms;
Chris PeBenito 103fe2
files_pid_filetrans(httpd_t,httpd_var_run_t, { file sock_file })
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t squirrelmail_spool_t:dir create_dir_perms;
Chris PeBenito a996bd
allow httpd_t squirrelmail_spool_t:file create_file_perms;
Chris PeBenito a996bd
allow httpd_t squirrelmail_spool_t:lnk_file create_lnk_perms;
Chris PeBenito a996bd
Chris PeBenito 445522
kernel_read_kernel_sysctls(httpd_t)
Chris PeBenito a996bd
kernel_tcp_recvfrom(httpd_t)
Chris PeBenito a996bd
# for modules that want to access /proc/meminfo
Chris PeBenito a996bd
kernel_read_system_state(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
corenet_tcp_sendrecv_all_if(httpd_t)
Chris PeBenito a996bd
corenet_udp_sendrecv_all_if(httpd_t)
Chris PeBenito a996bd
corenet_raw_sendrecv_all_if(httpd_t)
Chris PeBenito a996bd
corenet_tcp_sendrecv_all_nodes(httpd_t)
Chris PeBenito a996bd
corenet_udp_sendrecv_all_nodes(httpd_t)
Chris PeBenito a996bd
corenet_raw_sendrecv_all_nodes(httpd_t)
Chris PeBenito a996bd
corenet_tcp_sendrecv_all_ports(httpd_t)
Chris PeBenito a996bd
corenet_udp_sendrecv_all_ports(httpd_t)
Chris PeBenito bd7037
corenet_non_ipsec_sendrecv(httpd_t)
Chris PeBenito a996bd
corenet_tcp_bind_all_nodes(httpd_t)
Chris PeBenito a996bd
corenet_udp_bind_all_nodes(httpd_t)
Chris PeBenito a996bd
corenet_tcp_bind_http_port(httpd_t)
Chris PeBenito a996bd
corenet_tcp_bind_http_cache_port(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
dev_read_sysfs(httpd_t)
Chris PeBenito a996bd
dev_read_rand(httpd_t)
Chris PeBenito a996bd
dev_read_urand(httpd_t)
Chris PeBenito c2b18f
dev_rw_crypto(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
fs_getattr_all_fs(httpd_t)
Chris PeBenito a996bd
fs_search_auto_mountpoints(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
term_dontaudit_use_console(httpd_t)
Chris PeBenito a996bd
Chris PeBenito 77f6e2
auth_use_nsswitch(httpd_t)
Chris PeBenito 77f6e2
Chris PeBenito a996bd
# execute perl
Chris PeBenito a996bd
corecmd_exec_bin(httpd_t)
Chris PeBenito a996bd
corecmd_exec_sbin(httpd_t)
Chris PeBenito a996bd
Chris PeBenito 15722e
domain_use_interactive_fds(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
files_read_usr_files(httpd_t)
Chris PeBenito a996bd
files_list_mnt(httpd_t)
Chris PeBenito a996bd
files_search_spool(httpd_t)
Chris PeBenito a996bd
files_read_var_lib_files(httpd_t)
Chris PeBenito a996bd
files_search_home(httpd_t)
Chris PeBenito a996bd
files_getattr_home_dir(httpd_t)
Chris PeBenito a996bd
# for modules that want to access /etc/mtab
Chris PeBenito a996bd
files_read_etc_runtime_files(httpd_t)
Chris PeBenito a996bd
# Allow httpd_t to have access to files such as nisswitch.conf
Chris PeBenito a996bd
files_read_etc_files(httpd_t)
Chris PeBenito 6e99a6
# for tomcat
Chris PeBenito 6e99a6
files_read_var_lib_symlinks(httpd_t)
Chris PeBenito a996bd
Chris PeBenito 1c1ac6
init_use_fds(httpd_t)
Chris PeBenito 1815ba
init_use_script_ptys(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
libs_use_ld_so(httpd_t)
Chris PeBenito a996bd
libs_use_shared_libs(httpd_t)
Chris PeBenito 1815ba
libs_read_lib_files(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
logging_send_syslog_msg(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
miscfiles_read_localization(httpd_t)
Chris PeBenito a996bd
miscfiles_read_fonts(httpd_t)
Chris PeBenito 6e99a6
miscfiles_read_public_files(httpd_t)
Chris PeBenito 6e99a6
miscfiles_read_certs(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
seutil_dontaudit_search_config(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
sysnet_use_ldap(httpd_t)
Chris PeBenito a996bd
sysnet_read_config(httpd_t)
Chris PeBenito a996bd
Chris PeBenito 103fe2
userdom_use_unpriv_users_fds(httpd_t)
Chris PeBenito 103fe2
userdom_dontaudit_search_sysadm_home_dirs(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
mta_send_mail(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
ifdef(`targeted_policy',`
Chris PeBenito 1815ba
	term_dontaudit_use_unallocated_ttys(httpd_t)
Chris PeBenito 1815ba
	term_dontaudit_use_generic_ptys(httpd_t)
Chris PeBenito 9e04f5
	files_dontaudit_read_root_files(httpd_t)
Chris PeBenito 4614e8
Chris PeBenito 4614e8
	tunable_policy(`httpd_enable_homedirs',`
Chris PeBenito 103fe2
		userdom_search_generic_user_home_dirs(httpd_t)
Chris PeBenito 4614e8
	')
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 6e99a6
tunable_policy(`allow_httpd_anon_write',`
Chris PeBenito 6e99a6
	miscfiles_manage_public_files(httpd_t)
Chris PeBenito 6e99a6
') 
Chris PeBenito 6e99a6
Chris PeBenito 6e99a6
tunable_policy(`httpd_can_network_connect',`
Chris PeBenito 6e99a6
	allow httpd_t self:tcp_socket create_socket_perms;
Chris PeBenito 6e99a6
	allow httpd_t self:udp_socket create_socket_perms;
Chris PeBenito 6e99a6
Chris PeBenito 6e99a6
	corenet_tcp_sendrecv_all_if(httpd_t)
Chris PeBenito 6e99a6
	corenet_udp_sendrecv_all_if(httpd_t)
Chris PeBenito 6e99a6
	corenet_raw_sendrecv_all_if(httpd_t)
Chris PeBenito 6e99a6
	corenet_tcp_sendrecv_all_nodes(httpd_t)
Chris PeBenito 6e99a6
	corenet_udp_sendrecv_all_nodes(httpd_t)
Chris PeBenito 6e99a6
	corenet_raw_sendrecv_all_nodes(httpd_t)
Chris PeBenito 6e99a6
	corenet_tcp_sendrecv_all_ports(httpd_t)
Chris PeBenito 6e99a6
	corenet_udp_sendrecv_all_ports(httpd_t)
Chris PeBenito bd7037
	corenet_non_ipsec_sendrecv(httpd_t)
Chris PeBenito 6e99a6
	corenet_tcp_bind_all_nodes(httpd_t)
Chris PeBenito 6e99a6
	corenet_udp_bind_all_nodes(httpd_t)
Chris PeBenito 6e99a6
	corenet_tcp_connect_all_ports(httpd_t)
Chris PeBenito 6e99a6
Chris PeBenito 6e99a6
	sysnet_read_config(httpd_t)
Chris PeBenito 6e99a6
')
Chris PeBenito 6e99a6
Chris PeBenito bb4372
tunable_policy(`httpd_can_network_connect_db',`
Chris PeBenito bb4372
	# allow httpd to connect to mysql/posgresql
Chris PeBenito bb4372
	corenet_tcp_connect_postgresql_port(httpd_t)
Chris PeBenito bb4372
	corenet_tcp_connect_mysqld_port(httpd_t)
Chris PeBenito bb4372
')
Chris PeBenito bb4372
Chris PeBenito bb4372
tunable_policy(`httpd_can_network_relay',`
Chris PeBenito bb4372
	# allow httpd to work as a relay
Chris PeBenito bb4372
	corenet_tcp_connect_gopher_port(httpd_t)
Chris PeBenito bb4372
	corenet_tcp_connect_ftp_port(httpd_t)
Chris PeBenito bb4372
	corenet_tcp_connect_http_port(httpd_t)
Chris PeBenito bb4372
	corenet_tcp_connect_http_cache_port(httpd_t)
Chris PeBenito bb4372
')
Chris PeBenito bb4372
Chris PeBenito a996bd
tunable_policy(`httpd_enable_cgi',`
Chris PeBenito a996bd
	domain_auto_trans(httpd_t, httpd_unconfined_script_exec_t, httpd_unconfined_script_t)
Chris PeBenito a996bd
	allow httpd_t httpd_unconfined_script_t:fd use;
Chris PeBenito a996bd
	allow httpd_unconfined_script_t httpd_t:fd use;
Chris PeBenito a996bd
	allow httpd_unconfined_script_t httpd_t:fifo_file rw_file_perms;
Chris PeBenito a996bd
	allow httpd_unconfined_script_t httpd_t:process sigchld;
Chris PeBenito a996bd
Chris PeBenito a996bd
	allow httpd_t httpd_unconfined_script_t:process { signal sigkill sigstop };
Chris PeBenito a996bd
	allow httpd_t httpd_unconfined_script_exec_t:dir r_dir_perms;
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 6e99a6
tunable_policy(`httpd_enable_cgi && httpd_unified && httpd_builtin_scripting',`
Chris PeBenito 6e99a6
	domain_auto_trans(httpd_t, httpdcontent, httpd_sys_script_t)
Chris PeBenito 6e99a6
	allow httpd_t httpd_sys_script_t:fd use;
Chris PeBenito 6e99a6
	allow httpd_sys_script_t httpd_t:fd use;
Chris PeBenito 6e99a6
	allow httpd_sys_script_t httpd_t:fifo_file rw_file_perms;
Chris PeBenito 6e99a6
	allow httpd_sys_script_t httpd_t:process sigchld;
Chris PeBenito 6e99a6
Chris PeBenito 6e99a6
	allow httpd_t httpdcontent:dir create_dir_perms;
Chris PeBenito 6e99a6
	allow httpd_t httpdcontent:file create_file_perms;
Chris PeBenito 6e99a6
	allow httpd_t httpdcontent:lnk_file create_lnk_perms;
Chris PeBenito 4614e8
Chris PeBenito 4614e8
	# make sediff easier
Chris PeBenito 4614e8
	allow httpd_sys_script_t httpdcontent:file { rx_file_perms entrypoint };
Chris PeBenito 6e99a6
')
Chris PeBenito 6e99a6
Chris PeBenito bea7b4
tunable_policy(`httpd_enable_ftp_server',`
Chris PeBenito bea7b4
	corenet_tcp_bind_ftp_port(httpd_t)
Chris PeBenito bea7b4
')
Chris PeBenito bea7b4
Chris PeBenito a996bd
tunable_policy(`httpd_enable_homedirs && use_nfs_home_dirs',`
Chris PeBenito a996bd
	fs_read_nfs_files(httpd_t)
Chris PeBenito a996bd
	fs_read_nfs_symlinks(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
tunable_policy(`httpd_enable_homedirs && use_samba_home_dirs',`
Chris PeBenito a996bd
	fs_read_cifs_files(httpd_t)
Chris PeBenito a996bd
	fs_read_cifs_symlinks(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito e749cd
tunable_policy(`httpd_ssi_exec',`
Chris PeBenito e749cd
	corecmd_shell_domtrans(httpd_t,httpd_sys_script_t)
Chris PeBenito e749cd
	allow httpd_t httpd_sys_script_t:fd use;
Chris PeBenito e749cd
	allow httpd_sys_script_t httpd_t:fd use;
Chris PeBenito e749cd
	allow httpd_sys_script_t httpd_t:fifo_file rw_file_perms;
Chris PeBenito e749cd
	allow httpd_sys_script_t httpd_t:process sigchld;
Chris PeBenito e749cd
')
Chris PeBenito e749cd
Chris PeBenito 6e99a6
# When the admin starts the server, the server wants to access
Chris PeBenito 6e99a6
# the TTY or PTY associated with the session. The httpd appears
Chris PeBenito 6e99a6
# to run correctly without this permission, so the permission
Chris PeBenito 6e99a6
# are dontaudited here. 
Chris PeBenito 6e99a6
tunable_policy(`httpd_tty_comm',`
Chris PeBenito 9ca7e7
	# cjp: this is redundant:
Chris PeBenito 9ca7e7
	term_use_controlling_term(httpd_t)
Chris PeBenito 9ca7e7
Chris PeBenito 6e99a6
	userdom_use_sysadm_terms(httpd_t)
Chris PeBenito 6e99a6
',`
Chris PeBenito 6e99a6
	userdom_dontaudit_use_sysadm_terms(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 44d5d9
optional_policy(`daemontools',`
Chris PeBenito 44d5d9
	daemontools_service_domain(httpd_t, httpd_exec_t)
Chris PeBenito 44d5d9
')
Chris PeBenito 44d5d9
Chris PeBenito 132880
optional_policy(`kerberos',`
Chris PeBenito a996bd
	kerberos_use(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 132880
optional_policy(`mailman',`
Chris PeBenito 799a0b
	mailman_signal_cgi(httpd_t)
Chris PeBenito 799a0b
	mailman_domtrans_cgi(httpd_t)
Chris PeBenito 799a0b
	# should have separate types for public and private archives
Chris PeBenito 0500e0
	mailman_search_data(httpd_t)
Chris PeBenito 799a0b
	mailman_read_archive(httpd_t)
Chris PeBenito 799a0b
')
Chris PeBenito 799a0b
Chris PeBenito 132880
optional_policy(`mysql',`
Chris PeBenito a996bd
	mysql_stream_connect(httpd_t)
Chris PeBenito 1815ba
	mysql_rw_db_sockets(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 132880
optional_policy(`nscd',`
Chris PeBenito 1815ba
	nscd_socket_use(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 132880
optional_policy(`postgresql',` 
Chris PeBenito 725926
	# Allow httpd to work with postgresql
Chris PeBenito 1815ba
	postgresql_stream_connect(httpd_t)
Chris PeBenito 725926
')
Chris PeBenito 725926
Chris PeBenito 132880
optional_policy(`selinuxutil',`
Chris PeBenito a996bd
	seutil_sigchld_newrole(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 132880
optional_policy(`udev', `
Chris PeBenito a996bd
	udev_read_db(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
ifdef(`TODO',`
Chris PeBenito a996bd
can_tcp_connect(web_client_domain, httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
') dnl end TODO
Chris PeBenito a996bd
Chris PeBenito a996bd
########################################
Chris PeBenito a996bd
#
Chris PeBenito a996bd
# Apache helper local policy
Chris PeBenito a996bd
#
Chris PeBenito a996bd
Chris PeBenito a996bd
domain_auto_trans(httpd_t, httpd_helper_exec_t, httpd_helper_t)
Chris PeBenito a996bd
allow httpd_t httpd_helper_t:fd use;
Chris PeBenito a996bd
allow httpd_helper_t httpd_t:fd use;
Chris PeBenito a996bd
allow httpd_helper_t httpd_t:fifo_file rw_file_perms;
Chris PeBenito a996bd
allow httpd_helper_t httpd_t:process sigchld;
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_helper_t httpd_config_t:file { getattr read };
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_helper_t httpd_log_t:file append;
Chris PeBenito a996bd
Chris PeBenito a996bd
libs_use_ld_so(httpd_helper_t)
Chris PeBenito a996bd
libs_use_shared_libs(httpd_helper_t)
Chris PeBenito a996bd
Chris PeBenito e749cd
logging_send_syslog_msg(httpd_helper_t)
Chris PeBenito e749cd
Chris PeBenito aba9c7
tunable_policy(`httpd_tty_comm',`
Chris PeBenito aba9c7
	# cjp: this is redundant:
Chris PeBenito aba9c7
	term_use_controlling_term(httpd_helper_t)
Chris PeBenito aba9c7
Chris PeBenito aba9c7
	userdom_use_sysadm_terms(httpd_helper_t)
Chris PeBenito aba9c7
')
Chris PeBenito aba9c7
Chris PeBenito a996bd
########################################
Chris PeBenito a996bd
#
Chris PeBenito a996bd
# Apache PHP script local policy
Chris PeBenito a996bd
#
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_php_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
Chris PeBenito a996bd
allow httpd_php_t self:fd use;
Chris PeBenito a996bd
allow httpd_php_t self:fifo_file rw_file_perms;
Chris PeBenito 9ca7e7
allow httpd_php_t self:sock_file r_file_perms;
Chris PeBenito a996bd
allow httpd_php_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito a996bd
allow httpd_php_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito a996bd
allow httpd_php_t self:unix_dgram_socket sendto;
Chris PeBenito a996bd
allow httpd_php_t self:unix_stream_socket connectto;
Chris PeBenito a996bd
allow httpd_php_t self:shm create_shm_perms;
Chris PeBenito a996bd
allow httpd_php_t self:sem create_sem_perms;
Chris PeBenito a996bd
allow httpd_php_t self:msgq create_msgq_perms;
Chris PeBenito a996bd
allow httpd_php_t self:msg { send receive };
Chris PeBenito a996bd
Chris PeBenito a996bd
domain_auto_trans(httpd_t, httpd_php_exec_t, httpd_php_t)
Chris PeBenito a996bd
allow httpd_t httpd_php_t:fd use;
Chris PeBenito a996bd
allow httpd_php_t httpd_t:fd use;
Chris PeBenito a996bd
allow httpd_php_t httpd_t:fifo_file rw_file_perms;
Chris PeBenito a996bd
allow httpd_php_t httpd_t:process sigchld;
Chris PeBenito a996bd
Chris PeBenito a996bd
# allow php to read and append to apache logfiles
Chris PeBenito a996bd
allow httpd_php_t httpd_log_t:file ra_file_perms;
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_php_t httpd_php_tmp_t:dir create_dir_perms;
Chris PeBenito a996bd
allow httpd_php_t httpd_php_tmp_t:file create_file_perms;
Chris PeBenito 103fe2
files_tmp_filetrans(httpd_php_t, httpd_php_tmp_t, { file dir })
Chris PeBenito a996bd
Chris PeBenito a996bd
fs_search_auto_mountpoints(httpd_php_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
libs_exec_lib_files(httpd_php_t)
Chris PeBenito a996bd
libs_use_ld_so(httpd_php_t)
Chris PeBenito a996bd
libs_use_shared_libs(httpd_php_t)
Chris PeBenito a996bd
Chris PeBenito 103fe2
userdom_use_unpriv_users_fds(httpd_php_t)
Chris PeBenito a996bd
Chris PeBenito 132880
optional_policy(`mysql',`
Chris PeBenito a996bd
	mysql_stream_connect(httpd_php_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 132880
optional_policy(`nis',`
Chris PeBenito a996bd
	nis_use_ypbind(httpd_php_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
########################################
Chris PeBenito a996bd
#
Chris PeBenito a996bd
# Apache suexec local policy
Chris PeBenito a996bd
#
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_suexec_t self:capability { setuid setgid };
Chris PeBenito a996bd
allow httpd_suexec_t self:process signal_perms;
Chris PeBenito a996bd
allow httpd_suexec_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito a996bd
Chris PeBenito 4614e8
ifdef(`targeted_policy',`
Chris PeBenito 4614e8
	gen_tunable(httpd_suexec_disable_trans,false)
Chris PeBenito 4614e8
Chris PeBenito 4614e8
	tunable_policy(`httpd_suexec_disable_trans',`',`
Chris PeBenito 4614e8
		domain_auto_trans(httpd_t, httpd_suexec_exec_t, httpd_suexec_t)
Chris PeBenito 4614e8
		allow httpd_t httpd_suexec_t:fd use;
Chris PeBenito 4614e8
		allow httpd_suexec_t httpd_t:fd use;
Chris PeBenito 4614e8
		allow httpd_suexec_t httpd_t:fifo_file rw_file_perms;
Chris PeBenito 4614e8
		allow httpd_suexec_t httpd_t:process sigchld;
Chris PeBenito 4614e8
	')
Chris PeBenito 4614e8
')
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_suexec_t httpd_log_t:dir ra_dir_perms;
Chris PeBenito a996bd
allow httpd_suexec_t httpd_log_t:file { create ra_file_perms };
Chris PeBenito a996bd
allow httpd_suexec_t httpd_t:fifo_file getattr;
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_suexec_t httpd_suexec_tmp_t:dir create_dir_perms;
Chris PeBenito a996bd
allow httpd_suexec_t httpd_suexec_tmp_t:file create_file_perms;
Chris PeBenito 103fe2
files_tmp_filetrans(httpd_suexec_t, httpd_suexec_tmp_t, { file dir })
Chris PeBenito a996bd
Chris PeBenito 445522
kernel_read_kernel_sysctls(httpd_suexec_t)
Chris PeBenito a996bd
kernel_list_proc(httpd_suexec_t)
Chris PeBenito a996bd
kernel_read_proc_symlinks(httpd_suexec_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
dev_read_urand(httpd_suexec_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
fs_search_auto_mountpoints(httpd_suexec_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
# for shell scripts
Chris PeBenito a996bd
corecmd_exec_bin(httpd_suexec_t)
Chris PeBenito a996bd
corecmd_exec_shell(httpd_suexec_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
files_read_etc_files(httpd_suexec_t)
Chris PeBenito a996bd
files_read_usr_files(httpd_suexec_t)
Chris PeBenito 6e99a6
files_dontaudit_search_pids(httpd_suexec_t)
Chris PeBenito 725926
files_search_home(httpd_suexec_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
libs_use_ld_so(httpd_suexec_t)
Chris PeBenito a996bd
libs_use_shared_libs(httpd_suexec_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
logging_search_logs(httpd_suexec_t)
Chris PeBenito a996bd
logging_send_syslog_msg(httpd_suexec_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
miscfiles_read_localization(httpd_suexec_t)
Chris PeBenito a996bd
Chris PeBenito 4614e8
ifdef(`targeted_policy',`
Chris PeBenito 4614e8
	tunable_policy(`httpd_enable_homedirs',`
Chris PeBenito 103fe2
		userdom_search_generic_user_home_dirs(httpd_suexec_t)
Chris PeBenito 4614e8
	')
Chris PeBenito 4614e8
')
Chris PeBenito 4614e8
Chris PeBenito a996bd
tunable_policy(`httpd_can_network_connect',`
Chris PeBenito a996bd
	allow httpd_suexec_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito a996bd
	allow httpd_suexec_t self:udp_socket create_socket_perms;
Chris PeBenito a996bd
Chris PeBenito a996bd
	corenet_tcp_sendrecv_all_if(httpd_suexec_t)
Chris PeBenito a996bd
	corenet_udp_sendrecv_all_if(httpd_suexec_t)
Chris PeBenito a996bd
	corenet_raw_sendrecv_all_if(httpd_suexec_t)
Chris PeBenito a996bd
	corenet_tcp_sendrecv_all_nodes(httpd_suexec_t)
Chris PeBenito a996bd
	corenet_udp_sendrecv_all_nodes(httpd_suexec_t)
Chris PeBenito a996bd
	corenet_raw_sendrecv_all_nodes(httpd_suexec_t)
Chris PeBenito a996bd
	corenet_tcp_sendrecv_all_ports(httpd_suexec_t)
Chris PeBenito a996bd
	corenet_udp_sendrecv_all_ports(httpd_suexec_t)
Chris PeBenito bd7037
	corenet_non_ipsec_sendrecv(httpd_suexec_t)
Chris PeBenito a996bd
	corenet_tcp_bind_all_nodes(httpd_suexec_t)
Chris PeBenito a996bd
	corenet_udp_bind_all_nodes(httpd_suexec_t)
Chris PeBenito a996bd
	corenet_tcp_connect_all_ports(httpd_suexec_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
	sysnet_read_config(httpd_suexec_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 6e99a6
tunable_policy(`httpd_enable_cgi',`
Chris PeBenito 6e99a6
	domain_auto_trans(httpd_suexec_t, httpd_unconfined_script_exec_t, httpd_unconfined_script_t)
Chris PeBenito 4614e8
	allow httpd_suexec_t httpd_unconfined_script_t:fd use;
Chris PeBenito 4614e8
	allow httpd_unconfined_script_t httpd_suexec_t:fd use;
Chris PeBenito 4614e8
	allow httpd_unconfined_script_t httpd_suexec_t:fifo_file rw_file_perms;
Chris PeBenito 4614e8
	allow httpd_unconfined_script_t httpd_suexec_t:process sigchld;
Chris PeBenito 4614e8
Chris PeBenito 4614e8
	# make sediff happy
Chris PeBenito 4614e8
	allow httpd_unconfined_script_t httpd_unconfined_script_exec_t:file { ioctl read getattr lock execute entrypoint };
Chris PeBenito 6e99a6
')
Chris PeBenito 6e99a6
Chris PeBenito 6e99a6
tunable_policy(`httpd_enable_cgi && httpd_unified',`
Chris PeBenito 6e99a6
	domain_auto_trans(httpd_suexec_t, httpdcontent, httpd_sys_script_t)
Chris PeBenito 6e99a6
	allow httpd_suexec_t httpd_sys_script_t:fd use;
Chris PeBenito 6e99a6
	allow httpd_sys_script_t httpd_suexec_t:fd use;
Chris PeBenito 6e99a6
	allow httpd_sys_script_t httpd_suexec_t:fifo_file rw_file_perms;
Chris PeBenito 6e99a6
	allow httpd_sys_script_t httpd_suexec_t:process sigchld;
Chris PeBenito 6e99a6
')
Chris PeBenito 6e99a6
Chris PeBenito 955019
tunable_policy(`httpd_enable_cgi && httpd_unified && httpd_builtin_scripting',`
Chris PeBenito 955019
	domain_auto_trans(httpd_suexec_t, httpdcontent, httpd_sys_script_t)
Chris PeBenito 955019
')
Chris PeBenito 955019
Chris PeBenito a996bd
tunable_policy(`httpd_enable_homedirs && use_nfs_home_dirs',`
Chris PeBenito a996bd
	fs_read_nfs_files(httpd_suexec_t)
Chris PeBenito a996bd
	fs_read_nfs_symlinks(httpd_suexec_t)
Chris PeBenito 4d851f
	fs_exec_nfs_files(httpd_suexec_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
tunable_policy(`httpd_enable_homedirs && use_samba_home_dirs',`
Chris PeBenito a996bd
	fs_read_cifs_files(httpd_suexec_t)
Chris PeBenito a996bd
	fs_read_cifs_symlinks(httpd_suexec_t)
Chris PeBenito 4d851f
	fs_exec_cifs_files(httpd_suexec_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 132880
optional_policy(`mailman',`
Chris PeBenito 799a0b
	mailman_domtrans_cgi(httpd_suexec_t)
Chris PeBenito 799a0b
')
Chris PeBenito 799a0b
Chris PeBenito 132880
optional_policy(`mount',`
Chris PeBenito a996bd
	tunable_policy(`httpd_can_network_connect',`
Chris PeBenito a996bd
		mount_send_nfs_client_request(httpd_suexec_t)
Chris PeBenito a996bd
	')
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 132880
optional_policy(`mta',`
Chris PeBenito 725926
	mta_stub(httpd_suexec_t)
Chris PeBenito 725926
Chris PeBenito 725926
	# apache should set close-on-exec
Chris PeBenito 725926
	dontaudit httpd_suexec_t httpd_t:unix_stream_socket { read write };
Chris PeBenito 725926
')
Chris PeBenito 725926
Chris PeBenito 132880
optional_policy(`nis',`
Chris PeBenito a996bd
	nis_use_ypbind(httpd_suexec_t)
Chris PeBenito a996bd
')
Chris PeBenito e11d2e
Chris PeBenito 132880
optional_policy(`nscd',`
Chris PeBenito 1815ba
	nscd_socket_use(httpd_suexec_t)
Chris PeBenito e11d2e
')
Chris PeBenito a996bd
Chris PeBenito a996bd
########################################
Chris PeBenito a996bd
#
Chris PeBenito a996bd
# Apache system script local policy
Chris PeBenito a996bd
#
Chris PeBenito a996bd
Chris PeBenito 6e99a6
allow httpd_sys_script_t httpd_t:tcp_socket { read write };
Chris PeBenito 6e99a6
Chris PeBenito 6e99a6
dontaudit httpd_sys_script_t httpd_config_t:dir search;
Chris PeBenito 6e99a6
Chris PeBenito 6e99a6
allow httpd_sys_script_t httpd_squirrelmail_t:file { append read };
Chris PeBenito 6e99a6
Chris PeBenito 6e99a6
allow httpd_sys_script_t squirrelmail_spool_t:dir r_dir_perms;
Chris PeBenito 6e99a6
allow httpd_sys_script_t squirrelmail_spool_t:file r_file_perms;
Chris PeBenito 6e99a6
allow httpd_sys_script_t squirrelmail_spool_t:lnk_file { getattr read };
Chris PeBenito 6e99a6
Chris PeBenito 445522
kernel_read_kernel_sysctls(httpd_sys_script_t)
Chris PeBenito 6e99a6
Chris PeBenito 6e99a6
files_search_var_lib(httpd_sys_script_t)
Chris PeBenito 6e99a6
files_search_spool(httpd_sys_script_t)
Chris PeBenito 6e99a6
Chris PeBenito 6e99a6
ifdef(`distro_redhat',`
Chris PeBenito 6e99a6
	allow httpd_sys_script_t httpd_log_t:file { getattr append };
Chris PeBenito 6e99a6
')
Chris PeBenito 6e99a6
Chris PeBenito 4614e8
ifdef(`targeted_policy',`
Chris PeBenito 4614e8
	tunable_policy(`httpd_enable_homedirs',`
Chris PeBenito 103fe2
		userdom_search_generic_user_home_dirs(httpd_sys_script_t)
Chris PeBenito 4614e8
	')
Chris PeBenito 4614e8
')
Chris PeBenito 4614e8
Chris PeBenito 132880
optional_policy(`mysql',`
Chris PeBenito 6e99a6
	mysql_stream_connect(httpd_sys_script_t)
Chris PeBenito 1815ba
	mysql_rw_db_sockets(httpd_sys_script_t)
Chris PeBenito 6e99a6
')
Chris PeBenito 6e99a6
Chris PeBenito a996bd
########################################
Chris PeBenito a996bd
#
Chris PeBenito a996bd
# Apache unconfined script local policy
Chris PeBenito a996bd
#
Chris PeBenito a996bd
Chris PeBenito 955019
unconfined_domain(httpd_unconfined_script_t)
Chris PeBenito a996bd
Chris PeBenito 93727e
optional_policy(`cron',`
Chris PeBenito 93727e
	cron_system_entry(httpd_t, httpd_exec_t)
Chris PeBenito 93727e
')
Chris PeBenito 93727e
Chris PeBenito 132880
optional_policy(`nscd',`
Chris PeBenito 1815ba
	nscd_socket_use(httpd_unconfined_script_t)
Chris PeBenito a996bd
')