summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-06-20 12:24:46 -0700
committerGitHub <noreply@github.com>2017-06-20 12:24:46 -0700
commit2d3ca5cd7bfc119b463eaf3b331296c2e370c2de (patch)
treedc0ecd2901c28379e63cbd3294f5a5d81855410a
parent0455024df6b737e959fc7c2129aafc8cf4fddc88 (diff)
parentcd41c110238cd694f2ded6a0c2535e19ea8034c4 (diff)
downloadmixlib-shellout-2d3ca5cd7bfc119b463eaf3b331296c2e370c2de.tar.gz
Merge pull request #146 from chef/lcg/chefstyle
fix chefstyle offenses
-rw-r--r--lib/mixlib/shellout.rb2
-rw-r--r--lib/mixlib/shellout/unix.rb24
-rw-r--r--lib/mixlib/shellout/windows.rb26
3 files changed, 27 insertions, 25 deletions
diff --git a/lib/mixlib/shellout.rb b/lib/mixlib/shellout.rb
index c9f2fa1..ca1cd22 100644
--- a/lib/mixlib/shellout.rb
+++ b/lib/mixlib/shellout.rb
@@ -212,7 +212,7 @@ module Mixlib
def gid
return group.kind_of?(Integer) ? group : Etc.getgrnam(group.to_s).gid if group
return Etc.getpwuid(uid).gid if using_login?
- return nil
+ nil
end
def timeout
diff --git a/lib/mixlib/shellout/unix.rb b/lib/mixlib/shellout/unix.rb
index 238273c..90e63e9 100644
--- a/lib/mixlib/shellout/unix.rb
+++ b/lib/mixlib/shellout/unix.rb
@@ -32,7 +32,7 @@ module Mixlib
# Whether we're simulating a login shell
def using_login?
- return login && user
+ login && user
end
# Helper method for sgids
@@ -43,7 +43,7 @@ module Mixlib
ret << g
end
Etc.endgrent
- return ret
+ ret
end
# The secondary groups that the subprocess will switch to.
@@ -68,7 +68,7 @@ module Mixlib
# Merges the two environments for the process
def process_environment
- logon_environment.merge(self.environment)
+ logon_environment.merge(environment)
end
# Run the command, writing the command's standard out and standard error
@@ -351,16 +351,14 @@ module Mixlib
# If it's there, un-marshal it and raise. If it's not there,
# assume everything went well.
def propagate_pre_exec_failure
- begin
- attempt_buffer_read until child_process_status.eof?
- e = Marshal.load(@process_status)
- raise(Exception === e ? e : "unknown failure: #{e.inspect}")
- rescue ArgumentError # If we get an ArgumentError error, then the exec was successful
- true
- ensure
- child_process_status.close
- open_pipes.delete(child_process_status)
- end
+ attempt_buffer_read until child_process_status.eof?
+ e = Marshal.load(@process_status)
+ raise(Exception === e ? e : "unknown failure: #{e.inspect}")
+ rescue ArgumentError # If we get an ArgumentError error, then the exec was successful
+ true
+ ensure
+ child_process_status.close
+ open_pipes.delete(child_process_status)
end
def reap_errant_child
diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb
index 5f6058d..adb6583 100644
--- a/lib/mixlib/shellout/windows.rb
+++ b/lib/mixlib/shellout/windows.rb
@@ -54,7 +54,7 @@ module Mixlib
#
# Set cwd, environment, appname, etc.
#
- app_name, command_line = command_to_run(self.command)
+ app_name, command_line = command_to_run(command)
create_process_args = {
:app_name => app_name,
:command_line => command_line,
@@ -180,7 +180,7 @@ module Mixlib
end
end
- return true
+ true
end
def command_to_run(command)
@@ -278,7 +278,7 @@ module Mixlib
env = false if c !~ /[A-Za-z1-9_]/
end
end
- return false
+ false
end
# FIXME: reduce code duplication with chef/chef
@@ -337,16 +337,20 @@ module Mixlib
def kill_process(instance, logger)
child_pid = instance.wmi_ole_object.processid
- logger.debug([
- "killing child process #{child_pid}::",
- "#{instance.wmi_ole_object.Name} of parent #{pid}",
- ].join) if logger
+ if logger
+ logger.debug([
+ "killing child process #{child_pid}::",
+ "#{instance.wmi_ole_object.Name} of parent #{pid}",
+ ].join)
+ end
Process.kill(:KILL, instance.wmi_ole_object.processid)
rescue Errno::EIO, SystemCallError
- logger.debug([
- "Failed to kill child process #{child_pid}::",
- "#{instance.wmi_ole_object.Name} of parent #{pid}",
- ].join) if logger
+ if logger
+ logger.debug([
+ "Failed to kill child process #{child_pid}::",
+ "#{instance.wmi_ole_object.Name} of parent #{pid}",
+ ].join)
+ end
end
def format_process(process, app_name, command_line, timeout)