win32-file-security 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +6 -0
- data/MANIFEST +4 -0
- data/lib/win32/file/security.rb +61 -4
- data/lib/win32/file/security/constants.rb +3 -0
- data/test/test_win32_file_security_acls.rb +28 -0
- data/test/test_win32_file_security_encryption.rb +1 -1
- data/test/test_win32_file_security_ownership.rb +1 -1
- data/test/test_win32_file_security_permissions.rb +1 -2
- data/test/test_win32_file_security_version.rb +1 -1
- data/win32-file-security.gemspec +1 -1
- metadata +15 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d234ea5f580422f9afe3ca568dca698212b4c31c
|
4
|
+
data.tar.gz: a3bee9399b1407bc23609a44315194cb361ef9c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e119edd6768169b2b37995be0656b59d3dbf304eedc2ba7f1ddffa4d3f130d3519e6cbf1cbe6e918813a04cf0049820630c3c71c23093603f5f2be19b7308ec
|
7
|
+
data.tar.gz: f3e9124fdd6acaea83dfd678ad150ea057695e2e600cfa443047776efa4877ae0b59c3c40975be6404dd0e59eb72e5f96696230f99d020754a2c78ec3e8b18f7
|
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
= 1.0.5 - 2-May-2015
|
2
|
+
* Added the File.supports_acls? singleton method.
|
3
|
+
* The File.get_permissions and File.set_permissions methods now explicitly
|
4
|
+
raise an error if the filesystem does not support ACL's.
|
5
|
+
* Fixed some deprecation warnings in the test suite.
|
6
|
+
|
1
7
|
= 1.0.4 - 2-May-2014
|
2
8
|
* All methods that accept a filename argument now honor objects that implement
|
3
9
|
either to_str or to_path.
|
data/MANIFEST
CHANGED
@@ -7,6 +7,10 @@
|
|
7
7
|
* lib/win32/file/windows/constants.rb
|
8
8
|
* lib/win32/file/windows/functions.rb
|
9
9
|
* lib/win32/file/windows/structs.rb
|
10
|
+
* test/test_win32_file_security_acls.rb
|
11
|
+
* test/test_win32_file_security_constants.rb
|
10
12
|
* test/test_win32_file_security_encryption.rb
|
13
|
+
* test/test_win32_file_security_ffi.rb
|
14
|
+
* test/test_win32_file_security_ownership.rb
|
11
15
|
* test/test_win32_file_security_permissions.rb
|
12
16
|
* test/test_win32_file_security_version.rb
|
data/lib/win32/file/security.rb
CHANGED
@@ -12,7 +12,7 @@ class File
|
|
12
12
|
extend Windows::File::Functions
|
13
13
|
|
14
14
|
# The version of the win32-file library
|
15
|
-
WIN32_FILE_SECURITY_VERSION = '1.0.
|
15
|
+
WIN32_FILE_SECURITY_VERSION = '1.0.5'
|
16
16
|
|
17
17
|
class << self
|
18
18
|
remove_method(:chown)
|
@@ -61,15 +61,15 @@ class File
|
|
61
61
|
end
|
62
62
|
|
63
63
|
# Returns whether or not the root path of the specified file is
|
64
|
-
# encryptable. If a relative path is specified, it will
|
65
|
-
# the root of the current directory.
|
64
|
+
# encryptable. If no path or a relative path is specified, it will
|
65
|
+
# check against the root of the current directory.
|
66
66
|
#
|
67
67
|
# Be sure to include a trailing slash if specifying a root path.
|
68
68
|
#
|
69
69
|
# Examples:
|
70
70
|
#
|
71
71
|
# p File.encryptable?
|
72
|
-
# p File.encryptable?("D
|
72
|
+
# p File.encryptable?("D:/")
|
73
73
|
# p File.encryptable?("C:/foo/bar.txt") # Same as 'C:\'
|
74
74
|
#
|
75
75
|
def encryptable?(file = nil)
|
@@ -102,6 +102,49 @@ class File
|
|
102
102
|
bool
|
103
103
|
end
|
104
104
|
|
105
|
+
|
106
|
+
# Returns whether or not the root path of the specified file supports
|
107
|
+
# ACL's. If no path or a relative path is specified, it will check against
|
108
|
+
# the root of the current directory.
|
109
|
+
#
|
110
|
+
# Be sure to include a trailing slash if specifying a root path.
|
111
|
+
#
|
112
|
+
# Examples:
|
113
|
+
#
|
114
|
+
# p File.supports_acls?
|
115
|
+
# p File.supports_acls?("D:/")
|
116
|
+
# p File.supports_acls?("C:/foo/bar.txt") # Same as 'C:\'
|
117
|
+
#
|
118
|
+
def supports_acls?(file = nil)
|
119
|
+
bool = false
|
120
|
+
flags_ptr = FFI::MemoryPointer.new(:ulong)
|
121
|
+
|
122
|
+
if file
|
123
|
+
file = File.expand_path(string_check(file))
|
124
|
+
wide_file = file.wincode
|
125
|
+
|
126
|
+
if !PathIsRootW(wide_file)
|
127
|
+
unless PathStripToRootW(wide_file)
|
128
|
+
raise SystemCallError.new("PathStripToRoot", FFI.errno)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
else
|
132
|
+
wide_file = nil
|
133
|
+
end
|
134
|
+
|
135
|
+
unless GetVolumeInformationW(wide_file, nil, 0, nil, nil, flags_ptr, nil, 0)
|
136
|
+
raise SystemCallError.new("GetVolumeInformation", FFI.errno)
|
137
|
+
end
|
138
|
+
|
139
|
+
flags = flags_ptr.read_ulong
|
140
|
+
|
141
|
+
if flags & FILE_PERSISTENT_ACLS > 0
|
142
|
+
bool = true
|
143
|
+
end
|
144
|
+
|
145
|
+
bool
|
146
|
+
end
|
147
|
+
|
105
148
|
# Encrypts a file or directory. All data streams in a file are encrypted.
|
106
149
|
# All new files created in an encrypted directory are encrypted.
|
107
150
|
#
|
@@ -159,6 +202,14 @@ class File
|
|
159
202
|
# }
|
160
203
|
#
|
161
204
|
def get_permissions(file, host=nil)
|
205
|
+
# Check local filesystem to see if it supports ACL's. If not, bail early
|
206
|
+
# because the GetFileSecurity function will not fail on an unsupported FS.
|
207
|
+
if host.nil?
|
208
|
+
unless supports_acls?(file)
|
209
|
+
raise ArgumentError, "Filesystem does not implement ACL support"
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
162
213
|
wide_file = string_check(file).wincode
|
163
214
|
wide_host = host ? host.wincode : nil
|
164
215
|
|
@@ -321,6 +372,12 @@ class File
|
|
321
372
|
# File.set_permissions(file, "host\\userid" => File::GENERIC_ALL)
|
322
373
|
#
|
323
374
|
def set_permissions(file, perms)
|
375
|
+
# Check local filesystem to see if it supports ACL's. If not, bail early
|
376
|
+
# because the GetFileSecurity function will not fail on an unsupported FS.
|
377
|
+
unless supports_acls?(file)
|
378
|
+
raise ArgumentError, "Filesystem does not implement ACL support"
|
379
|
+
end
|
380
|
+
|
324
381
|
wide_file = string_check(file).wincode
|
325
382
|
raise TypeError unless perms.kind_of?(Hash)
|
326
383
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# test_win32_file_acls.rb
|
3
|
+
#
|
4
|
+
# Test case for the File.supports_acls? method.
|
5
|
+
##############################################################################
|
6
|
+
require 'test-unit'
|
7
|
+
require 'win32/file/security'
|
8
|
+
require 'socket'
|
9
|
+
require 'etc'
|
10
|
+
|
11
|
+
class TC_Win32_File_Security_ACLS < Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
@dir = "C:/"
|
14
|
+
end
|
15
|
+
|
16
|
+
test "supports_acls? basic functionality" do
|
17
|
+
assert_respond_to(File, :supports_acls?)
|
18
|
+
assert_boolean(File.supports_acls?(@dir))
|
19
|
+
end
|
20
|
+
|
21
|
+
test "supports_acls? returns the expected results" do
|
22
|
+
assert_true(File.supports_acls?(@dir))
|
23
|
+
end
|
24
|
+
|
25
|
+
def teardown
|
26
|
+
@perms = nil
|
27
|
+
end
|
28
|
+
end
|
@@ -5,7 +5,6 @@
|
|
5
5
|
# use the 'rake test' or 'rake test:perms' task to run this.
|
6
6
|
##############################################################################
|
7
7
|
require 'test-unit'
|
8
|
-
require 'test/unit'
|
9
8
|
require 'win32/file/security'
|
10
9
|
require 'socket'
|
11
10
|
require 'etc'
|
@@ -80,7 +79,7 @@ class TC_Win32_File_Security_Permissions < Test::Unit::TestCase
|
|
80
79
|
end
|
81
80
|
|
82
81
|
def self.shutdown
|
83
|
-
File.delete(@@file) if File.
|
82
|
+
File.delete(@@file) if File.exist?(@@file)
|
84
83
|
@@file = nil
|
85
84
|
@@host = nil
|
86
85
|
@@user = nil
|
@@ -8,6 +8,6 @@ require 'win32/file/security'
|
|
8
8
|
|
9
9
|
class TC_Win32_File_Security_Version < Test::Unit::TestCase
|
10
10
|
test "version is set to expected value" do
|
11
|
-
assert_equal('1.0.
|
11
|
+
assert_equal('1.0.5', File::WIN32_FILE_SECURITY_VERSION)
|
12
12
|
end
|
13
13
|
end
|
data/win32-file-security.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32-file-security
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -9,62 +9,62 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: test-unit
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: win32-security
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: sys-admin
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
description: |2
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/win32/file/security/functions.rb
|
89
89
|
- lib/win32/file/security/helper.rb
|
90
90
|
- lib/win32/file/security/structs.rb
|
91
|
+
- test/test_win32_file_security_acls.rb
|
91
92
|
- test/test_win32_file_security_constants.rb
|
92
93
|
- test/test_win32_file_security_encryption.rb
|
93
94
|
- test/test_win32_file_security_ffi.rb
|
@@ -105,21 +106,22 @@ require_paths:
|
|
105
106
|
- lib
|
106
107
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
108
|
requirements:
|
108
|
-
- -
|
109
|
+
- - ">="
|
109
110
|
- !ruby/object:Gem::Version
|
110
111
|
version: '0'
|
111
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
113
|
requirements:
|
113
|
-
- -
|
114
|
+
- - ">="
|
114
115
|
- !ruby/object:Gem::Version
|
115
116
|
version: '0'
|
116
117
|
requirements: []
|
117
118
|
rubyforge_project: win32utils
|
118
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.4.7
|
119
120
|
signing_key:
|
120
121
|
specification_version: 4
|
121
122
|
summary: File security methods for the File class on MS Windows
|
122
123
|
test_files:
|
124
|
+
- test/test_win32_file_security_acls.rb
|
123
125
|
- test/test_win32_file_security_constants.rb
|
124
126
|
- test/test_win32_file_security_encryption.rb
|
125
127
|
- test/test_win32_file_security_ffi.rb
|