Skip to content

Commit 07b158e

Browse files
committed
fix(ssh): reuse fresh credentials on duplicate connections
1 parent 2be0725 commit 07b158e

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

gtk3/PCM.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,15 @@ def _on_connetti(self, panel, nome: str, dati: dict):
766766
self._pannello.aggiorna()
767767
self._aggiorna_welcome_recenti()
768768

769+
# La sidebar può contenere un riferimento creato prima dell'ultimo
770+
# unlock o aggiornamento della cache. Usa il profilo appena ricaricato
771+
# per evitare di passare a SSH credenziali ancora in formato ENC:.
772+
profili_correnti = config_manager.load_profiles()
773+
if nome in profili_correnti:
774+
dati = dict(profili_correnti[nome])
775+
else:
776+
dati = dict(dati)
777+
769778
use_gateway = self._needs_ssh_gateway(dati)
770779

771780
if pre_cmd or wol_mac or use_gateway:

gtk3/terminal_widget.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ def _setup_expect_watcher(self, rules: list[dict]):
323323
"max_trigger": max_t,
324324
"delay": delay,
325325
"sent": 0,
326+
"last_prompt": None,
326327
})
327328

328329
if not compiled:
@@ -348,12 +349,22 @@ def _do_check():
348349
for c in compiled:
349350
if c["sent"] >= c["max_trigger"]:
350351
continue
351-
if c["re"].search(tail):
352-
c["sent"] += 1
353-
cmd = c["command"]
354-
if not cmd.endswith("\n"):
355-
cmd += "\n"
356-
self._vte.feed_child(cmd.encode("utf-8"))
352+
match = c["re"].search(tail)
353+
if not match:
354+
continue
355+
356+
# Il prompt resta nello scrollback anche dopo feed_child().
357+
# Senza una chiave, ogni output successivo (per esempio il
358+
# banner SSH) faceva reinviare la password nel nuovo shell.
359+
prompt_key = tail[:match.end()]
360+
if prompt_key == c["last_prompt"]:
361+
continue
362+
c["last_prompt"] = prompt_key
363+
c["sent"] += 1
364+
cmd = c["command"]
365+
if not cmd.endswith("\n"):
366+
cmd += "\n"
367+
self._vte.feed_child(cmd.encode("utf-8"))
357368
return False
358369

359370
def _on_changed(_vte):

0 commit comments

Comments
 (0)