MCPcopy Create free account
hub / github.com/DBCDK/morph / askForSudoPassword

Function askForSudoPassword

ssh/ssh.go:216–232  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

214}
215
216func askForSudoPassword() (string, error) {
217 fmt.Fprint(os.Stderr, "Please enter remote sudo password: ")
218 stdin := int(syscall.Stdin)
219 state, err := terminal.GetState(stdin)
220 if err != nil {
221 return "", err
222 }
223 utils.AddFinalizer(func() {
224 terminal.Restore(stdin, state)
225 })
226 bytePassword, err := terminal.ReadPassword(stdin)
227 if err != nil {
228 return "", err
229 }
230 fmt.Fprintln(os.Stderr)
231 return string(bytePassword), nil
232}
233
234func writeSudoPassword(cmd *exec.Cmd, sudoPasswd string) (err error) {
235 stdin, err := cmd.StdinPipe()

Callers 1

SudoCmdContextMethod · 0.85

Calls 1

AddFinalizerFunction · 0.92

Tested by

no test coverage detected