Skip to content

Commit

Permalink
Merge 0521bfe into e9f3e2f
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasundhara Jagdale committed Jun 11, 2019
2 parents e9f3e2f + 0521bfe commit f2e0c00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/train/extras/command_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,16 @@ class CommandWrapper
include_options WindowsCommand

def self.load(transport, options)
if transport.os.unix?
if transport.platform.unix?
return nil unless LinuxCommand.active?(options)
res = LinuxCommand.new(transport, options)
verification_res = res.verify
if verification_res
msg, reason = verification_res
raise Train::UserError.new("Sudo failed: #{msg}", reason)
raise Train::UserError, "Sudo failed: #{msg}", reason
end
res
elsif transport.os.windows?
elsif transport.platform.windows?
res = WindowsCommand.new(transport, options)
res
end
Expand Down
6 changes: 6 additions & 0 deletions lib/train/platforms/detect/helpers/os_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def unix_file_exist?(path)

def command_output(cmd)
res = @backend.run_command(cmd).stdout
# When you try to execute command using ssh connction as root user and you have provided ssh user identity file
# it gives standard output to login as authorised user other than root. To show this standard ouput as an error
# to user we are matching the string of stdout and raising the error here so that user gets exact information.
if @backend.class.to_s == "Train::Transports::SSH::Connection" && res =~ /Please login as the user/
raise Train::UserError, "SSHFailed: #{res}"
end
res.strip! unless res.nil?
res
end
Expand Down

0 comments on commit f2e0c00

Please sign in to comment.