Skip to content

Got errors when using sudo with ps #1043

@MiniPierre

Description

@MiniPierre

Hi,

This is not exactly an issue, more of a warning for people having this kind of issues. It is both related to the invoke and the paramiko library

I am using fabric (which is based on paramiko and invoke) in order to retrieve a list of running processus on a Debian server with ps axww -o pid=,ppid=,etimes=,command=. At that time, I used the sudo function to run it.

From time to time, I got a ThreadException, and it came out that it was coming from the invoke library: when doing the ps command, I got the following output:

3432669       1       0 /lib/systemd/systemd --user
3432670 3432669       0 (sd-pam)
3432716       2       0 [kworker/9:1]
3432730 3432625       0 sshd: xxx@notty
3432731 3432730       0 sudo -S -p [sudo] password:  ps axww -o pid=,ppid=,etimes=,command=
3432732 3432731       0 ps axww -o pid=,ppid=,etimes=,command=

As the -p [sudo] password: option appears in the command output, the watchers.Responder.submit function returns matches, and triggers the runner.Runner.handle_output -> _handle_output -> respond -> write_proc_stdin function, thinking it should send the password.

As the paramiko channel get closed once the command output is printed, the write_proc_stdin sometimes tries to write the password after the channel closure, which triggers a ThreadException OSError: Socket is closed

(Sorry if I am not using the correct terminology, I am not a developer)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions