From 3cc8dfd7f406db8d8764b8f1a4636c266bf93511 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 22 Nov 2024 14:59:32 -0500 Subject: [PATCH] cli: Add interception for ostree extension verbs This allows us to fully own the symlinks in `/usr/libexec/libostree/ext`. Signed-off-by: Colin Walters --- lib/src/cli.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/src/cli.rs b/lib/src/cli.rs index eb1b9a8e8..8425714d5 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -907,6 +907,9 @@ impl Opt { InternalsOpts::GENERATOR_BIN => { Some(["bootc", "internals", "systemd-generator"].as_slice()) } + "ostree-container" | "ostree-ima-sign" | "ostree-provisional-repair" => { + Some(["bootc", "internals", "ostree-ext"].as_slice()) + } _ => None, }; if let Some(base_args) = mapped { @@ -1123,4 +1126,28 @@ fn test_parse_ostree_ext() { Opt::parse_including_static(["bootc", "internals", "ostree-container"]), Opt::Internals(InternalsOpts::OstreeContainer { .. }) )); + + fn peel(o: Opt) -> Vec { + match o { + Opt::Internals(InternalsOpts::OstreeExt { args }) => args, + o => panic!("unexpected {o:?}"), + } + } + let args = peel(Opt::parse_including_static([ + "/usr/libexec/libostree/ext/ostree-ima-sign", + "ima-sign", + "--repo=foo", + "foo", + "bar", + "baz", + ])); + assert_eq!(args.as_slice(), ["--repo=foo", "foo", "bar", "baz"]); + + let args = peel(Opt::parse_including_static([ + "/usr/libexec/libostree/ext/ostree-container", + "container", + "image", + "pull", + ])); + assert_eq!(args.as_slice(), ["image", "pull"]); }