chef 10.20.0 → 10.22.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- data/distro/common/html/chef-client.8.html +3 -3
- data/distro/common/html/chef-expander.8.html +3 -3
- data/distro/common/html/chef-expanderctl.8.html +3 -3
- data/distro/common/html/chef-server-webui.8.html +3 -3
- data/distro/common/html/chef-server.8.html +3 -3
- data/distro/common/html/chef-solo.8.html +3 -3
- data/distro/common/html/chef-solr.8.html +3 -3
- data/distro/common/html/knife-bootstrap.1.html +4 -4
- data/distro/common/html/knife-client.1.html +4 -4
- data/distro/common/html/knife-configure.1.html +3 -3
- data/distro/common/html/knife-cookbook-site.1.html +6 -6
- data/distro/common/html/knife-cookbook.1.html +3 -3
- data/distro/common/html/knife-data-bag.1.html +3 -3
- data/distro/common/html/knife-environment.1.html +6 -6
- data/distro/common/html/knife-exec.1.html +3 -3
- data/distro/common/html/knife-index.1.html +4 -4
- data/distro/common/html/knife-node.1.html +3 -3
- data/distro/common/html/knife-role.1.html +3 -3
- data/distro/common/html/knife-search.1.html +3 -3
- data/distro/common/html/knife-ssh.1.html +3 -3
- data/distro/common/html/knife-status.1.html +3 -3
- data/distro/common/html/knife-tag.1.html +3 -3
- data/distro/common/html/knife.1.html +11 -11
- data/distro/common/html/shef.1.html +3 -3
- data/distro/common/man/man1/knife-bootstrap.1 +1 -1
- data/distro/common/man/man1/knife-client.1 +1 -1
- data/distro/common/man/man1/knife-configure.1 +1 -1
- data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
- data/distro/common/man/man1/knife-cookbook.1 +1 -1
- data/distro/common/man/man1/knife-data-bag.1 +1 -1
- data/distro/common/man/man1/knife-environment.1 +1 -1
- data/distro/common/man/man1/knife-exec.1 +1 -1
- data/distro/common/man/man1/knife-index.1 +1 -1
- data/distro/common/man/man1/knife-node.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +1 -1
- data/distro/common/man/man1/knife-search.1 +1 -1
- data/distro/common/man/man1/knife-ssh.1 +1 -1
- data/distro/common/man/man1/knife-status.1 +1 -1
- data/distro/common/man/man1/knife-tag.1 +1 -1
- data/distro/common/man/man1/knife.1 +1 -1
- data/distro/common/man/man1/shef.1 +1 -1
- data/distro/common/man/man8/chef-client.8 +1 -1
- data/distro/common/man/man8/chef-expander.8 +1 -1
- data/distro/common/man/man8/chef-expanderctl.8 +1 -1
- data/distro/common/man/man8/chef-server-webui.8 +1 -1
- data/distro/common/man/man8/chef-server.8 +1 -1
- data/distro/common/man/man8/chef-solo.8 +1 -1
- data/distro/common/man/man8/chef-solr.8 +1 -1
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/json_compat.rb +94 -1
- data/lib/chef/provider/cookbook_file.rb +24 -0
- data/lib/chef/resource.rb +18 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/process.rb +1 -0
- data/lib/chef/win32/handle.rb +8 -1
- data/spec/data/big_json.json +2 -1
- data/spec/data/big_json_plus_one.json +2 -1
- data/spec/functional/resource/cookbook_file_spec.rb +18 -0
- data/spec/support/shared/functional/file_resource.rb +21 -0
- data/spec/support/shared/functional/securable_resource.rb +74 -70
- data/spec/unit/json_compat_spec.rb +61 -0
- metadata +23 -33
- data/spec/unit/json_compat_spect.rb +0 -53
@@ -44,6 +44,7 @@ class Chef
|
|
44
44
|
Chef::Log.debug("#{@new_resource} staging #{file_cache_location} to #{tempfile.path}")
|
45
45
|
tempfile.close
|
46
46
|
FileUtils.cp(file_cache_location, tempfile.path)
|
47
|
+
enforce_tempfile_inheritance(tempfile.path)
|
47
48
|
end
|
48
49
|
Chef::Log.info("#{@new_resource} created file #{@new_resource.path}")
|
49
50
|
end
|
@@ -76,6 +77,29 @@ class Chef
|
|
76
77
|
( ! ::File.exist?(@new_resource.path)) || ( ! compare_content)
|
77
78
|
end
|
78
79
|
|
80
|
+
protected
|
81
|
+
|
82
|
+
def enforce_tempfile_inheritance(tempfile_path)
|
83
|
+
# On the Windows platform, files in the temp directory
|
84
|
+
# default to not inherit unless the new resource specifies rights of
|
85
|
+
# some sort. Here we ensure that even when no rights are
|
86
|
+
# specified, the dacl's inheritance flag is set.
|
87
|
+
if Chef::Platform.windows? &&
|
88
|
+
@new_resource.rights.nil? &&
|
89
|
+
@new_resource.group.nil? &&
|
90
|
+
@new_resource.owner.nil? &&
|
91
|
+
@new_resource.deny_rights.nil?
|
92
|
+
|
93
|
+
securable_tempfile = Chef::ReservedNames::Win32::Security::SecurableObject.new(tempfile_path)
|
94
|
+
|
95
|
+
# No rights were specified, so the dacl will have no explicit aces
|
96
|
+
default_dacl = Chef::ReservedNames::Win32::Security::ACL.create([])
|
97
|
+
|
98
|
+
# In setting this default dacl, set inheritance to true
|
99
|
+
securable_tempfile.set_dacl(default_dacl, true)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
79
103
|
end
|
80
104
|
end
|
81
105
|
end
|
data/lib/chef/resource.rb
CHANGED
@@ -119,6 +119,24 @@ F
|
|
119
119
|
FORBIDDEN_IVARS = [:@run_context, :@node, :@not_if, :@only_if, :@enclosing_provider]
|
120
120
|
HIDDEN_IVARS = [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@name, :@node, :@not_if, :@only_if, :@elapsed_time, :@enclosing_provider]
|
121
121
|
|
122
|
+
# Track all subclasses of Resource. This is used so names can be looked up
|
123
|
+
# when attempting to deserialize from JSON. (See: json_compat)
|
124
|
+
def self.resource_classes
|
125
|
+
@resource_classes ||= []
|
126
|
+
end
|
127
|
+
|
128
|
+
# Callback when subclass is defined. Adds subclass to list of subclasses.
|
129
|
+
def self.inherited(subclass)
|
130
|
+
resource_classes << subclass
|
131
|
+
end
|
132
|
+
|
133
|
+
# Look up a subclass by +class_name+ which should be a string that matches
|
134
|
+
# `Subclass.name`
|
135
|
+
def self.find_subclass_by_name(class_name)
|
136
|
+
resource_classes.first {|c| c.name == class_name }
|
137
|
+
end
|
138
|
+
|
139
|
+
|
122
140
|
include Chef::Mixin::CheckHelper
|
123
141
|
include Chef::Mixin::ParamsValidate
|
124
142
|
include Chef::Mixin::Language
|
data/lib/chef/version.rb
CHANGED
@@ -33,6 +33,7 @@ class Chef
|
|
33
33
|
safe_attach_function :GetCurrentProcess, [], :HANDLE
|
34
34
|
safe_attach_function :GetProcessHandleCount, [ :HANDLE, :LPDWORD ], :BOOL
|
35
35
|
safe_attach_function :GetProcessId, [ :HANDLE ], :DWORD
|
36
|
+
safe_attach_function :CloseHandle, [ :HANDLE ], :BOOL
|
36
37
|
|
37
38
|
end
|
38
39
|
end
|
data/lib/chef/win32/handle.rb
CHANGED
@@ -26,6 +26,10 @@ class Chef
|
|
26
26
|
class Handle
|
27
27
|
extend Chef::ReservedNames::Win32::API::Process
|
28
28
|
|
29
|
+
# See http://msdn.microsoft.com/en-us/library/windows/desktop/ms683179(v=vs.85).aspx
|
30
|
+
# The handle value returned by the GetCurrentProcess function is the pseudo handle (HANDLE)-1 (which is 0xFFFFFFFF)
|
31
|
+
CURRENT_PROCESS_HANDLE = 4294967295
|
32
|
+
|
29
33
|
def initialize(handle)
|
30
34
|
@handle = handle
|
31
35
|
ObjectSpace.define_finalizer(self, Handle.close_handle_finalizer(handle))
|
@@ -34,7 +38,10 @@ class Chef
|
|
34
38
|
attr_reader :handle
|
35
39
|
|
36
40
|
def self.close_handle_finalizer(handle)
|
37
|
-
|
41
|
+
# According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms683179(v=vs.85).aspx, it is not necessary
|
42
|
+
# to close the pseudo handle returned by the GetCurrentProcess function. The docs also say that it doesn't hurt to call
|
43
|
+
# CloseHandle on it. However, doing so from inside of Ruby always seems to produce an invalid handle error.
|
44
|
+
proc { close_handle(handle) unless handle == CURRENT_PROCESS_HANDLE }
|
38
45
|
end
|
39
46
|
|
40
47
|
def self.close_handle(handle)
|
data/spec/data/big_json.json
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":
|
1
|
+
{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":"test"
|
2
|
+
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
|
@@ -1 +1,2 @@
|
|
1
|
-
{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":
|
1
|
+
{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":"test"
|
2
|
+
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
|
@@ -54,4 +54,22 @@ describe Chef::Resource::CookbookFile do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it_behaves_like "a file resource"
|
57
|
+
|
58
|
+
# These examples cover CHEF-3467 where unexpected and incorrect
|
59
|
+
# permissions can result on Windows because CookbookFile's implementation
|
60
|
+
# stages files in temp.
|
61
|
+
context "targets a file outside of the system temp directory" do
|
62
|
+
let(:windows_non_temp_dir) { File.join(ENV['systemdrive'], make_tmpname(file_base, "non-temp")) }
|
63
|
+
let(:path) { File.join(windows_non_temp_dir, make_tmpname(file_base, nil)) }
|
64
|
+
|
65
|
+
before do
|
66
|
+
FileUtils::mkdir_p(windows_non_temp_dir) if Chef::Platform.windows?
|
67
|
+
end
|
68
|
+
|
69
|
+
after do
|
70
|
+
FileUtils.rm_r(windows_non_temp_dir) if Chef::Platform.windows? && File.exists?(windows_non_temp_dir)
|
71
|
+
end
|
72
|
+
|
73
|
+
it_behaves_like "a file that inherits permissions from a parent directory"
|
74
|
+
end
|
57
75
|
end
|
@@ -87,6 +87,9 @@ shared_examples_for "a file resource" do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
context "when the target file does not exist" do
|
90
|
+
|
91
|
+
it_behaves_like "a securable resource"
|
92
|
+
|
90
93
|
it "creates the file when the :create action is run" do
|
91
94
|
resource.run_action(:create)
|
92
95
|
File.should exist(path)
|
@@ -167,6 +170,24 @@ shared_examples_for "a file resource" do
|
|
167
170
|
end
|
168
171
|
end
|
169
172
|
|
173
|
+
it_behaves_like "a file that inherits permissions from a parent directory"
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
shared_examples_for "a file that inherits permissions from a parent directory" do
|
178
|
+
include_context "use Windows permissions"
|
179
|
+
context "on Windows", :windows_only do
|
180
|
+
it "has only inherited aces if no explicit aces were specified" do
|
181
|
+
File.exist?(path).should == false
|
182
|
+
|
183
|
+
resource.run_action(:create)
|
184
|
+
|
185
|
+
descriptor.dacl_inherits?.should == true
|
186
|
+
descriptor.dacl.each do | ace |
|
187
|
+
ace.inherited?.should == true
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
170
191
|
end
|
171
192
|
|
172
193
|
shared_context Chef::Resource::File do
|
@@ -65,6 +65,78 @@ shared_context "setup broken permissions" do
|
|
65
65
|
# FIXME: windows
|
66
66
|
end
|
67
67
|
|
68
|
+
shared_context "use Windows permissions", :windows_only do
|
69
|
+
|
70
|
+
if windows?
|
71
|
+
SID ||= Chef::ReservedNames::Win32::Security::SID
|
72
|
+
ACE ||= Chef::ReservedNames::Win32::Security::ACE
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_security_descriptor(path)
|
76
|
+
Chef::ReservedNames::Win32::Security.get_named_security_info(path)
|
77
|
+
end
|
78
|
+
|
79
|
+
def explicit_aces
|
80
|
+
descriptor.dacl.select { |ace| ace.explicit? }
|
81
|
+
end
|
82
|
+
|
83
|
+
def extract_ace_properties(aces)
|
84
|
+
hashes = []
|
85
|
+
aces.each do |ace|
|
86
|
+
hashes << { :mask => ace.mask, :type => ace.type, :flags => ace.flags }
|
87
|
+
end
|
88
|
+
hashes
|
89
|
+
end
|
90
|
+
|
91
|
+
# Standard expected rights
|
92
|
+
let(:expected_read_perms) do
|
93
|
+
{
|
94
|
+
:generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ,
|
95
|
+
:specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ,
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
let(:expected_read_execute_perms) do
|
100
|
+
{
|
101
|
+
:generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE,
|
102
|
+
:specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
106
|
+
let(:expected_write_perms) do
|
107
|
+
{
|
108
|
+
:generic => Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE,
|
109
|
+
:specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
let(:expected_modify_perms) do
|
114
|
+
{
|
115
|
+
:generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE,
|
116
|
+
:specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
let(:expected_full_control_perms) do
|
121
|
+
{
|
122
|
+
:generic => Chef::ReservedNames::Win32::API::Security::GENERIC_ALL,
|
123
|
+
:specific => Chef::ReservedNames::Win32::API::Security::FILE_ALL_ACCESS
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
127
|
+
RSpec::Matchers.define :have_expected_properties do |mask, type, flags|
|
128
|
+
match do |ace|
|
129
|
+
ace.mask == mask
|
130
|
+
ace.type == type
|
131
|
+
ace.flags == flags
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def descriptor
|
136
|
+
get_security_descriptor(path)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
68
140
|
shared_examples_for "a securable resource" do
|
69
141
|
context "on Unix", :unix_only do
|
70
142
|
let(:expected_user_name) { 'nobody' }
|
@@ -107,75 +179,7 @@ shared_examples_for "a securable resource" do
|
|
107
179
|
end
|
108
180
|
|
109
181
|
context "on Windows", :windows_only do
|
110
|
-
|
111
|
-
if windows?
|
112
|
-
SID = Chef::ReservedNames::Win32::Security::SID
|
113
|
-
ACE = Chef::ReservedNames::Win32::Security::ACE
|
114
|
-
end
|
115
|
-
|
116
|
-
def get_security_descriptor(path)
|
117
|
-
Chef::ReservedNames::Win32::Security.get_named_security_info(path)
|
118
|
-
end
|
119
|
-
|
120
|
-
def explicit_aces
|
121
|
-
descriptor.dacl.select { |ace| ace.explicit? }
|
122
|
-
end
|
123
|
-
|
124
|
-
def extract_ace_properties(aces)
|
125
|
-
hashes = []
|
126
|
-
aces.each do |ace|
|
127
|
-
hashes << { :mask => ace.mask, :type => ace.type, :flags => ace.flags }
|
128
|
-
end
|
129
|
-
hashes
|
130
|
-
end
|
131
|
-
|
132
|
-
# Standard expected rights
|
133
|
-
let(:expected_read_perms) do
|
134
|
-
{
|
135
|
-
:generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ,
|
136
|
-
:specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ,
|
137
|
-
}
|
138
|
-
end
|
139
|
-
|
140
|
-
let(:expected_read_execute_perms) do
|
141
|
-
{
|
142
|
-
:generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE,
|
143
|
-
:specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE
|
144
|
-
}
|
145
|
-
end
|
146
|
-
|
147
|
-
let(:expected_write_perms) do
|
148
|
-
{
|
149
|
-
:generic => Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE,
|
150
|
-
:specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE
|
151
|
-
}
|
152
|
-
end
|
153
|
-
|
154
|
-
let(:expected_modify_perms) do
|
155
|
-
{
|
156
|
-
:generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE,
|
157
|
-
:specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE
|
158
|
-
}
|
159
|
-
end
|
160
|
-
|
161
|
-
let(:expected_full_control_perms) do
|
162
|
-
{
|
163
|
-
:generic => Chef::ReservedNames::Win32::API::Security::GENERIC_ALL,
|
164
|
-
:specific => Chef::ReservedNames::Win32::API::Security::FILE_ALL_ACCESS
|
165
|
-
}
|
166
|
-
end
|
167
|
-
|
168
|
-
RSpec::Matchers.define :have_expected_properties do |mask, type, flags|
|
169
|
-
match do |ace|
|
170
|
-
ace.mask == mask
|
171
|
-
ace.type == type
|
172
|
-
ace.flags == flags
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def descriptor
|
177
|
-
get_security_descriptor(path)
|
178
|
-
end
|
182
|
+
include_context "use Windows permissions"
|
179
183
|
|
180
184
|
before(:each) do
|
181
185
|
resource.run_action(:delete)
|
@@ -325,7 +329,7 @@ shared_examples_for "a securable resource" do
|
|
325
329
|
|
326
330
|
context "with a mode attribute" do
|
327
331
|
if windows?
|
328
|
-
Security
|
332
|
+
Security ||= Chef::ReservedNames::Win32::API::Security
|
329
333
|
end
|
330
334
|
|
331
335
|
it "respects mode in string form as an octal number" do
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Juanje Ojeda (<juanje.ojeda@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
20
|
+
require 'chef/json_compat'
|
21
|
+
|
22
|
+
describe Chef::JSONCompat do
|
23
|
+
|
24
|
+
describe "with JSON containing an existing class" do
|
25
|
+
let(:json){'{"json_class": "Chef::Role"}'}
|
26
|
+
it "returns an instance of the class instead of a Hash" do
|
27
|
+
Chef::JSONCompat.from_json(json).class.should eq Chef::Role
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "with a file with 300 or less nested entries" do
|
32
|
+
before(:all) do
|
33
|
+
@json = IO.read(File.join(CHEF_SPEC_DATA, 'big_json.json'))
|
34
|
+
@hash = Chef::JSONCompat.from_json(@json)
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "when a big json file is loaded" do
|
38
|
+
it "should create a Hash from the file" do
|
39
|
+
@hash.should be_kind_of(Hash)
|
40
|
+
end
|
41
|
+
it "should has 'test' as a 300th nested value" do
|
42
|
+
@hash['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key'].should == 'test'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
describe "with a file with more than 300 nested entries" do
|
47
|
+
before(:all) do
|
48
|
+
@json = IO.read(File.join(CHEF_SPEC_DATA, 'big_json_plus_one.json'))
|
49
|
+
@hash = Chef::JSONCompat.from_json(@json, {:max_nesting => 301})
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "when a big json file is loaded" do
|
53
|
+
it "should create a Hash from the file" do
|
54
|
+
@hash.should be_kind_of(Hash)
|
55
|
+
end
|
56
|
+
it "should has 'test' as a 301st nested value" do
|
57
|
+
@hash['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key']['key'].should == 'test'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: -2485545712
|
5
|
+
prerelease: 8
|
6
6
|
segments:
|
7
7
|
- 10
|
8
|
-
-
|
8
|
+
- 22
|
9
9
|
- 0
|
10
|
-
|
10
|
+
- rc
|
11
|
+
- 0
|
12
|
+
version: 10.22.0.rc.0
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Adam Jacob
|
@@ -15,7 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2013-02-
|
20
|
+
date: 2013-02-12 00:00:00 Z
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
21
23
|
name: mixlib-config
|
@@ -334,7 +336,7 @@ dependencies:
|
|
334
336
|
type: :development
|
335
337
|
version_requirements: *id019
|
336
338
|
- !ruby/object:Gem::Dependency
|
337
|
-
name:
|
339
|
+
name: rake
|
338
340
|
prerelease: false
|
339
341
|
requirement: &id020 !ruby/object:Gem::Requirement
|
340
342
|
none: false
|
@@ -348,7 +350,7 @@ dependencies:
|
|
348
350
|
type: :development
|
349
351
|
version_requirements: *id020
|
350
352
|
- !ruby/object:Gem::Dependency
|
351
|
-
name:
|
353
|
+
name: rack
|
352
354
|
prerelease: false
|
353
355
|
requirement: &id021 !ruby/object:Gem::Requirement
|
354
356
|
none: false
|
@@ -362,7 +364,7 @@ dependencies:
|
|
362
364
|
type: :development
|
363
365
|
version_requirements: *id021
|
364
366
|
- !ruby/object:Gem::Dependency
|
365
|
-
name:
|
367
|
+
name: rspec_junit_formatter
|
366
368
|
prerelease: false
|
367
369
|
requirement: &id022 !ruby/object:Gem::Requirement
|
368
370
|
none: false
|
@@ -375,24 +377,10 @@ dependencies:
|
|
375
377
|
version: "0"
|
376
378
|
type: :development
|
377
379
|
version_requirements: *id022
|
378
|
-
- !ruby/object:Gem::Dependency
|
379
|
-
name: rspec_junit_formatter
|
380
|
-
prerelease: false
|
381
|
-
requirement: &id023 !ruby/object:Gem::Requirement
|
382
|
-
none: false
|
383
|
-
requirements:
|
384
|
-
- - ">="
|
385
|
-
- !ruby/object:Gem::Version
|
386
|
-
hash: 3
|
387
|
-
segments:
|
388
|
-
- 0
|
389
|
-
version: "0"
|
390
|
-
type: :development
|
391
|
-
version_requirements: *id023
|
392
380
|
- !ruby/object:Gem::Dependency
|
393
381
|
name: rspec-core
|
394
382
|
prerelease: false
|
395
|
-
requirement: &
|
383
|
+
requirement: &id023 !ruby/object:Gem::Requirement
|
396
384
|
none: false
|
397
385
|
requirements:
|
398
386
|
- - ~>
|
@@ -404,11 +392,11 @@ dependencies:
|
|
404
392
|
- 0
|
405
393
|
version: 2.8.0
|
406
394
|
type: :development
|
407
|
-
version_requirements: *
|
395
|
+
version_requirements: *id023
|
408
396
|
- !ruby/object:Gem::Dependency
|
409
397
|
name: rspec-expectations
|
410
398
|
prerelease: false
|
411
|
-
requirement: &
|
399
|
+
requirement: &id024 !ruby/object:Gem::Requirement
|
412
400
|
none: false
|
413
401
|
requirements:
|
414
402
|
- - ~>
|
@@ -420,11 +408,11 @@ dependencies:
|
|
420
408
|
- 0
|
421
409
|
version: 2.8.0
|
422
410
|
type: :development
|
423
|
-
version_requirements: *
|
411
|
+
version_requirements: *id024
|
424
412
|
- !ruby/object:Gem::Dependency
|
425
413
|
name: rspec-mocks
|
426
414
|
prerelease: false
|
427
|
-
requirement: &
|
415
|
+
requirement: &id025 !ruby/object:Gem::Requirement
|
428
416
|
none: false
|
429
417
|
requirements:
|
430
418
|
- - ~>
|
@@ -436,7 +424,7 @@ dependencies:
|
|
436
424
|
- 0
|
437
425
|
version: 2.8.0
|
438
426
|
type: :development
|
439
|
-
version_requirements: *
|
427
|
+
version_requirements: *id025
|
440
428
|
description: A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.
|
441
429
|
email: adam@opscode.com
|
442
430
|
executables:
|
@@ -986,6 +974,7 @@ files:
|
|
986
974
|
- spec/unit/checksum/storage/filesystem_spec.rb
|
987
975
|
- spec/unit/client_spec.rb
|
988
976
|
- spec/unit/resource_spec.rb
|
977
|
+
- spec/unit/json_compat_spec.rb
|
989
978
|
- spec/unit/monkey_patches/string_spec.rb
|
990
979
|
- spec/unit/solr_query/query_transform_spec.rb
|
991
980
|
- spec/unit/solr_query/solr_http_request_spec.rb
|
@@ -1043,7 +1032,6 @@ files:
|
|
1043
1032
|
- spec/unit/index_queue_spec.rb
|
1044
1033
|
- spec/unit/file_access_control_spec.rb
|
1045
1034
|
- spec/unit/run_status_spec.rb
|
1046
|
-
- spec/unit/json_compat_spect.rb
|
1047
1035
|
- spec/unit/mash_spec.rb
|
1048
1036
|
- spec/unit/rest_spec.rb
|
1049
1037
|
- spec/unit/couchdb_spec.rb
|
@@ -1420,12 +1408,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1420
1408
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1421
1409
|
none: false
|
1422
1410
|
requirements:
|
1423
|
-
- - "
|
1411
|
+
- - ">"
|
1424
1412
|
- !ruby/object:Gem::Version
|
1425
|
-
hash:
|
1413
|
+
hash: 25
|
1426
1414
|
segments:
|
1427
|
-
-
|
1428
|
-
|
1415
|
+
- 1
|
1416
|
+
- 3
|
1417
|
+
- 1
|
1418
|
+
version: 1.3.1
|
1429
1419
|
requirements: []
|
1430
1420
|
|
1431
1421
|
rubyforge_project:
|