2005-10-05 19:52:53 +00:00
|
|
|
|
2006-01-17 20:14:04 +00:00
|
|
|
policy_module(ftp,1.2.0)
|
2005-10-05 19:52:53 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Declarations
|
|
|
|
#
|
|
|
|
|
|
|
|
type ftpd_t;
|
|
|
|
type ftpd_exec_t;
|
|
|
|
init_daemon_domain(ftpd_t,ftpd_exec_t)
|
|
|
|
|
|
|
|
type ftpd_etc_t;
|
2005-10-24 18:40:24 +00:00
|
|
|
files_config_file(ftpd_etc_t)
|
2005-10-05 19:52:53 +00:00
|
|
|
|
|
|
|
# ftpd_lock_t is only needed when ftpd_is_daemon is true, but we cannot define types conditionally
|
|
|
|
type ftpd_lock_t;
|
|
|
|
files_lock_file(ftpd_lock_t)
|
|
|
|
|
|
|
|
type ftpd_tmp_t;
|
|
|
|
files_tmp_file(ftpd_tmp_t)
|
|
|
|
|
|
|
|
type ftpd_tmpfs_t;
|
|
|
|
files_tmpfs_file(ftpd_tmpfs_t)
|
|
|
|
|
|
|
|
type ftpd_var_run_t;
|
|
|
|
files_pid_file(ftpd_var_run_t)
|
|
|
|
|
|
|
|
type xferlog_t;
|
|
|
|
logging_log_file(xferlog_t)
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Local policy
|
|
|
|
#
|
|
|
|
|
|
|
|
allow ftpd_t self:capability { chown fowner fsetid setgid setuid sys_chroot sys_nice sys_resource };
|
|
|
|
dontaudit ftpd_t self:capability sys_tty_config;
|
|
|
|
allow ftpd_t self:process signal_perms;
|
|
|
|
allow ftpd_t self:process { getcap setcap setsched setrlimit };
|
|
|
|
allow ftpd_t self:fifo_file rw_file_perms;
|
|
|
|
allow ftpd_t self:unix_dgram_socket { sendto create_socket_perms };
|
|
|
|
allow ftpd_t self:unix_stream_socket create_socket_perms;
|
|
|
|
allow ftpd_t self:tcp_socket create_stream_socket_perms;
|
|
|
|
allow ftpd_t self:udp_socket create_socket_perms;
|
|
|
|
|
2005-10-21 21:35:25 +00:00
|
|
|
allow ftpd_t ftpd_etc_t:file r_file_perms;
|
2005-10-05 19:52:53 +00:00
|
|
|
|
|
|
|
allow ftpd_t ftpd_tmp_t:dir create_dir_perms;
|
|
|
|
allow ftpd_t ftpd_tmp_t:file create_file_perms;
|
2006-01-13 21:06:49 +00:00
|
|
|
files_filetrans_tmp(ftpd_t, ftpd_tmp_t, { file dir })
|
2005-10-05 19:52:53 +00:00
|
|
|
|
2005-10-21 21:35:25 +00:00
|
|
|
allow ftpd_t ftpd_tmpfs_t:fifo_file create_file_perms;
|
|
|
|
allow ftpd_t ftpd_tmpfs_t:dir create_dir_perms;
|
|
|
|
allow ftpd_t ftpd_tmpfs_t:file create_file_perms;
|
|
|
|
allow ftpd_t ftpd_tmpfs_t:lnk_file create_lnk_perms;
|
|
|
|
allow ftpd_t ftpd_tmpfs_t:sock_file create_file_perms;
|
2006-01-13 21:06:49 +00:00
|
|
|
fs_filetrans_tmpfs(ftpd_t,ftpd_tmpfs_t,{ dir file lnk_file sock_file fifo_file })
|
2005-10-05 19:52:53 +00:00
|
|
|
|
2005-10-21 21:35:25 +00:00
|
|
|
allow ftpd_t ftpd_var_run_t:file create_file_perms;
|
|
|
|
allow ftpd_t ftpd_var_run_t:dir rw_dir_perms;
|
2006-01-13 21:06:49 +00:00
|
|
|
files_filetrans_pid(ftpd_t,ftpd_var_run_t)
|
2005-10-21 21:35:25 +00:00
|
|
|
|
2005-10-05 19:52:53 +00:00
|
|
|
# Create and modify /var/log/xferlog.
|
|
|
|
allow ftpd_t xferlog_t:file create_file_perms;
|
2006-01-13 21:06:49 +00:00
|
|
|
logging_filetrans_log(ftpd_t,xferlog_t)
|
2005-10-05 19:52:53 +00:00
|
|
|
|
2006-01-31 16:49:43 +00:00
|
|
|
kernel_read_kernel_sysctls(ftpd_t)
|
2005-10-05 19:52:53 +00:00
|
|
|
kernel_read_system_state(ftpd_t)
|
|
|
|
|
|
|
|
dev_read_sysfs(ftpd_t)
|
|
|
|
dev_read_urand(ftpd_t)
|
|
|
|
|
2005-12-09 15:42:39 +00:00
|
|
|
corecmd_exec_bin(ftpd_t)
|
|
|
|
corecmd_exec_sbin(ftpd_t)
|
|
|
|
# Execute /bin/ls (can comment this out for proftpd)
|
|
|
|
# also may need rules to allow tar etc...
|
|
|
|
corecmd_exec_ls(ftpd_t)
|
2005-10-05 19:52:53 +00:00
|
|
|
|
|
|
|
corenet_tcp_sendrecv_all_if(ftpd_t)
|
|
|
|
corenet_udp_sendrecv_all_if(ftpd_t)
|
|
|
|
corenet_raw_sendrecv_all_if(ftpd_t)
|
|
|
|
corenet_tcp_sendrecv_all_nodes(ftpd_t)
|
|
|
|
corenet_udp_sendrecv_all_nodes(ftpd_t)
|
|
|
|
corenet_raw_sendrecv_all_nodes(ftpd_t)
|
|
|
|
corenet_tcp_sendrecv_all_ports(ftpd_t)
|
|
|
|
corenet_udp_sendrecv_all_ports(ftpd_t)
|
2005-12-06 19:59:50 +00:00
|
|
|
corenet_non_ipsec_sendrecv(ftpd_t)
|
2005-10-05 19:52:53 +00:00
|
|
|
corenet_tcp_bind_all_nodes(ftpd_t)
|
|
|
|
corenet_udp_bind_all_nodes(ftpd_t)
|
|
|
|
corenet_tcp_bind_ftp_data_port(ftpd_t)
|
|
|
|
corenet_tcp_bind_generic_port(ftpd_t)
|
|
|
|
corenet_tcp_connect_all_ports(ftpd_t)
|
|
|
|
|
2005-12-09 15:42:39 +00:00
|
|
|
domain_use_wide_inherit_fd(ftpd_t)
|
|
|
|
|
|
|
|
files_search_etc(ftpd_t)
|
|
|
|
files_read_etc_files(ftpd_t)
|
|
|
|
files_read_etc_runtime_files(ftpd_t)
|
2006-01-31 19:21:01 +00:00
|
|
|
files_search_var_lib(ftpd_t)
|
2005-12-09 15:42:39 +00:00
|
|
|
|
|
|
|
fs_search_auto_mountpoints(ftpd_t)
|
|
|
|
fs_getattr_all_fs(ftpd_t)
|
|
|
|
|
2005-10-05 19:52:53 +00:00
|
|
|
term_dontaudit_use_console(ftpd_t)
|
|
|
|
|
2005-12-09 15:42:39 +00:00
|
|
|
auth_use_nsswitch(ftpd_t)
|
2005-10-21 21:35:25 +00:00
|
|
|
auth_domtrans_chk_passwd(ftpd_t)
|
2005-10-05 19:52:53 +00:00
|
|
|
# Append to /var/log/wtmp.
|
|
|
|
auth_append_login_records(ftpd_t)
|
|
|
|
#kerberized ftp requires the following
|
|
|
|
auth_write_login_records(ftpd_t)
|
|
|
|
|
|
|
|
init_use_fd(ftpd_t)
|
2006-02-02 21:08:12 +00:00
|
|
|
init_use_script_ptys(ftpd_t)
|
2005-10-05 19:52:53 +00:00
|
|
|
|
|
|
|
libs_use_ld_so(ftpd_t)
|
|
|
|
libs_use_shared_libs(ftpd_t)
|
|
|
|
|
|
|
|
logging_send_syslog_msg(ftpd_t)
|
|
|
|
|
|
|
|
miscfiles_read_localization(ftpd_t)
|
|
|
|
miscfiles_read_public_files(ftpd_t)
|
|
|
|
|
|
|
|
seutil_dontaudit_search_config(ftpd_t)
|
|
|
|
|
|
|
|
sysnet_read_config(ftpd_t)
|
|
|
|
|
|
|
|
userdom_dontaudit_search_sysadm_home_dir(ftpd_t)
|
|
|
|
userdom_dontaudit_use_unpriv_user_fd(ftpd_t)
|
|
|
|
|
|
|
|
ifdef(`targeted_policy',`
|
2006-01-31 19:21:01 +00:00
|
|
|
files_dontaudit_read_root_files(ftpd_t)
|
2005-10-05 19:52:53 +00:00
|
|
|
|
2006-02-02 21:08:12 +00:00
|
|
|
term_dontaudit_use_generic_ptys(ftpd_t)
|
|
|
|
term_dontaudit_use_unallocated_ttys(ftpd_t)
|
2005-11-08 22:00:30 +00:00
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`ftp',`
|
2005-11-08 22:00:30 +00:00
|
|
|
tunable_policy(`ftpd_is_daemon',`
|
|
|
|
# cjp: fix this to use regular interfaces
|
|
|
|
userdom_manage_user_home_subdir_files(user,ftpd_t)
|
|
|
|
userdom_manage_user_home_subdir_symlinks(user,ftpd_t)
|
|
|
|
userdom_manage_user_home_subdir_sockets(user,ftpd_t)
|
|
|
|
userdom_manage_user_home_subdir_pipes(user,ftpd_t)
|
|
|
|
userdom_create_user_home(user,ftpd_t,{ dir file lnk_file sock_file fifo_file })
|
|
|
|
')
|
|
|
|
')
|
2005-10-05 19:52:53 +00:00
|
|
|
')
|
|
|
|
|
|
|
|
tunable_policy(`allow_ftpd_anon_write',`
|
|
|
|
miscfiles_manage_public_files(ftpd_t)
|
|
|
|
')
|
|
|
|
|
|
|
|
tunable_policy(`ftp_home_dir',`
|
|
|
|
# allow access to /home
|
2005-10-14 17:55:40 +00:00
|
|
|
files_list_home(ftpd_t)
|
2005-10-05 19:52:53 +00:00
|
|
|
userdom_read_all_user_files(ftpd_t)
|
|
|
|
userdom_manage_all_user_dirs(ftpd_t)
|
|
|
|
userdom_manage_all_user_files(ftpd_t)
|
|
|
|
userdom_manage_all_user_symlinks(ftpd_t)
|
2005-10-14 17:55:40 +00:00
|
|
|
|
|
|
|
ifdef(`targeted_policy',`
|
2006-01-13 21:06:49 +00:00
|
|
|
userdom_filetrans_generic_user_home(ftpd_t,{ dir file lnk_file sock_file fifo_file })
|
2005-10-14 17:55:40 +00:00
|
|
|
')
|
2005-10-05 19:52:53 +00:00
|
|
|
')
|
|
|
|
|
|
|
|
tunable_policy(`ftpd_is_daemon',`
|
|
|
|
allow ftpd_t ftpd_lock_t:file create_file_perms;
|
2006-01-13 21:06:49 +00:00
|
|
|
files_filetrans_lock(ftpd_t,ftpd_lock_t)
|
2005-10-05 19:52:53 +00:00
|
|
|
|
|
|
|
corenet_tcp_bind_ftp_port(ftpd_t)
|
|
|
|
')
|
|
|
|
|
|
|
|
tunable_policy(`use_nfs_home_dirs && ftp_home_dir',`
|
|
|
|
fs_read_nfs_files(ftpd_t)
|
|
|
|
fs_read_nfs_symlinks(ftpd_t)
|
|
|
|
')
|
|
|
|
|
|
|
|
tunable_policy(`use_samba_home_dirs && ftp_home_dir',`
|
|
|
|
fs_read_cifs_files(ftpd_t)
|
|
|
|
fs_read_cifs_symlinks(ftpd_t)
|
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`cron',`
|
2005-10-05 19:52:53 +00:00
|
|
|
corecmd_exec_shell(ftpd_t)
|
|
|
|
|
2005-10-13 20:59:36 +00:00
|
|
|
files_read_usr_files(ftpd_t)
|
2005-10-05 19:52:53 +00:00
|
|
|
|
|
|
|
cron_system_entry(ftpd_t, ftpd_exec_t)
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`logrotate',`
|
2005-10-05 19:52:53 +00:00
|
|
|
logrotate_exec(ftpd_t)
|
|
|
|
')
|
|
|
|
')
|
|
|
|
|
2006-01-16 18:30:14 +00:00
|
|
|
optional_policy(`daemontools',`
|
|
|
|
daemontools_service_domain(ftpd_t, ftpd_exec_t)
|
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`inetd',`
|
2005-10-25 17:50:00 +00:00
|
|
|
#reh: typeattributes not allowed in conditionals yet.
|
|
|
|
#tunable_policy(`! ftpd_is_daemon',`
|
|
|
|
# inetd_tcp_service_domain(ftpd_t,ftpd_exec_t)
|
|
|
|
#')
|
2005-10-05 19:52:53 +00:00
|
|
|
|
2005-11-01 21:15:11 +00:00
|
|
|
inetd_tcp_service_domain(ftpd_t,ftpd_exec_t)
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`tcpd',`
|
2005-10-13 20:59:36 +00:00
|
|
|
tunable_policy(`! ftpd_is_daemon',`
|
2005-10-05 19:52:53 +00:00
|
|
|
tcpd_domtrans(tcpd_t)
|
|
|
|
')
|
2005-10-13 20:59:36 +00:00
|
|
|
')
|
2005-10-05 19:52:53 +00:00
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`mount',`
|
2005-10-05 19:52:53 +00:00
|
|
|
mount_send_nfs_client_request(ftpd_t)
|
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`nscd',`
|
2006-02-02 21:08:12 +00:00
|
|
|
nscd_socket_use(ftpd_t)
|
2005-10-21 21:35:25 +00:00
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`selinuxutil',`
|
2005-10-05 19:52:53 +00:00
|
|
|
seutil_sigchld_newrole(ftpd_t)
|
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`udev', `
|
2005-10-05 19:52:53 +00:00
|
|
|
udev_read_db(ftpd_t)
|
|
|
|
')
|