puppet 6.2.0-x64-mingw32 → 6.3.0-x64-mingw32
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.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +70 -0
- data/Gemfile.lock +7 -7
- data/lib/puppet/application.rb +1 -1
- data/lib/puppet/application/lookup.rb +1 -1
- data/lib/puppet/confine/boolean.rb +45 -0
- data/lib/puppet/confine/false.rb +7 -1
- data/lib/puppet/confine/true.rb +7 -1
- data/lib/puppet/defaults.rb +0 -18
- data/lib/puppet/functions/call.rb +2 -1
- data/lib/puppet/functions/group_by.rb +54 -0
- data/lib/puppet/functions/index.rb +167 -0
- data/lib/puppet/functions/partition.rb +54 -0
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +1 -1
- data/lib/puppet/pops/issues.rb +4 -0
- data/lib/puppet/pops/model/factory.rb +38 -4
- data/lib/puppet/pops/parser/egrammar.ra +2 -2
- data/lib/puppet/pops/parser/eparser.rb +2 -2
- data/lib/puppet/pops/parser/heredoc_support.rb +17 -7
- data/lib/puppet/pops/parser/lexer2.rb +6 -1
- data/lib/puppet/pops/parser/locator.rb +106 -86
- data/lib/puppet/pops/parser/parser_support.rb +11 -2
- data/lib/puppet/pops/types/type_mismatch_describer.rb +1 -1
- data/lib/puppet/pops/validation/checker4_0.rb +2 -2
- data/lib/puppet/provider/group/windows_adsi.rb +4 -1
- data/lib/puppet/provider/package/apt.rb +2 -2
- data/lib/puppet/provider/package/dnf.rb +2 -2
- data/lib/puppet/provider/package/gem.rb +2 -2
- data/lib/puppet/provider/package/openbsd.rb +2 -2
- data/lib/puppet/provider/package/pacman.rb +1 -2
- data/lib/puppet/provider/package/pip.rb +1 -2
- data/lib/puppet/provider/package/pip3.rb +1 -2
- data/lib/puppet/provider/package/pkg.rb +2 -4
- data/lib/puppet/provider/package/portage.rb +1 -2
- data/lib/puppet/provider/package/rpm.rb +1 -2
- data/lib/puppet/provider/package/sun.rb +2 -2
- data/lib/puppet/provider/package/windows.rb +2 -2
- data/lib/puppet/provider/package/yum.rb +1 -2
- data/lib/puppet/provider/package/zypper.rb +2 -2
- data/lib/puppet/provider/service/upstart.rb +16 -6
- data/lib/puppet/transaction/resource_harness.rb +1 -0
- data/lib/puppet/type/file.rb +6 -1
- data/lib/puppet/util/log.rb +7 -2
- data/lib/puppet/util/pidlock.rb +14 -1
- data/lib/puppet/util/windows/process.rb +73 -5
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +92 -92
- data/man/man5/puppet.conf.5 +2 -2
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +2 -2
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-ssl.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/unit/application_spec.rb +8 -1
- data/spec/unit/confine/false_spec.rb +27 -0
- data/spec/unit/confine/true_spec.rb +27 -0
- data/spec/unit/defaults_spec.rb +0 -14
- data/spec/unit/functions/group_by_spec.rb +40 -0
- data/spec/unit/functions/index_spec.rb +184 -0
- data/spec/unit/functions/partition_spec.rb +40 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +5 -0
- data/spec/unit/pops/parser/locator_spec.rb +45 -0
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +111 -15
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +9 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +7 -1
- data/spec/unit/transaction/resource_harness_spec.rb +26 -0
- data/spec/unit/util/execution_spec.rb +2 -2
- data/spec/unit/util/log_spec.rb +15 -0
- data/spec/unit/util/pidlock_spec.rb +21 -1
- metadata +13 -2
@@ -114,8 +114,17 @@ class Parser
|
|
114
114
|
pos = nil
|
115
115
|
if token != 0
|
116
116
|
file = value[:file]
|
117
|
-
|
118
|
-
|
117
|
+
locator = value.locator
|
118
|
+
if locator.is_a?(Puppet::Pops::Parser::Locator::SubLocator)
|
119
|
+
# The error occurs when doing sub-parsing and the token must be transformed
|
120
|
+
# Transpose the local offset, length to global "coordinates"
|
121
|
+
global_offset, _ = locator.to_global(value.offset, value.length)
|
122
|
+
line = locator.locator.line_for_offset(global_offset)
|
123
|
+
pos = locator.locator.pos_on_line(global_offset)
|
124
|
+
else
|
125
|
+
line = value[:line]
|
126
|
+
pos = value[:pos]
|
127
|
+
end
|
119
128
|
else
|
120
129
|
# At end of input, use what the lexer thinks is the source file
|
121
130
|
file = lexer.file
|
@@ -753,7 +753,7 @@ module Types
|
|
753
753
|
end
|
754
754
|
|
755
755
|
def describe_POptionalType(expected, original, actual, path)
|
756
|
-
return EMPTY_ARRAY if actual.is_a?(PUndefType)
|
756
|
+
return EMPTY_ARRAY if actual.is_a?(PUndefType) || expected.optional_type.nil?
|
757
757
|
internal_describe(expected.optional_type, original.is_a?(PTypeAliasType) ? original : expected, actual, path)
|
758
758
|
end
|
759
759
|
|
@@ -330,8 +330,8 @@ class Checker4_0 < Evaluator::LiteralEvaluator
|
|
330
330
|
end
|
331
331
|
|
332
332
|
def check_HeredocExpression(o)
|
333
|
-
# Only check static text in heredoc
|
334
|
-
expr = o.text_expr
|
333
|
+
# Only syntax check static text in heredoc during validation - dynamic text is validated by the evaluator.
|
334
|
+
expr = o.text_expr
|
335
335
|
if expr.is_a?(Model::LiteralString)
|
336
336
|
assert_external_syntax(nil, expr.value, o.syntax, o.text_expr)
|
337
337
|
end
|
@@ -67,7 +67,10 @@ Puppet::Type.type(:group).provide :windows_adsi do
|
|
67
67
|
|
68
68
|
def members
|
69
69
|
@members ||= Puppet::Util::Windows::ADSI::Group.name_sid_hash(group.members)
|
70
|
-
|
70
|
+
|
71
|
+
# @members.keys returns an array of SIDs. We need to convert those SIDs into
|
72
|
+
# names so that `puppet resource` prints the right output.
|
73
|
+
members_to_s(@members.keys).split(',')
|
71
74
|
end
|
72
75
|
|
73
76
|
def members=(members)
|
@@ -5,8 +5,8 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do
|
|
5
5
|
desc "Package management via `apt-get`.
|
6
6
|
|
7
7
|
This provider supports the `install_options` attribute, which allows command-line flags to be passed to apt-get.
|
8
|
-
These options should be specified as
|
9
|
-
|
8
|
+
These options should be specified as an array where each element is either a
|
9
|
+
string or a hash."
|
10
10
|
|
11
11
|
has_feature :versionable, :install_options
|
12
12
|
|
@@ -6,8 +6,8 @@ Puppet::Type.type(:package).provide :dnf, :parent => :yum do
|
|
6
6
|
feature is destructive and should be used with the utmost care.
|
7
7
|
|
8
8
|
This provider supports the `install_options` attribute, which allows command-line flags to be passed to dnf.
|
9
|
-
These options should be specified as
|
10
|
-
|
9
|
+
These options should be specified as an array where each element is either
|
10
|
+
a string or a hash."
|
11
11
|
|
12
12
|
has_feature :install_options, :versionable, :virtual_packages
|
13
13
|
|
@@ -12,8 +12,8 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
|
|
12
12
|
|
13
13
|
This provider supports the `install_options` and `uninstall_options` attributes,
|
14
14
|
which allow command-line flags to be passed to the gem command.
|
15
|
-
These options should be specified as
|
16
|
-
|
15
|
+
These options should be specified as an array where each element is either a
|
16
|
+
string or a hash."
|
17
17
|
|
18
18
|
has_feature :versionable, :install_options, :uninstall_options
|
19
19
|
|
@@ -6,8 +6,8 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
|
|
6
6
|
|
7
7
|
This provider supports the `install_options` and `uninstall_options`
|
8
8
|
attributes, which allow command-line flags to be passed to pkg_add and pkg_delete.
|
9
|
-
These options should be specified as
|
10
|
-
|
9
|
+
These options should be specified as an array where each element is either a
|
10
|
+
string or a hash."
|
11
11
|
|
12
12
|
commands :pkginfo => "pkg_info",
|
13
13
|
:pkgadd => "pkg_add",
|
@@ -6,8 +6,7 @@ Puppet::Type.type(:package).provide :pacman, :parent => Puppet::Provider::Packag
|
|
6
6
|
desc "Support for the Package Manager Utility (pacman) used in Archlinux.
|
7
7
|
|
8
8
|
This provider supports the `install_options` attribute, which allows command-line flags to be passed to pacman.
|
9
|
-
These options should be specified as a string
|
10
|
-
or an array where each element is either a string or a hash."
|
9
|
+
These options should be specified as an array where each element is either a string or a hash."
|
11
10
|
|
12
11
|
# If yaourt is installed, we can make use of it
|
13
12
|
def self.yaourt?
|
@@ -10,8 +10,7 @@ Puppet::Type.type(:package).provide :pip,
|
|
10
10
|
desc "Python packages via `pip`.
|
11
11
|
|
12
12
|
This provider supports the `install_options` attribute, which allows command-line flags to be passed to pip.
|
13
|
-
These options should be specified as a string
|
14
|
-
or an array where each element is either a string or a hash."
|
13
|
+
These options should be specified as an array where each element is either a string or a hash."
|
15
14
|
|
16
15
|
has_feature :installable, :uninstallable, :upgradeable, :versionable, :install_options
|
17
16
|
|
@@ -9,8 +9,7 @@ Puppet::Type.type(:package).provide :pip3,
|
|
9
9
|
desc "Python packages via `pip3`.
|
10
10
|
|
11
11
|
This provider supports the `install_options` attribute, which allows command-line flags to be passed to pip3.
|
12
|
-
These options should be specified as a string
|
13
|
-
or an array where each element is either a string or a hash."
|
12
|
+
These options should be specified as an array where each element is either a string or a hash."
|
14
13
|
|
15
14
|
has_feature :installable, :uninstallable, :upgradeable, :versionable, :install_options
|
16
15
|
|
@@ -4,10 +4,8 @@ Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package d
|
|
4
4
|
desc "OpenSolaris image packaging system. See pkg(5) for more information.
|
5
5
|
|
6
6
|
This provider supports the `install_options` attribute, which allows
|
7
|
-
command-line flags to be passed to pkg. These options should be specified
|
8
|
-
|
9
|
-
- as a hash (for example, {'--flag' => 'value'}), or
|
10
|
-
- as an array where each element is either a string or a hash."
|
7
|
+
command-line flags to be passed to pkg. These options should be specified as an
|
8
|
+
array where each element is either a string or a hash."
|
11
9
|
|
12
10
|
# https://docs.oracle.com/cd/E19963-01/html/820-6572/managepkgs.html
|
13
11
|
# A few notes before we start:
|
@@ -5,8 +5,7 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
|
|
5
5
|
desc "Provides packaging support for Gentoo's portage system.
|
6
6
|
|
7
7
|
This provider supports the `install_options` and `uninstall_options` attributes, which allows command-line
|
8
|
-
flags to be passed to emerge.
|
9
|
-
(e.g. {'--flag' => 'value'}), or an array where each element is either a string or a hash."
|
8
|
+
flags to be passed to emerge. These options should be specified as an array where each element is either a string or a hash."
|
10
9
|
|
11
10
|
has_features :install_options, :purgeable, :reinstallable, :uninstall_options, :versionable, :virtual_packages
|
12
11
|
|
@@ -7,8 +7,7 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr
|
|
7
7
|
|
8
8
|
This provider supports the `install_options` and `uninstall_options`
|
9
9
|
attributes, which allow command-line flags to be passed to rpm.
|
10
|
-
|
11
|
-
or an array where each element is either a string or a hash."
|
10
|
+
These options should be specified as an array where each element is either a string or a hash."
|
12
11
|
|
13
12
|
has_feature :versionable
|
14
13
|
has_feature :install_options
|
@@ -7,8 +7,8 @@ Puppet::Type.type(:package).provide :sun, :parent => Puppet::Provider::Package d
|
|
7
7
|
the packages you're managing.
|
8
8
|
|
9
9
|
This provider supports the `install_options` attribute, which allows command-line flags to be passed to pkgadd.
|
10
|
-
These options should be specified as
|
11
|
-
|
10
|
+
These options should be specified as an array where each element is either a string
|
11
|
+
or a hash."
|
12
12
|
|
13
13
|
commands :pkginfo => "/usr/bin/pkginfo",
|
14
14
|
:pkgadd => "/usr/sbin/pkgadd",
|
@@ -12,8 +12,8 @@ Puppet::Type.type(:package).provide(:windows, :parent => Puppet::Provider::Packa
|
|
12
12
|
|
13
13
|
This provider supports the `install_options` and `uninstall_options`
|
14
14
|
attributes, which allow command-line flags to be passed to the installer.
|
15
|
-
These options should be specified as
|
16
|
-
|
15
|
+
These options should be specified as an array where each element is either
|
16
|
+
a string or a hash.
|
17
17
|
|
18
18
|
If the executable requires special arguments to perform a silent install or
|
19
19
|
uninstall, then the appropriate arguments should be specified using the
|
@@ -6,8 +6,7 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
|
|
6
6
|
feature is destructive and should be used with the utmost care.
|
7
7
|
|
8
8
|
This provider supports the `install_options` attribute, which allows command-line flags to be passed to yum.
|
9
|
-
These options should be specified as a string
|
10
|
-
or an array where each element is either a string or a hash."
|
9
|
+
These options should be specified as an array where each element is either a string or a hash."
|
11
10
|
|
12
11
|
has_feature :install_options, :versionable, :virtual_packages
|
13
12
|
|
@@ -2,8 +2,8 @@ Puppet::Type.type(:package).provide :zypper, :parent => :rpm, :source => :rpm do
|
|
2
2
|
desc "Support for SuSE `zypper` package manager. Found in SLES10sp2+ and SLES11.
|
3
3
|
|
4
4
|
This provider supports the `install_options` attribute, which allows command-line flags to be passed to zypper.
|
5
|
-
These options should be specified as
|
6
|
-
|
5
|
+
These options should be specified as an array where each element is either a
|
6
|
+
string or a hash."
|
7
7
|
|
8
8
|
has_feature :versionable, :install_options, :virtual_packages
|
9
9
|
|
@@ -28,12 +28,22 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
|
|
28
28
|
# We only want to use upstart as our provider if the upstart daemon is running.
|
29
29
|
# This can be checked by running `initctl version --quiet` on a machine that has
|
30
30
|
# upstart installed.
|
31
|
-
confine :true =>
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
confine :true => lambda {
|
32
|
+
# Puppet::Util::Execution.execute does not currently work on jRuby.
|
33
|
+
# Unfortunately, since this confine is invoked whenever we check for
|
34
|
+
# provider suitability and since provider suitability is still checked
|
35
|
+
# on the master, this confine will still be invoked on the master. Thus
|
36
|
+
# to avoid raising an exception, we do an early return if we're running
|
37
|
+
# on jRuby.
|
38
|
+
next false if Puppet::Util::Platform.jruby?
|
39
|
+
|
40
|
+
begin
|
41
|
+
initctl('version', '--quiet')
|
42
|
+
true
|
43
|
+
rescue
|
44
|
+
false
|
45
|
+
end
|
46
|
+
}
|
37
47
|
|
38
48
|
# upstart developer haven't implemented initctl enable/disable yet:
|
39
49
|
# http://www.linuxplanet.com/linuxplanet/tutorials/7033/2/
|
@@ -161,6 +161,7 @@ class Puppet::Transaction::ResourceHarness
|
|
161
161
|
name = param.name.to_s
|
162
162
|
event.message ||= _("could not create change error message for %{name}") % { name: name }
|
163
163
|
event.calculate_corrective_change(@persistence.get_system_value(context.resource.ref, name))
|
164
|
+
event.message << ' (corrective)' if event.corrective_change
|
164
165
|
context.record(event)
|
165
166
|
event.send_log
|
166
167
|
context.synced_params << param.name
|
data/lib/puppet/type/file.rb
CHANGED
@@ -31,7 +31,12 @@ Puppet::Type.newtype(:file) do
|
|
31
31
|
|
32
32
|
**Autorequires:** If Puppet is managing the user or group that owns a
|
33
33
|
file, the file resource will autorequire them. If Puppet is managing any
|
34
|
-
parent directories of a file, the file resource
|
34
|
+
parent directories of a file, the file resource autorequires them.
|
35
|
+
|
36
|
+
Warning: Enabling `recurse` on directories containing large numbers of
|
37
|
+
files slows agent runs. To manage file attributes for many files,
|
38
|
+
consider using alternative methods such as the `chmod_r`, `chown_r`,
|
39
|
+
or `recursive_file_permissions` modules from the Forge."
|
35
40
|
|
36
41
|
feature :manages_symlinks,
|
37
42
|
"The provider can manage symbolic links."
|
data/lib/puppet/util/log.rb
CHANGED
@@ -60,7 +60,7 @@ class Puppet::Util::Log
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def self.close_all
|
63
|
-
destinations.keys.each { |dest|
|
63
|
+
@destinations.keys.each { |dest|
|
64
64
|
close(dest)
|
65
65
|
}
|
66
66
|
#TRANSLATORS "Log.close_all" is a method name and should not be translated
|
@@ -147,7 +147,12 @@ class Puppet::Util::Log
|
|
147
147
|
Puppet.log_exception(detail)
|
148
148
|
|
149
149
|
# If this was our only destination, then add the console back in.
|
150
|
-
|
150
|
+
if destinations.empty? && dest.intern != :console
|
151
|
+
newdestination(:console)
|
152
|
+
end
|
153
|
+
|
154
|
+
# Re-raise (end exit Puppet) because we could not set up logging correctly.
|
155
|
+
raise detail
|
151
156
|
end
|
152
157
|
end
|
153
158
|
|
data/lib/puppet/util/pidlock.rb
CHANGED
@@ -54,7 +54,20 @@ class Puppet::Util::Pidlock
|
|
54
54
|
begin
|
55
55
|
Process.kill(0, lock_pid)
|
56
56
|
rescue *errors
|
57
|
-
@lockfile.unlock
|
57
|
+
return @lockfile.unlock
|
58
|
+
end
|
59
|
+
|
60
|
+
# Ensure the process associated with this pid is our process. If
|
61
|
+
# not, we can unlock the lockfile. For now this is only done on
|
62
|
+
# POSIX and Windows platforms (PUP-9247).
|
63
|
+
if Puppet.features.posix?
|
64
|
+
procname = Puppet::Util::Execution.execute(["ps", "-p", lock_pid, "-o", "comm="]).strip
|
65
|
+
@lockfile.unlock unless procname =~ /puppet$/
|
66
|
+
elsif Puppet.features.microsoft_windows?
|
67
|
+
# On Windows, we're checking if the filesystem path name of the running
|
68
|
+
# process is our vendored ruby:
|
69
|
+
exe_path = Puppet::Util::Windows::Process::get_process_image_name_by_pid(lock_pid)
|
70
|
+
@lockfile.unlock unless exe_path =~ /Puppet\\puppet\\bin\\ruby.exe/
|
58
71
|
end
|
59
72
|
end
|
60
73
|
private :clear_if_stale
|
@@ -10,6 +10,10 @@ module Puppet::Util::Windows::Process
|
|
10
10
|
WAIT_INTERVAL = 200
|
11
11
|
# https://docs.microsoft.com/en-us/windows/desktop/ProcThread/process-creation-flags
|
12
12
|
CREATE_NO_WINDOW = 0x08000000
|
13
|
+
# https://docs.microsoft.com/en-us/windows/desktop/ProcThread/process-security-and-access-rights
|
14
|
+
PROCESS_QUERY_INFORMATION = 0x0400
|
15
|
+
# https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation
|
16
|
+
MAX_PATH_LENGTH = 32767
|
13
17
|
|
14
18
|
def execute(command, arguments, stdin, stdout, stderr)
|
15
19
|
create_args = {
|
@@ -24,12 +28,10 @@ module Puppet::Util::Windows::Process
|
|
24
28
|
if arguments[:suppress_window]
|
25
29
|
create_args[:creation_flags] = CREATE_NO_WINDOW
|
26
30
|
end
|
27
|
-
|
28
|
-
|
29
|
-
Dir.chdir(cwd) { Process.create(create_args) }
|
30
|
-
else
|
31
|
-
Process.create(create_args)
|
31
|
+
if arguments[:cwd]
|
32
|
+
create_args[:cwd] = arguments[:cwd]
|
32
33
|
end
|
34
|
+
Process.create(create_args)
|
33
35
|
end
|
34
36
|
module_function :execute
|
35
37
|
|
@@ -62,6 +64,26 @@ module Puppet::Util::Windows::Process
|
|
62
64
|
end
|
63
65
|
module_function :get_current_process
|
64
66
|
|
67
|
+
def open_process(desired_access, inherit_handle, process_id, &block)
|
68
|
+
phandle = nil
|
69
|
+
inherit = inherit_handle ? FFI::WIN32_TRUE : FFI::WIN32_FALSE
|
70
|
+
begin
|
71
|
+
phandle = OpenProcess(desired_access, inherit, process_id)
|
72
|
+
if phandle == FFI::Pointer::NULL_HANDLE
|
73
|
+
raise Puppet::Util::Windows::Error.new(
|
74
|
+
"OpenProcess(#{desired_access.to_s(8)}, #{inherit}, #{process_id})")
|
75
|
+
end
|
76
|
+
|
77
|
+
yield phandle
|
78
|
+
ensure
|
79
|
+
FFI::WIN32.CloseHandle(phandle) if phandle
|
80
|
+
end
|
81
|
+
|
82
|
+
# phandle has had CloseHandle called against it, so nothing to return
|
83
|
+
nil
|
84
|
+
end
|
85
|
+
module_function :open_process
|
86
|
+
|
65
87
|
def open_process_token(handle, desired_access, &block)
|
66
88
|
token_handle = nil
|
67
89
|
begin
|
@@ -97,6 +119,32 @@ module Puppet::Util::Windows::Process
|
|
97
119
|
end
|
98
120
|
module_function :with_process_token
|
99
121
|
|
122
|
+
def get_process_image_name_by_pid(pid)
|
123
|
+
image_name = ""
|
124
|
+
|
125
|
+
open_process(PROCESS_QUERY_INFORMATION, false, pid) do |phandle|
|
126
|
+
|
127
|
+
FFI::MemoryPointer.new(:dword, 1) do |exe_name_length_ptr|
|
128
|
+
# Add 1 for the null terminator, and UTF is 2 bytes/char:
|
129
|
+
max_path_length = (MAX_PATH_LENGTH + 1) * 2
|
130
|
+
exe_name_length_ptr.write_dword(max_path_length)
|
131
|
+
FFI::MemoryPointer.new(max_path_length) do |exe_name_ptr|
|
132
|
+
use_win32_path_format = 0
|
133
|
+
result = QueryFullProcessImageNameW(phandle, use_win32_path_format, exe_name_ptr, exe_name_length_ptr)
|
134
|
+
if result == FFI::WIN32_FALSE
|
135
|
+
raise Puppet::Util::Windows::Error.new(
|
136
|
+
"QueryFullProcessImageNameW(phandle, #{use_win32_path_format}, " +
|
137
|
+
"exe_name_ptr, #{max_path_length}")
|
138
|
+
end
|
139
|
+
image_name = exe_name_ptr.read_wide_string(MAX_PATH_LENGTH + 1)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
image_name
|
145
|
+
end
|
146
|
+
module_function :get_process_image_name_by_pid
|
147
|
+
|
100
148
|
def lookup_privilege_value(name, system_name = '', &block)
|
101
149
|
FFI::MemoryPointer.new(LUID.size) do |luid_ptr|
|
102
150
|
result = LookupPrivilegeValueW(
|
@@ -366,6 +414,16 @@ module Puppet::Util::Windows::Process
|
|
366
414
|
attach_function_private :SetEnvironmentVariableW,
|
367
415
|
[:lpcwstr, :lpcwstr], :win32_bool
|
368
416
|
|
417
|
+
# https://msdn.microsoft.com/en-us/library/windows/desktop/ms684320(v=vs.85).aspx
|
418
|
+
# HANDLE WINAPI OpenProcess(
|
419
|
+
# _In_ DWORD DesiredAccess,
|
420
|
+
# _In_ BOOL InheritHandle,
|
421
|
+
# _In_ DWORD ProcessId
|
422
|
+
# );
|
423
|
+
ffi_lib :kernel32
|
424
|
+
attach_function_private :OpenProcess,
|
425
|
+
[:dword, :win32_bool, :dword], :handle
|
426
|
+
|
369
427
|
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa379295(v=vs.85).aspx
|
370
428
|
# BOOL WINAPI OpenProcessToken(
|
371
429
|
# _In_ HANDLE ProcessHandle,
|
@@ -376,6 +434,16 @@ module Puppet::Util::Windows::Process
|
|
376
434
|
attach_function_private :OpenProcessToken,
|
377
435
|
[:handle, :dword, :phandle], :win32_bool
|
378
436
|
|
437
|
+
# https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-queryfullprocessimagenamew
|
438
|
+
# BOOL WINAPI QueryFullProcessImageName(
|
439
|
+
# _In_ HANDLE hProcess,
|
440
|
+
# _In_ DWORD dwFlags,
|
441
|
+
# _Out_ LPWSTR lpExeName,
|
442
|
+
# _In_ PDWORD lpdwSize,
|
443
|
+
# );
|
444
|
+
ffi_lib :kernel32
|
445
|
+
attach_function_private :QueryFullProcessImageNameW,
|
446
|
+
[:handle, :dword, :lpwstr, :pdword], :win32_bool
|
379
447
|
|
380
448
|
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa379261(v=vs.85).aspx
|
381
449
|
# typedef struct _LUID {
|
data/lib/puppet/version.rb
CHANGED