Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use --decode on base64 command to maintain compatibility with Darwin. #137

Merged
merged 2 commits into from
Aug 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/train/extras/command_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def build_prefix

unless @sudo_password.nil?
b64pw = Base64.strict_encode64(@sudo_password + "\n")
res = "echo #{b64pw} | base64 -d | #{res}-S "
res = "echo #{b64pw} | base64 --decode | #{res}-S "
end

res << @sudo_options.to_s + ' ' unless @sudo_options.nil?
Expand Down
4 changes: 2 additions & 2 deletions test/unit/extras/command_wrapper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
pw = rand.to_s
lc = cls.new(backend, { sudo: true, sudo_password: pw })
bpw = Base64.strict_encode64(pw + "\n")
lc.run(cmd).must_equal "echo #{bpw} | base64 -d | sudo -S #{cmd}"
lc.run(cmd).must_equal "echo #{bpw} | base64 --decode | sudo -S #{cmd}"
end

it 'wraps commands in sudo_command instead of sudo' do
Expand All @@ -57,7 +57,7 @@
sudo_command = rand.to_s
lc = cls.new(backend, { sudo: true, sudo_command: sudo_command, sudo_password: pw })
bpw = Base64.strict_encode64(pw + "\n")
lc.run(cmd).must_equal "echo #{bpw} | base64 -d | #{sudo_command} -S #{cmd}"
lc.run(cmd).must_equal "echo #{bpw} | base64 --decode | #{sudo_command} -S #{cmd}"
end
end

Expand Down