LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1833|回复: 8

各位大虾请帮忙——vsftpd的覆盖问题?

[复制链接]
发表于 2006-7-19 09:36:33 | 显示全部楼层 |阅读模式
可以上传文件到上传目录,而且不能删除,但为什么还是能同名覆盖?
当然,如果cmds_allowed中去掉STOR后,就不能覆盖文件了,但同时也不能上传了。
请这里的高手指点。


配置如下:

local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
#chown_uploads=YES
#chown_username=whoever
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
idle_session_timeout=180
data_connection_timeout=120
#nopriv_user=ftpsecure
#async_abor_enable=YES
#ascii_upload_enable=YES
#ascii_download_enable=YES
ftpd_banner=Welcome to vsFTP service.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
chroot_list_enable=YES
# (default follows)
#chroot_local_user=YES
chroot_list_file=/etc/vsftpd.chroot_list
#ls_recurse_enable=YES
listen=YES
chmod_enable=NO
max_clients=30
max_per_ip=3
cmds_allowed=ABOR,CWD,LIST,MDTM,MKD,NLST,PASS,PASV,PORT,PWD,QUIT,RETR,RNFR,RNTO,SIZE,[color="Red"]STOR,TYPE,USER,REST,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST,FEAT
发表于 2006-7-19 10:34:07 | 显示全部楼层
似乎是一个简单的问题,大家将其复杂化!实现起来非常简单:)

环境:
[root@rhce ~]# uname -r
2.6.9-5.EL

用户:
[root@rhce ~]# cat /etc/passwd |grep 'ftp';cat /etc/group |grep 'ftp'
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
ftp:x:50:
# 确保系统中有ftp用户

[root@rhce ~]# ls -l /var |grep 'ftp'
drwxr-xr-x   4 root    root     4096 Jul 18 09:50 ftp
# 确保系统中有/var/ftp目录,属主和组为root

[root@rhce ~]# ls -l /var/ftp
total 16
drwxr-xr-x  4 ftp  ftp  4096 Jul 19 10:09 anonymous
drwxr-xr-x  2 root root 4096 Oct  4  2004 pub
# 在/var/ftp下建立任意目录,目录属主和组均为ftp

配置文件:
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
# 充许匿名用户上传
anon_mkdir_write_enable=YES
# 充许匿名用户立目录
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
pam_service_name=vsftpd
userlist_enable=YES
listen=YES
tcp_wrappers=YES

# 基本上是默认设置,除anon_upload_enable=YES,anon_mkdir_write_enable=YES之外,未作任何设置,

测试cuteftp:
由于仅为测试,未启用被动模式,ftp或lftp有些问题
STATUS:>          Transferring file "/anonymous/walking in the air.txt"...
STATUS:>          Checking directory existence: "/anonymous".
STATUS:>          Remote directory already exists: "/anonymous".
COMMAND:>        SIZE walking in the air.txt
                550 Could not get file size.
STATUS:>          Requested action not taken (e.g., file or directory not found, no access).
COMMAND:>        CWD /anonymous/walking in the air.txt
                550 Failed to change directory.
STATUS:>          Requested action not taken (e.g., file or directory not found, no access).
COMMAND:>        CWD /anonymous
                250 Directory successfully changed.
STATUS:>          PWD skipped. Current folder: "/anonymous".
COMMAND:>        PORT 192,168,1,3,7,90
                200 PORT command successful. Consider using PASV.
COMMAND:>        STOR walking in the air.txt
                150 Ok to send data.
                226 File receive OK.
STATUS:>          Transfer complete.

# 上传 walking in the air.txt 文件成功

NOTE:>            New transfer created for \"C:\Documents and Settings\Tanmeng\桌面\walking in the air.txt\" <133>
STATUS:>          Transferring file "/anonymous/walking in the air.txt"...
STATUS:>          Checking directory existence: "/anonymous".
STATUS:>          Remote directory already exists: "/anonymous".
COMMAND:>        TYPE A
                200 Switching to ASCII mode.
COMMAND:>        SIZE walking in the air.txt
                213 774
COMMAND:>        MDTM walking in the air.txt
                213 20060719023052
STATUS:>          An identical file already exists on the remote site.
STATUS:>          Applying Smart Overwrite rule: prompting.
COMMAND:>        PORT 192,168,1,3,7,98
                200 PORT command successful. Consider using PASV.
COMMAND:>        STOR walking in the air.txt
                553 Could not create file.
ERROR:>           Access denied.

# 试图覆盖walking in the air.txt 文件,提示 Access denied,

******************************************************
以是解决上传用户上传文件不能覆盖!
回复 支持 反对

使用道具 举报

发表于 2006-7-19 12:36:47 | 显示全部楼层
为啥不允许创建文件呢。。不太明白。

设置的参数中,没有哪个是说明不允许覆盖的。我也没看man,不太清楚。。。
回复 支持 反对

使用道具 举报

发表于 2006-7-19 13:49:27 | 显示全部楼层
终版,不知你是不是在问我,

BTW,说实在的,我也奇怪,FTP能匿能上传,但不能覆盖原文件,我也是偶然才发现;可以肯定并不是文件夹的权限设置。
但是不是在vsftpd中,开启anon_upload_enable=YES,anon_mkdir_write_enable=YES设置后,默认匿名用户能上传文件,但不能见删除或覆盖,就不得而知了,没有man

但,其它新建的用户,如果有上传权限,是可以覆盖同名文件、和删除的。
回复 支持 反对

使用道具 举报

发表于 2006-7-19 14:09:57 | 显示全部楼层
anon_other_write_enable
    如果设为 YES, 匿名用户将拥有除 上载, 和创建目录 外更多的权限, 比如 删除和重命名. 通常不建议这么做, 但完整的配置文件是包括这一选项的.

    默认: NO

更多选项, 参阅 http://etony.9966.org/doc/other/vsftpd-man-zh.html
回复 支持 反对

使用道具 举报

发表于 2006-7-19 15:00:02 | 显示全部楼层
to eTony兄

奇怪得很,我的2.4和2.6的2个核心的RedHat中vsftpd.conf默认竟然都没有anon_other_write_enable这个选项!

以上我的测试环境vsftpd.conf配置中,匿名用户是不能重命名,删除和覆盖重名文件的。
STATUS:>          Renaming remote file "/anonymous/walking in the air.txt" to "/anonymous/rename.txt"...
COMMAND:>        RNFR /anonymous/walking in the air.txt
                550 Permission denied.
ERROR:>           Requested action not taken (e.g., file or directory not found, no access).

BTW,你的主页做和不错,朴实,有内涵。比那些华而不实的东东强多了。
回复 支持 反对

使用道具 举报

发表于 2006-7-19 16:34:06 | 显示全部楼层
Post by kevin.tan
to eTony兄

奇怪得很,我的2.4和2.6的2个核心的RedHat中vsftpd.conf默认竟然都没有anon_other_write_enable这个选项!

以上我的测试环境vsftpd.conf配置中,匿名用户是不能重命名,删除和覆盖重名文件的。
STATUS:>          Renaming remote file "/anonymous/walking in the air.txt" to "/anonymous/rename.txt"...
COMMAND:>        RNFR /anonymous/walking in the air.txt
                550 Permission denied.
ERROR:>           Requested action not taken (e.g., file or directory not found, no access).

BTW,你的主页做和不错,朴实,有内涵。比那些华而不实的东东强多了。

默认配置文件是没有这个选项的, 需要你手动加进去

btw:
谢谢对我主页的评价
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-7-20 13:04:43 | 显示全部楼层
刚才的解决方法不是很好,不能上传到新建的目录中。


vsftpd只能上传,不能删除,不能覆盖。
不能删除还是按上述配置:cmds_allowed
不能覆盖:file_open_mode=0444,去掉所有的w属性。


还是谢谢大家了!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-7-20 17:15:30 | 显示全部楼层
顶一下,up
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表