mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
Hang on first sudo
Currently sudoloop is run in parallel with the rest of the code this causes the first sudo prompt to ask for a password while the code continues running. Instead hang on the first sudo, giving the chance for the user to enter a password then continue the loop in the background.
This commit is contained in:
parent
e0dc149c76
commit
d04ca15228
21
cmd.go
21
cmd.go
@ -266,15 +266,29 @@ cleanup:
|
||||
os.Exit(status)
|
||||
}
|
||||
|
||||
func sudoLoopBackground() {
|
||||
updateSudo()
|
||||
go sudoLoop()
|
||||
}
|
||||
|
||||
func sudoLoop() {
|
||||
for {
|
||||
updateSudo()
|
||||
time.Sleep(298 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func updateSudo() {
|
||||
for {
|
||||
cmd := exec.Command("sudo", "-v")
|
||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
time.Sleep(298 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +306,7 @@ func handleCmd() (err error) {
|
||||
}
|
||||
|
||||
if config.SudoLoop == true && cmdArgs.needRoot() {
|
||||
go sudoLoop()
|
||||
sudoLoopBackground()
|
||||
}
|
||||
|
||||
switch cmdArgs.op {
|
||||
@ -656,9 +670,8 @@ func numberMenu(pkgS []string, flags []string) (err error) {
|
||||
repoI = removeListFromList(repoNI, repoI)
|
||||
|
||||
if config.SudoLoop == true {
|
||||
go sudoLoop()
|
||||
sudoLoopBackground()
|
||||
}
|
||||
|
||||
arguments := makeArguments()
|
||||
arguments.addTarget(repoI...)
|
||||
arguments.addTarget(aurI...)
|
||||
|
Loading…
Reference in New Issue
Block a user