diff --git a/connection.go b/connection.go index b0f2aa50..0825903b 100644 --- a/connection.go +++ b/connection.go @@ -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 }