sshkit 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/lib/sshkit/command.rb +4 -1
- data/lib/sshkit/version.rb +1 -1
- data/test/unit/test_command.rb +3 -3
- metadata +1 -1
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,13 @@
|
|
3
3
|
This file is written in reverse chronological order, newer releases will
|
4
4
|
appear at the top.
|
5
5
|
|
6
|
+
## 0.0.13
|
7
|
+
|
8
|
+
* Correctly quote `as(user)` commands, previously it would expand to:
|
9
|
+
`sudo su user -c /usr/bin/env echo "Hello World"`, in which the command to
|
10
|
+
run was taken as simply `/usr/bin/env`. By quoting all arguments it should
|
11
|
+
now work as expected. `sudo su user -c "/usr/bin/env echo \""Hello World\""`
|
12
|
+
|
6
13
|
## 0.0.12
|
7
14
|
|
8
15
|
* Also print anything the program wrote to stdout when the exit status is
|
data/lib/sshkit/command.rb
CHANGED
@@ -142,7 +142,7 @@ module SSHKit
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
if options[:user]
|
145
|
-
cs << "sudo su #{options[:user]} -c "
|
145
|
+
cs << "sudo su #{options[:user]} -c \""
|
146
146
|
end
|
147
147
|
if options[:run_in_background]
|
148
148
|
cs << 'nohup '
|
@@ -155,6 +155,9 @@ module SSHKit
|
|
155
155
|
if options[:run_in_background]
|
156
156
|
cs << ' > /dev/null &'
|
157
157
|
end
|
158
|
+
if options[:user]
|
159
|
+
cs << "\""
|
160
|
+
end
|
158
161
|
if options[:env]
|
159
162
|
cs << ' )'
|
160
163
|
end
|
data/lib/sshkit/version.rb
CHANGED
data/test/unit/test_command.rb
CHANGED
@@ -78,7 +78,7 @@ module SSHKit
|
|
78
78
|
|
79
79
|
def test_working_as_a_given_user
|
80
80
|
c = Command.new(:whoami, user: :anotheruser)
|
81
|
-
assert_equal "sudo su anotheruser -c /usr/bin/env whoami", String(c)
|
81
|
+
assert_equal "sudo su anotheruser -c \"/usr/bin/env whoami\"", String(c)
|
82
82
|
end
|
83
83
|
|
84
84
|
def test_backgrounding_a_task
|
@@ -88,12 +88,12 @@ module SSHKit
|
|
88
88
|
|
89
89
|
def test_backgrounding_a_task_as_a_given_user
|
90
90
|
c = Command.new(:sleep, 15, run_in_background: true, user: :anotheruser)
|
91
|
-
assert_equal "sudo su anotheruser -c nohup /usr/bin/env sleep 15 > /dev/null
|
91
|
+
assert_equal "sudo su anotheruser -c \"nohup /usr/bin/env sleep 15 > /dev/null &\"", String(c)
|
92
92
|
end
|
93
93
|
|
94
94
|
def test_backgrounding_a_task_as_a_given_user_with_env
|
95
95
|
c = Command.new(:sleep, 15, run_in_background: true, user: :anotheruser, env: {a: :b})
|
96
|
-
assert_equal "( A=b sudo su anotheruser -c nohup /usr/bin/env sleep 15 > /dev/null
|
96
|
+
assert_equal "( A=b sudo su anotheruser -c \"nohup /usr/bin/env sleep 15 > /dev/null &\" )", String(c)
|
97
97
|
end
|
98
98
|
|
99
99
|
def test_complete?
|