chef 12.5.0.alpha.1 → 12.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +21 -25
- data/Gemfile +46 -0
- data/README.md +4 -4
- data/Rakefile +5 -110
- data/distro/common/html/knife_cookbook_site.html +18 -18
- data/distro/common/man/man1/knife-cookbook-site.1 +11 -11
- data/lib/chef/application.rb +1 -1
- data/lib/chef/application/apply.rb +19 -1
- data/lib/chef/application/client.rb +11 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/windows_service_manager.rb +9 -7
- data/lib/chef/chef_class.rb +39 -0
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +3 -1
- data/lib/chef/chef_fs/file_system/acl_dir.rb +3 -4
- data/lib/chef/chef_fs/file_system/acls_dir.rb +5 -1
- data/lib/chef/chef_fs/file_system/base_fs_dir.rb +0 -5
- data/lib/chef/chef_fs/file_system/base_fs_object.rb +5 -2
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +10 -17
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -12
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +15 -11
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +8 -2
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +3 -4
- data/lib/chef/chef_fs/file_system/cookbooks_acl_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -11
- data/lib/chef/chef_fs/file_system/data_bags_dir.rb +3 -5
- data/lib/chef/chef_fs/file_system/environments_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +7 -4
- data/lib/chef/chef_fs/file_system/memory_dir.rb +2 -3
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +15 -0
- data/lib/chef/chef_fs/file_system/nodes_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/organization_members_entry.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +4 -9
- data/lib/chef/client.rb +2 -3
- data/lib/chef/config.rb +34 -2
- data/lib/chef/cookbook/metadata.rb +25 -3
- data/lib/chef/cookbook/synchronizer.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/deprecation/mixin/template.rb +1 -2
- data/lib/chef/deprecation/provider/cookbook_file.rb +1 -1
- data/lib/chef/deprecation/provider/file.rb +1 -1
- data/lib/chef/deprecation/provider/remote_directory.rb +52 -0
- data/lib/chef/deprecation/provider/remote_file.rb +1 -2
- data/lib/chef/deprecation/provider/template.rb +1 -1
- data/lib/chef/deprecation/warnings.rb +3 -4
- data/lib/chef/dsl/reboot_pending.rb +3 -2
- data/lib/chef/dsl/recipe.rb +6 -5
- data/lib/chef/dsl/resources.rb +2 -2
- data/lib/chef/event_dispatch/base.rb +12 -7
- data/lib/chef/event_dispatch/dispatcher.rb +21 -6
- data/lib/chef/exceptions.rb +22 -0
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/base.rb +3 -0
- data/lib/chef/formatters/doc.rb +53 -5
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +36 -0
- data/lib/chef/formatters/minimal.rb +2 -2
- data/lib/chef/knife.rb +35 -55
- data/lib/chef/knife/bootstrap.rb +41 -0
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -0
- data/lib/chef/knife/bootstrap/client_builder.rb +16 -0
- data/lib/chef/knife/bootstrap/templates/README.md +3 -4
- data/lib/chef/knife/cookbook_create.rb +1 -1
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +6 -6
- data/lib/chef/knife/cookbook_site_unshare.rb +2 -2
- data/lib/chef/knife/core/bootstrap_context.rb +12 -4
- data/lib/chef/knife/core/custom_manifest_loader.rb +69 -0
- data/lib/chef/knife/core/gem_glob_loader.rb +138 -0
- data/lib/chef/knife/core/hashed_command_loader.rb +80 -0
- data/lib/chef/knife/core/node_presenter.rb +24 -1
- data/lib/chef/knife/core/object_loader.rb +1 -0
- data/lib/chef/knife/core/subcommand_loader.rb +131 -146
- data/lib/chef/knife/node_run_list_remove.rb +12 -1
- data/lib/chef/knife/null.rb +10 -0
- data/lib/chef/knife/rehash.rb +62 -0
- data/lib/chef/knife/search.rb +3 -3
- data/lib/chef/knife/ssh.rb +52 -30
- data/lib/chef/local_mode.rb +5 -0
- data/lib/chef/log.rb +5 -1
- data/lib/chef/mixin/deprecation.rb +8 -8
- data/lib/chef/mixin/params_validate.rb +2 -2
- data/lib/chef/mixin/template.rb +48 -0
- data/lib/chef/mixin/which.rb +1 -1
- data/lib/chef/mixin/wide_string.rb +72 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +15 -39
- data/lib/chef/mixin/windows_env_helper.rb +4 -1
- data/lib/chef/monkey_patches/webrick-utils.rb +51 -0
- data/lib/chef/monkey_patches/win32/registry.rb +72 -0
- data/lib/chef/node.rb +97 -3
- data/lib/chef/node_map.rb +2 -2
- data/lib/chef/platform/provider_mapping.rb +5 -6
- data/lib/chef/platform/query_helpers.rb +46 -4
- data/lib/chef/platform/service_helpers.rb +30 -32
- data/lib/chef/policy_builder.rb +1 -8
- data/lib/chef/policy_builder/dynamic.rb +186 -0
- data/lib/chef/policy_builder/expand_node_object.rb +30 -15
- data/lib/chef/policy_builder/policyfile.rb +155 -18
- data/lib/chef/property.rb +38 -9
- data/lib/chef/provider.rb +104 -12
- data/lib/chef/provider/batch.rb +8 -0
- data/lib/chef/provider/deploy.rb +2 -2
- data/lib/chef/provider/directory.rb +14 -2
- data/lib/chef/provider/dsc_resource.rb +5 -9
- data/lib/chef/provider/group/pw.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +2 -2
- data/lib/chef/provider/mount.rb +7 -3
- data/lib/chef/provider/package/dpkg.rb +5 -11
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/yum.rb +17 -5
- data/lib/chef/provider/powershell_script.rb +27 -4
- data/lib/chef/provider/remote_directory.rb +190 -102
- data/lib/chef/provider/service.rb +12 -2
- data/lib/chef/provider/service/aix.rb +1 -1
- data/lib/chef/provider/service/debian.rb +3 -5
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +3 -3
- data/lib/chef/provider/service/init.rb +3 -3
- data/lib/chef/provider/service/insserv.rb +2 -4
- data/lib/chef/provider/service/invokercd.rb +2 -4
- data/lib/chef/provider/service/openbsd.rb +2 -1
- data/lib/chef/provider/service/redhat.rb +52 -16
- data/lib/chef/provider/service/simple.rb +2 -2
- data/lib/chef/provider/service/systemd.rb +3 -5
- data/lib/chef/provider/service/upstart.rb +4 -6
- data/lib/chef/provider/subversion.rb +13 -7
- data/lib/chef/provider/template/content.rb +16 -6
- data/lib/chef/provider/user/solaris.rb +32 -4
- data/lib/chef/provider/windows_script.rb +3 -5
- data/lib/chef/provider_resolver.rb +2 -2
- data/lib/chef/resource.rb +85 -27
- data/lib/chef/resource/action_class.rb +83 -0
- data/lib/chef/resource/chef_gem.rb +3 -3
- data/lib/chef/resource/deploy.rb +8 -2
- data/lib/chef/resource/dsc_script.rb +2 -0
- data/lib/chef/resource/file/verification.rb +1 -1
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/service.rb +10 -2
- data/lib/chef/resource/subversion.rb +5 -0
- data/lib/chef/resource/windows_script.rb +6 -2
- data/lib/chef/resource/yum_package.rb +10 -1
- data/lib/chef/resource_resolver.rb +3 -3
- data/lib/chef/run_context.rb +6 -8
- data/lib/chef/run_list/versioned_recipe_list.rb +15 -0
- data/lib/chef/run_lock.rb +30 -21
- data/lib/chef/util/powershell/ps_credential.rb +4 -0
- data/lib/chef/util/windows.rb +0 -32
- data/lib/chef/util/windows/net_group.rb +85 -106
- data/lib/chef/util/windows/net_use.rb +35 -71
- data/lib/chef/util/windows/net_user.rb +0 -1
- data/lib/chef/util/windows/volume.rb +19 -19
- data/lib/chef/version.rb +3 -3
- data/lib/chef/win32/api.rb +1 -0
- data/lib/chef/win32/api/file.rb +20 -0
- data/lib/chef/win32/api/net.rb +163 -43
- data/lib/chef/win32/api/registry.rb +51 -0
- data/lib/chef/win32/api/system.rb +23 -0
- data/lib/chef/win32/api/unicode.rb +0 -43
- data/lib/chef/win32/crypto.rb +2 -1
- data/lib/chef/win32/file.rb +28 -3
- data/lib/chef/win32/mutex.rb +1 -2
- data/lib/chef/win32/net.rb +162 -8
- data/lib/chef/win32/process.rb +13 -0
- data/lib/chef/win32/registry.rb +25 -28
- data/lib/chef/win32/security.rb +1 -1
- data/lib/chef/win32/security/token.rb +1 -1
- data/lib/chef/win32/system.rb +62 -0
- data/lib/chef/win32/unicode.rb +7 -2
- data/lib/chef/win32/version.rb +0 -4
- data/spec/data/cookbooks/openldap/templates/default/helpers.erb +14 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_openldap_partials.erb +1 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_partial.erb +1 -0
- data/spec/data/dsc_lcm.pfx +0 -0
- data/spec/functional/dsl/reboot_pending_spec.rb +33 -43
- data/spec/functional/knife/cookbook_delete_spec.rb +17 -7
- data/spec/functional/knife/ssh_spec.rb +16 -0
- data/spec/functional/resource/deploy_revision_spec.rb +1 -1
- data/spec/functional/resource/dsc_resource_spec.rb +2 -0
- data/spec/functional/resource/dsc_script_spec.rb +91 -2
- data/spec/functional/resource/group_spec.rb +67 -44
- data/spec/functional/resource/powershell_script_spec.rb +104 -15
- data/spec/functional/resource/windows_service_spec.rb +1 -1
- data/spec/functional/run_lock_spec.rb +368 -189
- data/spec/functional/win32/{registry_helper_spec.rb → registry_spec.rb} +4 -23
- data/spec/integration/client/client_spec.rb +51 -0
- data/spec/integration/knife/download_spec.rb +4 -0
- data/spec/integration/knife/list_spec.rb +8 -0
- data/spec/integration/knife/upload_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
- data/spec/integration/recipes/remote_directory.rb +74 -0
- data/spec/integration/recipes/resource_action_spec.rb +42 -22
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +423 -0
- data/spec/integration/recipes/resource_load_spec.rb +206 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/platform_helpers.rb +13 -0
- data/{lib/chef/mixin/wstring.rb → spec/support/shared/context/win32.rb} +15 -12
- data/spec/support/shared/functional/windows_script.rb +63 -26
- data/spec/support/shared/unit/mock_shellout.rb +46 -0
- data/spec/support/shared/unit/provider/file.rb +10 -4
- data/spec/unit/application/client_spec.rb +16 -3
- data/spec/unit/application/knife_spec.rb +2 -2
- data/spec/unit/chef_class_spec.rb +0 -4
- data/spec/unit/client_spec.rb +6 -1
- data/spec/unit/config_spec.rb +31 -0
- data/spec/unit/cookbook/metadata_spec.rb +23 -3
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/deprecation_spec.rb +3 -6
- data/spec/unit/dsl/reboot_pending_spec.rb +12 -6
- data/spec/unit/event_dispatch/dispatcher_spec.rb +65 -3
- data/spec/unit/event_dispatch/dsl_spec.rb +0 -4
- data/spec/unit/formatters/doc_spec.rb +32 -0
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +26 -0
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +27 -0
- data/spec/unit/knife/bootstrap_spec.rb +55 -3
- data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
- data/spec/unit/knife/core/bootstrap_context_spec.rb +21 -4
- data/spec/unit/knife/core/custom_manifest_loader_spec.rb +41 -0
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +210 -0
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +93 -0
- data/spec/unit/knife/core/subcommand_loader_spec.rb +16 -192
- data/spec/unit/knife/node_run_list_remove_spec.rb +17 -0
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +10 -10
- data/spec/unit/mixin/template_spec.rb +5 -1
- data/spec/unit/mixin/windows_architecture_helper_spec.rb +13 -8
- data/spec/unit/node_spec.rb +213 -0
- data/spec/unit/platform/query_helpers_spec.rb +146 -3
- data/spec/unit/policy_builder/dynamic_spec.rb +275 -0
- data/spec/unit/policy_builder/expand_node_object_spec.rb +37 -38
- data/spec/unit/policy_builder/policyfile_spec.rb +260 -46
- data/spec/unit/property/validation_spec.rb +5 -0
- data/spec/unit/property_spec.rb +152 -26
- data/spec/unit/provider/deploy_spec.rb +5 -5
- data/spec/unit/provider/directory_spec.rb +35 -0
- data/spec/unit/provider/dsc_resource_spec.rb +3 -10
- data/spec/unit/provider/ifconfig_spec.rb +22 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -1
- data/spec/unit/provider/mount/mount_spec.rb +6 -0
- data/spec/unit/provider/mount/windows_spec.rb +14 -0
- data/spec/unit/provider/mount_spec.rb +12 -1
- data/spec/unit/provider/package/dpkg_spec.rb +8 -1
- data/spec/unit/provider/package/rpm_spec.rb +18 -1
- data/spec/unit/provider/package/rubygems_spec.rb +18 -0
- data/spec/unit/provider/package/yum_spec.rb +97 -24
- data/spec/unit/provider/powershell_script_spec.rb +52 -26
- data/spec/unit/provider/remote_directory_spec.rb +1 -2
- data/spec/unit/provider/service/aix_service_spec.rb +3 -3
- data/spec/unit/provider/service/gentoo_service_spec.rb +4 -4
- data/spec/unit/provider/service/openbsd_service_spec.rb +10 -8
- data/spec/unit/provider/service/redhat_spec.rb +88 -8
- data/spec/unit/provider/service/upstart_service_spec.rb +11 -7
- data/spec/unit/provider/service/windows_spec.rb +211 -200
- data/spec/unit/provider/subversion_spec.rb +50 -31
- data/spec/unit/provider/template/content_spec.rb +93 -2
- data/spec/unit/provider/user/solaris_spec.rb +66 -9
- data/spec/unit/provider_resolver_spec.rb +707 -650
- data/spec/unit/resource/deploy_spec.rb +7 -1
- data/spec/unit/resource/dsc_script_spec.rb +4 -0
- data/spec/unit/resource/file/verification_spec.rb +1 -1
- data/spec/unit/resource/powershell_script_spec.rb +17 -13
- data/spec/unit/resource/service_spec.rb +4 -4
- data/spec/unit/resource/subversion_spec.rb +4 -0
- data/spec/unit/resource/yum_package_spec.rb +10 -1
- data/spec/unit/run_list/versioned_recipe_list_spec.rb +5 -0
- data/spec/unit/win32/registry_spec.rb +394 -0
- data/tasks/external_tests.rb +47 -23
- data/tasks/maintainers.rb +155 -14
- metadata +51 -26
- data/lib/chef/knife/bootstrap/templates/archlinux-gems.erb +0 -76
- data/lib/chef/knife/bootstrap/templates/chef-aix.erb +0 -72
- data/spec/unit/registry_helper_spec.rb +0 -390
@@ -21,61 +21,18 @@
|
|
21
21
|
#see also cmd.exe: net use /?
|
22
22
|
|
23
23
|
require 'chef/util/windows'
|
24
|
+
require 'chef/win32/net'
|
24
25
|
|
25
26
|
class Chef::Util::Windows::NetUse < Chef::Util::Windows
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
USE_NOFORCE = 0
|
30
|
-
USE_FORCE = 1
|
31
|
-
USE_LOTS_OF_FORCE = 2 #every windows API should support this flag
|
32
|
-
|
33
|
-
USE_INFO_2 = [
|
34
|
-
[:local, nil],
|
35
|
-
[:remote, nil],
|
36
|
-
[:password, nil],
|
37
|
-
[:status, 0],
|
38
|
-
[:asg_type, 0],
|
39
|
-
[:refcount, 0],
|
40
|
-
[:usecount, 0],
|
41
|
-
[:username, nil],
|
42
|
-
[:domainname, nil]
|
43
|
-
]
|
44
|
-
|
45
|
-
USE_INFO_2_TEMPLATE =
|
46
|
-
USE_INFO_2.collect { |field| field[1].class == Fixnum ? 'i' : 'L' }.join
|
47
|
-
|
48
|
-
SIZEOF_USE_INFO_2 = #sizeof(USE_INFO_2)
|
49
|
-
USE_INFO_2.inject(0) do |sum, item|
|
50
|
-
sum + (item[1].class == Fixnum ? 4 : PTR_SIZE)
|
51
|
-
end
|
52
|
-
|
53
|
-
def use_info_2(args)
|
54
|
-
USE_INFO_2.collect { |field|
|
55
|
-
args.include?(field[0]) ? args[field[0]] : field[1]
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
def use_info_2_pack(use)
|
60
|
-
use.collect { |v|
|
61
|
-
v.class == Fixnum ? v : str_to_ptr(multi_to_wide(v))
|
62
|
-
}.pack(USE_INFO_2_TEMPLATE)
|
27
|
+
def initialize(localname)
|
28
|
+
@use_name = localname
|
63
29
|
end
|
64
30
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
dword_to_i(buffer, offset) : lpwstr_to_s(buffer, offset)
|
31
|
+
def to_ui2_struct(use_info)
|
32
|
+
use_info.inject({}) do |memo, (k,v)|
|
33
|
+
memo["ui2_#{k}".to_sym] = v
|
34
|
+
memo
|
70
35
|
end
|
71
|
-
use
|
72
|
-
end
|
73
|
-
|
74
|
-
public
|
75
|
-
|
76
|
-
def initialize(localname)
|
77
|
-
@localname = localname
|
78
|
-
@name = multi_to_wide(localname)
|
79
36
|
end
|
80
37
|
|
81
38
|
def add(args)
|
@@ -84,38 +41,45 @@ class Chef::Util::Windows::NetUse < Chef::Util::Windows
|
|
84
41
|
args = Hash.new
|
85
42
|
args[:remote] = remote
|
86
43
|
end
|
87
|
-
args[:local] ||=
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
44
|
+
args[:local] ||= use_name
|
45
|
+
ui2_hash = to_ui2_struct(args)
|
46
|
+
|
47
|
+
begin
|
48
|
+
Chef::ReservedNames::Win32::Net.net_use_add_l2(nil, ui2_hash)
|
49
|
+
rescue Chef::Exceptions::Win32APIError => e
|
50
|
+
raise ArgumentError, e
|
93
51
|
end
|
94
52
|
end
|
95
53
|
|
96
|
-
def
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
if rc != NERR_Success
|
101
|
-
raise ArgumentError, get_last_error(rc)
|
54
|
+
def from_use_info_struct(ui2_hash)
|
55
|
+
ui2_hash.inject({}) do |memo, (k,v)|
|
56
|
+
memo[k.to_s.sub('ui2_', '').to_sym] = v
|
57
|
+
memo
|
102
58
|
end
|
59
|
+
end
|
103
60
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
61
|
+
def get_info
|
62
|
+
begin
|
63
|
+
ui2 = Chef::ReservedNames::Win32::Net.net_use_get_info_l2(nil, use_name)
|
64
|
+
from_use_info_struct(ui2)
|
65
|
+
rescue Chef::Exceptions::Win32APIError => e
|
66
|
+
raise ArgumentError, e
|
67
|
+
end
|
109
68
|
end
|
110
69
|
|
111
70
|
def device
|
112
71
|
get_info()[:remote]
|
113
72
|
end
|
114
|
-
|
73
|
+
|
115
74
|
def delete
|
116
|
-
|
117
|
-
|
118
|
-
|
75
|
+
begin
|
76
|
+
Chef::ReservedNames::Win32::Net.net_use_del(nil, use_name, :use_noforce)
|
77
|
+
rescue Chef::Exceptions::Win32APIError => e
|
78
|
+
raise ArgumentError, e
|
119
79
|
end
|
120
80
|
end
|
81
|
+
|
82
|
+
def use_name
|
83
|
+
@use_name
|
84
|
+
end
|
121
85
|
end
|
@@ -18,42 +18,42 @@
|
|
18
18
|
|
19
19
|
#simple wrapper around Volume APIs. might be possible with WMI, but possibly more complex.
|
20
20
|
|
21
|
+
require 'chef/win32/api/file'
|
21
22
|
require 'chef/util/windows'
|
22
|
-
require 'windows/volume'
|
23
23
|
|
24
24
|
class Chef::Util::Windows::Volume < Chef::Util::Windows
|
25
|
-
|
26
|
-
private
|
27
|
-
include Windows::Volume
|
28
|
-
#XXX not defined in the current windows-pr release
|
29
|
-
DeleteVolumeMountPoint =
|
30
|
-
Windows::API.new('DeleteVolumeMountPoint', 'S', 'B') unless defined? DeleteVolumeMountPoint
|
31
|
-
|
32
|
-
public
|
25
|
+
attr_reader :mount_point
|
33
26
|
|
34
27
|
def initialize(name)
|
35
28
|
name += "\\" unless name =~ /\\$/ #trailing slash required
|
36
|
-
@
|
29
|
+
@mount_point = name
|
37
30
|
end
|
38
31
|
|
39
32
|
def device
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
raise ArgumentError, get_last_error
|
33
|
+
begin
|
34
|
+
Chef::ReservedNames::Win32::File.get_volume_name_for_volume_mount_point(mount_point)
|
35
|
+
rescue Chef::Exceptions::Win32APIError => e
|
36
|
+
raise ArgumentError, e
|
45
37
|
end
|
46
38
|
end
|
47
39
|
|
48
40
|
def delete
|
49
|
-
|
50
|
-
|
41
|
+
begin
|
42
|
+
Chef::ReservedNames::Win32::File.delete_volume_mount_point(mount_point)
|
43
|
+
rescue Chef::Exceptions::Win32APIError => e
|
44
|
+
raise ArgumentError, e
|
51
45
|
end
|
52
46
|
end
|
53
47
|
|
54
48
|
def add(args)
|
55
|
-
|
56
|
-
|
49
|
+
begin
|
50
|
+
Chef::ReservedNames::Win32::File.set_volume_mount_point(mount_point, args[:remote])
|
51
|
+
rescue Chef::Exceptions::Win32APIError => e
|
52
|
+
raise ArgumentError, e
|
57
53
|
end
|
58
54
|
end
|
55
|
+
|
56
|
+
def mount_point
|
57
|
+
@mount_point
|
58
|
+
end
|
59
59
|
end
|
data/lib/chef/version.rb
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
|
22
22
|
class Chef
|
23
23
|
CHEF_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
|
24
|
-
VERSION = '12.5.
|
24
|
+
VERSION = '12.5.1'
|
25
25
|
end
|
26
26
|
|
27
27
|
#
|
@@ -29,6 +29,6 @@ end
|
|
29
29
|
#
|
30
30
|
# NOTE: DO NOT Use the Chef::Version class on Chef::VERSIONs. The
|
31
31
|
# Chef::Version class is for _cookbooks_ only, and cannot handle
|
32
|
-
# pre-release
|
33
|
-
#
|
32
|
+
# pre-release versions like "10.14.0.rc.2". Please use Rubygem's
|
33
|
+
# Gem::Version class instead.
|
34
34
|
#
|
data/lib/chef/win32/api.rb
CHANGED
@@ -188,6 +188,7 @@ class Chef
|
|
188
188
|
host.typedef :pointer, :PCRYPTPROTECT_PROMPTSTRUCT # Pointer to a CRYPTOPROTECT_PROMPTSTRUCT.
|
189
189
|
host.typedef :pointer, :PDATA_BLOB # Pointer to a DATA_BLOB.
|
190
190
|
host.typedef :pointer, :PTSTR # A PWSTR if UNICODE is defined, a PSTR otherwise.
|
191
|
+
host.typedef :pointer, :PSID
|
191
192
|
host.typedef :pointer, :PUCHAR # Pointer to a UCHAR.
|
192
193
|
host.typedef :pointer, :PUHALF_PTR # Pointer to a UHALF_PTR.
|
193
194
|
host.typedef :pointer, :PUINT # Pointer to a UINT.
|
data/lib/chef/win32/api/file.rb
CHANGED
@@ -20,6 +20,7 @@
|
|
20
20
|
require 'chef/win32/api'
|
21
21
|
require 'chef/win32/api/security'
|
22
22
|
require 'chef/win32/api/system'
|
23
|
+
require 'chef/win32/unicode'
|
23
24
|
|
24
25
|
class Chef
|
25
26
|
module ReservedNames::Win32
|
@@ -450,6 +451,25 @@ BOOL WINAPI DeviceIoControl(
|
|
450
451
|
=end
|
451
452
|
safe_attach_function :DeviceIoControl, [:HANDLE, :DWORD, :LPVOID, :DWORD, :LPVOID, :DWORD, :LPDWORD, :pointer], :BOOL
|
452
453
|
|
454
|
+
|
455
|
+
#BOOL WINAPI DeleteVolumeMountPoint(
|
456
|
+
#_In_ LPCTSTR lpszVolumeMountPoint
|
457
|
+
#);
|
458
|
+
safe_attach_function :DeleteVolumeMountPointW, [:LPCTSTR], :BOOL
|
459
|
+
|
460
|
+
#BOOL WINAPI SetVolumeMountPoint(
|
461
|
+
#_In_ LPCTSTR lpszVolumeMountPoint,
|
462
|
+
#_In_ LPCTSTR lpszVolumeName
|
463
|
+
#);
|
464
|
+
safe_attach_function :SetVolumeMountPointW, [:LPCTSTR, :LPCTSTR], :BOOL
|
465
|
+
|
466
|
+
#BOOL WINAPI GetVolumeNameForVolumeMountPoint(
|
467
|
+
#_In_ LPCTSTR lpszVolumeMountPoint,
|
468
|
+
#_Out_ LPTSTR lpszVolumeName,
|
469
|
+
#_In_ DWORD cchBufferLength
|
470
|
+
#);
|
471
|
+
safe_attach_function :GetVolumeNameForVolumeMountPointW, [:LPCTSTR, :LPTSTR, :DWORD], :BOOL
|
472
|
+
|
453
473
|
###############################################
|
454
474
|
# Helpers
|
455
475
|
###############################################
|
data/lib/chef/win32/api/net.rb
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'chef/win32/api'
|
20
|
+
require 'chef/win32/unicode'
|
20
21
|
|
21
22
|
class Chef
|
22
23
|
module ReservedNames::Win32
|
@@ -40,6 +41,10 @@ class Chef
|
|
40
41
|
UF_NORMAL_ACCOUNT = 0x000200
|
41
42
|
UF_DONT_EXPIRE_PASSWD = 0x010000
|
42
43
|
|
44
|
+
USE_NOFORCE = 0
|
45
|
+
USE_FORCE = 1
|
46
|
+
USE_LOTS_OF_FORCE = 2 #every windows API should support this flag
|
47
|
+
|
43
48
|
NERR_Success = 0
|
44
49
|
NERR_InvalidComputer = 2351
|
45
50
|
NERR_NotPrimary = 2226
|
@@ -49,41 +54,13 @@ class Chef
|
|
49
54
|
NERR_BadPassword = 2203
|
50
55
|
NERR_PasswordTooShort = 2245
|
51
56
|
NERR_UserNotFound = 2221
|
57
|
+
NERR_GroupNotFound = 2220
|
52
58
|
ERROR_ACCESS_DENIED = 5
|
59
|
+
ERROR_MORE_DATA = 234
|
53
60
|
|
54
61
|
ffi_lib "netapi32"
|
55
62
|
|
56
|
-
|
57
|
-
layout :usri3_name, :LPWSTR,
|
58
|
-
:usri3_password, :LPWSTR,
|
59
|
-
:usri3_password_age, :DWORD,
|
60
|
-
:usri3_priv, :DWORD,
|
61
|
-
:usri3_home_dir, :LPWSTR,
|
62
|
-
:usri3_comment, :LPWSTR,
|
63
|
-
:usri3_flags, :DWORD,
|
64
|
-
:usri3_script_path, :LPWSTR,
|
65
|
-
:usri3_auth_flags, :DWORD,
|
66
|
-
:usri3_full_name, :LPWSTR,
|
67
|
-
:usri3_usr_comment, :LPWSTR,
|
68
|
-
:usri3_parms, :LPWSTR,
|
69
|
-
:usri3_workstations, :LPWSTR,
|
70
|
-
:usri3_last_logon, :DWORD,
|
71
|
-
:usri3_last_logoff, :DWORD,
|
72
|
-
:usri3_acct_expires, :DWORD,
|
73
|
-
:usri3_max_storage, :DWORD,
|
74
|
-
:usri3_units_per_week, :DWORD,
|
75
|
-
:usri3_logon_hours, :PBYTE,
|
76
|
-
:usri3_bad_pw_count, :DWORD,
|
77
|
-
:usri3_num_logons, :DWORD,
|
78
|
-
:usri3_logon_server, :LPWSTR,
|
79
|
-
:usri3_country_code, :DWORD,
|
80
|
-
:usri3_code_page, :DWORD,
|
81
|
-
:usri3_user_id, :DWORD,
|
82
|
-
:usri3_primary_group_id, :DWORD,
|
83
|
-
:usri3_profile, :LPWSTR,
|
84
|
-
:usri3_home_dir_drive, :LPWSTR,
|
85
|
-
:usri3_password_expired, :DWORD
|
86
|
-
|
63
|
+
module StructHelpers
|
87
64
|
def set(key, val)
|
88
65
|
val = if val.is_a? String
|
89
66
|
encoded = if val.encoding == Encoding::UTF_16LE
|
@@ -115,6 +92,47 @@ class Chef
|
|
115
92
|
end
|
116
93
|
end
|
117
94
|
|
95
|
+
def as_ruby
|
96
|
+
members.inject({}) do |memo, key|
|
97
|
+
memo[key] = get(key)
|
98
|
+
memo
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
class USER_INFO_3 < FFI::Struct
|
105
|
+
include StructHelpers
|
106
|
+
layout :usri3_name, :LPWSTR,
|
107
|
+
:usri3_password, :LPWSTR,
|
108
|
+
:usri3_password_age, :DWORD,
|
109
|
+
:usri3_priv, :DWORD,
|
110
|
+
:usri3_home_dir, :LPWSTR,
|
111
|
+
:usri3_comment, :LPWSTR,
|
112
|
+
:usri3_flags, :DWORD,
|
113
|
+
:usri3_script_path, :LPWSTR,
|
114
|
+
:usri3_auth_flags, :DWORD,
|
115
|
+
:usri3_full_name, :LPWSTR,
|
116
|
+
:usri3_usr_comment, :LPWSTR,
|
117
|
+
:usri3_parms, :LPWSTR,
|
118
|
+
:usri3_workstations, :LPWSTR,
|
119
|
+
:usri3_last_logon, :DWORD,
|
120
|
+
:usri3_last_logoff, :DWORD,
|
121
|
+
:usri3_acct_expires, :DWORD,
|
122
|
+
:usri3_max_storage, :DWORD,
|
123
|
+
:usri3_units_per_week, :DWORD,
|
124
|
+
:usri3_logon_hours, :PBYTE,
|
125
|
+
:usri3_bad_pw_count, :DWORD,
|
126
|
+
:usri3_num_logons, :DWORD,
|
127
|
+
:usri3_logon_server, :LPWSTR,
|
128
|
+
:usri3_country_code, :DWORD,
|
129
|
+
:usri3_code_page, :DWORD,
|
130
|
+
:usri3_user_id, :DWORD,
|
131
|
+
:usri3_primary_group_id, :DWORD,
|
132
|
+
:usri3_profile, :LPWSTR,
|
133
|
+
:usri3_home_dir_drive, :LPWSTR,
|
134
|
+
:usri3_password_expired, :DWORD
|
135
|
+
|
118
136
|
def usri3_logon_hours
|
119
137
|
val = self[:usri3_logon_hours]
|
120
138
|
if !val.nil? && !val.null?
|
@@ -123,19 +141,66 @@ class Chef
|
|
123
141
|
nil
|
124
142
|
end
|
125
143
|
end
|
144
|
+
end
|
126
145
|
|
127
|
-
|
128
|
-
|
129
|
-
memo[key] = get(key)
|
130
|
-
memo
|
131
|
-
end
|
132
|
-
end
|
146
|
+
class LOCALGROUP_MEMBERS_INFO_0 < FFI::Struct
|
147
|
+
layout :lgrmi0_sid, :PSID
|
133
148
|
end
|
134
149
|
|
135
150
|
class LOCALGROUP_MEMBERS_INFO_3 < FFI::Struct
|
136
151
|
layout :lgrmi3_domainandname, :LPWSTR
|
137
152
|
end
|
138
153
|
|
154
|
+
class LOCALGROUP_INFO_0 < FFI::Struct
|
155
|
+
layout :lgrpi0_name, :LPWSTR
|
156
|
+
end
|
157
|
+
|
158
|
+
class USE_INFO_2 < FFI::Struct
|
159
|
+
include StructHelpers
|
160
|
+
|
161
|
+
layout :ui2_local, :LMSTR,
|
162
|
+
:ui2_remote, :LMSTR,
|
163
|
+
:ui2_password, :LMSTR,
|
164
|
+
:ui2_status, :DWORD,
|
165
|
+
:ui2_asg_type, :DWORD,
|
166
|
+
:ui2_refcount, :DWORD,
|
167
|
+
:ui2_usecount, :DWORD,
|
168
|
+
:ui2_username, :LPWSTR,
|
169
|
+
:ui2_domainname, :LMSTR
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
#NET_API_STATUS NetLocalGroupAdd(
|
174
|
+
#_In_ LPCWSTR servername,
|
175
|
+
#_In_ DWORD level,
|
176
|
+
#_In_ LPBYTE buf,
|
177
|
+
#_Out_ LPDWORD parm_err
|
178
|
+
#);
|
179
|
+
safe_attach_function :NetLocalGroupAdd, [
|
180
|
+
:LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
|
181
|
+
], :DWORD
|
182
|
+
|
183
|
+
#NET_API_STATUS NetLocalGroupDel(
|
184
|
+
#_In_ LPCWSTR servername,
|
185
|
+
#_In_ LPCWSTR groupname
|
186
|
+
#);
|
187
|
+
safe_attach_function :NetLocalGroupDel, [:LPCWSTR, :LPCWSTR], :DWORD
|
188
|
+
|
189
|
+
#NET_API_STATUS NetLocalGroupGetMembers(
|
190
|
+
#_In_ LPCWSTR servername,
|
191
|
+
#_In_ LPCWSTR localgroupname,
|
192
|
+
#_In_ DWORD level,
|
193
|
+
#_Out_ LPBYTE *bufptr,
|
194
|
+
#_In_ DWORD prefmaxlen,
|
195
|
+
#_Out_ LPDWORD entriesread,
|
196
|
+
#_Out_ LPDWORD totalentries,
|
197
|
+
#_Inout_ PDWORD_PTR resumehandle
|
198
|
+
#);
|
199
|
+
safe_attach_function :NetLocalGroupGetMembers, [
|
200
|
+
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD,
|
201
|
+
:LPDWORD, :LPDWORD, :PDWORD_PTR
|
202
|
+
], :DWORD
|
203
|
+
|
139
204
|
# NET_API_STATUS NetUserEnum(
|
140
205
|
# _In_ LPCWSTR servername,
|
141
206
|
# _In_ DWORD level,
|
@@ -146,12 +211,15 @@ class Chef
|
|
146
211
|
# _Out_ LPDWORD totalentries,
|
147
212
|
# _Inout_ LPDWORD resume_handle
|
148
213
|
# );
|
149
|
-
safe_attach_function :NetUserEnum, [
|
214
|
+
safe_attach_function :NetUserEnum, [
|
215
|
+
:LPCWSTR, :DWORD, :DWORD, :LPBYTE,
|
216
|
+
:DWORD, :LPDWORD, :LPDWORD, :LPDWORD
|
217
|
+
], :DWORD
|
150
218
|
|
151
219
|
# NET_API_STATUS NetApiBufferFree(
|
152
220
|
# _In_ LPVOID Buffer
|
153
221
|
# );
|
154
|
-
safe_attach_function :NetApiBufferFree, [
|
222
|
+
safe_attach_function :NetApiBufferFree, [:LPVOID], :DWORD
|
155
223
|
|
156
224
|
#NET_API_STATUS NetUserAdd(
|
157
225
|
#_In_ LMSTR servername,
|
@@ -159,7 +227,9 @@ class Chef
|
|
159
227
|
#_In_ LPBYTE buf,
|
160
228
|
#_Out_ LPDWORD parm_err
|
161
229
|
#);
|
162
|
-
safe_attach_function :NetUserAdd, [
|
230
|
+
safe_attach_function :NetUserAdd, [
|
231
|
+
:LMSTR, :DWORD, :LPBYTE, :LPDWORD
|
232
|
+
], :DWORD
|
163
233
|
|
164
234
|
#NET_API_STATUS NetLocalGroupAddMembers(
|
165
235
|
# _In_ LPCWSTR servername,
|
@@ -168,7 +238,31 @@ class Chef
|
|
168
238
|
# _In_ LPBYTE buf,
|
169
239
|
# _In_ DWORD totalentries
|
170
240
|
#);
|
171
|
-
safe_attach_function :NetLocalGroupAddMembers, [
|
241
|
+
safe_attach_function :NetLocalGroupAddMembers, [
|
242
|
+
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
|
243
|
+
], :DWORD
|
244
|
+
|
245
|
+
#NET_API_STATUS NetLocalGroupSetMembers(
|
246
|
+
# _In_ LPCWSTR servername,
|
247
|
+
# _In_ LPCWSTR groupname,
|
248
|
+
# _In_ DWORD level,
|
249
|
+
# _In_ LPBYTE buf,
|
250
|
+
# _In_ DWORD totalentries
|
251
|
+
#);
|
252
|
+
safe_attach_function :NetLocalGroupSetMembers, [
|
253
|
+
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
|
254
|
+
], :DWORD
|
255
|
+
|
256
|
+
#NET_API_STATUS NetLocalGroupDelMembers(
|
257
|
+
# _In_ LPCWSTR servername,
|
258
|
+
# _In_ LPCWSTR groupname,
|
259
|
+
# _In_ DWORD level,
|
260
|
+
# _In_ LPBYTE buf,
|
261
|
+
# _In_ DWORD totalentries
|
262
|
+
#);
|
263
|
+
safe_attach_function :NetLocalGroupDelMembers, [
|
264
|
+
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
|
265
|
+
], :DWORD
|
172
266
|
|
173
267
|
#NET_API_STATUS NetUserGetInfo(
|
174
268
|
# _In_ LPCWSTR servername,
|
@@ -176,7 +270,9 @@ class Chef
|
|
176
270
|
# _In_ DWORD level,
|
177
271
|
# _Out_ LPBYTE *bufptr
|
178
272
|
#);
|
179
|
-
safe_attach_function :NetUserGetInfo, [
|
273
|
+
safe_attach_function :NetUserGetInfo, [
|
274
|
+
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE
|
275
|
+
], :DWORD
|
180
276
|
|
181
277
|
#NET_API_STATUS NetApiBufferFree(
|
182
278
|
# _In_ LPVOID Buffer
|
@@ -190,7 +286,9 @@ class Chef
|
|
190
286
|
# _In_ LPBYTE buf,
|
191
287
|
# _Out_ LPDWORD parm_err
|
192
288
|
#);
|
193
|
-
safe_attach_function :NetUserSetInfo, [
|
289
|
+
safe_attach_function :NetUserSetInfo, [
|
290
|
+
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
|
291
|
+
], :DWORD
|
194
292
|
|
195
293
|
#NET_API_STATUS NetUserDel(
|
196
294
|
# _In_ LPCWSTR servername,
|
@@ -198,6 +296,28 @@ class Chef
|
|
198
296
|
#);
|
199
297
|
safe_attach_function :NetUserDel, [:LPCWSTR, :LPCWSTR], :DWORD
|
200
298
|
|
299
|
+
#NET_API_STATUS NetUseDel(
|
300
|
+
#_In_ LMSTR UncServerName,
|
301
|
+
#_In_ LMSTR UseName,
|
302
|
+
#_In_ DWORD ForceCond
|
303
|
+
#);
|
304
|
+
safe_attach_function :NetUseDel, [:LMSTR, :LMSTR, :DWORD], :DWORD
|
305
|
+
|
306
|
+
#NET_API_STATUS NetUseGetInfo(
|
307
|
+
#_In_ LMSTR UncServerName,
|
308
|
+
#_In_ LMSTR UseName,
|
309
|
+
#_In_ DWORD Level,
|
310
|
+
#_Out_ LPBYTE *BufPtr
|
311
|
+
#);
|
312
|
+
safe_attach_function :NetUseGetInfo, [:LMSTR, :LMSTR, :DWORD, :pointer], :DWORD
|
313
|
+
|
314
|
+
#NET_API_STATUS NetUseAdd(
|
315
|
+
#_In_ LMSTR UncServerName,
|
316
|
+
#_In_ DWORD Level,
|
317
|
+
#_In_ LPBYTE Buf,
|
318
|
+
#_Out_ LPDWORD ParmError
|
319
|
+
#);
|
320
|
+
safe_attach_function :NetUseAdd, [:LMSTR, :DWORD, :LPBYTE, :LPDWORD], :DWORD
|
201
321
|
end
|
202
322
|
end
|
203
323
|
end
|