嵌入式Linux的FTP服务端软件(stupid-ftpd)

2019-07-13 00:58发布

https://www.linuxidc.com/Linux/2012-03/56781.htm 在嵌入式Linux系统中,有时候需要搭建一个ftp服务器,以便windows或linux系统去访问嵌入式linux系统的数据。现在流行的ftp和vsftpd软件相对比较大,在嵌入式Linux系统下不太合适。最近由于需要,发现了一款很小型的ftp服务器 stupid-ftpd 下载地址: 免费下载地址在 http://linux.linuxidc.com/ 具体下载目录在 /2012年资料/3月/16日/嵌入式Linux的FTP服务端软件(stupid-ftpd) / 根据自己的需要,修改Makefile,将gcc修改为交叉工具链的gcc,比如mips-gnu-linux-gcc。 若要静态编译,在CFLAGS后面添加"-static"选项。 以下的Makefile已经修改:
  1. #  
  2. #  
  3. # Makefile for the linux version of stupid-ftpd  
  4. #  
  5. #  
  6. #  
  7.   
  8.   
  9. CC=mips-linux-gnu-gcc -EL          #修改  
  10. OBJS=ftpcommand.o ftpdconfig.o command.o ls.o stupid-ftpd.o  
  11. DOBJS=ftpcommand.do ftpdconfig.do command.do ls.do stupid-ftpd.do  
  12. POBJS=ftpcommand.po ftpdconfig.po command.po ls.po stupid-ftpd.po  
  13. LIBS=  
  14. CFLAGS=-O2 -Wall -Wstrict-prototypes -static    #修改  
  15. DCFLAGS=-g -DDEBUG -Wall -Wstrict-prototypes  
  16. PCFLAGS=-g -DDEBUG -Wall -Wstrict-prototypes -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs  
  17. EXEC=stupid-ftpd.Linux6  
  18.   
  19. .SUFFIXES: .c .o .do .po  
  20.   
  21. all: $(OBJS)  
  22.     $(CC) $(CFLAGS) -o $(EXEC) $(OBJS) $(LIBS)  
  23.   
  24. debug: $(DOBJS)  
  25.     $(CC) $(DCFLAGS) -o $(EXEC) $(DOBJS) $(LIBS)  
  26.   
  27. pedantic: $(POBJS)  
  28.     $(CC) $(PCFLAGS) -o $(EXEC) $(POBJS) $(LIBS)  
  29.   
  30. clean:  
  31.     rm -f $(OBJS) $(DOBJS) $(POBJS) $(EXEC) *~  
  32.   
  33. .c.o:  
  34.     $(CC) $(CFLAGS) -c -o $@ $<  
  35.   
  36. .c.do:  
  37.     $(CC) $(DCFLAGS) -c -o $@ $<  
  38.   
  39. .c.po:  
  40.     $(CC) $(PCFLAGS) -c -o $@ $<  
  41.   
  42. install:  
  43.     install -m 755 -s ./stupid-ftpd /usr/local/bin/stupid-ftpd  
  44.     install -m 700 -d /etc/stupid-ftpd  
  45.     install -m 755 -d /usr/local/stupid-ftpd  
  46.     install -m 600 ./stupid-ftpd.conf /etc/stupid-ftpd/stupid-ftpd.conf 
  47. 只需修改两个位置。 编译完成后,生成stupid-ftpd.Linux6可执行程序,该程序运行需要配置文件,以下的配置已经被修改并验证,是可以用的。但前提是运行在嵌入式Linux系统下,21端口没有被占用     
  48.  
  49. #  
  50. # This is a config-file for stupid-ftpd  
  51. # ------------------------------------  
  52. #  
  53. # The standard path should be /etc/stupid-ftpd.conf  
  54. # You can define other paths by using the "-f" option  
  55. # when starting stupid-ftpd.  
  56. #  
  57. #  
  58. # ATTENTION: 1) Remember, that the server is running with YOUR permissions.  
  59. #            It will fail to access other users directory, unless it is  
  60. #            root, but it also allows to access ALL YOUR directories,  
  61. #            which are deeper in a user's root-dir and YOU HAVE access to.  
  62. #            2) To solve the problem, the best way is to define a group-ID  
  63. #           for stupid-ftpd.   
  64. #       Or if you aren't root: set the MAIN root (serverroot=) to  
  65. #       the highest directory depth which is possible.  
  66. #            3) REMEMBER: DO NOT PUT THIS FILE in an accessible directory!!!  
  67. #               There are passwords defined here. The safest place is  
  68. #               outside the serverroot.  
  69.   
  70.   
  71. # Server operation mode:  
  72. # daemon      - quiet in background  
  73. # interactive - standard mode  
  74.   
  75. #mode=interactive  #交互式的形式运行  
  76. mode=daemon   #以守护进程的形式运行在后台  
  77.   
  78. # chroot to  
  79.   
  80. #serverroot=/usr/home/cinek/tmp3/aaa  
  81. serverroot=/mnt   #将ftp的根目录设置为/mnt目录下,在windows打开该ftp,就能访问/mnt目录  
  82.   
  83. # type of chroot  
  84. # real    - kernel chroot(), high security, but needs root privileges  
  85. # virtual - no real chroot(), software side (virtual) chroot  
  86.   
  87. #changeroottype=real  
  88. changeroottype=virtual  
  89.   
  90.   
  91. # Port number for the FTP-Protocol  
  92.   
  93. #port=2121  
  94. port=21  #默认为ftp的端口号。  
  95.   
  96.   
  97. # Maximum users allowed to log in  
  98.   
  99. maxusers=10  
  100.   
  101.   
  102. # Message Of The Day (motd)  
  103. # It will be displayed after the login procedure.  
  104.   
  105. #motd=/tmp/stupid-ftpd.motd  
  106.   
  107.   
  108. # Message on quit  
  109. # It will be displayed when quitting.  
  110.   
  111. #byemsg=/tmp/stupid-ftpd.bye  
  112.   
  113.   
  114. # Log  
  115.   
  116. #log=/tmp/stupid-ftpd.log  
  117.   
  118.   
  119. # User list:  
  120. # Format:  user=      
  121. #            user name  
  122. #           password or * for anonymous access  
  123. #           (internally appended to serverroot)  
  124. #               the user has access to the WHOLE SUBTREE,  
  125. #               if the server has access to it  
  126. #                maximal logins with this usertype  
  127. #            D - download  
  128. #               U - upload + making directories  
  129. #               O - overwrite existing files  
  130. #               M - allows multiple logins  
  131. #               E - allows erase operations  
  132. #               A - allows EVERYTHING(!)  
  133. #                 
  134. # user ftp is mapped to user anonymous, don't forget this  
  135. #   
  136. # Examples:  
  137. # user=user1 passx /tmp  2 D   
  138. #      - login: user1, passwd: passx, max login twice (different IPs!)  
  139. #        only download rights from directory /tmp         
  140. # user=user2 passy /home/user2 0 DU  
  141. #      - login: user2, passwd: passy, no login count limit (different IPs!)  
  142. #        download+upload rights to directory /home/user2   
  143. # user=user3 passz /home/user3 5 DUOM  
  144. #      - login: user3, passwd: passz, max login count 5 (even from same IP)  
  145. #        download+upload+overwrite rights to directory /home/user3   
  146. # user=user4 passq /tmp 10 -  
  147. #      - login: user4, passwd: passq, max login count 10 (even from same IP)  
  148. #        look-only rights at directory /tmp  
  149. #  
  150. # SEE: ATTENTION remark on the top of this file !!!  
  151.   
  152. user=anonymous  *    /    5   A  
  153.   
  154.   
  155. # Banned hosts  
  156. # "*" and "?" are allowed here  
  157.   
  158. #ban=192.168.*  
  159. #ban=localhost  
  160. #ban=*.banme.com  
  161.   
  162.   
  163. # Ban message (displayed to user who is banned)  
  164. # Please don't use more than 70 characters.  
  165.   
  166. #banmsg=Go away !  
  167.   
  168.   
  169. # Login/password timeout  
  170.   
  171. login-timeout=120  
  172.   
  173.   
  174. # Timeout (while logged in)  
  175.   
  176. timeout=240  
  剩下的用默认的配置就可以了,特别注意,设置port参数的时候,2121端口不能使用,无法提供ftp服务。要设置为21端口,经过测试,设置为21端口,在Linux的PC机,报错:21端口被占用。但在嵌入式Linux下,是可以使用的。 stupid-ftpd.Linux6的使用方法:
直接用-f选项指定配置文件:
stupid-ftpd.Linux6 -f stupid-ftpd.conf 然后保证windows与嵌入式Linux系统的IP地址在同一网段,然后再"我的电脑"输入:ftp://192.168.x.x/
这里就不截图了。