Skip to content

Commit d82446a

Browse files
committed
install: Fix exec helper to not swallow unexpected args
Our `exec-in-host-mount-namespace` internal helper was intended to be a "passthrough" that accepts whatever child arguments. However I misunderstood how to do this in clap. Before this change we get: ``` $ bootc blabla ERROR Re-exec in host mountns: Missing command ``` i.e. the exec code kicks in because `external_subcommand` takes over *everything* unknown. Fix things to use `trailing_var_arg` which is intended for this case. After this patch: ``` $ bootc blabla error: unrecognized subcommand 'blabla' Usage: bootc <COMMAND> For more information, try '--help'. ``` Signed-off-by: Colin Walters <[email protected]>
1 parent 57397fe commit d82446a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/src/cli.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ pub(crate) enum Opt {
167167
/// Execute the given command in the host mount namespace
168168
#[cfg(feature = "install")]
169169
#[clap(hide = true)]
170-
#[command(external_subcommand)]
171-
ExecInHostMountNamespace(Vec<OsString>),
172-
170+
ExecInHostMountNamespace {
171+
#[clap(trailing_var_arg = true, allow_hyphen_values = true)]
172+
args: Vec<OsString>,
173+
},
173174
/// Internal integration testing helpers.
174175
#[clap(hide(true), subcommand)]
175176
#[cfg(feature = "internal-testing-api")]
@@ -468,7 +469,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
468469
InstallOpts::ToFilesystem(opts) => crate::install::install_to_filesystem(opts).await,
469470
},
470471
#[cfg(feature = "install")]
471-
Opt::ExecInHostMountNamespace(args) => {
472+
Opt::ExecInHostMountNamespace { args } => {
472473
crate::install::exec_in_host_mountns(args.as_slice())
473474
}
474475
Opt::Status(opts) => super::status::status(opts).await,

lib/src/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ pub(crate) fn run_in_host_mountns(cmd: &str) -> Command {
673673

674674
#[context("Re-exec in host mountns")]
675675
pub(crate) fn exec_in_host_mountns(args: &[std::ffi::OsString]) -> Result<()> {
676-
let (cmd, args) = args[1..]
676+
let (cmd, args) = args
677677
.split_first()
678678
.ok_or_else(|| anyhow::anyhow!("Missing command"))?;
679679
tracing::trace!("{cmd:?} {args:?}");

0 commit comments

Comments
 (0)