Chris PeBenito a996bd
Chris PeBenito a996bd
policy_module(apache,1.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 a996bd
type httpd_t;
Chris PeBenito a996bd
type httpd_exec_t;
Chris PeBenito a996bd
init_daemon_domain(httpd_t,httpd_exec_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
domain_type(httpd_helper_t)
Chris PeBenito a996bd
role system_r types httpd_helper_t;
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_helper_exec_t;
Chris PeBenito a996bd
domain_entry_file(httpd_helper_t,httpd_helper_exec_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
domain_type(httpd_php_t)
Chris PeBenito a996bd
role system_r types httpd_php_t;
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_php_exec_t;
Chris PeBenito a996bd
domain_entry_file(httpd_php_t,httpd_php_exec_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
domain_type(httpd_suexec_t)
Chris PeBenito a996bd
role system_r types httpd_suexec_t;
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_suexec_exec_t;
Chris PeBenito a996bd
domain_entry_file(httpd_suexec_t,httpd_suexec_exec_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 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 a996bd
domain_type(httpd_unconfined_script_t)
Chris PeBenito a996bd
role system_r types httpd_unconfined_script_t;
Chris PeBenito a996bd
Chris PeBenito a996bd
type httpd_unconfined_script_exec_t; # customizable
Chris PeBenito a996bd
files_type(httpd_unconfined_script_exec_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 6e99a6
')
Chris PeBenito 6e99a6
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 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 a996bd
files_create_lock(httpd_t,httpd_lock_t)
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 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 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 a996bd
files_create_tmp_files(httpd_t, httpd_tmp_t, { file dir })
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t httpd_tmpfs_t:dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito a996bd
allow httpd_t httpd_tmpfs_t:file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito a996bd
allow httpd_t httpd_tmpfs_t:lnk_file { create read getattr setattr link unlink rename };
Chris PeBenito a996bd
allow httpd_t httpd_tmpfs_t:sock_file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito a996bd
allow httpd_t httpd_tmpfs_t:fifo_file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito a996bd
fs_create_tmpfs_data(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 a996bd
allow httpd_t httpd_var_lib_t:dir create_dir_perms;
Chris PeBenito a996bd
files_create_var_lib(httpd_t,httpd_var_lib_t)
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 a996bd
files_create_pid(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 a996bd
kernel_read_kernel_sysctl(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 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 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 a996bd
# execute perl
Chris PeBenito a996bd
corecmd_exec_bin(httpd_t)
Chris PeBenito a996bd
corecmd_exec_sbin(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
domain_use_wide_inherit_fd(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 a996bd
init_use_fd(httpd_t)
Chris PeBenito a996bd
init_use_script_pty(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 a996bd
libs_read_lib(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_dns_name_resolve(httpd_t)
Chris PeBenito a996bd
sysnet_use_ldap(httpd_t)
Chris PeBenito a996bd
sysnet_read_config(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
userdom_use_unpriv_users_fd(httpd_t)
Chris PeBenito a996bd
userdom_dontaudit_search_sysadm_home_dir(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
mta_send_mail(httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
ifdef(`targeted_policy',`
Chris PeBenito a996bd
	term_dontaudit_use_unallocated_tty(httpd_t)
Chris PeBenito a996bd
	term_dontaudit_use_generic_pty(httpd_t)
Chris PeBenito a996bd
	files_dontaudit_read_root_file(httpd_t)
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 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 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 6e99a6
')
Chris PeBenito 6e99a6
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 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 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 a996bd
optional_policy(`kerberos.te',`
Chris PeBenito a996bd
	kerberos_use(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`mta.te',`
Chris PeBenito a996bd
	# apache should set close-on-exec
Chris PeBenito a996bd
	dontaudit httpd_suexec_t httpd_t:unix_stream_socket { read write };
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`mysql.te',`
Chris PeBenito a996bd
	mysql_stream_connect(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`nis.te',`
Chris PeBenito a996bd
	nis_use_ypbind(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`nscd.te',`
Chris PeBenito a996bd
	nscd_use_socket(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`selinuxutil.te',`
Chris PeBenito a996bd
	seutil_sigchld_newrole(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`udev.te', `
Chris PeBenito a996bd
	udev_read_db(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
ifdef(`TODO',`
Chris PeBenito a996bd
optional_policy(`rhgb.te',`
Chris PeBenito a996bd
	rhgb_domain(httpd_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t var_log_t:dir ra_dir_perms;
Chris PeBenito a996bd
type_transition httpd_t var_log_t:file httpd_log_t;
Chris PeBenito a996bd
Chris PeBenito a996bd
can_tcp_connect(web_client_domain, httpd_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
allow httpd_t crypt_device_t:chr_file rw_file_perms;
Chris PeBenito a996bd
Chris PeBenito 6e99a6
allow httpd_t home_root_t:dir getattr;
Chris PeBenito a996bd
Chris PeBenito a996bd
dontaudit httpd_t sysadm_home_dir_t:dir getattr;
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`mysql.te',`
Chris PeBenito a996bd
	allow httpd_t mysqld_db_t:dir search;
Chris PeBenito a996bd
	allow httpd_t mysqld_db_t:sock_file rw_file_perms;
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
ifdef(`snmpd.te', `
Chris PeBenito a996bd
	dontaudit httpd_t snmpd_var_lib_t:dir search;
Chris PeBenito a996bd
	dontaudit httpd_t snmpd_var_lib_t:file { getattr write read };
Chris PeBenito a996bd
', `
Chris PeBenito a996bd
	dontaudit httpd_t usr_t:dir write;
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito 6e99a6
allow httpd_sys_script_t var_spool_t:dir getattr;
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`mysql.te',`
Chris PeBenito a996bd
	allow httpd_sys_script_t mysqld_db_t:dir search;
Chris PeBenito a996bd
	allow httpd_sys_script_t mysqld_db_t:sock_file rw_file_perms;
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
ifdef(`targeted_policy', `
Chris PeBenito a996bd
	typealias httpd_sys_content_t alias httpd_user_content_t;
Chris PeBenito a996bd
	typealias httpd_sys_script_exec_t alias httpd_user_script_exec_t;
Chris PeBenito a996bd
Chris PeBenito a996bd
	if (httpd_enable_homedirs) {
Chris PeBenito a996bd
		allow httpd_t user_home_dir_t:dir { getattr search };
Chris PeBenito a996bd
	}
Chris PeBenito a996bd
	if (httpd_enable_homedirs) {
Chris PeBenito a996bd
		allow httpd_sys_script_t user_home_dir_t:dir { getattr search };
Chris PeBenito a996bd
	}
Chris PeBenito a996bd
	if (httpd_enable_homedirs) {
Chris PeBenito a996bd
		allow httpd_suexec_t user_home_dir_t:dir { getattr search };
Chris PeBenito a996bd
	}
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
# We no longer call httpd_domain(sysadm), but need httpd_sysadm_content_t for file context
Chris PeBenito a996bd
typealias httpd_sys_content_t alias httpd_sysadm_content_t;
Chris PeBenito a996bd
Chris PeBenito 6e99a6
tunable_policy(`httpd_enable_cgi && httpd_unified',`
Chris PeBenito a996bd
	ifdef(`targeted_policy', `', `
Chris PeBenito a996bd
		domain_auto_trans(sysadm_t, httpdcontent, httpd_sys_script_t)
Chris PeBenito a996bd
	')
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`mta.te',`
Chris PeBenito a996bd
	# apache should set close-on-exec
Chris PeBenito a996bd
	dontaudit { system_mail_t mta_user_agent } { httpd_t httpd_sys_script_t }:unix_stream_socket { read write };
Chris PeBenito a996bd
	dontaudit system_mail_t httpd_log_t:file { append getattr };
Chris PeBenito a996bd
	allow system_mail_t httpd_squirrelmail_t:file { append read };
Chris PeBenito a996bd
	dontaudit system_mail_t httpd_t:tcp_socket { read write };
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 a996bd
# a "run" interface needs to be
Chris PeBenito a996bd
# added, and have sysadm_t use it
Chris PeBenito a996bd
# in a optional_policy block. for httpd_helper_t
Chris PeBenito a996bd
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 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 a996bd
files_create_tmp_files(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 a996bd
userdom_use_unpriv_users_fd(httpd_php_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`mysql.te',`
Chris PeBenito a996bd
	mysql_stream_connect(httpd_php_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`nis.te',`
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 a996bd
# cjp: need transitionbool
Chris PeBenito a996bd
domain_auto_trans(httpd_t, httpd_suexec_exec_t, httpd_suexec_t)
Chris PeBenito a996bd
allow httpd_t httpd_suexec_t:fd use;
Chris PeBenito a996bd
allow httpd_suexec_t httpd_t:fd use;
Chris PeBenito a996bd
allow httpd_suexec_t httpd_t:fifo_file rw_file_perms;
Chris PeBenito a996bd
allow httpd_suexec_t httpd_t:process sigchld;
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 a996bd
files_create_tmp_files(httpd_suexec_t, httpd_suexec_tmp_t, { file dir })
Chris PeBenito a996bd
Chris PeBenito a996bd
kernel_read_kernel_sysctl(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 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 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 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 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 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 a996bd
	fs_execute_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 a996bd
	fs_execute_cifs_files(httpd_suexec_t)
Chris PeBenito a996bd
')
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`mount.te',`
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 a996bd
optional_policy(`nis.te',`
Chris PeBenito a996bd
	nis_use_ypbind(httpd_suexec_t)
Chris PeBenito a996bd
')
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
# setup the system domain for system CGI scripts
Chris PeBenito a996bd
apache_content_template(sys)
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 6e99a6
kernel_read_kernel_sysctl(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 6e99a6
optional_policy(`mysql.te',`
Chris PeBenito 6e99a6
	mysql_stream_connect(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 a996bd
unconfined_domain_template(httpd_unconfined_script_t)
Chris PeBenito a996bd
Chris PeBenito a996bd
optional_policy(`nscd.te',`
Chris PeBenito a996bd
	nscd_use_socket(httpd_unconfined_script_t)
Chris PeBenito a996bd
')