mirror of https://github.com/apache/jclouds.git
Fixes Run SSH script for passwords with special characters (as parentheses)
This commit is contained in:
parent
6edb99c685
commit
889a7f1d6f
|
@ -112,7 +112,8 @@ public class RunScriptOnNodeUsingSsh implements RunScriptOnNode {
|
||||||
public String execAsRoot(String command) {
|
public String execAsRoot(String command) {
|
||||||
if (node.getCredentials().identity.equals("root")) {
|
if (node.getCredentials().identity.equals("root")) {
|
||||||
} else if (node.getCredentials().shouldAuthenticateSudo()) {
|
} else if (node.getCredentials().shouldAuthenticateSudo()) {
|
||||||
command = String.format("sudo -S sh <<'%s'\n%s\n%s%s\n", MARKER, node.getCredentials().getOptionalPassword().get(), command, MARKER);
|
command = String.format("sudo -S sh <<'%s'\n'%s'\n%s%s\n", MARKER, node.getCredentials().getOptionalPassword
|
||||||
|
().get(), command, MARKER);
|
||||||
} else {
|
} else {
|
||||||
command = String.format("sudo sh <<'%s'\n%s%s\n", MARKER, command, MARKER);
|
command = String.format("sudo sh <<'%s'\n%s%s\n", MARKER, command, MARKER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class RunScriptOnNodeUsingSshTest {
|
||||||
expect(sshClient.getUsername()).andReturn("tester");
|
expect(sshClient.getUsername()).andReturn("tester");
|
||||||
expect(sshClient.getHostAddress()).andReturn("somewhere.example.com");
|
expect(sshClient.getHostAddress()).andReturn("somewhere.example.com");
|
||||||
expect(
|
expect(
|
||||||
sshClient.exec("sudo -S sh <<'RUN_SCRIPT_AS_ROOT_SSH'\n" + "testpassword!\n" + "echo $USER\n"
|
sshClient.exec("sudo -S sh <<'RUN_SCRIPT_AS_ROOT_SSH'\n" + "'testpassword!'\n" + "echo $USER\n"
|
||||||
+ "echo $USER\n" + "RUN_SCRIPT_AS_ROOT_SSH\n")).andReturn(new ExecResponse("root\nroot\n", null, 0));
|
+ "echo $USER\n" + "RUN_SCRIPT_AS_ROOT_SSH\n")).andReturn(new ExecResponse("root\nroot\n", null, 0));
|
||||||
sshClient.disconnect();
|
sshClient.disconnect();
|
||||||
replay(sshClient);
|
replay(sshClient);
|
||||||
|
|
Loading…
Reference in New Issue