Skip to content

Commit 9ff946d

Browse files
authored
Merge pull request #9 from j-griffith/remove_cmd_arg_logging
Remove logging of args for failed iscsi cmds
2 parents 696aa76 + fca6aad commit 9ff946d

File tree

2 files changed

+5
-45
lines changed

2 files changed

+5
-45
lines changed

iscsi/iscsi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ func Connect(c Connector) (string, error) {
273273
// create db entry
274274
args := append(baseArgs, []string{"-I", iFace, "-o", "new"}...)
275275
debug.Printf("create the new record: %s\n", args)
276+
// Make sure we don't log the secrets
276277
err := CreateDBEntry(c.TargetIqn, p, iFace, c.DiscoverySecrets, c.SessionSecrets)
277278
if err != nil {
278279
debug.Printf("Error creating db entry: %s\n", err.Error())

iscsi/iscsiadm.go

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ package iscsi
33
import (
44
"bytes"
55
"fmt"
6-
"os/exec"
76
"strings"
8-
"syscall"
97
)
108

119
// Secrets provides optional iscsi security credentials (CHAP settings)
@@ -60,57 +58,18 @@ func iscsiCmd(args ...string) (string, error) {
6058
}
6159
}
6260

63-
iscsiadmDebug(args, string(stdout.Bytes()), iscsiadmError)
61+
iscsiadmDebug(string(stdout.Bytes()), iscsiadmError)
6462
return string(stdout.Bytes()), iscsiadmError
6563
}
6664

67-
func iscsiadmDebug(args []string, output string, cmdError error) {
65+
func iscsiadmDebug(output string, cmdError error) {
6866
debugOutput := strings.Replace(output, "\n", "\\n", -1)
69-
debug.Printf("Output of iscsiadm command: {{cmd: iscsiadm %s}, {output: %s}", args, debugOutput)
67+
debug.Printf("Output of iscsiadm command: {output: %s}", debugOutput)
7068
if cmdError != nil {
71-
debug.Printf("Error message returned from issiadm command: %s", cmdError.Error())
69+
debug.Printf("Error message returned from iscsiadm command: %s", cmdError.Error())
7270
}
7371
}
7472

75-
func iscsiCmdHide(args ...string) (string, error) {
76-
debug.Printf("Execute iscsiadm %s", args)
77-
var waitStatus syscall.WaitStatus
78-
var iscsiHelper = "iscsiadm"
79-
eStat := 0
80-
out := &bytes.Buffer{}
81-
cmdErr := &bytes.Buffer{}
82-
83-
c := execCommand(iscsiHelper, args...)
84-
c.Stdout = out
85-
c.Stderr = cmdErr
86-
iscsiadmErr := CmdError{}
87-
88-
if err := c.Run(); err != nil {
89-
if exitError, ok := err.(*exec.ExitError); ok {
90-
waitStatus = exitError.Sys().(syscall.WaitStatus)
91-
eStat = waitStatus.ExitStatus()
92-
}
93-
} else {
94-
waitStatus = c.ProcessState.Sys().(syscall.WaitStatus)
95-
eStat = waitStatus.ExitStatus()
96-
}
97-
if eStat != 0 || string(cmdErr.Bytes()) != "" {
98-
iscsiadmErr = CmdError{
99-
StdErr: string(cmdErr.Bytes()),
100-
ExitCode: eStat,
101-
CMD: iscsiHelper + " " + strings.Join(args, " "),
102-
}
103-
}
104-
if &iscsiadmErr != nil {
105-
debug.Printf("FUCK: %v\n", &iscsiadmErr)
106-
}
107-
debugOutput := strings.Replace(string(out.Bytes()), "\n", "\\n ", -1)
108-
debugStderr := strings.Replace(string(cmdErr.Bytes()), "\n", "\\n ", -1)
109-
110-
debug.Printf("Response from iscsiadm, {{output: %s}, {stderr: %s}, {exit-code: %d}}", debugOutput, debugStderr, eStat)
111-
return string(out.Bytes()), &iscsiadmErr
112-
}
113-
11473
// ListInterfaces returns a list of all iscsi interfaces configured on the node
11574
/// along with the raw output in Response.StdOut we add the convenience of
11675
// returning a list of entries found

0 commit comments

Comments
 (0)