audit _run: detection sudo refused plus robuste (accent-insensitive, sudo:, no tty)
This commit is contained in:
parent
2f880da275
commit
2746188f1c
@ -245,9 +245,13 @@ def _run(client, cmd):
|
||||
out = stdout.read().decode("utf-8", errors="replace").strip()
|
||||
err = stderr.read().decode("utf-8", errors="replace").strip()
|
||||
|
||||
# Fallback sans sudo si sudoers refuse bash -c
|
||||
if (not out) and err and ("pas autorisé" in err or "not allowed to execute" in err
|
||||
or "is not allowed" in err or "command not found" in err.lower()):
|
||||
# Fallback sans sudo si sudoers refuse (detection robuste case/accent insensible)
|
||||
err_low = err.lower()
|
||||
sudo_refused = any(kw in err_low for kw in [
|
||||
"pas autoris", "non autoris", "not allowed to execute",
|
||||
"is not allowed", "no tty present", "sudo:",
|
||||
])
|
||||
if (not out) and err and sudo_refused:
|
||||
_, stdout, stderr = client.exec_command(cmd, timeout=15)
|
||||
out = stdout.read().decode("utf-8", errors="replace").strip()
|
||||
err2 = stderr.read().decode("utf-8", errors="replace").strip()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user