Odpovedám si sám, jedným z tých lepších riešení je vlastný modul, ktorý umožní FTP serveru zapisovať do kontextov
httpd_sys_content_t a
httpd_sys_rw_content_t.
Predpokladám, že niečo podobné máte už nastavené:
semanage fcontext -a -t httpd_sys_content_t "/srv/www/data(/.*)?"
restorecon -Rv /srv/www/data
module my_ftp_http 1.0;
require {
type ftpd_t;
type httpd_sys_content_t;
type httpd_sys_rw_content_t;
class dir read;
class dir write;
class dir add_name;
class dir create;
class dir rmdir;
class dir rename;
class dir remove_name;
class dir unlink;
class file getattr;
class file read;
class file open;
class file write;
class file create;
class file rename;
class file unlink;
}
#============= ftpd_t ==============
allow ftpd_t httpd_sys_content_t:dir read;
allow ftpd_t httpd_sys_content_t:dir write;
allow ftpd_t httpd_sys_content_t:dir add_name;
allow ftpd_t httpd_sys_content_t:dir create;
allow ftpd_t httpd_sys_content_t:dir rmdir;
allow ftpd_t httpd_sys_content_t:dir rename;
allow ftpd_t httpd_sys_content_t:dir remove_name;
allow ftpd_t httpd_sys_content_t:dir unlink;
allow ftpd_t httpd_sys_content_t:file getattr;
allow ftpd_t httpd_sys_content_t:file read;
allow ftpd_t httpd_sys_content_t:file open;
allow ftpd_t httpd_sys_content_t:file write;
allow ftpd_t httpd_sys_content_t:file create;
allow ftpd_t httpd_sys_content_t:file rename;
allow ftpd_t httpd_sys_content_t:file unlink;
allow ftpd_t httpd_sys_rw_content_t:dir read;
allow ftpd_t httpd_sys_rw_content_t:dir write;
allow ftpd_t httpd_sys_rw_content_t:dir add_name;
allow ftpd_t httpd_sys_rw_content_t:dir create;
allow ftpd_t httpd_sys_rw_content_t:dir rmdir;
allow ftpd_t httpd_sys_rw_content_t:dir rename;
allow ftpd_t httpd_sys_rw_content_t:dir remove_name;
allow ftpd_t httpd_sys_rw_content_t:dir unlink;
allow ftpd_t httpd_sys_rw_content_t:file getattr;
allow ftpd_t httpd_sys_rw_content_t:file read;
allow ftpd_t httpd_sys_rw_content_t:file open;
allow ftpd_t httpd_sys_rw_content_t:file write;
allow ftpd_t httpd_sys_rw_content_t:file create;
allow ftpd_t httpd_sys_rw_content_t:file rename;
allow ftpd_t httpd_sys_rw_content_t:file unlink;
Kontrola, kompilácia a zaradenie modulu do systému
checkmodule -M -m -o my_ftp_http.mod my_ftp_http.te
semodule_package -o my_ftp_http.pp -m my_ftp_http.mod
semodule -i my_ftp_http.pp
Ak bude PHP-FPM počúvať na inom než štandardnom porte 9000 (napr. 33333):
semanage port -a -t http_port_t -p tcp 33333