vagrant-unbundled 2.0.3.0 → 2.0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -10
  3. data/Gemfile.lock +16 -2
  4. data/README.md +1 -0
  5. data/bin/vagrant +1 -1
  6. data/lib/vagrant/action/builtin/handle_box.rb +1 -1
  7. data/lib/vagrant/action/general/package.rb +1 -1
  8. data/lib/vagrant/action.rb +3 -1
  9. data/lib/vagrant/alias.rb +56 -0
  10. data/lib/vagrant/bundler.rb +1 -1
  11. data/lib/vagrant/capability_host.rb +1 -1
  12. data/lib/vagrant/cli.rb +8 -0
  13. data/lib/vagrant/config/version_base.rb +1 -1
  14. data/lib/vagrant/environment.rb +7 -1
  15. data/lib/vagrant/errors.rb +4 -0
  16. data/lib/vagrant/host.rb +1 -1
  17. data/lib/vagrant/machine.rb +1 -1
  18. data/lib/vagrant/machine_index.rb +1 -1
  19. data/lib/vagrant/plugin/v1/guest.rb +1 -1
  20. data/lib/vagrant/plugin/v1/host.rb +1 -1
  21. data/lib/vagrant/plugin/v1/plugin.rb +1 -1
  22. data/lib/vagrant/plugin/v1/provider.rb +1 -1
  23. data/lib/vagrant/plugin/v2/guest.rb +1 -1
  24. data/lib/vagrant/plugin/v2/host.rb +1 -1
  25. data/lib/vagrant/plugin/v2/plugin.rb +1 -1
  26. data/lib/vagrant/plugin/v2/provider.rb +1 -1
  27. data/lib/vagrant/shared_helpers.rb +30 -9
  28. data/lib/vagrant/util/checkpoint_client.rb +8 -0
  29. data/lib/vagrant/util/downloader.rb +1 -1
  30. data/lib/vagrant/util/platform.rb +11 -3
  31. data/lib/vagrant/util/powershell.rb +17 -1
  32. data/lib/vagrant/util/safe_exec.rb +1 -1
  33. data/lib/vagrant/util/ssh.rb +4 -1
  34. data/lib/vagrant/util/stacked_proc_runner.rb +1 -1
  35. data/lib/vagrant/util/template_renderer.rb +2 -2
  36. data/lib/vagrant/vagrantfile.rb +1 -1
  37. data/lib/vagrant.rb +8 -0
  38. data/plugins/commands/plugin/gem_helper.rb +1 -1
  39. data/plugins/commands/powershell/command.rb +2 -2
  40. data/plugins/commands/powershell/scripts/enable_psremoting.ps1 +1 -1
  41. data/plugins/communicators/ssh/communicator.rb +10 -1
  42. data/plugins/communicators/winrm/command_filters/mkdir.rb +4 -2
  43. data/plugins/communicators/winrm/command_filters/rm.rb +5 -3
  44. data/plugins/communicators/winrm/command_filters/test.rb +3 -1
  45. data/plugins/communicators/winrm/command_filters/which.rb +4 -2
  46. data/plugins/communicators/winrm/communicator.rb +3 -3
  47. data/plugins/guests/amazon/cap/flavor.rb +1 -1
  48. data/plugins/guests/coreos/cap/configure_networks.rb +1 -1
  49. data/plugins/guests/coreos/guest.rb +1 -1
  50. data/plugins/guests/debian/cap/configure_networks.rb +1 -1
  51. data/plugins/guests/freebsd/cap/configure_networks.rb +1 -1
  52. data/plugins/guests/photon/guest.rb +1 -1
  53. data/plugins/guests/windows/cap/change_host_name.rb +6 -1
  54. data/plugins/guests/windows/cap/mount_shared_folder.rb +1 -1
  55. data/plugins/hosts/alt/plugin.rb +1 -1
  56. data/plugins/hosts/arch/plugin.rb +1 -1
  57. data/plugins/hosts/gentoo/plugin.rb +1 -1
  58. data/plugins/hosts/linux/plugin.rb +1 -1
  59. data/plugins/hosts/redhat/plugin.rb +1 -1
  60. data/plugins/hosts/slackware/plugin.rb +2 -2
  61. data/plugins/kernel_v2/config/push.rb +1 -1
  62. data/plugins/kernel_v2/config/vm.rb +1 -1
  63. data/plugins/providers/docker/action/compare_synced_folders.rb +1 -1
  64. data/plugins/providers/virtualbox/action/network.rb +9 -5
  65. data/plugins/providers/virtualbox/action/network_fix_ipv6.rb +1 -1
  66. data/plugins/provisioners/chef/config/chef_zero.rb +1 -1
  67. data/plugins/provisioners/chef/provisioner/chef_solo.rb +2 -2
  68. data/plugins/provisioners/chef/provisioner/chef_zero.rb +3 -3
  69. data/plugins/provisioners/puppet/config/puppet.rb +2 -0
  70. data/plugins/provisioners/puppet/provisioner/puppet.rb +18 -1
  71. data/plugins/provisioners/salt/config.rb +6 -0
  72. data/plugins/provisioners/salt/provisioner.rb +11 -1
  73. data/templates/locales/command_ps.yml +1 -1
  74. data/templates/locales/en.yml +13 -4
  75. data/templates/locales/guest_windows.yml +1 -1
  76. data/templates/locales/providers_docker.yml +1 -1
  77. data/templates/locales/synced_folder_smb.yml +2 -2
  78. data/vagrant.gemspec +2 -0
  79. data/vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-spec-f3daedaac493/vagrant-spec.gemspec +1 -1
  80. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/.document +5 -0
  81. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/.gitignore +17 -0
  82. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/.travis.yml +21 -0
  83. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/CHANGELOG.md +209 -0
  84. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/Gemfile +4 -0
  85. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/LICENSE.txt +78 -0
  86. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/README.md +67 -0
  87. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/Rakefile +88 -0
  88. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/data/public_suffix_list.dat +12440 -0
  89. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/domain_name.gemspec +36 -0
  90. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/lib/domain_name/etld_data.rb +8474 -0
  91. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/lib/domain_name/etld_data.rb.erb +11 -0
  92. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/lib/domain_name/punycode.rb +283 -0
  93. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/lib/domain_name/version.rb +3 -0
  94. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/lib/domain_name.rb +297 -0
  95. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/test/helper.rb +17 -0
  96. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/test/test_domain_name-punycode.rb +97 -0
  97. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/test/test_domain_name.rb +317 -0
  98. data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/tool/gen_etld_data.rb +63 -0
  99. data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/CHANGES +13 -0
  100. data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/LICENSE +201 -0
  101. data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/MANIFEST +9 -0
  102. data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/README +48 -0
  103. data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/Rakefile +42 -0
  104. data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/certs/djberg96_pub.pem +21 -0
  105. data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/ffi-win32-extensions.gemspec +25 -0
  106. data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/lib/ffi/win32/extensions.rb +96 -0
  107. data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/lib/ffi-win32-extensions.rb +1 -0
  108. data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/test/test_ffi_extensions.rb +41 -0
  109. data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/test/test_string_extensions.rb +20 -0
  110. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/CHANGES +235 -0
  111. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/MANIFEST +16 -0
  112. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/README +73 -0
  113. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/Rakefile +49 -0
  114. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/appveyor.yml +50 -0
  115. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/certs/djberg96_pub.pem +21 -0
  116. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/lib/win32/file/constants.rb +33 -0
  117. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/lib/win32/file/functions.rb +42 -0
  118. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/lib/win32/file/structs.rb +54 -0
  119. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/lib/win32/file.rb +585 -0
  120. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/lib/win32-file.rb +1 -0
  121. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/test/test_win32_file_link.rb +141 -0
  122. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/test/test_win32_file_misc.rb +16 -0
  123. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/test/test_win32_file_path.rb +282 -0
  124. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/test/test_win32_file_stat.rb +330 -0
  125. data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/win32-file.gemspec +33 -0
  126. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/CHANGES +63 -0
  127. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/MANIFEST +18 -0
  128. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/README +47 -0
  129. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/Rakefile +66 -0
  130. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/appveyor.yml +53 -0
  131. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/certs/djberg96_pub.pem +21 -0
  132. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/lib/win32/file/security/constants.rb +149 -0
  133. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/lib/win32/file/security/functions.rb +63 -0
  134. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/lib/win32/file/security/structs.rb +68 -0
  135. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/lib/win32/file/security.rb +963 -0
  136. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/lib/win32-file-security.rb +1 -0
  137. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_acls.rb +34 -0
  138. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_constants.rb +54 -0
  139. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_encryption.rb +90 -0
  140. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_ffi.rb +33 -0
  141. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_ownership.rb +174 -0
  142. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_permissions.rb +88 -0
  143. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_version.rb +14 -0
  144. data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/win32-file-security.gemspec +28 -0
  145. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/CHANGES +169 -0
  146. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/MANIFEST +12 -0
  147. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/README +94 -0
  148. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/Rakefile +28 -0
  149. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/appveyor.yml +48 -0
  150. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/certs/djberg96_pub.pem +21 -0
  151. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/lib/win32/file/stat.rb +1008 -0
  152. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/lib/win32/file/windows/constants.rb +94 -0
  153. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/lib/win32/file/windows/functions.rb +68 -0
  154. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/lib/win32/file/windows/structs.rb +196 -0
  155. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/lib/win32-file-stat.rb +1 -0
  156. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/test/test_file_stat.rb +677 -0
  157. data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/win32-file-stat.gemspec +30 -0
  158. data/vendor/bundle/ruby/2.5.0/specifications/domain_name-0.5.20180417.gemspec +46 -0
  159. data/vendor/bundle/ruby/2.5.0/specifications/ffi-win32-extensions-1.0.3.gemspec +38 -0
  160. data/vendor/bundle/ruby/2.5.0/specifications/win32-file-0.8.1.gemspec +51 -0
  161. data/vendor/bundle/ruby/2.5.0/specifications/win32-file-security-1.0.10.gemspec +47 -0
  162. data/vendor/bundle/ruby/2.5.0/specifications/win32-file-stat-1.5.5.gemspec +48 -0
  163. data/version.txt +1 -1
  164. metadata +114 -2
@@ -0,0 +1 @@
1
+ require_relative 'win32/file/security'
@@ -0,0 +1,34 @@
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?)
19
+ end
20
+
21
+ test "supports_acls? returns the expected results" do
22
+ assert_true(File.supports_acls?)
23
+ assert_true(File.supports_acls?(@dir))
24
+ end
25
+
26
+ test "supports_acls? takes an optional file name" do
27
+ assert_nothing_raised{ File.supports_acls?(@dir) }
28
+ assert_boolean(File.supports_acls?(@dir))
29
+ end
30
+
31
+ def teardown
32
+ @perms = nil
33
+ end
34
+ end
@@ -0,0 +1,54 @@
1
+ ########################################################################
2
+ # test_win32_file_security_constants.rb
3
+ #
4
+ # Tests to ensure that certain constants are defined for the
5
+ # win32-file-security library.
6
+ ########################################################################
7
+ require 'test-unit'
8
+ require 'win32/file/security'
9
+
10
+ class TC_Win32_File_Constants < Test::Unit::TestCase
11
+ test "file security rights constants are defined" do
12
+ assert_not_nil(File::FILE_READ_DATA)
13
+ assert_not_nil(File::FILE_WRITE_DATA)
14
+ assert_not_nil(File::FILE_APPEND_DATA)
15
+ assert_not_nil(File::FILE_READ_EA)
16
+ assert_not_nil(File::FILE_EXECUTE)
17
+ assert_not_nil(File::FILE_DELETE_CHILD)
18
+ assert_not_nil(File::FILE_READ_ATTRIBUTES)
19
+ assert_not_nil(File::FILE_WRITE_ATTRIBUTES)
20
+ end
21
+
22
+ test "standard security rights constants are defined" do
23
+ assert_not_nil(File::STANDARD_RIGHTS_ALL)
24
+ assert_not_nil(File::STANDARD_RIGHTS_REQUIRED)
25
+ assert_not_nil(File::STANDARD_RIGHTS_READ)
26
+ assert_not_nil(File::STANDARD_RIGHTS_WRITE)
27
+ assert_not_nil(File::STANDARD_RIGHTS_EXECUTE)
28
+ end
29
+
30
+ test "generic security rights constants are defined" do
31
+ assert_not_nil(File::GENERIC_READ)
32
+ assert_not_nil(File::GENERIC_WRITE)
33
+ assert_not_nil(File::GENERIC_EXECUTE)
34
+ assert_not_nil(File::GENERIC_ALL)
35
+ end
36
+
37
+ test "combined security rights constants are defined" do
38
+ assert_not_nil(File::FULL)
39
+ assert_not_nil(File::READ)
40
+ assert_not_nil(File::CHANGE)
41
+ assert_not_nil(File::ADD)
42
+ assert_not_nil(File::DELETE)
43
+ end
44
+
45
+ test "miscellaneous security rights constants are defined" do
46
+ assert_not_nil(File::READ_CONTROL)
47
+ assert_not_nil(File::WRITE_DAC)
48
+ assert_not_nil(File::WRITE_OWNER)
49
+ assert_not_nil(File::SYNCHRONIZE)
50
+ assert_not_nil(File::SPECIFIC_RIGHTS_ALL)
51
+ assert_not_nil(File::ACCESS_SYSTEM_SECURITY)
52
+ assert_not_nil(File::MAXIMUM_ALLOWED)
53
+ end
54
+ end
@@ -0,0 +1,90 @@
1
+ #############################################################################
2
+ # test_win32_file_encryption.rb
3
+ #
4
+ # Test case for the encryption related methods of win32-file. You should
5
+ # run this test via the 'rake test' or 'rake test_encryption' task.
6
+ #
7
+ # Note: These tests may fail based on the security setup of your system.
8
+ #############################################################################
9
+ require 'test-unit'
10
+ require 'win32/security'
11
+ require 'win32/file/security'
12
+ require 'socket'
13
+
14
+ class TC_Win32_File_Security_Encryption < Test::Unit::TestCase
15
+ def self.startup
16
+ Dir.chdir(File.dirname(File.expand_path(File.basename(__FILE__))))
17
+ @@file = File.join(Dir.pwd, 'encryption_test.txt')
18
+ File.open(@@file, 'w'){ |fh| fh.puts "This is an encryption test." }
19
+ @@host = Socket.gethostname
20
+ end
21
+
22
+ def setup
23
+ @msg = '=> Ignore. May not work due to security setup of your system.'
24
+ @elevated = Win32::Security.elevated_security?
25
+ @statuses = ['encrypted', 'encryptable', 'unknown']
26
+ end
27
+
28
+ test "encrypt method basic functionality" do
29
+ omit_unless(@elevated)
30
+ assert_respond_to(File, :encrypt)
31
+ assert_nothing_raised(@msg){ File.encrypt(@@file) }
32
+ end
33
+
34
+ test "encrypt requires one argument" do
35
+ omit_unless(@elevated)
36
+ assert_raise(ArgumentError){ File.encrypt }
37
+ assert_raise(ArgumentError){ File.encrypt(@@file, @@file) }
38
+ end
39
+
40
+ test "encrypt requires a string argument" do
41
+ omit_unless(@elevated)
42
+ assert_raise(TypeError, NoMethodError){ File.encrypt(1) }
43
+ end
44
+
45
+ test "decrypt method basic functionality" do
46
+ omit_unless(@elevated)
47
+ assert_respond_to(File, :decrypt)
48
+ assert_nothing_raised(@msg){ File.decrypt(@@file) }
49
+ end
50
+
51
+ test "decrypt accepts a single argument only" do
52
+ omit_unless(@elevated)
53
+ assert_raise(ArgumentError){ File.decrypt }
54
+ end
55
+
56
+ test "decrypt requires a string argument" do
57
+ omit_unless(@elevated)
58
+ assert_raise(TypeError, NoMethodError){ File.decrypt(1) }
59
+ end
60
+
61
+ test "encryptable? basic functionality" do
62
+ assert_respond_to(File, :encryptable?)
63
+ end
64
+
65
+ test "encryptable? returns a boolean value" do
66
+ assert_boolean(File.encryptable?("C:\\"))
67
+ end
68
+
69
+ test "encryption_status basic functionality" do
70
+ assert_respond_to(File, :encryption_status)
71
+ end
72
+
73
+ test "encryption_status returns the expected result" do
74
+ status = File.encryption_status(@@file)
75
+ assert_kind_of(String, status)
76
+ assert_true(@statuses.include?(status))
77
+ end
78
+
79
+ def teardown
80
+ @msg = nil
81
+ @statuses = nil
82
+ @elevated = nil
83
+ end
84
+
85
+ def self.shutdown
86
+ File.delete(@@file) if File.exist?(@@file)
87
+ @@file = nil
88
+ @@host = nil
89
+ end
90
+ end
@@ -0,0 +1,33 @@
1
+ #############################################################################
2
+ # test_win32_file_security_ffi.rb
3
+ #
4
+ # Tests to ensure that the FFI functions are private
5
+ #############################################################################
6
+ require 'test-unit'
7
+ require 'win32/file/security'
8
+
9
+ class TC_Win32_File_Security_FFI < Test::Unit::TestCase
10
+ def setup
11
+ @singleton_methods = File.methods.map{ |m| m.to_s }
12
+ @instance_methods = File.instance_methods.map{ |m| m.to_s }
13
+ end
14
+
15
+ test "internal ffi functions are not public as singleton methods" do
16
+ assert_false(@singleton_methods.include?('AddAce'))
17
+ assert_false(@singleton_methods.include?('CloseHandle'))
18
+ assert_false(@singleton_methods.include?('GetFileSecurityW'))
19
+ assert_false(@singleton_methods.include?('PathIsRootW'))
20
+ end
21
+
22
+ test "internal ffi functions are not public as instance methods" do
23
+ assert_false(@instance_methods.include?('AddAce'))
24
+ assert_false(@instance_methods.include?('CloseHandle'))
25
+ assert_false(@instance_methods.include?('GetFileSecurityW'))
26
+ assert_false(@instance_methods.include?('PathIsRootW'))
27
+ end
28
+
29
+ def teardown
30
+ @singleton_methods = nil
31
+ @instance_methods = nil
32
+ end
33
+ end
@@ -0,0 +1,174 @@
1
+ #############################################################################
2
+ # test_win32_file_ownership.rb
3
+ #
4
+ # Test case for the file ownership related methods
5
+ #############################################################################
6
+ require 'etc'
7
+ require 'socket'
8
+ require 'sys/admin'
9
+ require 'test-unit'
10
+ require 'win32/security'
11
+ require 'win32/file/security'
12
+ require 'pathname'
13
+
14
+ class TC_Win32_File_Security_Ownership < Test::Unit::TestCase
15
+ extend FFI::Library
16
+ ffi_lib :netapi32
17
+ attach_function :NetGetDCName, [:pointer, :pointer, :buffer_out], :int
18
+ attach_function :NetApiBufferFree, [:pointer], :int
19
+
20
+ # Helper method to determine if we're on a domain controller
21
+ def self.in_domain?
22
+ bool = true
23
+ buf = (0.chr * 256).encode('UTF-16LE')
24
+ rv = NetGetDCName(nil, nil, buf)
25
+ bool = false if rv != 0
26
+ NetApiBufferFree(buf) if bool
27
+ bool
28
+ end
29
+
30
+ def self.startup
31
+ Dir.chdir(File.dirname(File.expand_path(File.basename(__FILE__))))
32
+ @@file = File.join(Dir.pwd, 'ownership_test.txt')
33
+
34
+ @@host = Socket.gethostname
35
+ @@temp = "Temp"
36
+ @@login = Etc.getlogin
37
+ @@domain = in_domain?
38
+
39
+ if Win32::Security.elevated_security?
40
+ Sys::Admin.add_user(:name => @@temp, :description => "Delete Me", :password => 'a1b2c3D4ekd92!38d')
41
+ end
42
+ end
43
+
44
+ def setup
45
+ @elevated = Win32::Security.elevated_security?
46
+ File.open(@@file, 'w'){ |fh| fh.puts "This is an ownership test." }
47
+ end
48
+
49
+ test "owned? method basic functionality" do
50
+ assert_respond_to(File, :owned?)
51
+ assert_nothing_raised{ File.owned?(@@file) }
52
+ assert_boolean(File.owned?(@@file))
53
+ end
54
+
55
+ test "owned? method returns expected result" do
56
+ if Win32::Security.elevated_security?
57
+ assert_false(File.owned?(@@file))
58
+ else
59
+ assert_true(File.owned?(@@file))
60
+ end
61
+ assert_false(File.owned?("C:\\Windows\\regedit.exe"))
62
+ end
63
+
64
+ test "owned? requires a single argument" do
65
+ assert_raise(ArgumentError){ File.owned? }
66
+ assert_raise(ArgumentError){ File.owned?(@@file, @@file) }
67
+ end
68
+
69
+ test "owner method basic functionality" do
70
+ assert_respond_to(File, :owner)
71
+ assert_nothing_raised{ File.owner(@@file) }
72
+ assert_kind_of(String, File.owner(@@file))
73
+ end
74
+
75
+ test "owner method returns the expected value" do
76
+ if Win32::Security.elevated_security?
77
+ expected = "BUILTIN\\Administrators"
78
+ else
79
+ expected = @@host + "\\" + @@login
80
+ end
81
+ assert_equal(expected, File.owner(@@file))
82
+ end
83
+
84
+ test "owner method requires a single argument" do
85
+ assert_raise(ArgumentError){ File.owner }
86
+ assert_raise(ArgumentError){ File.owner(@@file, @@file) }
87
+ end
88
+
89
+ test "owner allows a pathname object" do
90
+ assert_nothing_raised{ File.owner(Pathname.new(@@file)) }
91
+ end
92
+
93
+ test "grpowned? method basic functionality" do
94
+ assert_respond_to(File, :grpowned?)
95
+ assert_nothing_raised{ File.grpowned?(@@file) }
96
+ assert_boolean(File.grpowned?(@@file))
97
+ end
98
+
99
+ test "grpowned? method returns expected result" do
100
+ if Win32::Security.elevated_security? && @@domain
101
+ assert_false(File.grpowned?(@@file))
102
+ else
103
+ assert_true(File.grpowned?(@@file))
104
+ end
105
+ assert_false(File.grpowned?("C:\\Windows\\regedit.exe"))
106
+ end
107
+
108
+ test "grpowned? requires a single argument" do
109
+ assert_raise(ArgumentError){ File.grpowned? }
110
+ assert_raise(ArgumentError){ File.grpowned?(@@file, @@file) }
111
+ end
112
+
113
+ test "group method basic functionality" do
114
+ assert_respond_to(File, :group)
115
+ assert_nothing_raised{ File.group(@@file) }
116
+ assert_kind_of(String, File.group(@@file))
117
+ end
118
+
119
+ test "group method returns the expected value" do
120
+ if Win32::Security.elevated_security? && @@domain
121
+ expected = "BUILTIN\\Administrators"
122
+ else
123
+ expected = @@host + "\\None"
124
+ end
125
+ assert_equal(expected.downcase, File.group(@@file).downcase)
126
+ end
127
+
128
+ test "group method allows a pathname object" do
129
+ assert_nothing_raised{ File.group(Pathname.new(@@file)) }
130
+ end
131
+
132
+ test "group method requires a stringy argument" do
133
+ assert_raise(TypeError){ File.group(nil) }
134
+ assert_raise(TypeError){ File.group([]) }
135
+ end
136
+
137
+ test "chown method basic functionality" do
138
+ assert_respond_to(File, :chown)
139
+ end
140
+
141
+ test "chown works as expected" do
142
+ omit_unless(@elevated)
143
+ original_owner = File.owner(@@file).downcase
144
+ expected_owner = (@@host + "\\" + @@temp).downcase
145
+
146
+ assert_nothing_raised{ File.chown(@@temp, nil, @@file) }
147
+ assert_equal(expected_owner, File.owner(@@file).downcase)
148
+ assert_nothing_raised{ File.chown(original_owner, nil, @@file) }
149
+ assert_equal(original_owner, File.owner(@@file).downcase)
150
+ end
151
+
152
+ test "chown returns the number of files processed" do
153
+ omit_unless(@elevated)
154
+ assert_equal(1, File.chown(@@temp, nil, @@file))
155
+ end
156
+
157
+ test "chown requires at least two arguments" do
158
+ assert_raise(ArgumentError){ File.chown }
159
+ assert_raise(ArgumentError){ File.chown(@@temp) }
160
+ end
161
+
162
+ def teardown
163
+ @elevated = nil
164
+ File.delete(@@file) if File.exist?(@@file)
165
+ end
166
+
167
+ def self.shutdown
168
+ Sys::Admin.delete_user(@@temp) if Win32::Security.elevated_security?
169
+ @@file = nil
170
+ @@login = nil
171
+ @@host = nil
172
+ @@domain = nil
173
+ end
174
+ end
@@ -0,0 +1,88 @@
1
+ ##############################################################################
2
+ # test_win32_file_permissions.rb
3
+ #
4
+ # Test case for permission related methods of win32-file-security. You should
5
+ # use the 'rake test' or 'rake test:perms' task to run this.
6
+ ##############################################################################
7
+ require 'test-unit'
8
+ require 'win32/file/security'
9
+ require 'socket'
10
+ require 'etc'
11
+
12
+ class TC_Win32_File_Security_Permissions < Test::Unit::TestCase
13
+ def self.startup
14
+ @@user = Etc.getlogin
15
+ @@host = Socket.gethostname
16
+ @@file = File.join(Dir.pwd, 'security_test.txt')
17
+
18
+ Dir.chdir(File.dirname(File.expand_path(File.basename(__FILE__))))
19
+ File.open(@@file, 'w'){ |fh| fh.puts "This is a security test." }
20
+ end
21
+
22
+ def setup
23
+ @perms = nil
24
+ end
25
+
26
+ test "get_permissions basic functionality" do
27
+ assert_respond_to(File, :get_permissions)
28
+ assert_nothing_raised{ File.get_permissions(@@file) }
29
+ end
30
+
31
+ test "get_permissions returns a hash" do
32
+ assert_kind_of(Hash, File.get_permissions(@@file))
33
+ end
34
+
35
+ test "get_permissions accepts an optional hostname argument" do
36
+ assert_nothing_raised{ File.get_permissions(@@file, @@host) }
37
+ end
38
+
39
+ test "get_permissions requires at least one argument" do
40
+ assert_raise(ArgumentError){ File.get_permissions }
41
+ end
42
+
43
+ test "set_permissions basic functionality" do
44
+ assert_respond_to(File, :set_permissions)
45
+ end
46
+
47
+ test "set_permissions works as expected" do
48
+ assert_nothing_raised{ @perms = File.get_permissions(@@file) }
49
+ assert_nothing_raised{ File.set_permissions(@@file, @perms) }
50
+ assert_equal(@perms, File.get_permissions(@@file))
51
+ end
52
+
53
+ test "set_permissions works if host is specified" do
54
+ @perms = {"#{@@host}\\#{@@user}" => File::GENERIC_ALL}
55
+ assert_nothing_raised{ File.set_permissions(@@file, @perms) }
56
+ assert_equal(@perms.keys.map(&:downcase), File.get_permissions(@@file).keys.map(&:downcase))
57
+ assert_equal(@perms.values, File.get_permissions(@@file).values)
58
+ end
59
+
60
+ test "securities method basic functionality" do
61
+ assert_respond_to(File, :securities)
62
+ end
63
+
64
+ test "securities method works as expected" do
65
+ @perms = File.get_permissions(@@file)
66
+
67
+ @perms.each{ |acct, mask|
68
+ assert_nothing_raised{ File.securities(mask) }
69
+ assert_kind_of(Array, File.securities(mask))
70
+ }
71
+ end
72
+
73
+ test "securities method accepts a single argument only" do
74
+ assert_raise(ArgumentError){ File.securities }
75
+ assert_raise(ArgumentError){ File.securities({}, {}) }
76
+ end
77
+
78
+ def teardown
79
+ @perms = nil
80
+ end
81
+
82
+ def self.shutdown
83
+ File.delete(@@file) if File.exist?(@@file)
84
+ @@file = nil
85
+ @@host = nil
86
+ @@user = nil
87
+ end
88
+ end
@@ -0,0 +1,14 @@
1
+ #############################################################################
2
+ # test_win32_file_security_version.rb
3
+ #
4
+ # Just a test for the version of the library.
5
+ #############################################################################
6
+ require 'test-unit'
7
+ require 'win32/file/security'
8
+
9
+ class TC_Win32_File_Security_Version < Test::Unit::TestCase
10
+ test "version is set to expected value" do
11
+ assert_equal('1.0.10', File::WIN32_FILE_SECURITY_VERSION)
12
+ assert_true(File::WIN32_FILE_SECURITY_VERSION.frozen?)
13
+ end
14
+ end
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'win32-file-security'
5
+ spec.version = '1.0.10'
6
+ spec.authors = ['Daniel J. Berger', 'Park Heesob']
7
+ spec.license = 'Artistic 2.0'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'http://github.com/djberg96/win32-file-security'
10
+ spec.summary = 'File security methods for the File class on MS Windows'
11
+ spec.test_files = Dir['test/test*']
12
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
+ spec.cert_chain = Dir['certs/djberg96_pub.pem']
14
+
15
+ spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
16
+
17
+ spec.add_dependency('ffi')
18
+ spec.add_dependency('ffi-win32-extensions')
19
+ spec.add_development_dependency('test-unit')
20
+ spec.add_development_dependency('win32-security')
21
+ spec.add_development_dependency('sys-admin')
22
+
23
+ spec.description = <<-EOF
24
+ The win32-file-security library adds security related methods to the
25
+ core File class for MS Windows. This includes the ability to get or
26
+ set permissions, as well as encrypt or decrypt files.
27
+ EOF
28
+ end
@@ -0,0 +1,169 @@
1
+ == 1.5.5 - 7-Jun-2016
2
+ * Update to the internal get_current_process_sid method. No longer assumes
3
+ TOKEN_USER when reallocating a buffer.
4
+
5
+ == 1.5.4 - 7-Jun-2016
6
+ * It was possible that an internal FFI function (GetTokenInformation) could
7
+ fail if the buffer size wasn't large enough. That has been fixed. Thanks
8
+ go to ferfebles and Michael Lowell Roberts for the spot.
9
+ * Added an appveyor.yml file.
10
+
11
+ == 1.5.3 - 25-May-2016
12
+ * This gem is now signed.
13
+ * The local helper file has been replaced by ffi-win32-extensions, which
14
+ has been added as a dependency.
15
+
16
+ == 1.5.2 - 9-Jul-2015
17
+ * A working File::Stat#socket? method is now implemented. It is no longer
18
+ just an alias for the File::Stat#pipe? method.
19
+ * Fixed a bug in File::Stat#file? where it could return true for directories and
20
+ reparse points. Thanks go to zinga666 for the spot.
21
+
22
+ == 1.5.1 - 8-Dec-2014
23
+ * Added code to work around 64-bit JRuby bug.
24
+ * Some minor refactoring for the get_current_process_sid method.
25
+
26
+ == 1.5.0 - 10-Nov-2014
27
+ * Added the #streams method, which shows alt streams for the file.
28
+ * Use require_relative where appropriate.
29
+ * Removed reference to rubyforge_project in gemspec.
30
+
31
+ == 1.4.3 - 8-May-2014
32
+ * The #writable? method now ignores the readonly attribute if it's a directory.
33
+ * Replaced File.exists? with File.exist? to avoid warnings in Ruby 2.1.x.
34
+
35
+ == 1.4.2 - 28-Apr-2014
36
+ * Allow the File::Stat.new method to accept objects that respond to to_str
37
+ or to_path to mimic MRI.
38
+
39
+ == 1.4.1 - 12-Feb-2014
40
+ * The #writable? and #writable_real? methods now always return false if the
41
+ file has been marked readonly.
42
+ * Fixed an rdev test and added a writable test.
43
+
44
+ == 1.4.0 - 16-Dec-2013
45
+ * Conversion to FFI.
46
+ * Now requires Ruby 1.9 or later.
47
+ * The #mode method now more closely matches core MRI.
48
+ * The #executable? method now simply checks the extension name. The Windows
49
+ API method I was using before (GetBinaryType) was limited to .exe files and
50
+ could return false positives. The current version checks for .bat, .cmd,
51
+ .com and .exe.
52
+ * The #dev method returns the volume serial number instead of a drive letter.
53
+ * The #symlink? method was implemented.
54
+ * The #uid method was implemented. It now returns an actual user id. It can
55
+ optionally be passed a boolean argument. If true, it will return the full
56
+ string SID.
57
+ * The #owned? method was implemented.
58
+ * The #gid method was implemented. It now returns an actual group id. It can
59
+ optionally be passed a boolean argument. If true, it will return the full
60
+ string SID.
61
+ * The #grpowned? method was implemented.
62
+ * The #ino method was implemented.
63
+ * Added working implementations of the #readable?, #writable?,
64
+ #world_readable? and #world_writable? methods.
65
+ * The VERSION constant was changed to WIN32_FILE_STAT_VERSION.
66
+
67
+ == 1.3.6 - 24-Mar-2012
68
+ * Eliminated some warnings for Ruby 1.9.3.
69
+
70
+ == 1.3.5 - 21-Nov-2011
71
+ * Fixed a bug in the dev method for 1.9.x.
72
+ * Fixed some method redefinition warnings.
73
+ * Refactored the Rakefile and gemspec. The old install task has been
74
+ removed from the Rakefile.
75
+
76
+ == 1.3.4 - 13-Aug-2009
77
+ * Changed license to Artistic 2.0.
78
+ * Some gemspec updates, including the addition of a license, an updated
79
+ description, and changing test-unit from a runtime dependency to a
80
+ development dependency.
81
+ * Some documentation updates, mostly to make certain things invisible that
82
+ aren't meant for public consumption.
83
+ * One test now skipped on 64-bit versions of Windows.
84
+
85
+ == 1.3.3 - 9-Feb-2009
86
+ * Fixed a bug where File::Stat.new failed on locked files. Thanks go to
87
+ Montgomery Kosma for the spot.
88
+ * Now requires windows-pr 1.0.0 or later.
89
+ * Updated the README to note that 32 bit versions of Ruby which attempt
90
+ to access locked system files on 64 bit versions of MS Windows will fail.
91
+
92
+ == 1.3.2 - 1-Oct-2008
93
+ * Fixed an issue with the private get_blksize method.
94
+ * Updated the test suite to use Test::Unit 2.x, which also makes it a
95
+ required dependency.
96
+ * Removed the pre-generated .txt and .exe files that were used for testing.
97
+ These are now generated within the test suite itself.
98
+ * Fixed two broken size tests, and now omits one blockdev test if there's no
99
+ media in the drive.
100
+
101
+ == 1.3.1 - 9-Aug-2008
102
+ * Fixed the stat buf to be the proper size (I had too many struct members).
103
+ * Modified the tests slightly.
104
+
105
+ == 1.3.0 - 1-Aug-2008
106
+ * Fixed a couple of function calls where I had forgotten to call an
107
+ explicitly wide version.
108
+ * No longer ignores failures on empty block devices, e.g. CD-ROM drives
109
+ without any media in them. A SystemCallError is raised instead.
110
+ * Added blockdev boolean to the inspect/pp output.
111
+ * Fixed a potential issue with an internal helper function and the new 'S'
112
+ prototype from win32-api 1.2.0 or later.
113
+
114
+ == 1.2.8 - 29-Jul-2008
115
+ * Internally now always uses wide character functions.
116
+ * A private alias was made private.
117
+ * Now requires windows-pr 0.9.1 or later.
118
+
119
+ == 1.2.7 - 1-Oct-2007
120
+ * Changed an error type in a private method in order to maintain
121
+ compatibility with the FileUtils module.
122
+
123
+ == 1.2.6 - 29-Sep-2007
124
+ * Minor tweak to the way I handle redefining the initialize method. The
125
+ old_init alias is now removed.
126
+ * Now handles a potential failure in getting the atime, ctime and mtime,
127
+ caused by the underlying filesystem, e.g. Samba. If it fails, these
128
+ fields are set to the epoch. Thanks go an anonymous user for the spot.
129
+ * Added a Rakefile that includes tasks for installation and testing.
130
+ * Removed the install.rb file. That has been inlined into the Rakefile.
131
+
132
+ == 1.2.5 - 5-Apr-2007
133
+ * Now runs -w clean.
134
+
135
+ == 1.2.4 - 22-Jan-2007
136
+ * Improved block device handling.
137
+
138
+ == 1.2.3 - 4-Nov-2006
139
+ * Bug fix for file sizes over 4gb.
140
+
141
+ == 1.2.2 - 13-May-2006
142
+ * Yet another blksize bug fix.
143
+ * Minor tweak to the pretty_print method with regards to handling nil values.
144
+ * Bumped the minimum required windows-pr version to 0.4.0 in the gemspec.
145
+
146
+ == 1.2.1 - 12-May-2006
147
+ * Fixed a bug with regards to the block count where the constructor would die
148
+ with a FloatDomainError if the blksize returned 0 or nil. It now defaults
149
+ to nil in that event.
150
+
151
+ == 1.2.0 - 23-Apr-2006
152
+ * Removed the attribute setters. From now on this class provides readonly
153
+ methods. Use the win32-file library for attribute setters.
154
+ * Added the content_indexed? alias for the indexed? method.
155
+ * Corresponding test suite changes.
156
+ * Fixed the pp issue by writing a custom pretty_print method.
157
+
158
+ == 1.1.0 - 15-Apr-2006
159
+ * Added the chardev?, dev_major, dev_minor directory?, file?, executable?,
160
+ executable_real?, ftype, grpowned?, owned?, pipe?, readable?, readable_real?,
161
+ rdev_major, rdev_minor, setgid?, setuid?, size?, socket?, sticky?, symlink?,
162
+ writable?, writable_real? and zero? methods. Note that not all of these
163
+ methods return meaningful values and were merely added to match the current
164
+ spec. See documentation for details.
165
+ * Added a VERSION constant.
166
+ * Some optimization in the constructor.
167
+
168
+ == 1.0.0 - 13-Apr-2006
169
+ * Initial release