PORT = "7777"
REMOTE_HOST = "localhost"
REMOTE_PORT = "7777"
-AUTH_SOCK_DIR_PATTERN = re.compile(r"/ssh-[^/]+$")
-AUTH_SOCK_PATTERN = re.compile(
- rf"{AUTH_SOCK_DIR_PATTERN.pattern.rstrip('$')}/agent.[0-9]+$"
-)
+AUTH_SOCK_DIR_PATTERN = re.compile(r"ssh-")
+AUTH_SOCK_PATTERN = re.compile(f"agent.[0-9]+$")
class ReusableTCPServer(TCPServer):
for q in chain.from_iterable(
p.iterdir()
for p in Path(os.environ.get("TMPDIR") or "/tmp").iterdir()
- if p.is_dir() and AUTH_SOCK_DIR_PATTERN.search(str(p))
+ if p.is_dir() and AUTH_SOCK_DIR_PATTERN.match(p.name)
):
q_str = str(q)
if (
q.is_socket()
- and AUTH_SOCK_PATTERN.search(q_str)
+ and AUTH_SOCK_PATTERN.fullmatch(q.name)
and check_ssh_auth_sock(env={**os.environ, "SSH_AUTH_SOCK": q_str})
):
return q_str