Skip to content

Commit 097b743

Browse files
committed
move logging of cmd.SysProcAttr.CmdLine to the windows specific files, unixes do not have it
1 parent ed04636 commit 097b743

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

pkg/snclient/snclient.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,14 +1368,8 @@ func (snc *Agent) MakeCmd(ctx context.Context, command string) (*exec.Cmd, error
13681368
return nil, err
13691369
case cmd.Args != nil:
13701370
log.Tracef("command object:\n path: %s\n args: %v\n dir: %s\n workingDirectory: %s\n SysProcAttr: %#v\n", cmd.Path, cmd.Args, cmd.Dir, workingDirectory, cmd.SysProcAttr)
1371-
if cmd.SysProcAttr != nil {
1372-
log.Tracef("cmd.SysProcAttr.CmdLine: %s", cmd.SysProcAttr.CmdLine)
1373-
}
13741371
default:
13751372
log.Tracef("command object:\n path: %s\n args: (none)\n dir: %s\n workingDirectory: %s\n SysProcAttr: %#v\n", cmd.Path, cmd.Dir, workingDirectory, cmd.SysProcAttr)
1376-
if cmd.SysProcAttr != nil {
1377-
log.Tracef("cmd.SysProcAttr.CmdLine: %s", cmd.SysProcAttr.CmdLine)
1378-
}
13791373
}
13801374

13811375
return cmd, err

pkg/snclient/snclient_windows.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ func (snc *Agent) makeCmd(ctx context.Context, command string) (*exec.Cmd, error
262262
cmd := execCommandContext(ctx, "powershell", env)
263263
cmd.SysProcAttr.CmdLine = fmt.Sprintf(`%s -command %s; exit($LASTEXITCODE)`, POWERSHELL, command)
264264

265+
log.Tracef("cmd.SysProcAttr.CmdLine: %s", cmd.SysProcAttr.CmdLine)
266+
265267
return cmd, nil
266268

267269
// command does not exist
@@ -283,6 +285,8 @@ func (snc *Agent) makeCmd(ctx context.Context, command string) (*exec.Cmd, error
283285
strings.Join(cmdArgs, " "),
284286
)
285287

288+
log.Tracef("cmd.SysProcAttr.CmdLine: %s", cmd.SysProcAttr.CmdLine)
289+
286290
return cmd, nil
287291

288292
// powershell files
@@ -308,6 +312,8 @@ func (snc *Agent) makeCmd(ctx context.Context, command string) (*exec.Cmd, error
308312
cmd := execCommandContext(ctx, "powershell", env)
309313
cmd.SysProcAttr.CmdLine = fmt.Sprintf(`%s -Command ". '%s' %s ; exit($LASTEXITCODE)"`, POWERSHELL, cmdName, strings.Join(cmdArgsModified, " "))
310314

315+
log.Tracef("cmd.SysProcAttr.CmdLine: %s", cmd.SysProcAttr.CmdLine)
316+
311317
return cmd, nil
312318

313319
// other command but no shell special characters
@@ -325,6 +331,8 @@ func (snc *Agent) makeCmd(ctx context.Context, command string) (*exec.Cmd, error
325331
shell,
326332
strings.Replace(command, cmdName, syscall.EscapeArg(cmdName), 1))
327333

334+
log.Tracef("cmd.SysProcAttr.CmdLine: %s", cmd.SysProcAttr.CmdLine)
335+
328336
return cmd, nil
329337
}
330338
}

0 commit comments

Comments
 (0)