Chinaunix首页 | 论坛 | 博客

分类: LINUX

2011-09-05 09:26:30

Busybox 移植vsftp

编译环境:ubuntu 10.04

交叉工具链:gcc-3.4.6

工具链目录:/home/cpu/gcc-3.4.6-2f/bin


1 下载vsftpd

官方网站: 


2 交叉编译

需要修改的地方有两处。第一处是MakefileCC 

# Makefile for systems with GNU tools
CC
= mipsle-linux-gcc

第二处是脚本vsf_findlibs.sh。这里主要是牵扯到库libcap的问题。网上的修改都是更改到交叉编译器的lib文件夹下,发现即使在lib文件夹下面没有,也不影响。那么,我判断,这个库是没有必要的,直接注释就可以了。

48 # Look for libcap (capabilities)

49 #if locate_library /lib/libcap.so.1; then

50 # echo "/lib/libcap.so.1";

51 #elif locate_library /lib/libcap.so.2; then

52 # echo "/lib/libcap.so.2";

53 #else

54 # locate_library /usr/lib/libcap.so && echo "-lcap";

55 # locate_library /lib/libcap.so && echo "-lcap";

56 # locate_library /lib64/libcap.so && echo "-lcap";

57 #fi

3 make


4 查看依赖及其相应的配置文件

mipsel-linux-readelf -d vsftpd


Dynamic section at offset 0x15c contains 31 entries:

标记 类型 名称/

0x00000001 (NEEDED) 共享库:[libcrypt.so.1]

0x00000001 (NEEDED) 共享库:[libdl.so.2]

0x00000001 (NEEDED) 共享库:[libnsl.so.1]

0x00000001 (NEEDED) 共享库:[libresolv.so.2]

0x00000001 (NEEDED) 共享库:[libutil.so.1]

0x00000001 (NEEDED) 共享库:[libgcc_s.so.1]

0x00000001 (NEEDED) 共享库:[libc.so.6]

0x0000000c (INIT) 0x407fcc

0x0000000d (FINI) 0x4258e0

0x00000004 (HASH) 0x40027c

0x00000005 (STRTAB) 0x4042ac

0x00000006 (SYMTAB) 0x4015dc

0x0000000a (STRSZ) 14084 (bytes)

0x0000000b (SYMENT) 16 (bytes)

0x70000016 (MIPS_RLD_MAP) 0x4694b0

0x00000015 (DEBUG) 0x0

0x00000003 (PLTGOT) 0x4694c0

0x00000011 (REL) 0x0

0x00000012 (RELSZ) 0 (bytes)

0x00000013 (RELENT) 8 (bytes)

0x70000001 (MIPS_RLD_VERSION) 1

0x70000005 (MIPS_FLAGS) NOTPOT

0x70000006 (MIPS_BASE_ADDRESS) 0x400000

0x7000000a (MIPS_LOCAL_GOTNO) 14

0x70000011 (MIPS_SYMTABNO) 717

0x70000012 (MIPS_UNREFEXTNO) 28

0x70000013 (MIPS_GOTSYM) 0x5

0x6ffffffe (VERNEED) 0x407f4c

0x6fffffff (VERNEEDNUM) 3

0x6ffffff0 (VERSYM) 0x4079b0

0x00000000 (NULL) 0x0


5 拷贝相应的库 到开发板 lib目录



6 Vsftpd.conf配置: (红色为主要配置)
anonymous_enable=YES  
#
允许匿名访问(一般=NO)
local_enable=YES       
#
允许本地用户访问(/etc/passwd中的用户)
write_enable=YES
#
允许写入权限,包括修改,删除
local_umask=022
#
本地用户文件上传后的权限是-rw-r-r
#anon_umask=077
#
匿名用户上传后权限是-rw----
anon_world_readable_only=YES
#
允许匿名用户浏览,下载文件
anon_upload_enable=YES
#
允许匿名用户上传
#anon_mkdir_write_enable=YES
#
允许匿名用户建立目录
anon_other_write_enable=YES
#
允许匿名用户具有建立目录,上传之外的权限,如重命名,删除
dirmessage_enable=YES
#
当使用者转换目录,则会显示该目录下的.message信息
xferlog_enable=YES
#
记录s使用者所有上传下载信息
xferlog_file=/var/log/vsftpd.log
#
将上传下载信息记录到/var/log/vsftpd.log
connect_from_port_20=YES
#
确保ftp-datad 数据传送使用port 20
idle_session_timeout=600
#
如果使用者600秒没有动作,则踢出

chroot_list_enable=YES
#
限制使用者不能离开家目录,例如blue登陆后位于/home/blue,设置该选项后,他不可以转到/home/blue的上层目录,/bin, /usr,/opt...etc
chroot_list_file=/etc/vsftpd.chroot_list
#
与上条同时使用,设置限制使用者的存放文件为/etc/vsftpd.chroot_list 
#
建立文本文件/etc/vsftpd.chroot_list,写入要限制的用户,一行一个。
#
如果希望限制所有用户,则可以设置chroot_local_user=YES 代替上面两行
tcp_wrappers=YES
#
支持tcp_wrappers,限制访问(/etc/hosts.allow,/etc/hosts.deny)
listen=YES

#使用standalone启动vsftpd,而不是super daemon(xinetd)控制它 (vsftpd推荐使用standalone方式)
listen_port=21
#ftp
监听端口
userlist_enable=YES
userlist_deny=YES
userlist_file=/etc/vsftpd.user_list

#
以上三条设定不允许登陆的用户,用户列表存放在/etc/vsftpd.user_list,一行一个帐号
pam_service_name=vsftpd


我的参考配置

# Example config file /etc/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.

#

# READ THIS: This example file is NOT an exhaustive list of vsftpd options.

# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's

# capabilities.

#

#

# Run standalone? vsftpd can run either from an inetd or as a standalone

# daemon started from an initscript.

listen=YES

#

# Run standalone with IPv6?

# Like the listen parameter, except vsftpd will listen on an IPv6 socket

# instead of an IPv4 one. This parameter and the listen parameter are mutually

# exclusive.

#listen_ipv6=YES

#

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).

#anonymous_enable=YES

#

# Uncomment this to allow local users to log in.

local_enable=YES

#

# Uncomment this to enable any form of FTP write command.

write_enable=YES

#

# Default umask for local users is 077. You may wish to change this to 022,

# if your users expect that (022 is used by most other ftpd's)

local_umask=022

#

# Uncomment this to allow the anonymous FTP user to upload files. This only

# has an effect if the above global write enable is activated. Also, you will

# obviously need to create a directory writable by the FTP user.

#anon_upload_enable=YES

#

# Uncomment this if you want the anonymous FTP user to be able to create

# new directories.

#anon_mkdir_write_enable=YES

#

# Activate directory messages - messages given to remote users when they

# go into a certain directory.

dirmessage_enable=YES

#

# Activate logging of uploads/downloads.

xferlog_enable=YES

#

# Make sure PORT transfer connections originate from port 20 (ftp-data).

connect_from_port_20=YES

#

# If you want, you can arrange for uploaded anonymous files to be owned by

# a different user. Note! Using "root" for uploaded files is not

# recommended!

#chown_uploads=YES

#chown_username=whoever

#

# You may override where the log file goes if you like. The default is shown

# below.

#xferlog_file=/var/log/vsftpd.log

#

# If you want, you can have your log file in standard ftpd xferlog format

#xferlog_std_format=YES

#

# You may change the default value for timing out an idle session.

#idle_session_timeout=600

#

# You may change the default value for timing out a data connection.

#data_connection_timeout=120

#

# It is recommended that you define on your system a unique user which the

# ftp server can use as a totally isolated and unprivileged user.

#nopriv_user=ftpsecure

#

# Enable this and the server will recognise asynchronous ABOR requests. Not

# recommended for security (the code is non-trivial). Not enabling it,

# however, may confuse older FTP clients.

#async_abor_enable=YES

#

# By default the server will pretend to allow ASCII mode but in fact ignore

# the request. Turn on the below options to have the server actually do ASCII

# mangling on files when in ASCII mode.

# Beware that on some FTP servers, ASCII support allows a denial of service

# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd

# predicted this attack and has always been safe, reporting the size of the

# raw file.

# ASCII mangling is a horrible feature of the protocol.

#ascii_upload_enable=YES

#ascii_download_enable=YES

#

# You may fully customise the login banner string:

#ftpd_banner=Welcome to blah FTP service.

#

# You may specify a file of disallowed anonymous e-mail addresses. Apparently

# useful for combatting certain DoS attacks.

#deny_email_enable=YES

# (default follows)

#banned_email_file=/etc/vsftpd.banned_emails

#

# You may restrict local users to their home directories. See the FAQ for

# the possible risks in this before using chroot_local_user or

# chroot_list_enable below.

#chroot_local_user=YES

#

# You may specify an explicit list of local users to chroot() to their home

# directory. If chroot_local_user is YES, then this list becomes a list of

# users to NOT chroot().

chroot_list_enable=YES

# (default follows)

chroot_list_file=/etc/vsftpd.chroot_list

#

# You may activate the "-R" option to the builtin ls. This is disabled by

# default to avoid remote users being able to cause excessive I/O on large

# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume

# the presence of the "-R" option, so there is a strong case for enabling it.

#ls_recurse_enable=YES

#

#

# Debian customization

#

# Some of vsftpd's settings don't fit the Debian filesystem layout by

# default. These settings are more Debian-friendly.

#

# This option should be the name of a directory which is empty. Also, the

# directory should not be writable by the ftp user. This directory is used

# as a secure chroot() jail at times vsftpd does not require filesystem

# access.

secure_chroot_dir=/var/run/vsftpd

#

# This string is the name of the PAM service vsftpd will use.

#pam_service_name=vsftpd

#

# This option specifies the location of the RSA certificate to use for SSL

# encrypted connections.

rsa_cert_file=/etc/ssl/certs/vsftpd.pem



vsftp.chroot_list 配置文件

loongsonftp 直接写 登录用户名即可


7 添加登录用户


groupadd loongsonftp

adduser loongsonftp -g loongsonftp

passwd loongsonftp

mkdir /home/loongsonftp

chown loongsonftp:loongsonftp -R /home/loongsonftp


或者直接从host主机拷贝passwdgroup文件到开发办etc目录即可



8 启动

执行vsftpd即可



9 注意出现的问题

1

lengmian@lengmian-laptop:/home/server/nfsramdisk/home$ ftp 192.168.3.149

2 Connected to 192.168.3.149.

3 500 OOPS: vsftpd: cannot locate user specified in 'ftp_username':ftp

4 ftp> bye

网上很多解答是
/etc/vsftpd.conf 指定FTP用户
ftp_username=ftp
上面这句,就是指定FTP用户名ftp,或者其他指定的ftp用户名

确认有
listen=YES
background=YES #
启动后是否在后台运行 ?
local_enable=YES
write_enable=YES

只要确认有

listen=YES

local_enable=YES

write_enable=YES

然后copy libnss_files* into chroot directory /lib/即可


2

lengmian@lengmian-laptop:/home/server/nfsramdisk$ ftp 192.168.3.149

9 Connected to 192.168.3.149.

10 500 OOPS: vsftpd: not found: directory given in

11 'secure_chroot_dir':/var/run/vsftpd

12

解决方法

mkdir /var/run/vsftpd

如果有别的类似错误,同样创建所缺文件或者文件夹即可

3

ftp> put hwp

17 local: hwp remote: hwp

18 200 PORT command successful. Consider using PASV.

19 553 Could not create file.


权限问题

解决方法

/home/loongsonftp 的所属组和所属用户修改为loongsonftp即可

阅读(2953) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~