Check whether echo is executable with nopasswd

This commit is contained in:
knqyf263
2017-01-22 23:15:25 +09:00
parent 8fe34c8474
commit f62d869d27

View File

@@ -97,7 +97,11 @@ func detectRedhat(c config.ServerInfo) (itsMe bool, red osTypeInterface) {
}
func (o *redhat) checkIfSudoNoPasswd() error {
r := o.exec("yum --version", o.sudo())
cmd := "yum --version"
if o.Distro.Family == "centos" {
cmd = "echo N | " + cmd
}
r := o.exec(cmd, o.sudo())
if !r.isSuccess() {
o.log.Errorf("sudo error on %s", r)
return fmt.Errorf("Failed to sudo: %s", r)