Skip to content

Commit

Permalink
fix: make --passcmd actually execute a command
Browse files Browse the repository at this point in the history
I have literally no idea how to write go this might be full of bugs :D

Signed-off-by: Christina Sørensen <[email protected]>
  • Loading branch information
cafkafk committed Mar 6, 2024
1 parent f130e47 commit ac92108
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,20 @@ func (sshCtx *SSHContext) SudoCmdContext(ctx context.Context, host Host, parts .
return nil, err
}
} else if sshCtx.GetSudoPasswordCommand != "" {
sshCtx.sudoPassword = sshCtx.GetSudoPasswordCommand
command := strings.Fields(sshCtx.GetSudoPasswordCommand)
var argsArr = []string{}
for i, e := range command {
if i != 0 {
argsArr = append(argsArr, e)
}
}
passCmd := exec.Command(command[0], argsArr...)

passOut, err := passCmd.Output()
if err != nil {
panic(err)
}
sshCtx.sudoPassword = string(passOut)
}

cmd, cmdArgs := sshCtx.sshArgs(host, nil)
Expand Down

0 comments on commit ac92108

Please sign in to comment.