From 1e335362057c593d32c875ef95f7e2644ff81ab1 Mon Sep 17 00:00:00 2001 From: kota kanbe Date: Thu, 18 Aug 2016 16:20:01 +0900 Subject: [PATCH] Fix yum update --changelog stalled when non-root ssh user on CentOS #150 --- scan/redhat.go | 5 +---- scan/sshutil.go | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scan/redhat.go b/scan/redhat.go index d10d3272..23e23b91 100644 --- a/scan/redhat.go +++ b/scan/redhat.go @@ -576,10 +576,7 @@ func (o *redhat) getAllChangelog(packInfoList models.PackageInfoList) (stdout st packageNames += fmt.Sprintf("%s ", packInfo.Name) } - command := "" - if o.ServerInfo.User == "root" { - command = "echo N | " - } + command := "echo N | " if 0 < len(config.Conf.HTTPProxy) { command += util.ProxyEnv() } diff --git a/scan/sshutil.go b/scan/sshutil.go index 1042a79a..7c38ec57 100644 --- a/scan/sshutil.go +++ b/scan/sshutil.go @@ -299,6 +299,7 @@ func getSSHLogger(log ...*logrus.Entry) *logrus.Entry { func decolateCmd(c conf.ServerInfo, cmd string, sudo bool) string { if sudo && c.User != "root" && !c.IsContainer() { cmd = fmt.Sprintf("sudo -S %s", cmd) + cmd = strings.Replace(cmd, "|", "| sudo ", -1) } if c.Family != "FreeBSD" {