mirror of
https://github.com/HikariKnight/quickpassthrough.git
synced 2025-05-12 22:26:12 -04:00
update the elevate command, add missing error text
This commit is contained in:
parent
7b8923f68e
commit
d76f1fedd0
1 changed files with 5 additions and 4 deletions
|
@ -42,11 +42,11 @@ func Elevate(password string) {
|
||||||
cmd := exec.Command("sudo", "-Sk", "--", "echo")
|
cmd := exec.Command("sudo", "-Sk", "--", "echo")
|
||||||
|
|
||||||
// Wait for 500ms, if the password is correct, sudo will return immediately
|
// Wait for 500ms, if the password is correct, sudo will return immediately
|
||||||
cmd.WaitDelay = 500 * time.Millisecond
|
cmd.WaitDelay = 1000 * time.Millisecond
|
||||||
|
|
||||||
// Open STDIN
|
// Open STDIN
|
||||||
stdin, err := cmd.StdinPipe()
|
stdin, err := cmd.StdinPipe()
|
||||||
errorcheck.ErrorCheck(err, "Failed to get sudo STDIN")
|
errorcheck.ErrorCheck(err, "\nFailed to get sudo STDIN")
|
||||||
|
|
||||||
// Start the authentication
|
// Start the authentication
|
||||||
cmd.Start()
|
cmd.Start()
|
||||||
|
@ -54,11 +54,12 @@ func Elevate(password string) {
|
||||||
// Get the passed password
|
// Get the passed password
|
||||||
pw, _ := base64.StdEncoding.DecodeString(password)
|
pw, _ := base64.StdEncoding.DecodeString(password)
|
||||||
_, err = stdin.Write([]byte(string(pw) + "\n"))
|
_, 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
|
// Clear the password
|
||||||
pw = nil
|
pw = nil
|
||||||
stdin.Close()
|
stdin.Close()
|
||||||
|
|
||||||
|
// Wait for the sudo prompt (If the correct password was given, it will not stay behind)
|
||||||
err = cmd.Wait()
|
err = cmd.Wait()
|
||||||
errorcheck.ErrorCheck(err)
|
errorcheck.ErrorCheck(err, "\nError, password given was wrong")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue