Exemple #1
0
func (o *redhat) getChangelog(packageNames string) (stdout string, err error) {
	command := ""
	if o.ServerInfo.User == "root" {
		command = "echo N | "
	}
	if 0 < len(config.Conf.HTTPProxy) {
		command += util.ProxyEnv()
	}

	// yum update --changelog doesn't have --color option.
	command += fmt.Sprintf(" yum update --changelog %s | grep CVE", packageNames)

	r := o.ssh(command, sudo)
	if !r.isSuccess(0, 1) {
		return "", fmt.Errorf(
			"Failed to get changelog. status: %d, stdout: %s, stderr: %s",
			r.ExitStatus, r.Stdout, r.Stderr)
	}
	return r.Stdout, nil
}
Exemple #2
0
// CentOS
func (o *redhat) getAllChangelog(packInfoList models.PackageInfoList) (stdout string, err error) {
	packageNames := ""
	for _, packInfo := range packInfoList {
		packageNames += fmt.Sprintf("%s ", packInfo.Name)
	}

	command := ""
	if 0 < len(config.Conf.HTTPProxy) {
		command += util.ProxyEnv()
	}

	yumopts := ""
	if o.getServerInfo().Enablerepo != "" {
		yumopts = " --enablerepo=" + o.getServerInfo().Enablerepo
	}
	if config.Conf.SkipBroken {
		yumopts += " --skip-broken"
	}

	// CentOS 5 does not have --assumeno option.
	majorVersion, _ := o.Distro.MajorVersion()
	if majorVersion < 6 {
		command = "echo N | " + command
	} else {
		yumopts += " --assumeno"
	}

	// yum update --changelog doesn't have --color option.
	command += fmt.Sprintf(" LANGUAGE=en_US.UTF-8 yum %s --changelog update ", yumopts) + packageNames

	r := o.exec(command, sudo)
	if !r.isSuccess(0, 1) {
		return "", fmt.Errorf(
			"Failed to get changelog. status: %d, stdout: %s, stderr: %s",
			r.ExitStatus, r.Stdout, r.Stderr)
	}
	return r.Stdout, nil
}