sudo

package
v0.0.0-...-740721f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(cmd string) string

Escape escapes a cmd so that it can be used inside a single-quoted argument. The intended purpose e.g. when strings are used as input to sh -c '%s' The method assumes that the outer, surrounding quote is a singlequote. The surrounding quote must not be part of cmd.

Types

type Sudo

type Sudo struct {
	Stderr io.Writer // where to pass stderr once sudo is done

	StdinPipe io.WriteCloser // pipe to the cmds stdin
	// contains filtered or unexported fields
}

Sudo can be used to connect to stderr and stdin to detect and respond to sudo password prompts.

func New

func New(cmd, user, pwd string, stdin io.Reader) *Sudo

New returns a new Sudo

func (*Sudo) Args

func (s *Sudo) Args() []string

Args returns all args to the sudo command Useful for os.Exec

func (*Sudo) Cmd

func (s *Sudo) Cmd() string

Cmd returns a command that contains the command Useful for ssh.Session.Run

func (*Sudo) Write

func (s *Sudo) Write(p []byte) (int, error)

Write implements writer

func (*Sudo) WrongPwd

func (s *Sudo) WrongPwd() bool

WrongPwd reports if password prompt was recieved more than once

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL