Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"math"
"os"
"os/exec"
"regexp"
"strconv"
Expand Down Expand Up @@ -261,8 +262,11 @@ func ipmitoolConfig(config IPMIConfig) []string {
if config.User != "" {
args = append(args, "-U", config.User)
}
// Using -P for the password is bad, since it would show up in the
// process info (ps). Instead use -E and provide the password via
// environment variable IPMITOOL_PASSWORD
if config.Password != "" {
args = append(args, "-P", config.Password)
args = append(args, "-E")
}
if config.Timeout != 0 {
args = append(args, "-N", strconv.FormatInt(config.Timeout, 36))
Expand Down Expand Up @@ -299,6 +303,16 @@ func ipmitoolOutput(target ipmiTarget, command string) (string, error) {
cmdConfig = append(cmdConfig, cmdCommand...)

cmd := exec.Command("ipmitool", cmdConfig...)

// Using -P for the password is bad, since it would show up in the
// process info (ps). Instead use -E and provide the password via
// environment variable IPMITOOL_PASSWORD
if target.config.Password != "" {
passwordEnv := "IPMITOOL_PASSWORD=" + target.config.Password
newEnv := append(os.Environ(), passwordEnv)
cmd.Env = newEnv
}

var outBuf bytes.Buffer
cmd.Stdout = &outBuf
cmd.Stderr = &outBuf
Expand Down