fix: 解决网站设置用户/组报错的问题 (#710)

This commit is contained in:
zhengkunwang223
2023-04-19 11:17:00 +08:00
committed by GitHub
parent 6cee4bfe7c
commit a0b820649e
2 changed files with 18 additions and 1 deletions

View File

@@ -88,3 +88,14 @@ func Execf(cmdStr string, a ...interface{}) (string, error) {
}
return stdout.String(), nil
}
func HasNoPasswordSudo() bool {
cmd := exec.Command("sudo", "-v")
err := cmd.Run()
if err != nil {
return false
}
cmd2 := exec.Command("sudo", "-n", "ls")
err2 := cmd2.Run()
return err2 == nil
}