feat(su): use alternative privilege elevators when sudo is not available

When sudobin/custom wrapper is not available try the following in order:

- sudo
- doas
- pkexec
- su
This commit is contained in:
jguer
2021-08-31 01:40:43 +02:00
committed by J Guerreiro
parent e43c712c84
commit c8fcdeae5b
5 changed files with 212 additions and 11 deletions

10
main.go
View File

@@ -105,7 +105,7 @@ func main() {
config, err = settings.NewConfig(yayVersion)
if err != nil {
if str := err.Error(); str != "" {
fmt.Fprintln(os.Stderr, str)
text.Errorln(str)
}
ret = 1
@@ -117,7 +117,7 @@ func main() {
if err = config.ParseCommandLine(cmdArgs); err != nil {
if str := err.Error(); str != "" {
fmt.Fprintln(os.Stderr, str)
text.Errorln(str)
}
ret = 1
@@ -127,7 +127,7 @@ func main() {
if config.Runtime.SaveConfig {
if errS := config.Save(config.Runtime.ConfigPath); errS != nil {
fmt.Fprintln(os.Stderr, err)
text.Errorln(errS)
}
}
@@ -136,7 +136,7 @@ func main() {
config.Runtime.PacmanConf, useColor, err = initAlpm(cmdArgs, config.PacmanConf)
if err != nil {
if str := err.Error(); str != "" {
fmt.Fprintln(os.Stderr, str)
text.Errorln(str)
}
ret = 1
@@ -151,7 +151,7 @@ func main() {
dbExecutor, err := ialpm.NewExecutor(config.Runtime.PacmanConf)
if err != nil {
if str := err.Error(); str != "" {
fmt.Fprintln(os.Stderr, str)
text.Errorln(str)
}
ret = 1