Skip to content

Commit

Permalink
Allow sudofn injection into container
Browse files Browse the repository at this point in the history
- allow connection objects to have a sudofn injected
- if sudofn is set, then Connect won't try to detect it

Signed-off-by: James Nesbitt <[email protected]>
  • Loading branch information
james-nesbitt committed Nov 5, 2024
1 parent dc14b8a commit 0d51bc6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,19 @@ func (c *Connection) Connect() error {
c.OSVersion = &o
}

c.configureSudo()
if c.sudofunc == nil {
c.configureSudo()
}

return nil
}

// SetSudofn inject a sudofn into the connection before Connect()
// @NOTE this will avoid sudo detection if done before Connect()
func (c *Connection) SetSudofn(f func(string) string) {
c.sudofunc = f
}

func sudoNoop(cmd string) string {
return cmd
}
Expand Down

0 comments on commit 0d51bc6

Please sign in to comment.