]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Disallow `<SOURCE>:<TARGET>` with an empty target
authorGeorges Discry <georges@discry.be>
Sun, 23 Apr 2023 12:51:08 +0000 (14:51 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 23 Apr 2023 19:03:41 +0000 (21:03 +0200)
The configurations of the form `<SOURCE>[:<TARGET>]` require an absolute
target if given. However, `<SOURCE>:` would be ambiguously interpreted
as `<SOURCE>` so it is now disallowed.

For reference, `systemd-nspawn --bind` uses a similar form and refuses
to take an empty target.

mkosi/config.py

index 575e00d31f4beccde9320e4f389fdcc98fdff684..df1389cf5c559716ffe8d87f9cdfdb2693a7038f 100644 (file)
@@ -70,9 +70,9 @@ def parse_path(value: str, *, required: bool, absolute: bool = True, expanduser:
 
 
 def parse_source_target_paths(value: str) -> tuple[Path, Optional[Path]]:
-    src, _, target = value.partition(':')
+    src, sep, target = value.partition(':')
     src_path = parse_path(src, required=True)
-    if target:
+    if sep:
         target_path = parse_path(target, required=False, absolute=False, expanduser=False)
         if not target_path.is_absolute():
             die("Target path must be absolute")