From d76f1fedd0a4e66a8346fe5f15616eb8fbdc9923 Mon Sep 17 00:00:00 2001 From: HikariKnight <2557889+HikariKnight@users.noreply.github.com> Date: Tue, 11 Apr 2023 08:58:36 +0200 Subject: [PATCH] update the elevate command, add missing error text --- pkg/command/command.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/command/command.go b/pkg/command/command.go index 2070c1b..4c4698f 100644 --- a/pkg/command/command.go +++ b/pkg/command/command.go @@ -42,11 +42,11 @@ func Elevate(password string) { cmd := exec.Command("sudo", "-Sk", "--", "echo") // Wait for 500ms, if the password is correct, sudo will return immediately - cmd.WaitDelay = 500 * time.Millisecond + cmd.WaitDelay = 1000 * time.Millisecond // Open STDIN stdin, err := cmd.StdinPipe() - errorcheck.ErrorCheck(err, "Failed to get sudo STDIN") + errorcheck.ErrorCheck(err, "\nFailed to get sudo STDIN") // Start the authentication cmd.Start() @@ -54,11 +54,12 @@ func Elevate(password string) { // Get the passed password pw, _ := base64.StdEncoding.DecodeString(password) _, err = stdin.Write([]byte(string(pw) + "\n")) - errorcheck.ErrorCheck(err, "Failed at typing to STDIN") + errorcheck.ErrorCheck(err, "\nFailed at typing to STDIN") // Clear the password pw = nil stdin.Close() + // Wait for the sudo prompt (If the correct password was given, it will not stay behind) err = cmd.Wait() - errorcheck.ErrorCheck(err) + errorcheck.ErrorCheck(err, "\nError, password given was wrong") }