From: Joerg Behrmann Date: Wed, 1 Jun 2022 17:35:39 +0000 (+0200) Subject: ssh: make parse_ssh_agent only handle strings X-Git-Tag: v13~23^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F996%2Fhead;p=thirdparty%2Fmkosi.git ssh: make parse_ssh_agent only handle strings pyright complains (wrongly I think) about value being None when passed to Path to create the socket variable. Let's work around this by eliminating Nones as values. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 5b0fdff10..4381ea225 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -5167,10 +5167,10 @@ def parse_remove_files(value: str) -> List[str]: return ["/" + os.path.normpath(p).lstrip("/") for p in value.split(",") if p] -def parse_ssh_agent(value: Optional[str]) -> Optional[Path]: +def parse_ssh_agent(value: str) -> Optional[Path]: """Will return None or a path to a socket.""" - if value is None: + if not value: return None try: @@ -5179,7 +5179,7 @@ def parse_ssh_agent(value: Optional[str]) -> Optional[Path]: except ValueError: pass else: - value = os.getenv("SSH_AUTH_SOCK") + value = os.getenv("SSH_AUTH_SOCK", "") if not value: die("--ssh-agent=true but $SSH_AUTH_SOCK is not set (consider running 'sudo' with '-E')") @@ -5740,7 +5740,7 @@ def create_parser() -> ArgumentParserMkosi: group.add_argument( "--ssh-agent", type=parse_ssh_agent, - default=None, + default="", metavar="PATH", help="Path to the ssh agent socket, or true to use $SSH_AUTH_SOCK.", )