lib.ec.ssh.Exec: Fix askpass script #105
Loading…
Reference in a new issue
No description provided.
Delete branch "jan/fix/20260914-lib-ec-ssh-exec-fix-askpass-script"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
lib.ec.ssh.Exec: Fix askpass script
__init_askpass() embeds the password verbatim in a generated bash script, with a newline included inside the double quotes of the echo -n. The askpass program therefore always appends a newline to the password, and any password containing quotes or shell metacharacters either breaks the script or injects commands into it.
Embed the password as base64 and decode it with printf piped into base64 -d, so the script is safe for any password and prints the password exactly, byte for byte.
Make del() idempotent: it deletes the environment variables and the script file, so a second call, e.g. an explicit one followed by garbage collection, raises KeyError and FileNotFoundError.
Add a unit test that executes the generated script and compares its output with the password byte for byte.