-
-
Notifications
You must be signed in to change notification settings - Fork 450
Open
Labels
bugLabel for all kind of bugs.Label for all kind of bugs.
Description
Describe the bug
If remote system is configured with a locale different than English, sudo will fail to prompt for a password.
On remote system:
echo $LANG
fr_FR.UTF-8Example of failing command:
pyinfra --debug-all -y 192.168.1.16 server.shell "echo foo" _sudo=true--> Starting operation: server.shell (echo foo)
[pyinfra.api.operations] Starting operation {'server.shell'} on 192.168.1.16
[pyinfra.connectors.ssh] Running command on 192.168.1.16: (pty=False) sudo -H -n sh -c 'echo foo'
DEBUG:paramiko.transport:[chan 0] Max packet in: 32768 bytes
DEBUG:paramiko.transport:[chan 0] Max packet out: 32768 bytes
DEBUG:paramiko.transport:Secsh channel 0 opened.
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
DEBUG:paramiko.transport:[chan 0] EOF received (0)
DEBUG:paramiko.transport:[chan 0] EOF sent (0)
[pyinfra.connectors.ssh] Waiting for exit status...
[pyinfra.connectors.ssh] Command exit status: 1
[192.168.1.16] sudo: il est nécessaire de saisir un mot de passe
[192.168.1.16] Error: executed 0 commands
[pyinfra.api.state] Failing hosts: 192.168.1.16
The problem comes from this line:
pyinfra/pyinfra/connectors/util.py
Line 203 in 21b022b
| if last_line.strip() == "sudo: a password is required": |
In this case, the remote system being in French, sudo prints sudo: il est nécessaire de saisir un mot de passe.
I "fixed" the bug by changing this line:
pyinfra/pyinfra/connectors/util.py
Line 346 in 21b022b
| command_bits.extend(["sudo", "-H"]) |
into
command_bits.extend(["LANG=C", "sudo", "-H"])but I'm not sure whether this is the right fix.
Meta
Observed with Pip package 3.0b2.
I just spent this week-end testing Pyinfra, it looks promising! 👍
Hofer-Julian
Metadata
Metadata
Assignees
Labels
bugLabel for all kind of bugs.Label for all kind of bugs.