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.

Files changed (97) hide show
  1. data/Gemfile +17 -3
  2. data/Rakefile +7 -5
  3. data/ext/build_defaults.yaml +1 -1
  4. data/ext/debian/puppet.init +33 -34
  5. data/ext/debian/puppet.logrotate +2 -1
  6. data/ext/debian/puppetmaster.init +1 -2
  7. data/ext/suse/client.init +1 -1
  8. data/ext/suse/puppet.spec +3 -0
  9. data/ext/suse/server.init +1 -1
  10. data/ext/windows/service/daemon.rb +1 -1
  11. data/install.rb +32 -53
  12. data/lib/hiera/backend/puppet_backend.rb +6 -5
  13. data/lib/puppet/agent.rb +3 -3
  14. data/lib/puppet/application/agent.rb +1 -2
  15. data/lib/puppet/application/cert.rb +4 -5
  16. data/lib/puppet/application/kick.rb +3 -0
  17. data/lib/puppet/defaults.rb +15 -2
  18. data/lib/puppet/indirector/exec.rb +1 -1
  19. data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +1 -1
  20. data/lib/puppet/parser/functions/hiera_include.rb +6 -4
  21. data/lib/puppet/parser/lexer.rb +38 -1
  22. data/lib/puppet/parser/relationship.rb +3 -1
  23. data/lib/puppet/provider.rb +1 -1
  24. data/lib/puppet/provider/augeas/augeas.rb +1 -1
  25. data/lib/puppet/provider/file/windows.rb +10 -29
  26. data/lib/puppet/provider/group/ldap.rb +1 -1
  27. data/lib/puppet/provider/group/windows_adsi.rb +1 -1
  28. data/lib/puppet/provider/ldap.rb +5 -1
  29. data/lib/puppet/provider/macauthorization/macauthorization.rb +2 -6
  30. data/lib/puppet/provider/package/dpkg.rb +8 -12
  31. data/lib/puppet/provider/package/macports.rb +2 -2
  32. data/lib/puppet/provider/package/msi.rb +2 -2
  33. data/lib/puppet/provider/package/sun.rb +1 -1
  34. data/lib/puppet/provider/package/windows.rb +2 -2
  35. data/lib/puppet/provider/package/yum.rb +5 -1
  36. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
  37. data/lib/puppet/provider/service/freebsd.rb +1 -1
  38. data/lib/puppet/provider/user/directoryservice.rb +603 -65
  39. data/lib/puppet/provider/user/windows_adsi.rb +1 -1
  40. data/lib/puppet/provider/zpool/zpool.rb +1 -1
  41. data/lib/puppet/run.rb +2 -1
  42. data/lib/puppet/settings.rb +9 -5
  43. data/lib/puppet/ssl/certificate_authority.rb +2 -0
  44. data/lib/puppet/transaction.rb +1 -1
  45. data/lib/puppet/type/cron.rb +4 -4
  46. data/lib/puppet/type/exec.rb +10 -5
  47. data/lib/puppet/type/file.rb +1 -1
  48. data/lib/puppet/type/service.rb +3 -2
  49. data/lib/puppet/type/user.rb +24 -2
  50. data/lib/puppet/util.rb +3 -6
  51. data/lib/puppet/util/adsi.rb +3 -9
  52. data/lib/puppet/util/diff.rb +1 -1
  53. data/lib/puppet/util/execution.rb +13 -6
  54. data/lib/puppet/util/feature.rb +3 -1
  55. data/lib/puppet/util/log/destinations.rb +12 -16
  56. data/lib/puppet/util/selinux.rb +18 -2
  57. data/lib/puppet/util/windows.rb +1 -0
  58. data/lib/puppet/util/windows/security.rb +2 -39
  59. data/lib/puppet/util/windows/sid.rb +96 -0
  60. data/lib/puppet/version.rb +1 -1
  61. data/spec/integration/util/windows/security_spec.rb +3 -23
  62. data/spec/unit/agent_spec.rb +7 -3
  63. data/spec/unit/application/agent_spec.rb +13 -5
  64. data/spec/unit/daemon_spec.rb +2 -1
  65. data/spec/unit/hiera/backend/puppet_backend_spec.rb +49 -42
  66. data/spec/unit/indirector/exec_spec.rb +8 -6
  67. data/spec/unit/parser/functions/hiera_include_spec.rb +11 -4
  68. data/spec/unit/parser/lexer_spec.rb +120 -8
  69. data/spec/unit/parser/relationship_spec.rb +24 -0
  70. data/spec/unit/provider/file/windows_spec.rb +29 -29
  71. data/spec/unit/provider/group/windows_adsi_spec.rb +2 -2
  72. data/spec/unit/provider/nameservice/directoryservice_spec.rb +1 -1
  73. data/spec/unit/provider/package/dpkg_spec.rb +2 -2
  74. data/spec/unit/provider/package/macports_spec.rb +6 -5
  75. data/spec/unit/provider/package/msi_spec.rb +1 -1
  76. data/spec/unit/provider/package/pacman_spec.rb +1 -1
  77. data/spec/unit/provider/package/rpm_spec.rb +1 -1
  78. data/spec/unit/provider/package/sun_spec.rb +4 -4
  79. data/spec/unit/provider/package/windows_spec.rb +1 -1
  80. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +14 -11
  81. data/spec/unit/provider/user/directoryservice_spec.rb +943 -0
  82. data/spec/unit/provider/user/ldap_spec.rb +22 -8
  83. data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
  84. data/spec/unit/provider_spec.rb +1 -1
  85. data/spec/unit/run_spec.rb +1 -1
  86. data/spec/unit/settings_spec.rb +16 -0
  87. data/spec/unit/ssl/certificate_authority_spec.rb +24 -0
  88. data/spec/unit/util/adsi_spec.rb +4 -8
  89. data/spec/unit/util/diff_spec.rb +2 -2
  90. data/spec/unit/util/execution_spec.rb +78 -20
  91. data/spec/unit/util/feature_spec.rb +12 -1
  92. data/spec/unit/util/selinux_spec.rb +20 -0
  93. data/spec/unit/util/windows/sid_spec.rb +100 -0
  94. data/spec/unit/util_spec.rb +17 -0
  95. metadata +71 -48
  96. data/Gemfile.lock +0 -44
  97. data/lib/puppet/provider/interface/base.rb +0 -0
@@ -79,7 +79,7 @@ Puppet::Type.type(:user).provide :windows_adsi do
79
79
  end
80
80
 
81
81
  def uid
82
- Puppet::Util::ADSI.sid_for_account(@resource[:name])
82
+ Puppet::Util::Windows::Security.name_to_sid(@resource[:name])
83
83
  end
84
84
 
85
85
  def uid=(value)
@@ -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
@@ -11,7 +11,8 @@ class Puppet::Run
11
11
  attr_reader :status, :background, :options
12
12
 
13
13
  def agent
14
- Puppet::Agent.new(Puppet::Configurer)
14
+ # Forking disabled for "puppet kick" runs
15
+ Puppet::Agent.new(Puppet::Configurer, false)
15
16
  end
16
17
 
17
18
  def background?
@@ -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
- # remove this option from the arguments so that later parses don't think
177
- # it is an unknown option
178
- option_index = args.index '--run_mode'
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
@@ -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.inject({}) {|a,v| a.merge(v.name => v) }
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
@@ -364,9 +364,9 @@ Puppet::Type.newtype(:cron) do
364
364
  end
365
365
 
366
366
  newproperty(:target) do
367
- desc "Where the cron job should be stored. For crontab-style
368
- entries this is the same as the user and defaults that way.
369
- Other providers default accordingly."
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 user with crontab entries"
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
@@ -313,9 +313,11 @@ module Puppet
313
313
 
314
314
  newcheck(:creates, :parent => Puppet::Parameter::Path) do
315
315
  desc <<-'EOT'
316
- A file that this command creates. If this
317
- parameter is provided, then the command will only be run
318
- if the specified file does not exist.
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, if `/var/tmp/myfile` is ever deleted, the exec
327
- will bring it back by re-extracting the tarball.
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
@@ -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;
@@ -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. Defaults
202
- to true; note that this is a change from earlier versions of Puppet."
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
 
@@ -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
- Defaults to `false`."
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" unless provider.class.manages_homedir?
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(command, arguments = {})
533
+ def execute(*args)
538
534
  Puppet.deprecation_warning("Puppet::Util.execute is deprecated; please use Puppet::Util::Execution.execute")
539
- Puppet::Util::Execution.execute(command, arguments)
535
+
536
+ Puppet::Util::Execution.execute(*args)
540
537
  end
541
538
  module_function :execute
542
539
 
@@ -54,15 +54,9 @@ module Puppet::Util::ADSI
54
54
  end
55
55
 
56
56
  def sid_for_account(name)
57
- sid = nil
58
- if name =~ /\\/
59
- domain, name = name.split('\\', 2)
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
 
@@ -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 (default true) -- if this value is set to true, then this method will raise an error if the
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 (default true) -- sets whether or not to combine stdout/stderr in the output
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
- def self.execute(command, options = {})
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 => true,
87
+ :failonfail => NoOptionsSpecified.equal?(options),
81
88
  :uid => nil,
82
89
  :gid => nil,
83
- :combine => true,
90
+ :combine => NoOptionsSpecified.equal?(options),
84
91
  :stdinfile => nil,
85
92
  :squelch => false,
86
93
  :override_locale => true,
@@ -23,7 +23,9 @@ class Puppet::Util::Feature
23
23
  end
24
24
 
25
25
  meta_def(method) do
26
- @results[name] = test(name, options) unless @results.include?(name)
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
- error_levels = {
110
- :warning => 'Warning',
111
- :err => 'Error',
112
- :alert => 'Alert',
113
- :emerg => 'Emergency',
114
- :crit => 'Critical'
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
- case msg.level
121
- when *error_levels.keys
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
 
@@ -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 = File.lstat(file)
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
- rescue Errno::ENOENT
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
@@ -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)