ftpd 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ftpd might be problematic. Click here for more details.

Files changed (49) hide show
  1. data/Changelog.md +24 -3
  2. data/Gemfile +2 -1
  3. data/Gemfile.lock +9 -2
  4. data/README.md +20 -9
  5. data/VERSION +1 -1
  6. data/doc/rfc.md +277 -0
  7. data/features/ftp_server/cdup.feature +36 -0
  8. data/features/ftp_server/command_errors.feature +0 -4
  9. data/features/ftp_server/delete.feature +1 -1
  10. data/features/ftp_server/directory_navigation.feature +18 -6
  11. data/features/ftp_server/get.feature +1 -1
  12. data/features/ftp_server/get_tls.feature +2 -2
  13. data/features/ftp_server/implicit_tls.feature +18 -0
  14. data/features/ftp_server/list_tls.feature +2 -2
  15. data/features/ftp_server/mkdir.feature +70 -0
  16. data/features/ftp_server/name_list_tls.feature +2 -2
  17. data/features/ftp_server/put.feature +1 -1
  18. data/features/ftp_server/put_tls.feature +2 -2
  19. data/features/ftp_server/rename.feature +90 -0
  20. data/features/ftp_server/rmdir.feature +71 -0
  21. data/features/ftp_server/step_definitions/debug.rb +6 -6
  22. data/features/ftp_server/step_definitions/test_server.rb +3 -2
  23. data/features/step_definitions/connect.rb +4 -3
  24. data/features/step_definitions/{directories.rb → directory_navigation.rb} +4 -0
  25. data/features/step_definitions/error_replies.rb +5 -5
  26. data/features/step_definitions/login.rb +2 -2
  27. data/features/step_definitions/mkdir.rb +9 -0
  28. data/features/step_definitions/rename.rb +11 -0
  29. data/features/step_definitions/rmdir.rb +9 -0
  30. data/features/step_definitions/server_files.rb +9 -0
  31. data/features/support/test_client.rb +19 -5
  32. data/features/support/test_server.rb +28 -3
  33. data/features/support/test_server_files.rb +5 -0
  34. data/ftpd.gemspec +17 -6
  35. data/lib/ftpd.rb +1 -0
  36. data/lib/ftpd/disk_file_system.rb +97 -16
  37. data/lib/ftpd/error.rb +16 -0
  38. data/lib/ftpd/exception_translator.rb +1 -1
  39. data/lib/ftpd/exceptions.rb +10 -4
  40. data/lib/ftpd/file_system_error_translator.rb +8 -4
  41. data/lib/ftpd/ftp_server.rb +1 -0
  42. data/lib/ftpd/session.rb +98 -87
  43. data/rake_tasks/yard.rake +1 -0
  44. data/spec/disk_file_system_spec.rb +55 -8
  45. data/spec/exception_translator_spec.rb +1 -1
  46. data/spec/file_system_error_translator_spec.rb +20 -4
  47. data/spec/translate_exceptions_spec.rb +1 -1
  48. metadata +32 -7
  49. data/sandbox/em-server.rb +0 -37
@@ -1,8 +1,29 @@
1
- ### dev
1
+ ### 0.2.1
2
2
 
3
- Bug fixes
3
+ API changes
4
+
5
+ * Introduced PermanentFileSystemError and TransientFileSystemError exceptions.
6
+ * Deprecated FileSystemError (use PermanentFileSystemError instead).
7
+ * DiskFileSystem errors generate 550 responses, not 450
8
+
9
+ Enhancements
4
10
 
5
- * Fixed formatting in Changelog
11
+ * Support MKD and XMKD (make directory)
12
+ * Support RMD and XRMD (remove directory)
13
+ * Support RNFR/RNTO (rename/move file/directory)
14
+ * Support XCUP (alias for CDUP)
15
+ * Support XPWD (alias for PWD)
16
+ * Support XCWD (alias for CWD)
17
+ * Test implicit TLS
18
+
19
+ Bug Fixes
20
+
21
+ * Passive mode transfers bind to the correct interface. They were
22
+ erroneously binding to the local interface, which kept passive mode
23
+ transfers from working when the client was on another machine.
24
+ * CDUP responds with syntax error if given an argument.
25
+ * RNTO checks that RNFM was called.
26
+ * Tests pass in Ruby 2.0.
6
27
 
7
28
  ### 0.2.0
8
29
 
data/Gemfile CHANGED
@@ -4,9 +4,10 @@ gem 'memoizer', '~> 1.0.1'
4
4
 
5
5
  group :development do
6
6
  gem 'cucumber'
7
- gem 'double-bag-ftps'
7
+ gem 'double-bag-ftps', :git => 'git@github.com:wconrad/double-bag-ftps.git'
8
8
  gem 'jeweler'
9
9
  gem 'rake'
10
+ gem 'redcarpet'
10
11
  gem 'rspec'
11
12
  gem 'yard'
12
13
  end
@@ -1,3 +1,9 @@
1
+ GIT
2
+ remote: git@github.com:wconrad/double-bag-ftps.git
3
+ revision: 043ba70309ed622302d3aa5c6f3169872d1211ca
4
+ specs:
5
+ double-bag-ftps (0.1.0)
6
+
1
7
  GEM
2
8
  remote: http://rubygems.org/
3
9
  specs:
@@ -8,7 +14,6 @@ GEM
8
14
  gherkin (~> 2.11.0)
9
15
  json (>= 1.4.6)
10
16
  diff-lcs (1.1.3)
11
- double-bag-ftps (0.1.0)
12
17
  gherkin (2.11.6)
13
18
  json (>= 1.7.6)
14
19
  git (1.2.5)
@@ -22,6 +27,7 @@ GEM
22
27
  rake (10.0.3)
23
28
  rdoc (3.12.1)
24
29
  json (~> 1.4)
30
+ redcarpet (2.2.2)
25
31
  rspec (2.12.0)
26
32
  rspec-core (~> 2.12.0)
27
33
  rspec-expectations (~> 2.12.0)
@@ -37,9 +43,10 @@ PLATFORMS
37
43
 
38
44
  DEPENDENCIES
39
45
  cucumber
40
- double-bag-ftps
46
+ double-bag-ftps!
41
47
  jeweler
42
48
  memoizer (~> 1.0.1)
43
49
  rake
50
+ redcarpet
44
51
  rspec
45
52
  yard
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # FTPD
2
2
 
3
3
  ftpd is a pure Ruby FTP server library. It supports implicit and
4
- explicit TLS, and can be used as part of a test fixture or to embed in
5
- another program.
4
+ explicit TLS, passive and active mode, and most of the commands
5
+ specified in RFC 969. It an be used as part of a test fixture or
6
+ embedded in a program.
6
7
 
7
8
  ## HELLO WORLD
8
9
 
@@ -87,9 +88,8 @@ output without having to change any code.
87
88
 
88
89
  ## LIMITATIONS
89
90
 
90
- TLS is only supported in passive mode, not active, but I don't know
91
- why. Either the FTPS client used by the test doesn't work in active
92
- mode, or this server doesn't work in FTPS active mode (or both).
91
+ The automated tests don't cover TLS in passive mode (although it works
92
+ fine): The FTPS client used by the test locks up in active mode.
93
93
 
94
94
  The DiskFileSystem class only works in Linux. This is because it
95
95
  shells out to the "ls" command. This affects the example, which uses
@@ -106,17 +106,28 @@ implemented. They result in a "502 Command not implemented" response.
106
106
  * ACCT - Account
107
107
  * APPE - Append (with create)
108
108
  * HELP - Help
109
- * MKD - Make directory
110
109
  * REIN - Reinitialize
111
110
  * REST - Restart
112
- * RMD - Remove directory
113
- * RNFR - Rename from
114
- * RNTO - Rename to
115
111
  * SITE - Site parameters
116
112
  * SMNT - Structure mount
117
113
  * STAT - Status
118
114
  * STOU - Store Unique
119
115
 
116
+ To bind the server to an external interface, the interface must be set
117
+ to the public IP of that interface (e.g. "1.2.3.4"), not to "0.0.0.0".
118
+ That's because the interface IP is used both for binding server ports,
119
+ _and_ for advertising to the client which IP to connect to. Binding
120
+ to 0.0.0.0 will work fine, but when the client tries to connect to
121
+ 0.0.0.0, it won't get to the server.
122
+
123
+ ## VERSIONS
124
+
125
+ The tests pass with these Rubies:
126
+
127
+ * ruby-1.8.7-p371
128
+ * ruby-1.9.3-p392
129
+ * ruby-2.0.0-p0
130
+
120
131
  ## DEVELOPMENT
121
132
 
122
133
  ### TESTS
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -0,0 +1,277 @@
1
+ # RFC compliance
2
+
3
+ This page documents FTPDs compliance (or not) with the RFCs that
4
+ define the FTP protocol.
5
+
6
+ This document is modeled after [this one from the pyftpdlib
7
+ wiki](http://code.google.com/p/pyftpdlib/wiki/RFCsCompliance).
8
+ pyftpdlib is what every FTP library wants to be when it grows up.
9
+
10
+ ## RFC-959 - File Transfer Protocol
11
+
12
+ * Issued: October 1985
13
+ * Status: STANDARD
14
+ * Obsoletes: [RFC-765](http://tools.ietf.org/rfc/rfc765.txt)
15
+ * Updated by:
16
+ [RFC-1123](http://tools.ietf.org/rfc/rfc1123.txt)
17
+ [RFC-2228](http://tools.ietf.org/rfc/rfc2228.txt)
18
+ [RFC-2640](http://tools.ietf.org/rfc/rfc2640.txt)
19
+ [RFC-2773](http://tools.ietf.org/rfc/rfc2773.txt)
20
+ * [link](http://tools.ietf.org/rfc/rfc959.txt)
21
+
22
+ Commands supported:
23
+
24
+ ABOR No --- Abort transfer
25
+ ACCT No --- Specify user's account
26
+ ALLO Yes 0.2.0 Allocate storage space
27
+ Treated as a NOOP
28
+ APPE No --- Append to file
29
+ CDUP Yes 0.1.0 Change to parent directory
30
+ CWD Yes 0.1.0 Change working directory
31
+ DELE Yes 0.1.0 Delete file
32
+ HELP No --- Help
33
+ LIST Yes 0.1.0 List directory
34
+ MKD Yes dev Make directory
35
+ MODE Yes 0.1.0 Set transfer mode
36
+ "Stream" mode supported; "Block" and
37
+ "Compressed" are not
38
+ NLST Yes 0.1.0 Name list
39
+ NOOP Yes 0.1.0 No Operation
40
+ PASS Yes 0.1.0 Set user password
41
+ PASV Yes 0.1.0 Set passive mode
42
+ PORT Yes 0.1.0 Set active mode
43
+ PWD Yes 0.1.0 Print working directory
44
+ QUIT Yes 0.1.0 Quit session
45
+ REIN No --- Reinitialize session
46
+ REST No --- Restart transfer
47
+ RETR Yes 0.1.0 Retrieve file
48
+ RMD Yes dev Remove directory
49
+ RNFR Yes dev Rename file (from)
50
+ RNTO Yes dev Rename file (to)
51
+ SITE No --- Site specific commands
52
+ SMNT No --- Structure Mount
53
+ STAT No --- Server status
54
+ STOR Yes 0.1.0 Store file
55
+ STOU No --- Store with unique name
56
+ STRU Yes 0.1.0 Set file structure
57
+ Supports "File" structure only. "Record" and
58
+ "Page" are not supported
59
+ SYST Yes 0.2.0 Get system type
60
+ Always returns "UNIX Type: L8"
61
+ TYPE Yes 0.1.0 Set representation type
62
+ Supports ascii non-print and binary-non-print
63
+ only
64
+ USER Yes 0.1.0 Set user
65
+
66
+ ## RFC-1123 - Requirements for Internet Hosts
67
+
68
+ Extends and clarifies some aspects of RFC-959. Introduces new response
69
+ codes 554 and 555.
70
+
71
+ * Issued: October 1989
72
+ * Status: STANDARD
73
+ * [link](http://tools.ietf.org/rfc/rfc1123.txt)
74
+
75
+ The following compliance table is lifted out of the RFC and annotated
76
+ with "C" where FTPD complies, or "E" where compliance is not required.
77
+
78
+ <pre>
79
+ | | | | |S| |
80
+ | | | | |H| |F
81
+ | | | | |O|M|o
82
+ | | |S| |U|U|o
83
+ | | |H| |L|S|t
84
+ | |M|O| |D|T|n
85
+ | |U|U|M| | |o
86
+ | |S|L|A|N|N|t
87
+ | |T|D|Y|O|O|t
88
+ FEATURE |SECTION | | | |T|T|e
89
+ -------------------------------------------|---------------|-|-|-|-|-|--
90
+ Implement TYPE T if same as TYPE N |4.1.2.2 | |x| | | |
91
+ File/Record transform invertible if poss. |4.1.2.4 | |x| | | |
92
+ Server-FTP implement PASV |4.1.2.6 |x| | | | | C
93
+ PASV is per-transfer |4.1.2.6 |x| | | | |
94
+ NLST reply usable in RETR cmds |4.1.2.7 |x| | | | | C
95
+ Implied type for LIST and NLST |4.1.2.7 | |x| | | | C
96
+ SITE cmd for non-standard features |4.1.2.8 | |x| | | |
97
+ STOU cmd return pathname as specified |4.1.2.9 |x| | | | |
98
+ Use TCP READ boundaries on control conn. |4.1.2.10 | | | | |x| C
99
+ Server-FTP send only correct reply format |4.1.2.11 |x| | | | | C
100
+ Server-FTP use defined reply code if poss. |4.1.2.11 | |x| | | | C
101
+ New reply code following Section 4.2 |4.1.2.11 | | |x| | |
102
+ Default data port same IP addr as ctl conn |4.1.2.12 |x| | | | |
103
+ Server-FTP handle Telnet options |4.1.2.12 |x| | | | |
104
+ Handle "Experimental" directory cmds |4.1.3.1 | |x| | | | C
105
+ Idle timeout in server-FTP |4.1.3.2 | |x| | | |
106
+ Configurable idle timeout |4.1.3.2 | |x| | | |
107
+ Receiver checkpoint data at Restart Marker |4.1.3.4 | |x| | | |
108
+ Sender assume 110 replies are synchronous |4.1.3.4 | | | | |x|
109
+ | | | | | | |
110
+ Support TYPE: | | | | | | |
111
+ ASCII - Non-Print (AN) |4.1.2.13 |x| | | | | C
112
+ ASCII - Telnet (AT) -- if same as AN |4.1.2.2 | |x| | | |
113
+ ASCII - Carriage Control (AC) |959 3.1.1.5.2 | | |x| | |
114
+ EBCDIC - (any form) |959 3.1.1.2 | | |x| | |
115
+ IMAGE |4.1.2.1 |x| | | | | C
116
+ LOCAL 8 |4.1.2.1 |x| | | | |
117
+ LOCAL m |4.1.2.1 | | |x| | |2
118
+ | | | | | | |
119
+ Support MODE: | | | | | | |
120
+ Stream |4.1.2.13 |x| | | | | C
121
+ Block |959 3.4.2 | | |x| | |
122
+ | | | | | | |
123
+ Support STRUCTURE: | | | | | | |
124
+ File |4.1.2.13 |x| | | | | C
125
+ Record |4.1.2.13 |x| | | | |3 E
126
+ Page |4.1.2.3 | | | |x| |
127
+ | | | | | | |
128
+ Support commands: | | | | | | |
129
+ USER |4.1.2.13 |x| | | | | C
130
+ PASS |4.1.2.13 |x| | | | | C
131
+ ACCT |4.1.2.13 |x| | | | |
132
+ CWD |4.1.2.13 |x| | | | | C
133
+ CDUP |4.1.2.13 |x| | | | | C
134
+ SMNT |959 5.3.1 | | |x| | |
135
+ REIN |959 5.3.1 | | |x| | |
136
+ QUIT |4.1.2.13 |x| | | | | C
137
+ | | | | | | |
138
+ PORT |4.1.2.13 |x| | | | | C
139
+ PASV |4.1.2.6 |x| | | | | C
140
+ TYPE |4.1.2.13 |x| | | | |1 C
141
+ STRU |4.1.2.13 |x| | | | |1 C
142
+ MODE |4.1.2.13 |x| | | | |1 C
143
+ | | | | | | |
144
+ RETR |4.1.2.13 |x| | | | | C
145
+ STOR |4.1.2.13 |x| | | | | C
146
+ STOU |959 5.3.1 | | |x| | |
147
+ APPE |4.1.2.13 |x| | | | |
148
+ ALLO |959 5.3.1 | | |x| | | C
149
+ REST |959 5.3.1 | | |x| | |
150
+ RNFR |4.1.2.13 |x| | | | | C
151
+ RNTO |4.1.2.13 |x| | | | | C
152
+ ABOR |959 5.3.1 | | |x| | |
153
+ DELE |4.1.2.13 |x| | | | | C
154
+ RMD |4.1.2.13 |x| | | | | C
155
+ MKD |4.1.2.13 |x| | | | | C
156
+ PWD |4.1.2.13 |x| | | | | C
157
+ LIST |4.1.2.13 |x| | | | | C
158
+ NLST |4.1.2.13 |x| | | | | C
159
+ SITE |4.1.2.8 | | |x| | |
160
+ STAT |4.1.2.13 |x| | | | |
161
+ SYST |4.1.2.13 |x| | | | |
162
+ HELP |4.1.2.13 |x| | | | |
163
+ NOOP |4.1.2.13 |x| | | | | C
164
+
165
+ Footnotes:
166
+
167
+ (1) For the values shown earlier.
168
+ (2) Here m is number of bits in a memory word.
169
+ (3) Required for host with record-structured file system, optional
170
+ otherwise.
171
+
172
+ </pre>
173
+
174
+ ## RFC-2228 - FTP Security Extensions
175
+
176
+ Specifies several security extensions to the base FTP protocol defined
177
+ in RFC-959. New commands: AUTH, ADAT, PROT, PBSZ, CCC, MIC, CONF, and
178
+ ENC. New response codes: 232, 234, 235, 334, 335, 336, 431, 533, 534,
179
+ 535, 536, 537, 631, 632, and 633.
180
+
181
+ <pre>
182
+ AUTH Yes 0.1.0 Authentication/Security Mechanism
183
+ ADAT No --- Authentication/Security Data
184
+ PROT Yes 0.1.0 Data Channel Protection Level
185
+ PBSZ Yes 0.1.0 Protection Buffer Size
186
+ CCC No --- Clear Command Channel
187
+ MIC No --- Integrity Protect Command
188
+ CONF No --- Confidentiality Protected Command
189
+ ENC No --- Privacy Protected Command
190
+ </pre>
191
+
192
+ ## RFC-2389 - Feature negotiation mechanism for the File Transfer Protocol
193
+
194
+ Introduces the new FEAT and OPTS commands.
195
+
196
+ * Issued: August 1998
197
+ * Status: PROPOSED STANDARD
198
+ * [link](http://tools.ietf.org/rfc/rfc2389.txt)
199
+
200
+ <pre>
201
+ FEAT No --- List new supported commands
202
+ OPTS No --- Set options for certain commands
203
+ </pre>
204
+
205
+ ##RFC-2577 - FTP Security Considerations
206
+
207
+ Provides several configuration and implementation suggestions to
208
+ mitigate some security concerns, including limiting failed password
209
+ attempts and third-party "proxy FTP" transfers, which can be used in
210
+ "bounce attacks".
211
+
212
+ * Issued: May 1999
213
+ * Status: INFORMATIONAL
214
+ * [link](http://tools.ietf.org/rfc/rfc2577.txt)
215
+
216
+ <pre>
217
+ FTP bounce protection
218
+ Restruct PASV/PORT to non-priv. ports No ---
219
+ Disconnect after so many wrong auths. No ---
220
+ Delay on invalid password No ---
221
+ Per-source IP limit No ---
222
+ Do not reject wrong usernames Yes ---
223
+ Port stealing protection No ---
224
+ </pre>
225
+
226
+ ## RFC-2640 - Internationalization of the File Transfer Protocol
227
+
228
+ Extends the FTP protocol to support multiple character sets, in
229
+ addition to the original 7-bit ASCII. Introduces the new LANG command.
230
+
231
+ * Issued: July 1999
232
+ * Status: PROPOSED STANDARD
233
+ * [link](http://tools.ietf.org/rfc/rfc2640.txt)
234
+
235
+ <pre>
236
+ LANG command No ---
237
+ UNICODE No ---
238
+ </pre>
239
+
240
+ RFC-3659 - Extensions to FTP
241
+
242
+ Four new commands are added: "SIZE", "MDTM", "MLST", and "MLSD". The existing command "REST" is modified.
243
+
244
+ * Issued: March 2007
245
+ * Status: PROPOSED STANDARD
246
+ * Updates: [RFC-959](http://tools.ietf.org/rfc/rfc959.txt)
247
+ * [link](http://tools.ietf.org/rfc/rfc3659.txt)
248
+
249
+ <pre>
250
+ MDTM command No --- Get file's last modification time
251
+ MLSD command No --- Get directory list in a standardized form.
252
+ MLST command No --- Get file information in a standardized form.
253
+ SIZE command No --- Get file size.
254
+ TVSF mechanism No --- Unix-like file system naming conventions
255
+ Min. MLST facts No ---
256
+ GMT timestamps No ---
257
+ </pre>
258
+
259
+ ##RFC-4217 - Securing FTP with TLS
260
+
261
+ Provides a description on how to implement TLS as a security mechanism to secure FTP clients and/or servers.
262
+
263
+ * Issued: October 2005
264
+ * Status: STANDARD
265
+ * Updates:
266
+ [RFC-959](http://tools.ietf.org/rfc/rfc959.txt)
267
+ [RFC-2246](http://tools.ietf.org/rfc/rfc2246.txt)
268
+ [RFC-2228](http://tools.ietf.org/rfc/rfc2228.txt)
269
+ * [link](http://tools.ietf.org/rfc/rfc4217.txt)
270
+
271
+ <pre>
272
+ AUTH Yes --- Authentication/Security Mechanism
273
+ CCC No --- Clear Command Channel
274
+ PBSZ Yes --- Protection Buffer Size
275
+ PROT Yes --- Data Channel Protection Level.
276
+ Support only "Private" level
277
+ </pre>
@@ -0,0 +1,36 @@
1
+ Feature: Change Directory
2
+
3
+ As a client
4
+ I want to change to the parent directory
5
+
6
+ Background:
7
+ Given the test server is started
8
+
9
+ Scenario: From subdir
10
+ Given a successful login
11
+ And the server has directory "subdir"
12
+ And the client successfully cd's to "subdir"
13
+ When the client successfully cd's up
14
+ Then the current directory should be "/"
15
+
16
+ Scenario: From root
17
+ Given a successful login
18
+ When the client successfully cd's up
19
+ Then the current directory should be "/"
20
+
21
+ Scenario: XCUP
22
+ Given a successful login
23
+ And the server has directory "subdir"
24
+ And the client successfully cd's to "subdir"
25
+ When the client successfully sends "XCUP"
26
+ Then the current directory should be "/"
27
+
28
+ Scenario: With argument
29
+ Given a successful login
30
+ When the client sends "CDUP abc"
31
+ Then the server returns a syntax error
32
+
33
+ Scenario: Not logged in
34
+ Given a successful connection
35
+ When the client cd's to "subdir"
36
+ Then the server returns a not logged in error