Skip to content

Commit

Permalink
usroverlay: Pass arguments to ostree admin unlock
Browse files Browse the repository at this point in the history
So that `--help` works.

Closes: #4508
  • Loading branch information
cgwalters committed Aug 25, 2023
1 parent 9e9a403 commit 78b852c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
24 changes: 1 addition & 23 deletions rust/src/builtins/usroverlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,15 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use anyhow::{Context, Result};
use clap::Command;
use std::os::unix::prelude::CommandExt;

/// Directly exec(ostree admin unlock) - does not return on success.
pub fn usroverlay_entrypoint(args: &Vec<String>) -> Result<()> {
let cmd = cli_cmd();
cmd.get_matches_from(args.iter().skip(1));

let exec_err = std::process::Command::new("ostree")
.args(&["admin", "unlock"])
.args(args.into_iter().skip(1))
.exec();

// This is only reached if the `exec()` above failed; otherwise
// execution got transferred to `ostree` at that point.
Err(exec_err).context("Failed to execute 'ostree admin unlock'")
}

/// CLI parser, handle --help and error on extra arguments.
fn cli_cmd() -> Command {
Command::new("rpm-ostree usroverlay")
.bin_name("rpm-ostree usroverlay")
.long_version("")
.long_about("Apply a transient overlayfs to /usr")
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_clap_cmd() {
cli_cmd().debug_assert()
}
}
7 changes: 7 additions & 0 deletions tests/kolainst/nondestructive/misc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ for verb in container ima-sign; do
done
echo "ok multicall corectly set up and working"

# Verify that we process arguments correctly
rpm-ostree usroverlay --help >out.txt
assert_file_has_content out.txt "ostree admin unlock"
rm -f out.txt
rpm-ostree -h usroverlay >out.txt
assert_file_has_content out.txt "ostree admin unlock"

# make sure that package-related entries are always present,
# even when they're empty.
# Validate there's no live state by default.
Expand Down

0 comments on commit 78b852c

Please sign in to comment.