em-ftpd-memory 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0744dde341febc22360dc49fb92b41909272e8ea
4
- data.tar.gz: 0cde755aab1c955576c8225eed23622bfc111aa1
3
+ metadata.gz: f956464e630343b641be99ed93084dcb2a611315
4
+ data.tar.gz: 29590d20f13333be333625911bd2e926b72f8d00
5
5
  SHA512:
6
- metadata.gz: c2d9b81bfbefa1c169245ba6debb3cd3d1d3041217b5f670c894cf27efb028dc4ca057c41ec261f04dc97c0de01efa603378aff56d873f7476ec6aecb8915353
7
- data.tar.gz: b531295f70b050fdc1b0f630587632260b2549853332d4ff703ca9ec3471d2fd9f8ba1bf56102666bba2295924ee49d6deead724992fe78cf0948425fee16ef7
6
+ metadata.gz: 478ecd65ede2e791ce9e15379feecc04766b5e5896ca9c77cc3a8b885df3dc4d408dd233cd48c3674d3463a989124b3d107b19bdedf6d0892eadbc3050d6131e
7
+ data.tar.gz: 88f9881f706324244c08740de23803f298e14b52ff57ee4d88b7a2b43c46b957b4f9744e369721b343a77766197eb8e05b9aa9d1f3b054aeeba985e8bfb963c2
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "em-ftpd-memory"
7
- spec.version = "0.0.3"
7
+ spec.version = "0.0.4"
8
8
  spec.authors = ["chrislee35"]
9
9
  spec.email = ["rubygems@chrislee.dhs.org"]
10
10
  spec.summary = %q{Memory-based backing store for em-ftpd}
@@ -62,5 +62,9 @@ module EM::FTPD::Memory
62
62
  yield @fs.create_dir(path, @authenticated_user)
63
63
  end
64
64
 
65
+ def mtime(path, &block)
66
+ yield @fs.modified_time(path, @authenticated_user)
67
+ end
68
+
65
69
  end
66
70
  end
@@ -52,6 +52,13 @@ module EM::FTPD::Memory
52
52
  f.size
53
53
  end
54
54
 
55
+ def modified_time(path, user = nil)
56
+ return nil unless use_allowed?(path, :time, user)
57
+ f = get_file(path)
58
+ return nil unless f
59
+ f.time
60
+ end
61
+
55
62
  def file_contents(path, user = nil)
56
63
  return false unless use_allowed?(path, :read, user)
57
64
  # nil || false => false
@@ -162,11 +169,12 @@ module EM::FTPD::Memory
162
169
  raise InvalidPermissionsError.new if permissions.nil?
163
170
  raise InvalidPermissionsError.new(permissions.to_s) unless permissions.class == String
164
171
  raise InvalidPermissionsError.new(permissions) unless permissions =~ /^[r\.][w\.][x\.][r\.][w\.][x\.][r\.][w\.][x\.]$/
165
- entry = get_entry(path)
166
- return false unless entry
167
- return false unless user and (entry.owner == user or user == "root")
168
- entry.permissions = permissions
169
- true
172
+ if use_allowed?(path, :chmod, user)
173
+ entry = get_entry(path)
174
+ entry.permissions = permissions
175
+ return true
176
+ end
177
+ false
170
178
  end
171
179
 
172
180
  def set_owner(path, owner, user = nil)
@@ -230,6 +238,11 @@ module EM::FTPD::Memory
230
238
  return allowed?(path, 'rx', username)
231
239
  when :size
232
240
  return true # since we've already checked everything
241
+ when :time
242
+ return true # since we've already checked everything
243
+ when :chmod
244
+ entry = get_entry(path)
245
+ return entry.owner == username
233
246
  when :delete
234
247
  return allowed?(dirname, "rwx", username)
235
248
  when :create
@@ -28,7 +28,7 @@ class TestFTPDMemory < Minitest::Test
28
28
 
29
29
  EM.run {
30
30
  EventMachine::start_server("0.0.0.0", 2021, EM::FTPD::Server, EM::FTPD::Memory::Driver, options)
31
- EM::Timer.new(100) do
31
+ EM::Timer.new(0.1) do
32
32
  EM.stop
33
33
  end
34
34
  }
@@ -171,12 +171,17 @@ class TestMemoryFilesystem < Minitest::Test
171
171
  assert_equal(169, fs.file_size("/pub/pub2/pub3/pub4/helper.rb", "root"))
172
172
 
173
173
 
174
- assert_equal(0, fs.list_files("/pub/pub2/pub3", "charlie").length)
175
- refute(fs.file_size("/pub/pub2/pub3/pub4/helper.rb", "charlie"))
176
- assert(fs.set_owner("/pub/pub2/pub3", "charlie", "root"))
177
- assert_equal(1, fs.list_files("/pub/pub2/pub3", "charlie").length)
178
- assert_equal(169, fs.file_size("/pub/pub2/pub3/pub4/helper.rb", "charlie"))
179
-
174
+ assert_equal(0, fs.list_files("/pub/pub2/pub3", "jem").length)
175
+ refute(fs.file_size("/pub/pub2/pub3/pub4/helper.rb", "jem"))
176
+ assert(fs.set_owner("/pub/pub2/pub3", "jem", "root"))
177
+ assert_equal(1, fs.list_files("/pub/pub2/pub3", "jem").length)
178
+ assert_equal(169, fs.file_size("/pub/pub2/pub3/pub4/helper.rb", "jem"))
179
+
180
+ assert(fs.set_permissions("/pub/pub2", "rwx......", "root"))
181
+ # jem owns pub3, but should be denied since she can't traverse pub2
182
+ refute(fs.set_permissions("/pub/pub2/pub3", "rwx......", "jem"))
183
+ assert(fs.set_permissions("/pub/pub2", "rwxr.xr.x", "root"))
184
+ assert(fs.set_permissions("/pub/pub2/pub3", "rwx......", "jem"))
180
185
  end
181
186
 
182
187
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-ftpd-memory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrislee35
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-15 00:00:00.000000000 Z
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-ftpd