]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
ssh: make parse_ssh_agent only handle strings 996/head
authorJoerg Behrmann <behrmann@physik.fu-berlin.de>
Wed, 1 Jun 2022 17:35:39 +0000 (19:35 +0200)
committerJoerg Behrmann <behrmann@physik.fu-berlin.de>
Wed, 1 Jun 2022 17:41:26 +0000 (19:41 +0200)
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.

mkosi/__init__.py

index 5b0fdff100e361f6a6ed6c2e0cfa975523ac455e..4381ea2251cd321ca6711f704fd86fd7ba0359ae 100644 (file)
@@ -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.",
     )