Skip to content

Commit

Permalink
cli: Add interception for ostree extension verbs
Browse files Browse the repository at this point in the history
This allows us to fully own the symlinks in `/usr/libexec/libostree/ext`.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Nov 22, 2024
1 parent df92c9d commit 3cc8dfd
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<OsString> {
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"]);
}

0 comments on commit 3cc8dfd

Please sign in to comment.