移植vsftpd到ARM开发板

来源:互联网 发布:java实现群发短信 编辑:程序博客网 时间:2024/06/06 01:41

1. 下载源码

https://security.appspot.com/downloads/vsftpd-3.0.3.tar.gz

2. 解压并编译

2.1 解压

tar -zxvf /home/chy/work/tar/vsftpd-3.0.3.tar.gz -C ./

2.2 设置交叉编译环境

$ export PATH=/opt/ARM/mys-4279/bin:$PATH

$ export CC=arm-linux-gnueabihf-gcc

2.3 编译

$ make

最好不要执行make install。

2.4 编译可能出现的问题

sysdeputil.o:在函数‘vsf_sysdep_has_capabilities’中:
sysdeputil.c:(.text+0x22a):对‘cap_get_proc’未定义的引用
sysdeputil.c:(.text+0x235):对‘cap_free’未定义的引用
sysdeputil.o:在函数‘vsf_sysdep_adopt_capabilities’中:
sysdeputil.c:(.text+0x26b):对‘cap_init’未定义的引用
sysdeputil.c:(.text+0x285):对‘cap_set_proc’未定义的引用
sysdeputil.c:(.text+0x29d):对‘cap_free’未定义的引用
sysdeputil.c:(.text+0x2d1):对‘cap_set_flag’未定义的引用
sysdeputil.c:(.text+0x2ec):对‘cap_set_flag’未定义的引用
sysdeputil.c:(.text+0x319):对‘cap_set_flag’未定义的引用
sysdeputil.c:(.text+0x334):对‘cap_set_flag’未定义的引用
collect2: error: ld returned 1 exit status
Makefile:29: recipe for target 'vsftpd' failed
make: *** [vsftpd] Error 1

在Makefile的LDFLAGS =       -fPIE -pie -Wl,-z,relro -Wl,-z,now后添加,-lcap,执行make clean然后执行make。

3. 移植到开发板

3.1 检查依赖的共享库

$ arm-linux-gnueabihf-readelf ./vsftpd -a | grep "共享库"


图一

3.2 复制vsftpd、vsftpd.conf 到开发板

把vsftpd放到/usr/sbin/目录下,并添加可执行权限,vsftpd.conf放到/etc/目录下。可以使用nfs方式挂载根文件系统,或打包到根文件系统再烧入开发板,或通过tftp传输到开发板。

3.3 修改配置文件

#anonymous_enable=YES
local_enable=YES

主要修改上面两行,禁止陌生人登陆,允许本地用户登陆。更详细配置参考:http://blog.csdn.net/c1194758555/article/details/63683641

4.  尝试连接

C:\Users\chenhongyu>ftp 172.20.27.128

连接到 172.20.27.128。
500 OOPS: vsftpd: not found: directory given in 'secure_chroot_dir':/usr/share/empty
500 OOPS: priv_sock_get_cmd
远程主机关闭连接。

出现上面的错误,则需要建立/usr/share/empty目录。

5. 开机自启

$ link -s /usr/sbin/vsftpd /etc/init.d/vsftpd

在/etc/init.d/rcS中加入

/etc/init.d/vsftpd &

6. 运行效果


图二


原创粉丝点击