From 02a16b02ec7aca469346d2ce4942a404df87b199 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Fri, 30 Aug 2024 10:54:46 +0200 Subject: [PATCH] Escape quotes in password --- tests/thread_tests/remote.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/thread_tests/remote.go b/tests/thread_tests/remote.go index 82c0919..2441e18 100644 --- a/tests/thread_tests/remote.go +++ b/tests/thread_tests/remote.go @@ -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 {