且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

selinux与ftp

更新时间:2022-09-14 16:16:53


500 OOPS: cannot change directory
 
打开SELinux后,SELinux会阻止ftp daemon读取用户home目录。所以FTP会甩出一句 “500 OOPS: cannot
change directory”。无法进入目录,出错退出。
解决办法有两个:
1. 降低SELinux安全级别,把enforcing降低到permissive 或disabled
vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=permissive
这时FTP的登录功能就正常了。但降低整体系统安全作为代价来解决一个小问题,这总不是***方案。
2. 经过研究,又找到了另一个更理想的办法。首先查看SELinux中有关FTP的设置状态:
# getsebool -a | grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
allow_tftp_anon_write --> off
ftp_home_dir --> off
ftpd_connect_db --> off
ftpd_disable_trans --> on
ftpd_is_daemon --> on
httpd_enable_ftp_server --> off
tftpd_disable_trans --> off
 
经过尝试发现,打开ftp_home_dir或者 ftpd_disable_trans。都可以达到在enforcing级别下,允许FTP正常登
录的效果。
# setsebool -P ftpd_disable_trans 1
或者
# setsebool -P ftp_home_dir 1
重启ftp
# service vsftpd restart
加-P是保存选项,每次重启时不必重新执行这个命令了。
本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/836038如需转载请自行联系原作者

yangzhimingg