mixlib-shellout 3.0.4-universal-mingw32 → 3.0.7-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68567052a253b4c6bba0f3ff4c884402a41dd3175a00a3a4cef1d9fab8ca753a
4
- data.tar.gz: ca9b2511628cb6655397abf24ea39a9d49a7c72f5550708e1daa2fe553328e91
3
+ metadata.gz: 186751ae841fbb1870c136daba95716c5d0a8bbe4c4809e6ea72b8c2c6775159
4
+ data.tar.gz: 1d0ba8b3836b296a9c4ad3382f4e2cc4031e855d7258ac48eb1a1febfb70f1dc
5
5
  SHA512:
6
- metadata.gz: 215b9612e24919b285530b202cb3e62ab27436f82fb5cb95efc0bccfc4538794800c57c88a66cfab978479c3718d5b9d5fa40de43833fd05c61a8a769831c571
7
- data.tar.gz: 40458ab0286b067c4811be58fa4ad4c93568f25c5ca036137023690588c0b65e84f2f8dd034e0b0dc1f7070113305a6a262242207cab0eb8f9c53b38ffa125fe
6
+ metadata.gz: 156a332c90e03429eeaef5c4bda0c79f311d774846b8a4baf38a6ed8a8f801e139349862e37471d85dc8a4d5e5bcb9e45dea76cac251639d10eaeac5adea5c91
7
+ data.tar.gz: 37d380bf516a9c4f703094d35eb2aea69cde10fec676ed0d9eb80a2b82c20057205781d57d02b74165a9ddffaea36025af39ae609250738da6e9aaaabb05dc8b
@@ -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
- user.kind_of?(Integer) ? user : Etc.getpwnam(user.to_s).uid
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.kind_of?(Integer) ? group : Etc.getgrnam(group.to_s).gid if 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
@@ -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 { |g| g.gid }
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.kind_of?(Array) ? exec(*command, close_others: true) : exec(command, close_others: true)
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)
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class ShellOut
3
- VERSION = "3.0.4".freeze
3
+ VERSION = "3.0.7".freeze
4
4
  end
5
5
  end
@@ -88,7 +88,7 @@ module Mixlib
88
88
  #
89
89
  # Start the process
90
90
  #
91
- process, profile, token = Process.create(create_process_args)
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 if ! ready
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
- [:handle, :pointer], :bool
76
+ %i{handle pointer}, :bool
77
77
 
78
78
  attach_pfunc :UnloadUserProfile,
79
- [:handle, :handle], :bool
79
+ %i{handle handle}, :bool
80
80
 
81
81
  ffi_lib :advapi32
82
82
 
83
83
  attach_pfunc :LogonUserW,
84
- [:buffer_in, :buffer_in, :buffer_in, :ulong, :ulong, :pointer], :bool
84
+ %i{buffer_in buffer_in buffer_in ulong ulong pointer}, :bool
85
85
 
86
86
  attach_pfunc :CreateProcessAsUserW,
87
- [:ulong, :buffer_in, :buffer_inout, :pointer, :pointer, :int,
88
- :ulong, :buffer_in, :buffer_in, :pointer, :pointer], :bool
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
- [:ulong, :uint, :buffer_out, :ulong, :pointer], :bool
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
- unless args.kind_of?(Hash)
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
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-06-06 00:00:00.000000000 Z
11
+ date: 2019-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: win32-process