如何移植ftp服务器到arm板子?

news/2025/1/27 19:51:14/文章来源:https://www.cnblogs.com/yikoulinux/p/18691243

很多厂家提供的sdk,一般都不自带ftp服务器功能,

需要要发人员自己移植ftp服务器程序。

本文手把手教大家如何移植ftp server到arm板子。

环境

sdk:复旦微
Buildroot 2018.02.3

1. 解压

$ mkdir ~/vsftpd 
$ cp vsftpd-3.0.2.tar.gz ~/vsftpd 
$ cd ~/vsftpd $ tar xzf vsftpd-3.0.2.tar.gz 
$ cd vsftpd-3.0.2/

软件包获取方法:件文末。

2. 配置工具链

修改Makefile文件:

CC = arm-linux-gnueabihf-gcc

根据自己的平台的工具链

3. 设置交叉编译环境&编译

peng@ubuntu:~/vsftpd/vsftpd-3.0.2$ make
arm-linux-gnueabihf-gcc -c main.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c utility.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c prelogin.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c ftpcmdio.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c postlogin.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c privsock.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c tunables.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c ftpdataio.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c secbuf.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c ls.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c postprivparent.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c logging.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c str.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c netstr.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c sysstr.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c strlist.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c banner.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c filestr.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c parseconf.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c secutil.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c ascii.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c oneprocess.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c twoprocess.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c privops.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c standalone.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c hash.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c tcpwrap.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c ipaddrparse.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c access.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c features.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c readwrite.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c opts.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c ssl.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c sslslave.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c ptracesandbox.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c ftppolicy.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c sysutil.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c sysdeputil.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -c seccompsandbox.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
arm-linux-gnueabihf-gcc -o vsftpd main.o utility.o prelogin.o ftpcmdio.o postlogin.o privsock.o tunables.o ftpdataio.o secbuf.o ls.o postprivparent.o logging.o str.o netstr.o sysstr.o strlist.o banner.o filestr.o parseconf.o secutil.o ascii.o oneprocess.o twoprocess.o privops.o standalone.o hash.o tcpwrap.o ipaddrparse.o access.o features.o readwrite.o opts.o ssl.o sslslave.o ptracesandbox.o ftppolicy.o sysutil.o sysdeputil.o seccompsandbox.o -Wl,-s -fPIE -pie -Wl,-z,relro -Wl,-z,now `./vsf_findlibs.sh`

make 后,当前目录下会生成两个文件:vsftpdvsftpd.conf,这两个文件是我们要用的。

4. 复制文件

将生成的 vsftpd 复制到目标板 /usr/sbin 目录,vsftpd.conf 复制到目标板 /etc 目录,并添加 vsftpd 为可执行:

  • 复制执行文件到目标板
vsftpd拷贝到板子usr/sbin
  • 添加可执行权限
chmod +x /usr/sbin/vsftpd 
  • 复制配置文件到目标板
 vsftpd.conf 拷贝到板子/etc/ 

5. 配置

在目标板上创建一个本地用户ftp,并设置密码123456

$ adduser ftp 
Changing password for root 
New password:  
Retype password:  
Password for ftpadmin changed by root

使用 vi 打开 vsftpd.conf 文件,并进行配置,如下配置可实现正常上传下载功能,(这段可以随便改)

用户:ftp

# 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.
#
# 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
file_open_mode=0777
#
# 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.
# Note that the default log file location is /var/log/xferlog in this case.
#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 6902 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 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().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#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
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YESftp_username=ftp            #登录用户
secure_chroot_dir=/mnt/     #

6. 打开vsftp

配置完之后,在目标板上打开vsftp,命令:

# /usr/sbin/vsftpd &

注意,后面还有一个 &,表示该服务放到后台运行。

7. 设置开机自启动

如果要让 vsftpd 开机启动,可以创建下面文件S70vsftpd,

然后将该文件添加到/etc/init.d/目录下。

#! /bin/shset -eDESC="vsftpd"
NAME=vsftpd
DAEMON=/usr/sbin/$NAMEcase "$1" instart)printf "Starting $DESC: "start-stop-daemon -S -b -x $NAMEecho "OK";;stop)printf "Stopping $DESC: "start-stop-daemon -K -x $NAMEecho "OK";;restart|force-reload)echo "Restarting $DESC: "$0 stopsleep 1$0 startecho "";;*)echo "Usage: $0 {start|stop|restart|force-reload}" >&2exit 1;;
esacexit 0

开启vsftpd:

 /etc/init.d/S70vsftpd restart

重启vsftpd:

 /etc/init.d/S70vsftpd restart

8. 客户端测试

下面以pc为例:

C:\Users\ricks>ftp
ftp> open 192.168.31.45
连接到 192.168.31.45。
220 Welcome to EC20 FTP service.
200 Always in UTF8 mode.
用户(192.168.31.45:(none)): root
331 Please specify the password.
密码:
230 Login successful.
  • 显示文件列表
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
123
226 Directory send OK.
ftp: 收到 5 字节,用时 0.00秒 1.25千字节/秒。
  • 下载文件
ftp> get 123
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 123 (8 bytes).
226 Transfer complete.
ftp: 收到 8 字节,用时 0.00秒 8.00千字节/秒。
  • 退出
ftp> quit
221 Goodbye.

后台回复:tools

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/875703.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

obs录制压缩体积和减少游戏性能开销

帧率降一点、编码器选硬件的、速率控制选好的、如果要调速度可以参考下面的NV官网推荐的截图视频录制编码器选硬件AV1(穷鬼用30系N卡没有AV1硬件编码器就退而求其次选了HEVC) 注:40系以上N卡、A系i卡、RDNA2以上A卡 应该都有AV1硬件编码器,名字都不一样。同时请记住AV1之间亦…

1.认识封装与电子元器件位号

1.电阻贴片电阻(R)封装对应着功率:0201->1/20W0402->1/16W0603->1/10W0805->1/8W1206->1/4W1210->1/3W1812->1/2W2010->3/4W2512->1W后缀L(小)和M(大)代表着焊盘的大小例:R 0201_L和R 0201_M对比精密贴片电阻(R_HP)命名中后缀加入HP例:R 0…

基于ESP32的桌面小屏幕实战[6]:环境搭建和软件基础

摘要 本文分为两部分:Linux开发环境搭建和软件基础。Linux开发环境搭建介绍了Ubuntu虚拟机安装及SSH、Samba配置,可以实现用VSCode操作虚拟机。为了后续工作,搭建了乐鑫ESP32 SDK环境。软件基础介绍了Linux开发常用的软件基础,包括Linux指令、Git、Makefile、裸机和RTOS。 …

SpringMvc请求与响应 -2025/1/19

请求 Post请求中文乱码处理List集合接受,请求后台接受参数 //集合参数:同名请求参数可以使用@RequestParam注解映射到对应名称的集合对象中作为数据 @RequestMapping("/listParam") @ResponseBody public String listParam(List<String> likes){System.out.pr…

Spring事务 -2025/1/15

Spring事务简介 Spring添加事务管理 1.2.Spring事务角色Spring事务配置 事务是可以进行配置的事务传播行为 事务传播行为:事务协调员对事务管理员所携带事务的处理态度。 propagation属性

AOP -2025/1/11

AOP简介连接点(JoinPoint):程序执行过程中的任意位置,粒度为执行方法、抛出异常、设置变量等在SpringAOP中,理解为方法的执行切入点(Pointcut):匹配连接点的式子在SpringAOP中,一个切入点可以描述一个具体方法,也可也匹配多个方法一个具体的方法:如com.itheima.dao包下的B…

牛客 小白109 20250119

牛客 小白 109 20250119 牛客小白月赛109_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ A: 题目大意:根据不等式求值 #include<bits/stdc++.h>using namespace std;int main() {int n;cin>>n;if (n<=19375331) cout<<n;else cout<<1937…

Vue3+ElementPlus+Koa2 全栈开发后台系统

Vue3+ElementPlus+Koa2 全栈开发后台系统 9 18 第1章 项目规划/1-1.mp4 Vue3+ElementPlus+Koa2全栈开发后台系统@河畔一角 前端Vue3+ElementPlus后台Koa2+MongoDB 如何构建通用型的后台管理系统如何搭建完备的前后台系统架构 掌握开发工作技巧 开发概述全栈后台管理系统 架构设…

User Agent Switcher不改变客户端UA

描述 如图,下面这个软件。软件设置中,包含以下选项,有个选项是不改变客户端的UA(navigator全局对象)然而,就算不勾选这玩意,navigator依然没有被正常改变。获取UA 可以在下面的网站,查看当前浏览器环境UA。 https://tool.ip138.com/useragent/ 客户端(浏览器) const …

事件监听,Vue,Ajax

1.事件监听点击查看代码 <!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>JS事件</title>…

用M实现类似Lookup的等级查找(Power Query 之 M 语言)

问题:表1和表2,需要根据表2中金额下限的设置反应对应的等级(=LOOKUP(A2,D$2:E$4)的结果)。 let源1 = Excel.CurrentWorkbook(){[Name="表1"]}[Content], 源2 = Excel.CurrentWorkbook(){[Name="表2"]}[Content],查找 = (对应金额) =>let筛选行 = T…

用M实现类似Lookup的等级查找(Power Query)

问题:表1和表2,需要根据表2中金额下限的设置反应对应的等级(=LOOKUP(A2,D$2:E$4)的结果)。 let源1 = Excel.CurrentWorkbook(){[Name="表1"]}[Content], 源2 = Excel.CurrentWorkbook(){[Name="表2"]}[Content],查找 = (对应金额) =>let筛选行 = T…