mixlib-shellout 3.0.4-universal-mingw32 → 3.0.7-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mixlib/shellout.rb +6 -2
- data/lib/mixlib/shellout/unix.rb +6 -2
- data/lib/mixlib/shellout/version.rb +1 -1
- data/lib/mixlib/shellout/windows.rb +9 -2
- data/lib/mixlib/shellout/windows/core_ext.rb +15 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 186751ae841fbb1870c136daba95716c5d0a8bbe4c4809e6ea72b8c2c6775159
|
4
|
+
data.tar.gz: 1d0ba8b3836b296a9c4ad3382f4e2cc4031e855d7258ac48eb1a1febfb70f1dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 156a332c90e03429eeaef5c4bda0c79f311d774846b8a4baf38a6ed8a8f801e139349862e37471d85dc8a4d5e5bcb9e45dea76cac251639d10eaeac5adea5c91
|
7
|
+
data.tar.gz: 37d380bf516a9c4f703094d35eb2aea69cde10fec676ed0d9eb80a2b82c20057205781d57d02b74165a9ddffaea36025af39ae609250738da6e9aaaabb05dc8b
|
data/lib/mixlib/shellout.rb
CHANGED
@@ -210,15 +210,17 @@ module Mixlib
|
|
210
210
|
# TODO migrate to shellout/unix.rb
|
211
211
|
def uid
|
212
212
|
return nil unless user
|
213
|
-
|
213
|
+
|
214
|
+
user.is_a?(Integer) ? user : Etc.getpwnam(user.to_s).uid
|
214
215
|
end
|
215
216
|
|
216
217
|
# The gid that the subprocess will switch to. If the group attribute is
|
217
218
|
# given as a group name, it is converted to a gid by Etc.getgrnam
|
218
219
|
# TODO migrate to shellout/unix.rb
|
219
220
|
def gid
|
220
|
-
return group.
|
221
|
+
return group.is_a?(Integer) ? group : Etc.getgrnam(group.to_s).gid if group
|
221
222
|
return Etc.getpwuid(uid).gid if using_login?
|
223
|
+
|
222
224
|
nil
|
223
225
|
end
|
224
226
|
|
@@ -231,6 +233,7 @@ module Mixlib
|
|
231
233
|
# results when the command exited with an unexpected status.
|
232
234
|
def format_for_exception
|
233
235
|
return "Command execution failed. STDOUT/STDERR suppressed for sensitive resource" if sensitive
|
236
|
+
|
234
237
|
msg = ""
|
235
238
|
msg << "#{@terminate_reason}\n" if @terminate_reason
|
236
239
|
msg << "---- Begin output of #{command} ----\n"
|
@@ -363,6 +366,7 @@ module Mixlib
|
|
363
366
|
if login && !user
|
364
367
|
raise InvalidCommandOption, "cannot set login without specifying a user"
|
365
368
|
end
|
369
|
+
|
366
370
|
super
|
367
371
|
end
|
368
372
|
end
|
data/lib/mixlib/shellout/unix.rb
CHANGED
@@ -53,14 +53,16 @@ module Mixlib
|
|
53
53
|
# to the user's secondary groups
|
54
54
|
def sgids
|
55
55
|
return nil unless using_login?
|
56
|
+
|
56
57
|
user_name = Etc.getpwuid(uid).name
|
57
|
-
all_seconderies.select { |g| g.mem.include?(user_name) }.map
|
58
|
+
all_seconderies.select { |g| g.mem.include?(user_name) }.map(&:gid)
|
58
59
|
end
|
59
60
|
|
60
61
|
# The environment variables that are deduced from simulating logon
|
61
62
|
# Only valid if login is used
|
62
63
|
def logon_environment
|
63
64
|
return {} unless using_login?
|
65
|
+
|
64
66
|
entry = Etc.getpwuid(uid)
|
65
67
|
# According to `man su`, the set fields are:
|
66
68
|
# $HOME, $SHELL, $USER, $LOGNAME, $PATH, and $IFS
|
@@ -269,6 +271,7 @@ module Mixlib
|
|
269
271
|
# Keep this unbuffered for now
|
270
272
|
def write_to_child_stdin
|
271
273
|
return unless input
|
274
|
+
|
272
275
|
child_stdin << input
|
273
276
|
child_stdin.close # Kick things off
|
274
277
|
end
|
@@ -337,7 +340,7 @@ module Mixlib
|
|
337
340
|
set_cwd
|
338
341
|
|
339
342
|
begin
|
340
|
-
command.
|
343
|
+
command.is_a?(Array) ? exec(*command, close_others: true) : exec(command, close_others: true)
|
341
344
|
|
342
345
|
raise "forty-two" # Should never get here
|
343
346
|
rescue Exception => e
|
@@ -365,6 +368,7 @@ module Mixlib
|
|
365
368
|
|
366
369
|
def reap_errant_child
|
367
370
|
return if attempt_reap
|
371
|
+
|
368
372
|
@terminate_reason = "Command exceeded allowed execution time, process terminated"
|
369
373
|
logger.error("Command exceeded allowed execution time, sending TERM") if logger
|
370
374
|
Process.kill(:TERM, child_pgid)
|
@@ -88,7 +88,7 @@ module Mixlib
|
|
88
88
|
#
|
89
89
|
# Start the process
|
90
90
|
#
|
91
|
-
process, profile, token = Process.
|
91
|
+
process, profile, token = Process.create3(create_process_args)
|
92
92
|
logger.debug(format_process(process, app_name, command_line, timeout)) if logger
|
93
93
|
begin
|
94
94
|
# Start pushing data into input
|
@@ -110,6 +110,7 @@ module Mixlib
|
|
110
110
|
unless GetExitCodeProcess(process.process_handle, exit_code)
|
111
111
|
raise get_last_error
|
112
112
|
end
|
113
|
+
|
113
114
|
@status = ThingThatLooksSortOfLikeAProcessStatus.new
|
114
115
|
@status.exitstatus = exit_code.unpack("l").first
|
115
116
|
|
@@ -170,8 +171,9 @@ module Mixlib
|
|
170
171
|
|
171
172
|
def consume_output(open_streams, stdout_read, stderr_read)
|
172
173
|
return false if open_streams.length == 0
|
174
|
+
|
173
175
|
ready = IO.select(open_streams, nil, nil, READ_WAIT_TIME)
|
174
|
-
return true
|
176
|
+
return true unless ready
|
175
177
|
|
176
178
|
if ready.first.include?(stdout_read)
|
177
179
|
begin
|
@@ -227,6 +229,7 @@ module Mixlib
|
|
227
229
|
# @return String
|
228
230
|
def combine_args(*args)
|
229
231
|
return args[0] if args.length == 1
|
232
|
+
|
230
233
|
args.map do |arg|
|
231
234
|
if arg =~ /[ \t\n\v"]/
|
232
235
|
arg = arg.gsub(/(\\*)"/, '\1\1\"') # interior quotes with N preceeding backslashes need 2N+1 backslashes
|
@@ -321,10 +324,12 @@ module Mixlib
|
|
321
324
|
return true unless quote
|
322
325
|
when "%"
|
323
326
|
return true if env
|
327
|
+
|
324
328
|
env = env_first_char = true
|
325
329
|
next
|
326
330
|
else
|
327
331
|
next unless env
|
332
|
+
|
328
333
|
if env_first_char
|
329
334
|
env_first_char = false
|
330
335
|
(env = false) && next if c !~ /[A-Za-z_]/
|
@@ -370,6 +375,7 @@ module Mixlib
|
|
370
375
|
|
371
376
|
def unsafe_process?(name, logger)
|
372
377
|
return false unless system_required_processes.include? name
|
378
|
+
|
373
379
|
logger.debug(
|
374
380
|
"A request to kill a critical system process - #{name} - was received and skipped."
|
375
381
|
)
|
@@ -383,6 +389,7 @@ module Mixlib
|
|
383
389
|
def kill_process_tree(pid, wmi, logger)
|
384
390
|
wmi.query("select * from Win32_Process where ParentProcessID=#{pid}").each do |instance|
|
385
391
|
next if unsafe_process?(instance.wmi_ole_object.name, logger)
|
392
|
+
|
386
393
|
child_pid = instance.wmi_ole_object.processid
|
387
394
|
kill_process_tree(child_pid, wmi, logger)
|
388
395
|
kill_process(instance, logger)
|
@@ -73,19 +73,19 @@ module Process::Functions
|
|
73
73
|
[:pointer], :bool
|
74
74
|
|
75
75
|
attach_pfunc :LoadUserProfileW,
|
76
|
-
|
76
|
+
%i{handle pointer}, :bool
|
77
77
|
|
78
78
|
attach_pfunc :UnloadUserProfile,
|
79
|
-
|
79
|
+
%i{handle handle}, :bool
|
80
80
|
|
81
81
|
ffi_lib :advapi32
|
82
82
|
|
83
83
|
attach_pfunc :LogonUserW,
|
84
|
-
|
84
|
+
%i{buffer_in buffer_in buffer_in ulong ulong pointer}, :bool
|
85
85
|
|
86
86
|
attach_pfunc :CreateProcessAsUserW,
|
87
|
-
|
88
|
-
|
87
|
+
%i{ulong buffer_in buffer_inout pointer pointer int
|
88
|
+
ulong buffer_in buffer_in pointer pointer}, :bool
|
89
89
|
|
90
90
|
ffi_lib :user32
|
91
91
|
|
@@ -93,7 +93,7 @@ module Process::Functions
|
|
93
93
|
[], :ulong
|
94
94
|
|
95
95
|
attach_pfunc :GetUserObjectInformationA,
|
96
|
-
|
96
|
+
%i{ulong uint buffer_out ulong pointer}, :bool
|
97
97
|
end
|
98
98
|
|
99
99
|
# Override Process.create to check for running in the Service window station and doing
|
@@ -109,7 +109,11 @@ module Process
|
|
109
109
|
class << self
|
110
110
|
|
111
111
|
def create(args)
|
112
|
-
|
112
|
+
create3(args).first
|
113
|
+
end
|
114
|
+
|
115
|
+
def create3(args)
|
116
|
+
unless args.is_a?(Hash)
|
113
117
|
raise TypeError, "hash keyword arguments expected"
|
114
118
|
end
|
115
119
|
|
@@ -137,6 +141,7 @@ module Process
|
|
137
141
|
unless valid_keys.include?(key)
|
138
142
|
raise ArgumentError, "invalid key '#{key}'"
|
139
143
|
end
|
144
|
+
|
140
145
|
hash[key] = val
|
141
146
|
end
|
142
147
|
|
@@ -149,6 +154,7 @@ module Process
|
|
149
154
|
unless valid_si_keys.include?(key)
|
150
155
|
raise ArgumentError, "invalid startup_info key '#{key}'"
|
151
156
|
end
|
157
|
+
|
152
158
|
si_hash[key] = val
|
153
159
|
end
|
154
160
|
end
|
@@ -367,6 +373,7 @@ module Process
|
|
367
373
|
unless GetProfileType(ptr)
|
368
374
|
raise SystemCallError.new("GetProfileType", FFI.errno)
|
369
375
|
end
|
376
|
+
|
370
377
|
ptr.read_uint
|
371
378
|
end
|
372
379
|
|
@@ -374,6 +381,7 @@ module Process
|
|
374
381
|
unless LoadUserProfileW(token, profile_ptr)
|
375
382
|
raise SystemCallError.new("LoadUserProfileW", FFI.errno)
|
376
383
|
end
|
384
|
+
|
377
385
|
true
|
378
386
|
end
|
379
387
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixlib-shellout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.7
|
5
5
|
platform: universal-mingw32
|
6
6
|
authors:
|
7
7
|
- Chef Software Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: win32-process
|