puppet 3.0.1 → 3.0.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/Gemfile +17 -3
- data/Rakefile +7 -5
- data/ext/build_defaults.yaml +1 -1
- data/ext/debian/puppet.init +33 -34
- data/ext/debian/puppet.logrotate +2 -1
- data/ext/debian/puppetmaster.init +1 -2
- data/ext/suse/client.init +1 -1
- data/ext/suse/puppet.spec +3 -0
- data/ext/suse/server.init +1 -1
- data/ext/windows/service/daemon.rb +1 -1
- data/install.rb +32 -53
- data/lib/hiera/backend/puppet_backend.rb +6 -5
- data/lib/puppet/agent.rb +3 -3
- data/lib/puppet/application/agent.rb +1 -2
- data/lib/puppet/application/cert.rb +4 -5
- data/lib/puppet/application/kick.rb +3 -0
- data/lib/puppet/defaults.rb +15 -2
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +1 -1
- data/lib/puppet/parser/functions/hiera_include.rb +6 -4
- data/lib/puppet/parser/lexer.rb +38 -1
- data/lib/puppet/parser/relationship.rb +3 -1
- data/lib/puppet/provider.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/file/windows.rb +10 -29
- data/lib/puppet/provider/group/ldap.rb +1 -1
- data/lib/puppet/provider/group/windows_adsi.rb +1 -1
- data/lib/puppet/provider/ldap.rb +5 -1
- data/lib/puppet/provider/macauthorization/macauthorization.rb +2 -6
- data/lib/puppet/provider/package/dpkg.rb +8 -12
- data/lib/puppet/provider/package/macports.rb +2 -2
- data/lib/puppet/provider/package/msi.rb +2 -2
- data/lib/puppet/provider/package/sun.rb +1 -1
- data/lib/puppet/provider/package/windows.rb +2 -2
- data/lib/puppet/provider/package/yum.rb +5 -1
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
- data/lib/puppet/provider/service/freebsd.rb +1 -1
- data/lib/puppet/provider/user/directoryservice.rb +603 -65
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/run.rb +2 -1
- data/lib/puppet/settings.rb +9 -5
- data/lib/puppet/ssl/certificate_authority.rb +2 -0
- data/lib/puppet/transaction.rb +1 -1
- data/lib/puppet/type/cron.rb +4 -4
- data/lib/puppet/type/exec.rb +10 -5
- data/lib/puppet/type/file.rb +1 -1
- data/lib/puppet/type/service.rb +3 -2
- data/lib/puppet/type/user.rb +24 -2
- data/lib/puppet/util.rb +3 -6
- data/lib/puppet/util/adsi.rb +3 -9
- data/lib/puppet/util/diff.rb +1 -1
- data/lib/puppet/util/execution.rb +13 -6
- data/lib/puppet/util/feature.rb +3 -1
- data/lib/puppet/util/log/destinations.rb +12 -16
- data/lib/puppet/util/selinux.rb +18 -2
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/security.rb +2 -39
- data/lib/puppet/util/windows/sid.rb +96 -0
- data/lib/puppet/version.rb +1 -1
- data/spec/integration/util/windows/security_spec.rb +3 -23
- data/spec/unit/agent_spec.rb +7 -3
- data/spec/unit/application/agent_spec.rb +13 -5
- data/spec/unit/daemon_spec.rb +2 -1
- data/spec/unit/hiera/backend/puppet_backend_spec.rb +49 -42
- data/spec/unit/indirector/exec_spec.rb +8 -6
- data/spec/unit/parser/functions/hiera_include_spec.rb +11 -4
- data/spec/unit/parser/lexer_spec.rb +120 -8
- data/spec/unit/parser/relationship_spec.rb +24 -0
- data/spec/unit/provider/file/windows_spec.rb +29 -29
- data/spec/unit/provider/group/windows_adsi_spec.rb +2 -2
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +1 -1
- data/spec/unit/provider/package/dpkg_spec.rb +2 -2
- data/spec/unit/provider/package/macports_spec.rb +6 -5
- data/spec/unit/provider/package/msi_spec.rb +1 -1
- data/spec/unit/provider/package/pacman_spec.rb +1 -1
- data/spec/unit/provider/package/rpm_spec.rb +1 -1
- data/spec/unit/provider/package/sun_spec.rb +4 -4
- data/spec/unit/provider/package/windows_spec.rb +1 -1
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +14 -11
- data/spec/unit/provider/user/directoryservice_spec.rb +943 -0
- data/spec/unit/provider/user/ldap_spec.rb +22 -8
- data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
- data/spec/unit/provider_spec.rb +1 -1
- data/spec/unit/run_spec.rb +1 -1
- data/spec/unit/settings_spec.rb +16 -0
- data/spec/unit/ssl/certificate_authority_spec.rb +24 -0
- data/spec/unit/util/adsi_spec.rb +4 -8
- data/spec/unit/util/diff_spec.rb +2 -2
- data/spec/unit/util/execution_spec.rb +78 -20
- data/spec/unit/util/feature_spec.rb +12 -1
- data/spec/unit/util/selinux_spec.rb +20 -0
- data/spec/unit/util/windows/sid_spec.rb +100 -0
- data/spec/unit/util_spec.rb +17 -0
- metadata +71 -48
- data/Gemfile.lock +0 -44
- data/lib/puppet/provider/interface/base.rb +0 -0
@@ -50,7 +50,7 @@ Puppet::Type.type(:zpool).provide(:zpool) do
|
|
50
50
|
def get_pool_data
|
51
51
|
# http://docs.oracle.com/cd/E19082-01/817-2271/gbcve/index.html
|
52
52
|
# we could also use zpool iostat -v mypool for a (little bit) cleaner output
|
53
|
-
out = execute("zpool status #{@resource[:pool]}", :failonfail => false)
|
53
|
+
out = execute("zpool status #{@resource[:pool]}", :failonfail => false, :combine => false)
|
54
54
|
zpool_data = out.lines.select { |line| line.index("\t") == 0 }.collect { |l| l.strip.split("\s")[0] }
|
55
55
|
zpool_data.shift
|
56
56
|
zpool_data
|
data/lib/puppet/run.rb
CHANGED
data/lib/puppet/settings.rb
CHANGED
@@ -172,15 +172,17 @@ class Puppet::Settings
|
|
172
172
|
"The effective 'run mode' of the application: master, agent, or user.",
|
173
173
|
:REQUIRED) do |arg|
|
174
174
|
Puppet.settings.preferred_run_mode = arg
|
175
|
+
end
|
176
|
+
|
177
|
+
option_parser.parse(args)
|
175
178
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
+
# remove run_mode options from the arguments so that later parses don't think
|
180
|
+
# it is an unknown option.
|
181
|
+
while option_index = args.index('--run_mode') do
|
179
182
|
args.delete_at option_index
|
180
183
|
args.delete_at option_index
|
181
184
|
end
|
182
|
-
|
183
|
-
option_parser.parse(args)
|
185
|
+
args.reject! { |arg| arg.start_with? '--run_mode=' }
|
184
186
|
end
|
185
187
|
private :parse_global_options
|
186
188
|
|
@@ -855,6 +857,8 @@ These parameters affect the required permissions of any files specified after
|
|
855
857
|
their specification. Puppet will sometimes use these parameters to check its
|
856
858
|
own configured state, so they can be used to make Puppet a bit more self-managing.
|
857
859
|
|
860
|
+
The file format supports octothorpe-commented lines, but not partial-line comments.
|
861
|
+
|
858
862
|
Generated on #{Time.now}.
|
859
863
|
|
860
864
|
}.gsub(/^/, "# ")
|
@@ -232,6 +232,8 @@ class Puppet::SSL::CertificateAuthority
|
|
232
232
|
|
233
233
|
if cert = Puppet::SSL::Certificate.indirection.find(name)
|
234
234
|
serial = cert.content.serial
|
235
|
+
elsif name =~ /^0x[0-9A-Fa-f]+$/
|
236
|
+
serial = name.hex
|
235
237
|
elsif ! serial = inventory.serial(name)
|
236
238
|
raise ArgumentError, "Could not find a serial number for #{name}"
|
237
239
|
end
|
data/lib/puppet/transaction.rb
CHANGED
@@ -151,7 +151,7 @@ class Puppet::Transaction
|
|
151
151
|
begin
|
152
152
|
made = resource.eval_generate.uniq
|
153
153
|
return false if made.empty?
|
154
|
-
made = made.
|
154
|
+
made = Hash[made.map(&:name).zip(made)]
|
155
155
|
rescue => detail
|
156
156
|
resource.log_exception(detail, "Failed to generate additional resources using 'eval_generate: #{detail}")
|
157
157
|
return false
|
data/lib/puppet/type/cron.rb
CHANGED
@@ -364,9 +364,9 @@ Puppet::Type.newtype(:cron) do
|
|
364
364
|
end
|
365
365
|
|
366
366
|
newproperty(:target) do
|
367
|
-
desc "
|
368
|
-
|
369
|
-
|
367
|
+
desc "The username that will own the cron entry. Defaults to
|
368
|
+
the value of $USER for the shell that invoked Puppet, or root if $USER
|
369
|
+
is empty."
|
370
370
|
|
371
371
|
defaultto {
|
372
372
|
if provider.is_a?(@resource.class.provider(:crontab))
|
@@ -374,7 +374,7 @@ Puppet::Type.newtype(:cron) do
|
|
374
374
|
val
|
375
375
|
else
|
376
376
|
raise ArgumentError,
|
377
|
-
"You must provide a
|
377
|
+
"You must provide a username with crontab entries"
|
378
378
|
end
|
379
379
|
elsif provider.class.ancestors.include?(Puppet::Provider::ParsedFile)
|
380
380
|
provider.class.default_target
|
data/lib/puppet/type/exec.rb
CHANGED
@@ -313,9 +313,11 @@ module Puppet
|
|
313
313
|
|
314
314
|
newcheck(:creates, :parent => Puppet::Parameter::Path) do
|
315
315
|
desc <<-'EOT'
|
316
|
-
A file
|
317
|
-
|
318
|
-
|
316
|
+
A file to look for before running the command. The command will
|
317
|
+
only run if the file **doesn't exist.**
|
318
|
+
|
319
|
+
This parameter doesn't cause Puppet to create a file; it is only
|
320
|
+
useful if **the command itself** creates a file.
|
319
321
|
|
320
322
|
exec { "tar -xf /Volumes/nfs02/important.tar":
|
321
323
|
cwd => "/var/tmp",
|
@@ -323,8 +325,11 @@ module Puppet
|
|
323
325
|
path => ["/usr/bin", "/usr/sbin"]
|
324
326
|
}
|
325
327
|
|
326
|
-
In this example,
|
327
|
-
|
328
|
+
In this example, `myfile` is assumed to be a file inside
|
329
|
+
`important.tar`. If it is ever deleted, the exec will bring it
|
330
|
+
back by re-extracting the tarball. If `important.tar` does **not**
|
331
|
+
actually contain `myfile`, the exec will keep running every time
|
332
|
+
Puppet runs.
|
328
333
|
EOT
|
329
334
|
|
330
335
|
accept_arrays
|
data/lib/puppet/type/file.rb
CHANGED
@@ -164,7 +164,7 @@ Puppet::Type.newtype(:file) do
|
|
164
164
|
end
|
165
165
|
|
166
166
|
newparam(:replace, :boolean => true) do
|
167
|
-
desc "Whether to replace a file that already exists on the local system but
|
167
|
+
desc "Whether to replace a file or symlink that already exists on the local system but
|
168
168
|
whose content doesn't match what the `source` or `content` attribute
|
169
169
|
specifies. Setting this to false allows file resources to initialize files
|
170
170
|
without overwriting future changes. Note that this only affects content;
|
data/lib/puppet/type/service.rb
CHANGED
@@ -198,8 +198,9 @@ module Puppet
|
|
198
198
|
newparam :hasrestart do
|
199
199
|
desc "Specify that an init script has a `restart` command. If this is
|
200
200
|
false and you do not specify a command in the `restart` attribute,
|
201
|
-
the init script's `stop` and `start` commands will be used.
|
202
|
-
|
201
|
+
the init script's `stop` and `start` commands will be used.
|
202
|
+
|
203
|
+
Defaults to false."
|
203
204
|
newvalues(:true, :false)
|
204
205
|
end
|
205
206
|
|
data/lib/puppet/type/user.rb
CHANGED
@@ -33,6 +33,10 @@ module Puppet
|
|
33
33
|
"The provider can set age requirements and restrictions for
|
34
34
|
passwords."
|
35
35
|
|
36
|
+
feature :manages_password_salt,
|
37
|
+
"The provider can set a password salt. This is for providers that
|
38
|
+
implement PBKDF2 passwords with salt properties."
|
39
|
+
|
36
40
|
feature :manages_solaris_rbac,
|
37
41
|
"The provider can manage roles and normal users"
|
38
42
|
|
@@ -295,7 +299,8 @@ module Puppet
|
|
295
299
|
|
296
300
|
newparam(:managehome, :boolean => true) do
|
297
301
|
desc "Whether to manage the home directory when managing the user.
|
298
|
-
|
302
|
+
This will create the home directory when `ensure => present`, and
|
303
|
+
delete the home directory when `ensure => absent`. Defaults to `false`."
|
299
304
|
|
300
305
|
newvalues(:true, :false)
|
301
306
|
|
@@ -303,7 +308,7 @@ module Puppet
|
|
303
308
|
|
304
309
|
validate do |val|
|
305
310
|
if val.to_s == "true"
|
306
|
-
raise ArgumentError, "User provider #{provider.class.name} can not manage home directories"
|
311
|
+
raise ArgumentError, "User provider #{provider.class.name} can not manage home directories" if provider and not provider.class.manages_homedir?
|
307
312
|
end
|
308
313
|
end
|
309
314
|
end
|
@@ -519,6 +524,23 @@ module Puppet
|
|
519
524
|
defaultto :minimum
|
520
525
|
end
|
521
526
|
|
527
|
+
newproperty(:salt, :required_features => :manages_password_salt) do
|
528
|
+
desc "This is the 32 byte salt used to generate the PBKDF2 password used in
|
529
|
+
OS X"
|
530
|
+
end
|
531
|
+
|
532
|
+
newproperty(:iterations, :required_features => :manages_password_salt) do
|
533
|
+
desc "This is the number of iterations of a chained computation of the
|
534
|
+
password hash (http://en.wikipedia.org/wiki/PBKDF2). This parameter
|
535
|
+
is used in OS X"
|
522
536
|
|
537
|
+
munge do |value|
|
538
|
+
if value.is_a?(String) and value =~/^[-0-9]+$/
|
539
|
+
Integer(value)
|
540
|
+
else
|
541
|
+
value
|
542
|
+
end
|
543
|
+
end
|
544
|
+
end
|
523
545
|
end
|
524
546
|
end
|
data/lib/puppet/util.rb
CHANGED
@@ -232,10 +232,6 @@ module Util
|
|
232
232
|
AbsolutePathWindows = %r!^(?:(?:[A-Z]:#{slash})|(?:#{slash}#{slash}#{label}#{slash}#{label})|(?:#{slash}#{slash}\?#{slash}#{label}))!io
|
233
233
|
AbsolutePathPosix = %r!^/!
|
234
234
|
def absolute_path?(path, platform=nil)
|
235
|
-
# Due to weird load order issues, I was unable to remove this require.
|
236
|
-
# This is fixed in Telly so it can be removed there.
|
237
|
-
require 'puppet' unless defined?(Puppet)
|
238
|
-
|
239
235
|
# Ruby only sets File::ALT_SEPARATOR on Windows and the Ruby standard
|
240
236
|
# library uses that to test what platform it's on. Normally in Puppet we
|
241
237
|
# would use Puppet.features.microsoft_windows?, but this method needs to
|
@@ -534,9 +530,10 @@ module Util
|
|
534
530
|
end
|
535
531
|
module_function :execfail
|
536
532
|
|
537
|
-
def execute(
|
533
|
+
def execute(*args)
|
538
534
|
Puppet.deprecation_warning("Puppet::Util.execute is deprecated; please use Puppet::Util::Execution.execute")
|
539
|
-
|
535
|
+
|
536
|
+
Puppet::Util::Execution.execute(*args)
|
540
537
|
end
|
541
538
|
module_function :execute
|
542
539
|
|
data/lib/puppet/util/adsi.rb
CHANGED
@@ -54,15 +54,9 @@ module Puppet::Util::ADSI
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def sid_for_account(name)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
query = "SELECT Sid from Win32_Account WHERE Name = '#{name}' AND Domain = '#{domain}' AND LocalAccount = true"
|
61
|
-
else
|
62
|
-
query = "SELECT Sid from Win32_Account WHERE Name = '#{name}' AND LocalAccount = true"
|
63
|
-
end
|
64
|
-
execquery(query).each { |u| sid ||= u.Sid }
|
65
|
-
sid
|
57
|
+
Puppet.deprecation_warning "Puppet::Util::ADSI.sid_for_account is deprecated and will be removed in 3.0, use Puppet::Util::Windows::SID.name_to_account instead."
|
58
|
+
|
59
|
+
Puppet::Util::Windows::Security.name_to_sid(name)
|
66
60
|
end
|
67
61
|
end
|
68
62
|
|
data/lib/puppet/util/diff.rb
CHANGED
@@ -13,7 +13,7 @@ module Puppet::Util::Diff
|
|
13
13
|
command << args
|
14
14
|
end
|
15
15
|
command << old << new
|
16
|
-
Puppet::Util::Execution.execute(command, :failonfail => false)
|
16
|
+
Puppet::Util::Execution.execute(command, :failonfail => false, :combine => false)
|
17
17
|
end
|
18
18
|
|
19
19
|
module_function :diff
|
@@ -52,18 +52,17 @@ module Util::Execution
|
|
52
52
|
end
|
53
53
|
|
54
54
|
|
55
|
-
|
56
55
|
# Execute the desired command, and return the status and output.
|
57
56
|
# def execute(command, options)
|
58
57
|
# [command] an Array or String representing the command to execute. If it is
|
59
58
|
# an Array the first element should be the executable and the rest of the
|
60
59
|
# elements should be the individual arguments to that executable.
|
61
60
|
# [options] a Hash optionally containing any of the following keys:
|
62
|
-
# :failonfail (
|
61
|
+
# :failonfail (see below) -- if this value is set to true, then this method will raise an error if the
|
63
62
|
# command is not executed successfully.
|
64
63
|
# :uid (default nil) -- the user id of the user that the process should be run as
|
65
64
|
# :gid (default nil) -- the group id of the group that the process should be run as
|
66
|
-
# :combine (
|
65
|
+
# :combine (see below) -- sets whether or not to combine stdout/stderr in the output
|
67
66
|
# :stdinfile (default nil) -- sets a file that can be used for stdin. Passing a string for stdin is not currently
|
68
67
|
# supported.
|
69
68
|
# :squelch (default false) -- if true, ignore stdout / stderr completely
|
@@ -73,14 +72,22 @@ module Util::Execution
|
|
73
72
|
# Passing in a value of false for this option will allow the command to be executed using the user/system locale.
|
74
73
|
# :custom_environment (default {}) -- a hash of key/value pairs to set as environment variables for the duration
|
75
74
|
# of the command
|
76
|
-
|
75
|
+
#
|
76
|
+
# Unfortunately, the default behavior for failonfail and combine (since
|
77
|
+
# 0.22.4 and 0.24.7, respectively) depend on whether options are specified
|
78
|
+
# or not. If specified, then failonfail and combine default to false (even
|
79
|
+
# when the options specified are neither failonfail nor combine). If no
|
80
|
+
# options are specified, then failonfail and combine default to true. See
|
81
|
+
# commits efe9a833c and d32d7f30
|
82
|
+
NoOptionsSpecified = {}
|
83
|
+
def self.execute(command, options = NoOptionsSpecified)
|
77
84
|
# specifying these here rather than in the method signature to allow callers to pass in a partial
|
78
85
|
# set of overrides without affecting the default values for options that they don't pass in
|
79
86
|
default_options = {
|
80
|
-
:failonfail =>
|
87
|
+
:failonfail => NoOptionsSpecified.equal?(options),
|
81
88
|
:uid => nil,
|
82
89
|
:gid => nil,
|
83
|
-
:combine =>
|
90
|
+
:combine => NoOptionsSpecified.equal?(options),
|
84
91
|
:stdinfile => nil,
|
85
92
|
:squelch => false,
|
86
93
|
:override_locale => true,
|
data/lib/puppet/util/feature.rb
CHANGED
@@ -23,7 +23,9 @@ class Puppet::Util::Feature
|
|
23
23
|
end
|
24
24
|
|
25
25
|
meta_def(method) do
|
26
|
-
|
26
|
+
# Positive cache only, except blocks which are executed just once above
|
27
|
+
final = @results[name] || block_given?
|
28
|
+
@results[name] = test(name, options) unless final
|
27
29
|
@results[name]
|
28
30
|
end
|
29
31
|
end
|
@@ -106,27 +106,23 @@ Puppet::Util::Log.newdesttype :console do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def handle(msg)
|
109
|
-
|
110
|
-
:
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
109
|
+
levels = {
|
110
|
+
:emerg => { :name => 'Emergency', :color => :hred, :stream => $stderr },
|
111
|
+
:alert => { :name => 'Alert', :color => :hred, :stream => $stderr },
|
112
|
+
:crit => { :name => 'Critical', :color => :hred, :stream => $stderr },
|
113
|
+
:err => { :name => 'Error', :color => :hred, :stream => $stderr },
|
114
|
+
:warning => { :name => 'Warning', :color => :hred, :stream => $stderr },
|
115
|
+
|
116
|
+
:notice => { :name => 'Notice', :color => :reset, :stream => $stdout },
|
117
|
+
:info => { :name => 'Info', :color => :green, :stream => $stdout },
|
118
|
+
:debug => { :name => 'Debug', :color => :cyan, :stream => $stdout },
|
115
119
|
}
|
116
120
|
|
117
121
|
str = msg.respond_to?(:multiline) ? msg.multiline : msg.to_s
|
118
122
|
str = msg.source == "Puppet" ? str : "#{msg.source}: #{str}"
|
119
123
|
|
120
|
-
|
121
|
-
|
122
|
-
$stderr.puts colorize(:hred, "#{error_levels[msg.level]}: #{str}")
|
123
|
-
when :info
|
124
|
-
$stdout.puts "#{colorize(:green, 'Info')}: #{str}"
|
125
|
-
when :debug
|
126
|
-
$stdout.puts "#{colorize(:cyan, 'Debug')}: #{str}"
|
127
|
-
else
|
128
|
-
$stdout.puts str
|
129
|
-
end
|
124
|
+
level = levels[msg.level]
|
125
|
+
level[:stream].puts colorize(level[:color], "#{level[:name]}: #{str}")
|
130
126
|
end
|
131
127
|
end
|
132
128
|
|
data/lib/puppet/util/selinux.rb
CHANGED
@@ -42,11 +42,17 @@ module Puppet::Util::SELinux
|
|
42
42
|
# If the file exists we should pass the mode to matchpathcon for the most specific
|
43
43
|
# matching. If not, we can pass a mode of 0.
|
44
44
|
begin
|
45
|
-
filestat =
|
45
|
+
filestat = file_lstat(file)
|
46
|
+
rescue Errno::EACCES, Errno::ENOENT => detail
|
47
|
+
warning "Could not stat; #{detail}"
|
48
|
+
end
|
49
|
+
|
50
|
+
if filestat
|
46
51
|
mode = filestat.mode
|
47
|
-
|
52
|
+
else
|
48
53
|
mode = 0
|
49
54
|
end
|
55
|
+
|
50
56
|
retval = Selinux.matchpathcon(file, mode)
|
51
57
|
if retval == -1
|
52
58
|
return nil
|
@@ -208,4 +214,14 @@ module Puppet::Util::SELinux
|
|
208
214
|
# Should never be reached...
|
209
215
|
return mounts['/']
|
210
216
|
end
|
217
|
+
|
218
|
+
##
|
219
|
+
# file_lstat is an internal, private method to allow precise stubbing and
|
220
|
+
# mocking without affecting the rest of the system.
|
221
|
+
#
|
222
|
+
# @return [File::Stat] File.lstat result
|
223
|
+
def file_lstat(path)
|
224
|
+
File.lstat(path)
|
225
|
+
end
|
226
|
+
private :file_lstat
|
211
227
|
end
|
data/lib/puppet/util/windows.rb
CHANGED
@@ -2,6 +2,7 @@ module Puppet::Util::Windows
|
|
2
2
|
if Puppet::Util::Platform.windows?
|
3
3
|
# these reference platform specific gems
|
4
4
|
require 'puppet/util/windows/error'
|
5
|
+
require 'puppet/util/windows/sid'
|
5
6
|
require 'puppet/util/windows/security'
|
6
7
|
require 'puppet/util/windows/user'
|
7
8
|
require 'puppet/util/windows/process'
|
@@ -80,6 +80,8 @@ module Puppet::Util::Windows::Security
|
|
80
80
|
include ::Windows::MSVCRT::Buffer
|
81
81
|
include ::Windows::Volume
|
82
82
|
|
83
|
+
include Puppet::Util::Windows::SID
|
84
|
+
|
83
85
|
extend Puppet::Util::Windows::Security
|
84
86
|
|
85
87
|
# file modes
|
@@ -553,45 +555,6 @@ module Puppet::Util::Windows::Security
|
|
553
555
|
end
|
554
556
|
end
|
555
557
|
|
556
|
-
# Convert a SID pointer to a string, e.g. "S-1-5-32-544".
|
557
|
-
def sid_ptr_to_string(psid)
|
558
|
-
sid_buf = 0.chr * 256
|
559
|
-
str_ptr = 0.chr * 4
|
560
|
-
|
561
|
-
raise Puppet::Util::Windows::Error.new("Invalid SID") unless IsValidSid(psid)
|
562
|
-
|
563
|
-
raise Puppet::Util::Windows::Error.new("Failed to convert binary SID") unless ConvertSidToStringSid(psid, str_ptr)
|
564
|
-
|
565
|
-
begin
|
566
|
-
strncpy(sid_buf, str_ptr.unpack('L')[0], sid_buf.size - 1)
|
567
|
-
sid_buf[sid_buf.size - 1] = 0.chr
|
568
|
-
return sid_buf.strip
|
569
|
-
ensure
|
570
|
-
LocalFree(str_ptr.unpack('L')[0])
|
571
|
-
end
|
572
|
-
end
|
573
|
-
|
574
|
-
# Convert a SID string, e.g. "S-1-5-32-544" to a pointer (containing the
|
575
|
-
# address of the binary SID structure). The returned value can be used in
|
576
|
-
# Win32 APIs that expect a PSID, e.g. IsValidSid.
|
577
|
-
def string_to_sid_ptr(string)
|
578
|
-
sid_buf = 0.chr * 80
|
579
|
-
string_addr = [string].pack('p*').unpack('L')[0]
|
580
|
-
|
581
|
-
raise Puppet::Util::Windows::Error.new("Failed to convert string SID: #{string}") unless ConvertStringSidToSid(string_addr, sid_buf)
|
582
|
-
|
583
|
-
sid_ptr = sid_buf.unpack('L')[0]
|
584
|
-
begin
|
585
|
-
if block_given?
|
586
|
-
yield sid_ptr
|
587
|
-
else
|
588
|
-
true
|
589
|
-
end
|
590
|
-
ensure
|
591
|
-
LocalFree(sid_ptr)
|
592
|
-
end
|
593
|
-
end
|
594
|
-
|
595
558
|
# Open an existing file with the specified access mode, and execute a
|
596
559
|
# block with the opened file HANDLE.
|
597
560
|
def open_file(path, access)
|