0ce23f
# This policy module provides support for mod_fcgid using the httpd system script domain.
0ce23f
# It provides "allow" rules that will overlap to varying degrees with selinux-policy
0ce23f
# packages for Fedora 5 onwards, and is a stepping stone to the merged policy included
0ce23f
# as updates for selinux-policy in Fedora 8, 9, and 10.
0ce23f
#
0ce23f
# Rules existing in selinux-policy 2.3.7 (FC5) have been stripped from this policy
0ce23f
#
0ce23f
# Previous versions of this policy module used a separate domain, httpd_fastcgi_script_t,
0ce23f
# which is now an alias for httpd_sys_script_t.
0ce23f
0ce23f
policy_module(fastcgi, 0.1.11)
0ce23f
0ce23f
require {
0ce23f
	type devpts_t;
0ce23f
	type httpd_t;
0ce23f
	type httpd_log_t;
0ce23f
	type httpd_sys_content_t;
0ce23f
	type httpd_sys_script_exec_t;
0ce23f
	type httpd_sys_script_ra_t;
0ce23f
	type httpd_sys_script_ro_t;
0ce23f
	type httpd_sys_script_rw_t;
0ce23f
	type httpd_sys_script_t;
0ce23f
	type httpd_tmp_t;
0ce23f
	type httpd_var_run_t;
0ce23f
};
0ce23f
0ce23f
# Type aliases for contexts used with older policy modules
0ce23f
typealias httpd_sys_content_t     alias httpd_fastcgi_content_t;
0ce23f
typealias httpd_sys_script_exec_t alias httpd_fastcgi_script_exec_t;
0ce23f
typealias httpd_sys_script_ra_t   alias httpd_fastcgi_script_ra_t;
0ce23f
typealias httpd_sys_script_ro_t   alias httpd_fastcgi_script_ro_t;
0ce23f
typealias httpd_sys_script_rw_t   alias httpd_fastcgi_script_rw_t;
0ce23f
typealias httpd_sys_script_t      alias httpd_fastcgi_script_t;
0ce23f
typealias httpd_var_run_t         alias httpd_fastcgi_var_run_t;
0ce23f
0ce23f
# ==========================================================
0ce23f
# Re-use httpd_sys_script_t for mod_fcgid apps
0ce23f
# ==========================================================
0ce23f
0ce23f
# Allow web applications to call getpw* functions
0ce23f
auth_use_nsswitch(httpd_sys_script_t)
0ce23f
0ce23f
# Allow httpd to create and use files and sockets for communicating with mod_fcgid
0ce23f
# Rules to do this are already in selinux-policy apart from dir setattr
0ce23f
allow httpd_t httpd_var_run_t:dir setattr;
0ce23f
0ce23f
# Allow FastCGI applications to listen for FastCGI requests on their
0ce23f
# sockets and respond to them
0ce23f
allow httpd_sys_script_t httpd_t:unix_stream_socket { rw_stream_socket_perms };
0ce23f
0ce23f
# These are probably leaked file descriptors
0ce23f
dontaudit httpd_t devpts_t:chr_file ioctl;
0ce23f
dontaudit httpd_sys_script_t httpd_log_t:file ioctl;
0ce23f
0ce23f
# Search automount filesystem to use automatically mounted filesystems
0ce23f
fs_search_auto_mountpoints(httpd_sys_script_t)
0ce23f
0ce23f
# PHP uploads a file to /tmp and then execs programs to action them
0ce23f
allow httpd_sys_script_t httpd_tmp_t:dir manage_dir_perms;
0ce23f
allow httpd_sys_script_t httpd_tmp_t:file manage_file_perms;
0ce23f
files_tmp_filetrans(httpd_sys_script_t,httpd_sys_script_rw_t,{ dir file lnk_file sock_file fifo_file })
0ce23f
0ce23f
# Support network home directories
0ce23f
tunable_policy(`httpd_enable_homedirs && use_nfs_home_dirs',`
0ce23f
	fs_read_nfs_files(httpd_sys_script_t)
0ce23f
	fs_read_nfs_symlinks(httpd_sys_script_t)
0ce23f
')
0ce23f
tunable_policy(`httpd_enable_homedirs && use_samba_home_dirs',`
0ce23f
	fs_read_cifs_files(httpd_sys_script_t)
0ce23f
	fs_read_cifs_symlinks(httpd_sys_script_t)
0ce23f
')