Skip to content

Commit 0a43239

Browse files
committed
more secure askpass handling
1 parent 3a8f108 commit 0a43239

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

gtk3/PCM.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,12 @@ def _apri_terminale(self, nome: str, dati: dict):
498498
pwd = dati.get("password", "")
499499
pkey = dati.get("private_key", "").strip()
500500
if pwd and not pkey:
501-
# SSH_ASKPASS: script temp mode 0700, password mai sulla cmdline
502-
_askpass = tempfile.mktemp(prefix=".pcm_ask_", suffix=".sh", dir="/tmp")
503-
with open(_askpass, "w") as _f:
504-
_f.write(f"#!/bin/sh\nprintf '%s' {_shlex.quote(pwd)}\n")
501+
# SSH_ASKPASS: script temp mode 0700, password via env (non embedded nel file)
502+
_fd, _askpass = tempfile.mkstemp(prefix=".pcm_ask_", suffix=".sh", dir="/tmp", text=True)
503+
with os.fdopen(_fd, "w") as _f:
504+
_f.write("#!/bin/sh\nprintf '%s' \"$PCM_ASKPASS_PASSWORD\"\n")
505505
os.chmod(_askpass, 0o700)
506+
env_extra["PCM_ASKPASS_PASSWORD"] = pwd
506507
env_extra["SSH_ASKPASS"] = _askpass
507508
env_extra["SSH_ASKPASS_REQUIRE"] = "force" # OpenSSH ≥ 8.4
508509
def _cleanup_askpass(path=_askpass):

0 commit comments

Comments
 (0)