Skip to content

Commit 297c11b

Browse files
committed
(PUP-11459) Always load Puppet::Util::Windows
Previously, 'puppet/util/windows.rb' was loaded on Windows due to requiring 'puppet/file_system/uniquefile'[1]. The second require[2] was actually a noop, since the file had already been required. And on non-Windows, the file was never loaded. Now we explicitly require 'puppet/util/windows' on all platforms. It must be done after 'puppet/util/platform' so we can detect if we're actually on Windows. We also remove the misleading requires that didn't do anything. [1] https://github.com/puppetlabs/puppet/blob/6.26.0/lib/puppet/util.rb#L11 [2] https://github.com/puppetlabs/puppet/blob/6.26.0/lib/puppet/util.rb#L25
1 parent 49f2309 commit 297c11b

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

lib/puppet/util.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
require 'pathname'
88
require 'ostruct'
99
require 'puppet/util/platform'
10+
require 'puppet/util/windows'
1011
require 'puppet/util/symbolic_file_mode'
1112
require 'puppet/file_system/uniquefile'
1213
require 'securerandom'
@@ -22,8 +23,6 @@ module Util
2223
require 'puppet/util/posix'
2324
extend Puppet::Util::POSIX
2425

25-
require 'puppet/util/windows/process' if Puppet::Util::Platform.windows?
26-
2726
extend Puppet::Util::SymbolicFileMode
2827

2928
def default_env

lib/puppet/util/monkey_patches.rb

-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ def initialize(*args)
7070
end
7171

7272
if Puppet::Util::Platform.windows?
73-
require 'puppet/util/windows'
74-
7573
class OpenSSL::X509::Store
7674
@puppet_certs_loaded = false
7775
alias __original_set_default_paths set_default_paths

spec/unit/util/windows_spec.rb

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe Puppet::Util::Windows do
6+
%w[
7+
ADSI
8+
ADSI::ADSIObject
9+
ADSI::User
10+
ADSI::UserProfile
11+
ADSI::Group
12+
EventLog
13+
File
14+
Process
15+
Registry
16+
Service
17+
SID
18+
].each do |name|
19+
it "defines Puppet::Util::Windows::#{name}" do
20+
expect(described_class.const_get(name)).to be
21+
end
22+
end
23+
end

0 commit comments

Comments
 (0)