Skip to content

Commit

Permalink
Escape quotes in password
Browse files Browse the repository at this point in the history
  • Loading branch information
jpm-canonical committed Aug 30, 2024
1 parent 45949a3 commit 02a16b0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/thread_tests/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ func remote_exec(t *testing.T, command string) string {

// Remote commands that require sudo might ask for the password. Always pass it in. See https://stackoverflow.com/a/11955358
if strings.HasPrefix(command, "sudo ") {
command = command[5:] // remove "sudo "
command = "echo \"" + remotePassword + "\" | sudo -S " + command
command = command[5:]
escapedPassword := strings.Replace(remotePassword, "\"", "\\\"", -1)
command = "echo \"" + escapedPassword + "\" | sudo -S " + command
}

if SSHClient == nil {
Expand Down

0 comments on commit 02a16b0

Please sign in to comment.