|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
policy_module(ftp,1.0)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
########################################
|
|
Chris PeBenito |
fc6524 |
#
|
|
Chris PeBenito |
fc6524 |
# Declarations
|
|
Chris PeBenito |
fc6524 |
#
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
type ftpd_t;
|
|
Chris PeBenito |
fc6524 |
type ftpd_exec_t;
|
|
Chris PeBenito |
fc6524 |
init_daemon_domain(ftpd_t,ftpd_exec_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
type ftpd_etc_t;
|
|
Chris PeBenito |
fc6524 |
files_type(ftpd_etc_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
# ftpd_lock_t is only needed when ftpd_is_daemon is true, but we cannot define types conditionally
|
|
Chris PeBenito |
fc6524 |
type ftpd_lock_t;
|
|
Chris PeBenito |
fc6524 |
files_lock_file(ftpd_lock_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
type ftpd_tmp_t;
|
|
Chris PeBenito |
fc6524 |
files_tmp_file(ftpd_tmp_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
type ftpd_tmpfs_t;
|
|
Chris PeBenito |
fc6524 |
files_tmpfs_file(ftpd_tmpfs_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
type ftpd_var_run_t;
|
|
Chris PeBenito |
fc6524 |
files_pid_file(ftpd_var_run_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
type xferlog_t;
|
|
Chris PeBenito |
fc6524 |
logging_log_file(xferlog_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
########################################
|
|
Chris PeBenito |
fc6524 |
#
|
|
Chris PeBenito |
fc6524 |
# Local policy
|
|
Chris PeBenito |
fc6524 |
#
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t self:capability { chown fowner fsetid setgid setuid sys_chroot sys_nice sys_resource };
|
|
Chris PeBenito |
fc6524 |
dontaudit ftpd_t self:capability sys_tty_config;
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t self:process signal_perms;
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t self:process { getcap setcap setsched setrlimit };
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t self:fifo_file rw_file_perms;
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t self:unix_dgram_socket { sendto create_socket_perms };
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t self:unix_stream_socket create_socket_perms;
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t self:tcp_socket create_stream_socket_perms;
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t self:udp_socket create_socket_perms;
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t ftpd_etc_t:file { getattr read };
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t ftpd_tmp_t:dir create_dir_perms;
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t ftpd_tmp_t:file create_file_perms;
|
|
Chris PeBenito |
fc6524 |
files_create_tmp_files(ftpd_t, ftpd_tmp_t, { file dir })
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t ftpd_tmpfs_t:fifo_file { create ioctl read getattr lock write setattr append link unlink rename };
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t ftpd_tmpfs_t:dir { read getattr lock search ioctl add_name remove_name write };
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t ftpd_tmpfs_t:file { create ioctl read getattr lock write setattr append link unlink rename };
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t ftpd_tmpfs_t:lnk_file { create read getattr setattr link unlink rename };
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t ftpd_tmpfs_t:sock_file { create ioctl read getattr lock write setattr append link unlink rename };
|
|
Chris PeBenito |
fc6524 |
fs_create_tmpfs_data(ftpd_t,ftpd_tmpfs_t,{ dir file lnk_file sock_file fifo_file })
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
# Create and modify /var/log/xferlog.
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t xferlog_t:file create_file_perms;
|
|
Chris PeBenito |
fc6524 |
logging_create_log(ftpd_t,xferlog_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
kernel_read_kernel_sysctl(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
kernel_read_system_state(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
dev_read_sysfs(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
dev_read_urand(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
fs_search_auto_mountpoints(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
fs_getattr_all_fs(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
corenet_tcp_sendrecv_all_if(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_udp_sendrecv_all_if(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_raw_sendrecv_all_if(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_tcp_sendrecv_all_nodes(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_udp_sendrecv_all_nodes(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_raw_sendrecv_all_nodes(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_tcp_sendrecv_all_ports(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_udp_sendrecv_all_ports(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_tcp_bind_all_nodes(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_udp_bind_all_nodes(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_tcp_bind_ftp_data_port(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_tcp_bind_generic_port(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
corenet_tcp_connect_all_ports(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
term_dontaudit_use_console(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
# Append to /var/log/wtmp.
|
|
Chris PeBenito |
fc6524 |
auth_append_login_records(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
#kerberized ftp requires the following
|
|
Chris PeBenito |
fc6524 |
auth_write_login_records(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
corecmd_exec_bin(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
# Execute /bin/ls (can comment this out for proftpd)
|
|
Chris PeBenito |
fc6524 |
# also may need rules to allow tar etc...
|
|
Chris PeBenito |
fc6524 |
corecmd_exec_ls(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
domain_use_wide_inherit_fd(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
files_search_etc(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
files_read_etc_files(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
files_read_etc_runtime_files(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
init_use_fd(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
init_use_script_pty(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
libs_use_ld_so(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
libs_use_shared_libs(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
logging_send_syslog_msg(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
miscfiles_read_localization(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
miscfiles_read_public_files(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
seutil_dontaudit_search_config(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
sysnet_read_config(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
userdom_dontaudit_search_sysadm_home_dir(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
userdom_dontaudit_use_unpriv_user_fd(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
ifdef(`targeted_policy',`
|
|
Chris PeBenito |
fc6524 |
files_dontaudit_read_root_file(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
term_dontaudit_use_generic_pty(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
term_dontaudit_use_unallocated_tty(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
tunable_policy(`allow_ftpd_anon_write',`
|
|
Chris PeBenito |
fc6524 |
miscfiles_manage_public_files(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
tunable_policy(`ftp_home_dir',`
|
|
Chris PeBenito |
fc6524 |
# allow access to /home
|
|
Chris PeBenito |
d8636f |
files_list_home(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
userdom_read_all_user_files(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
userdom_manage_all_user_dirs(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
userdom_manage_all_user_files(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
userdom_manage_all_user_symlinks(ftpd_t)
|
|
Chris PeBenito |
d8636f |
|
|
Chris PeBenito |
d8636f |
ifdef(`targeted_policy',`
|
|
Chris PeBenito |
d8636f |
userdom_create_user_home(ftpd_t,{ dir file lnk_file sock_file fifo_file })
|
|
Chris PeBenito |
d8636f |
')
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
tunable_policy(`ftpd_is_daemon',`
|
|
Chris PeBenito |
fc6524 |
allow ftpd_t ftpd_lock_t:file create_file_perms;
|
|
Chris PeBenito |
fc6524 |
files_create_lock(ftpd_t,ftpd_lock_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
corenet_tcp_bind_ftp_port(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
tunable_policy(`use_nfs_home_dirs && ftp_home_dir',`
|
|
Chris PeBenito |
fc6524 |
fs_read_nfs_files(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
fs_read_nfs_symlinks(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
tunable_policy(`use_samba_home_dirs && ftp_home_dir',`
|
|
Chris PeBenito |
fc6524 |
fs_read_cifs_files(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
fs_read_cifs_symlinks(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
77f6e2 |
optional_policy(`cron.te',`
|
|
Chris PeBenito |
fc6524 |
corecmd_exec_shell(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
77f6e2 |
files_read_usr_files(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
cron_system_entry(ftpd_t, ftpd_exec_t)
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
optional_policy(`logrotate.te',`
|
|
Chris PeBenito |
fc6524 |
logrotate_exec(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
optional_policy(`inetd.te',`
|
|
Chris PeBenito |
77f6e2 |
tunable_policy(`! ftpd_is_daemon',`
|
|
Chris PeBenito |
fc6524 |
#reh: typeattributes not allowed in conditionals yet.
|
|
Chris PeBenito |
fc6524 |
#inetd_tcp_service_domain(ftpd_t,ftpd_exec_t)
|
|
Chris PeBenito |
77f6e2 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
77f6e2 |
optional_policy(`tcpd.te',`
|
|
Chris PeBenito |
77f6e2 |
tunable_policy(`! ftpd_is_daemon',`
|
|
Chris PeBenito |
fc6524 |
tcpd_domtrans(tcpd_t)
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
77f6e2 |
')
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
optional_policy(`mount.te',`
|
|
Chris PeBenito |
fc6524 |
mount_send_nfs_client_request(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
optional_policy(`selinuxutil.te',`
|
|
Chris PeBenito |
fc6524 |
seutil_sigchld_newrole(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
optional_policy(`udev.te', `
|
|
Chris PeBenito |
fc6524 |
udev_read_db(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
fc6524 |
|
|
Chris PeBenito |
fc6524 |
ifdef(`TODO',`
|
|
Chris PeBenito |
fc6524 |
optional_policy(`rhgb.te',`
|
|
Chris PeBenito |
fc6524 |
rhgb_domain(ftpd_t)
|
|
Chris PeBenito |
fc6524 |
')
|
|
Chris PeBenito |
d8636f |
|
|
Chris PeBenito |
d8636f |
# cjp: this was in base user macro, but we cannot
|
|
Chris PeBenito |
d8636f |
# use typeattribute ftpd_t privhome; interface
|
|
Chris PeBenito |
d8636f |
# since typeattribute doesnt work in conditionals
|
|
Chris PeBenito |
d8636f |
ifdef(`ftpd.te' , `
|
|
Chris PeBenito |
d8636f |
if (ftpd_is_daemon) {
|
|
Chris PeBenito |
d8636f |
file_type_auto_trans(ftpd_t, $1_home_dir_t, $1_home_t)
|
|
Chris PeBenito |
d8636f |
}
|
|
Chris PeBenito |
d8636f |
')
|
|
Chris PeBenito |
fc6524 |
')
|