]> git.ipfire.org Git - people/stevee/selinux-policy.git/blame - refpolicy/policy/modules/services/ftp.te
renaming from 20060131 interface review
[people/stevee/selinux-policy.git] / refpolicy / policy / modules / services / ftp.te
CommitLineData
fc6524d7 1
d3d27022 2policy_module(ftp,1.2.0)
fc6524d7
CP
3
4########################################
5#
6# Declarations
7#
8
9type ftpd_t;
10type ftpd_exec_t;
11init_daemon_domain(ftpd_t,ftpd_exec_t)
12
13type ftpd_etc_t;
9bbc757a 14files_config_file(ftpd_etc_t)
fc6524d7
CP
15
16# ftpd_lock_t is only needed when ftpd_is_daemon is true, but we cannot define types conditionally
17type ftpd_lock_t;
18files_lock_file(ftpd_lock_t)
19
20type ftpd_tmp_t;
21files_tmp_file(ftpd_tmp_t)
22
23type ftpd_tmpfs_t;
24files_tmpfs_file(ftpd_tmpfs_t)
25
26type ftpd_var_run_t;
27files_pid_file(ftpd_var_run_t)
28
29type xferlog_t;
30logging_log_file(xferlog_t)
31
32########################################
33#
34# Local policy
35#
36
37allow ftpd_t self:capability { chown fowner fsetid setgid setuid sys_chroot sys_nice sys_resource };
38dontaudit ftpd_t self:capability sys_tty_config;
39allow ftpd_t self:process signal_perms;
40allow ftpd_t self:process { getcap setcap setsched setrlimit };
41allow ftpd_t self:fifo_file rw_file_perms;
42allow ftpd_t self:unix_dgram_socket { sendto create_socket_perms };
43allow ftpd_t self:unix_stream_socket create_socket_perms;
44allow ftpd_t self:tcp_socket create_stream_socket_perms;
45allow ftpd_t self:udp_socket create_socket_perms;
46
e6a2eaff 47allow ftpd_t ftpd_etc_t:file r_file_perms;
fc6524d7
CP
48
49allow ftpd_t ftpd_tmp_t:dir create_dir_perms;
50allow ftpd_t ftpd_tmp_t:file create_file_perms;
9d594986 51files_filetrans_tmp(ftpd_t, ftpd_tmp_t, { file dir })
fc6524d7 52
e6a2eaff
CP
53allow ftpd_t ftpd_tmpfs_t:fifo_file create_file_perms;
54allow ftpd_t ftpd_tmpfs_t:dir create_dir_perms;
55allow ftpd_t ftpd_tmpfs_t:file create_file_perms;
56allow ftpd_t ftpd_tmpfs_t:lnk_file create_lnk_perms;
57allow ftpd_t ftpd_tmpfs_t:sock_file create_file_perms;
9d594986 58fs_filetrans_tmpfs(ftpd_t,ftpd_tmpfs_t,{ dir file lnk_file sock_file fifo_file })
fc6524d7 59
e6a2eaff
CP
60allow ftpd_t ftpd_var_run_t:file create_file_perms;
61allow ftpd_t ftpd_var_run_t:dir rw_dir_perms;
9d594986 62files_filetrans_pid(ftpd_t,ftpd_var_run_t)
e6a2eaff 63
fc6524d7
CP
64# Create and modify /var/log/xferlog.
65allow ftpd_t xferlog_t:file create_file_perms;
9d594986 66logging_filetrans_log(ftpd_t,xferlog_t)
fc6524d7
CP
67
68kernel_read_kernel_sysctl(ftpd_t)
69kernel_read_system_state(ftpd_t)
70
71dev_read_sysfs(ftpd_t)
72dev_read_urand(ftpd_t)
73
049e11af
CP
74corecmd_exec_bin(ftpd_t)
75corecmd_exec_sbin(ftpd_t)
76# Execute /bin/ls (can comment this out for proftpd)
77# also may need rules to allow tar etc...
78corecmd_exec_ls(ftpd_t)
fc6524d7
CP
79
80corenet_tcp_sendrecv_all_if(ftpd_t)
81corenet_udp_sendrecv_all_if(ftpd_t)
82corenet_raw_sendrecv_all_if(ftpd_t)
83corenet_tcp_sendrecv_all_nodes(ftpd_t)
84corenet_udp_sendrecv_all_nodes(ftpd_t)
85corenet_raw_sendrecv_all_nodes(ftpd_t)
86corenet_tcp_sendrecv_all_ports(ftpd_t)
87corenet_udp_sendrecv_all_ports(ftpd_t)
bd70373d 88corenet_non_ipsec_sendrecv(ftpd_t)
fc6524d7
CP
89corenet_tcp_bind_all_nodes(ftpd_t)
90corenet_udp_bind_all_nodes(ftpd_t)
91corenet_tcp_bind_ftp_data_port(ftpd_t)
92corenet_tcp_bind_generic_port(ftpd_t)
93corenet_tcp_connect_all_ports(ftpd_t)
94
049e11af
CP
95domain_use_wide_inherit_fd(ftpd_t)
96
97files_search_etc(ftpd_t)
98files_read_etc_files(ftpd_t)
99files_read_etc_runtime_files(ftpd_t)
100files_search_var_lib_dir(ftpd_t)
101
102fs_search_auto_mountpoints(ftpd_t)
103fs_getattr_all_fs(ftpd_t)
104
fc6524d7
CP
105term_dontaudit_use_console(ftpd_t)
106
049e11af 107auth_use_nsswitch(ftpd_t)
e6a2eaff 108auth_domtrans_chk_passwd(ftpd_t)
fc6524d7
CP
109# Append to /var/log/wtmp.
110auth_append_login_records(ftpd_t)
111#kerberized ftp requires the following
112auth_write_login_records(ftpd_t)
113
fc6524d7
CP
114init_use_fd(ftpd_t)
115init_use_script_pty(ftpd_t)
116
117libs_use_ld_so(ftpd_t)
118libs_use_shared_libs(ftpd_t)
119
120logging_send_syslog_msg(ftpd_t)
121
122miscfiles_read_localization(ftpd_t)
123miscfiles_read_public_files(ftpd_t)
124
125seutil_dontaudit_search_config(ftpd_t)
126
127sysnet_read_config(ftpd_t)
128
129userdom_dontaudit_search_sysadm_home_dir(ftpd_t)
130userdom_dontaudit_use_unpriv_user_fd(ftpd_t)
131
132ifdef(`targeted_policy',`
133 files_dontaudit_read_root_file(ftpd_t)
134
135 term_dontaudit_use_generic_pty(ftpd_t)
136 term_dontaudit_use_unallocated_tty(ftpd_t)
725926c5 137
1328802a 138 optional_policy(`ftp',`
725926c5
CP
139 tunable_policy(`ftpd_is_daemon',`
140 # cjp: fix this to use regular interfaces
141 userdom_manage_user_home_subdir_files(user,ftpd_t)
142 userdom_manage_user_home_subdir_symlinks(user,ftpd_t)
143 userdom_manage_user_home_subdir_sockets(user,ftpd_t)
144 userdom_manage_user_home_subdir_pipes(user,ftpd_t)
145 userdom_create_user_home(user,ftpd_t,{ dir file lnk_file sock_file fifo_file })
146 ')
147 ')
fc6524d7
CP
148')
149
150tunable_policy(`allow_ftpd_anon_write',`
151 miscfiles_manage_public_files(ftpd_t)
152')
153
154tunable_policy(`ftp_home_dir',`
155 # allow access to /home
d8636fc9 156 files_list_home(ftpd_t)
fc6524d7
CP
157 userdom_read_all_user_files(ftpd_t)
158 userdom_manage_all_user_dirs(ftpd_t)
159 userdom_manage_all_user_files(ftpd_t)
160 userdom_manage_all_user_symlinks(ftpd_t)
d8636fc9
CP
161
162 ifdef(`targeted_policy',`
9d594986 163 userdom_filetrans_generic_user_home(ftpd_t,{ dir file lnk_file sock_file fifo_file })
d8636fc9 164 ')
fc6524d7
CP
165')
166
167tunable_policy(`ftpd_is_daemon',`
168 allow ftpd_t ftpd_lock_t:file create_file_perms;
9d594986 169 files_filetrans_lock(ftpd_t,ftpd_lock_t)
fc6524d7
CP
170
171 corenet_tcp_bind_ftp_port(ftpd_t)
172')
173
174tunable_policy(`use_nfs_home_dirs && ftp_home_dir',`
175 fs_read_nfs_files(ftpd_t)
176 fs_read_nfs_symlinks(ftpd_t)
177')
178
179tunable_policy(`use_samba_home_dirs && ftp_home_dir',`
180 fs_read_cifs_files(ftpd_t)
181 fs_read_cifs_symlinks(ftpd_t)
182')
183
1328802a 184optional_policy(`cron',`
fc6524d7
CP
185 corecmd_exec_shell(ftpd_t)
186
77f6e2cd 187 files_read_usr_files(ftpd_t)
fc6524d7
CP
188
189 cron_system_entry(ftpd_t, ftpd_exec_t)
190
1328802a 191 optional_policy(`logrotate',`
fc6524d7
CP
192 logrotate_exec(ftpd_t)
193 ')
194')
195
44d5d93f
CP
196optional_policy(`daemontools',`
197 daemontools_service_domain(ftpd_t, ftpd_exec_t)
198')
199
1328802a 200optional_policy(`inetd',`
784a3bbc
CP
201 #reh: typeattributes not allowed in conditionals yet.
202 #tunable_policy(`! ftpd_is_daemon',`
203 # inetd_tcp_service_domain(ftpd_t,ftpd_exec_t)
204 #')
fc6524d7 205
73ef293b
CP
206 inetd_tcp_service_domain(ftpd_t,ftpd_exec_t)
207
1328802a 208 optional_policy(`tcpd',`
77f6e2cd 209 tunable_policy(`! ftpd_is_daemon',`
fc6524d7
CP
210 tcpd_domtrans(tcpd_t)
211 ')
77f6e2cd 212 ')
fc6524d7
CP
213')
214
1328802a 215optional_policy(`mount',`
fc6524d7
CP
216 mount_send_nfs_client_request(ftpd_t)
217')
218
1328802a 219optional_policy(`nscd',`
e6a2eaff
CP
220 nscd_use_socket(ftpd_t)
221')
222
1328802a 223optional_policy(`selinuxutil',`
fc6524d7
CP
224 seutil_sigchld_newrole(ftpd_t)
225')
226
1328802a 227optional_policy(`udev', `
fc6524d7
CP
228 udev_read_db(ftpd_t)
229')