From 6453db0ef5ef1ce765af9fcfa20551988b98f591 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 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/src/cli.rs b/lib/src/cli.rs index eb1b9a8e..7efdda2e 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,31 @@ 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(), + ["ima-sign", "--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(), ["container", "image", "pull"]); }