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 +4 -4
- data/em-ftpd-memory.gemspec +1 -1
- data/lib/em/ftpd/memory/driver.rb +4 -0
- data/lib/em/ftpd/memory/filesystem.rb +18 -5
- data/test/test_ftpd-memory.rb +1 -1
- data/test/test_memory_filesystem.rb +11 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f956464e630343b641be99ed93084dcb2a611315
|
4
|
+
data.tar.gz: 29590d20f13333be333625911bd2e926b72f8d00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 478ecd65ede2e791ce9e15379feecc04766b5e5896ca9c77cc3a8b885df3dc4d408dd233cd48c3674d3463a989124b3d107b19bdedf6d0892eadbc3050d6131e
|
7
|
+
data.tar.gz: 88f9881f706324244c08740de23803f298e14b52ff57ee4d88b7a2b43c46b957b4f9744e369721b343a77766197eb8e05b9aa9d1f3b054aeeba985e8bfb963c2
|
data/em-ftpd-memory.gemspec
CHANGED
@@ -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.
|
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}
|
@@ -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
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
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
|
data/test/test_ftpd-memory.rb
CHANGED
@@ -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", "
|
175
|
-
refute(fs.file_size("/pub/pub2/pub3/pub4/helper.rb", "
|
176
|
-
assert(fs.set_owner("/pub/pub2/pub3", "
|
177
|
-
assert_equal(1, fs.list_files("/pub/pub2/pub3", "
|
178
|
-
assert_equal(169, fs.file_size("/pub/pub2/pub3/pub4/helper.rb", "
|
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.
|
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-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-ftpd
|