yum install vsftpd
usermod -d /var/ftp ftp
useradd -d /var/ftp ftpadmin
mkdir -p /var/ftp/upload
chmod 775 /var/ftp/upload
chown ftpadmin.ftp /var/ftp -R
cat >/etc/vsftpd.conf <<DELIM
anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=YES
chown_username=ftpadmin
chown_upload_mode=0644
idle_session_timeout=60
data_connection_timeout=120
ftpd_banner=Welcome to My FTP Server.
chroot_local_user=YES
ls_recurse_enable=YES
listen=YES
use_localtime=YES
# add this for local user
pam_service_name=vsftpd
DELIM
匿名用户登录到vsftpd后所拥有的权限即系统用户ftp的权限.
现在把vsftpd代码里的feat命令和对opts命令返回信息做一下修改.
把features.c文件中的
vsf_cmdio_write_raw(p_sess, " UTF8\r\n");
去掉
把opts.c文件的handle_opts函数修改成如下:
void
handle_opts(struct vsf_session* p_sess)
{
str_upper(&p_sess->ftp_arg_str);
//if (str_equal_text(&p_sess->ftp_arg_str, "UTF8 ON"))
//{
// vsf_cmdio_write(p_sess, FTP_OPTSOK, "Always in UTF8 mode.");
//}
//else
//{
vsf_cmdio_write(p_sess, FTP_BADOPTS, "Option not understood.");
//}
}
wget ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.2.2.tar.gz
tar xzvf vsftpd-2.2.2.tar.gz
cd vsftpd-2.2.2
wget http://guest/doku/doku.php?do=export_code&id=vsftpd&codeblock=3 -O vsftpd-gb2312-opts.patch
wget http://guest/doku/doku.php?do=export_code&id=vsftpd&codeblock=4 -O vsftpd-gb2312-features.patch
patch < vsftpd-gb2312-opts.patch
patch < vsftpd-gb2312-features.patch
make
service vsftpd stop
rm /usr/sbin/vsftpd -f
cp vsftpd /usr/sbin/
cat >vsftpd-gb2312-opts.patch <<DELIM
--- vsftpd-2.2.2/opts.c 2008-02-12 11:54:56.000000000 +0800
+++ vsftpd/opts.c 2010-08-01 01:58:03.146605998 +0800
@@ -15,13 +15,13 @@
handle_opts(struct vsf_session* p_sess)
{
str_upper(&p_sess->ftp_arg_str);
- if (str_equal_text(&p_sess->ftp_arg_str, "UTF8 ON"))
- {
- vsf_cmdio_write(p_sess, FTP_OPTSOK, "Always in UTF8 mode.");
- }
- else
- {
- vsf_cmdio_write(p_sess, FTP_BADOPTS, "Option not understood.");
- }
+ // if (str_equal_text(&p_sess->ftp_arg_str, "UTF8 ON"))
+ // {
+ // vsf_cmdio_write(p_sess, FTP_OPTSOK, "Always in UTF8 mode.");
+ // }
+ // else
+ // {
+ vsf_cmdio_write(p_sess, FTP_BADOPTS, "Option not understood.");
+ // }
}
DELIM
cat >vsftpd-gb2312-features.patch <<DELIM
--- vsftpd-2.2.2/features.c 2008-12-04 14:00:47.000000000 +0800
+++ vsftpd/features.c 2010-08-01 01:56:54.612830740 +0800
@@ -42,7 +42,7 @@
vsf_cmdio_write_raw(p_sess, " REST STREAM\r\n");
vsf_cmdio_write_raw(p_sess, " SIZE\r\n");
vsf_cmdio_write_raw(p_sess, " TVFS\r\n");
- vsf_cmdio_write_raw(p_sess, " UTF8\r\n");
+ // vsf_cmdio_write_raw(p_sess, " UTF8\r\n");
vsf_cmdio_write(p_sess, FTP_FEAT, "End");
}
DELIM