Merge pull request #298 from knqyf263/check_echo

Check whether echo is executable with nopasswd
This commit is contained in:
Kota Kanbe
2017-01-23 17:42:17 +09:00
committed by GitHub

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)