推薦一款嵌入式Linux的FTP服務端軟件(stupid-ftpd)

http://sourceforge.net/projects/stupid-ftpd/

作者:gzshun. 原創作品,轉載請標明出處!

來源:http://blog.csdn.net/gzshun

在嵌入式Linux系統中,有時候需要搭建一個ftp服務器,以便windows或linux系統去訪問嵌入式linux系統的數據。現在流行的ftp和vsftpd軟件相對比較大,在嵌入式Linux系統下不太合適。最近由於需要,發現了一款很小型的ftp服務器,在這裏分享。


stupid-ftpd 點擊下載


根據自己的需要,修改Makefile,將gcc修改爲交叉工具鏈的gcc,比如mips-gnu-linux-gcc。
若要靜態編譯,在CFLAGS後面添加"-static"選項。

以下的Makefile已經修改:

[plain] view plaincopy
  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  

只需修改兩個位置。

編譯完成後,生成stupid-ftpd.Linux6可執行程序,該程序運行需要配置文件,以下的配置已經被修改並驗證,是可以用的。但前提是運行在嵌入式Linux系統下,21端口沒有被佔用。

[plain] view plaincopy
  1. #  
  2. # This is a config-file for stupid-ftpd  
  3. # ------------------------------------  
  4. #  
  5. # The standard path should be /etc/stupid-ftpd.conf  
  6. # You can define other paths by using the "-f" option  
  7. # when starting stupid-ftpd.  
  8. #  
  9. #  
  10. # ATTENTION: 1) Remember, that the server is running with YOUR permissions.  
  11. #            It will fail to access other users directory, unless it is  
  12. #            root, but it also allows to access ALL YOUR directories,  
  13. #            which are deeper in a user's root-dir and YOU HAVE access to.  
  14. #            2) To solve the problem, the best way is to define a group-ID  
  15. #           for stupid-ftpd.   
  16. #       Or if you aren't root: set the MAIN root (serverroot=) to  
  17. #       the highest directory depth which is possible.  
  18. #            3) REMEMBER: DO NOT PUT THIS FILE in an accessible directory!!!  
  19. #               There are passwords defined here. The safest place is  
  20. #               outside the serverroot.  
  21.   
  22.   
  23. # Server operation mode:  
  24. # daemon      - quiet in background  
  25. # interactive - standard mode  
  26.   
  27. #mode=interactive  #交互式的形式運行  
  28. mode=daemon   #以守護進程的形式運行在後臺  
  29.   
  30. # chroot to  
  31.   
  32. #serverroot=/usr/home/cinek/tmp3/aaa  
  33. serverroot=/mnt   #將ftp的根目錄設置爲/mnt目錄下,在windows打開該ftp,就能訪問/mnt目錄  
  34.   
  35. # type of chroot  
  36. # real    - kernel chroot(), high security, but needs root privileges  
  37. # virtual - no real chroot(), software side (virtual) chroot  
  38.   
  39. #changeroottype=real  
  40. changeroottype=virtual  
  41.   
  42.   
  43. # Port number for the FTP-Protocol  
  44.   
  45. #port=2121  
  46. port=21  #默認爲ftp的端口號。  
  47.   
  48.   
  49. # Maximum users allowed to log in  
  50.   
  51. maxusers=10  
  52.   
  53.   
  54. # Message Of The Day (motd)  
  55. # It will be displayed after the login procedure.  
  56.   
  57. #motd=/tmp/stupid-ftpd.motd  
  58.   
  59.   
  60. # Message on quit  
  61. # It will be displayed when quitting.  
  62.   
  63. #byemsg=/tmp/stupid-ftpd.bye  
  64.   
  65.   
  66. # Log  
  67.   
  68. #log=/tmp/stupid-ftpd.log  
  69.   
  70.   
  71. # User list:  
  72. # Format:  user=<login> <passwd> <subdir> <maxlogins> <flags>  
  73. #       <login>     user name  
  74. #       <passwd>    password or * for anonymous access  
  75. #       <subdir>    (internally appended to serverroot)  
  76. #               the user has access to the WHOLE SUBTREE,  
  77. #               if the server has access to it  
  78. #               <maxlogins> maximal logins with this usertype  
  79. #       <flags>     D - download  
  80. #               U - upload + making directories  
  81. #               O - overwrite existing files  
  82. #               M - allows multiple logins  
  83. #               E - allows erase operations  
  84. #               A - allows EVERYTHING(!)  
  85. #                 
  86. # user ftp is mapped to user anonymous, don't forget this  
  87. #   
  88. # Examples:  
  89. # user=user1 passx /tmp  2 D   
  90. #      - login: user1, passwd: passx, max login twice (different IPs!)  
  91. #        only download rights from directory /tmp         
  92. # user=user2 passy /home/user2 0 DU  
  93. #      - login: user2, passwd: passy, no login count limit (different IPs!)  
  94. #        download+upload rights to directory /home/user2   
  95. # user=user3 passz /home/user3 5 DUOM  
  96. #      - login: user3, passwd: passz, max login count 5 (even from same IP)  
  97. #        download+upload+overwrite rights to directory /home/user3   
  98. # user=user4 passq /tmp 10 -  
  99. #      - login: user4, passwd: passq, max login count 10 (even from same IP)  
  100. #        look-only rights at directory /tmp  
  101. #  
  102. # SEE: ATTENTION remark on the top of this file !!!  
  103.   
  104. user=anonymous  *    /    5   A  
  105.   
  106.   
  107. # Banned hosts  
  108. # "*" and "?" are allowed here  
  109.   
  110. #ban=192.168.*  
  111. #ban=localhost  
  112. #ban=*.banme.com  
  113.   
  114.   
  115. # Ban message (displayed to user who is banned)  
  116. # Please don't use more than 70 characters.  
  117.   
  118. #banmsg=Go away !  
  119.   
  120.   
  121. # Login/password timeout  
  122.   
  123. login-timeout=120  
  124.   
  125.   
  126. # Timeout (while logged in)  
  127.   
  128. 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/
這裏就不截圖了。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章