mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Add a new tool called 'pvimg' that can be used to create and inspect
Secure Execution images. It has several subcommands:
+ create: create an IBM Secure Execution image (genprotimg compatible
sytnax) and C-'genprotimg' is going to be replaced by a
symlink to this subcommand.
+ test: test various aspects of an existing Secure Execution image
+ info: print information about an existing Secure Execution
image (experimental API!)
+ version: print version and exit
As mentioned above, the 'genprotimg' tool is now a symbolic link to the
'pvimg create' subcommand and the CLI is backward compatible with the
original genprotimg CLI, with the following exceptions:
- '-v' increases the verbosity instead of showing the version
- '-V' is now deprecated in favor of '-v'
- an existing output file is no longer silently overwritten, but there
is a new flag '--overwrite' to get the original behavior
- experimental options are no longer described in the help
- the commands '--cert ...' and '--root-ca' are now mutually exclusive
- to '--no-verify'
- there is now a component check, e.g. it checks if the specified
Linux kernel looks like a raw binary s390x kernel. These checks can be
disabled by using the new command line flag '--no-component-check'
Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
72 lines
2.0 KiB
Rust
72 lines
2.0 KiB
Rust
// SPDX-License-Identifier: MIT
|
|
//
|
|
// Copyright IBM Corp. 2024
|
|
|
|
//! # pvimg
|
|
//!
|
|
//! `pvimg` is a command line utility to create and inspect IBM Secure
|
|
//! Execution boot images.
|
|
//!
|
|
//! Use `pvimg` to create a IBM Secure Execution boot image file, which can
|
|
//! be loaded using `zipl` or `QEMU`. The tool can also be used to inspect
|
|
//! existing Secure Execution boot images.
|
|
|
|
mod cli;
|
|
mod cmd;
|
|
mod se_img;
|
|
mod se_img_comps;
|
|
|
|
use std::{env, process::ExitCode};
|
|
|
|
use clap::{Command, CommandFactory, Parser};
|
|
use cli::{validate_cli, CliOptions, SubCommands};
|
|
use log::trace;
|
|
use pvimg::error::OwnExitCode;
|
|
use utils::{print_cli_error, print_error, PvLogger};
|
|
|
|
use crate::cli::GenprotimgCliOptions;
|
|
|
|
static LOGGER: PvLogger = PvLogger;
|
|
|
|
fn main() -> ExitCode {
|
|
let exe = env::args_os().next().unwrap();
|
|
let (opts, cmd): (CliOptions, Command) = match exe.to_str() {
|
|
// Test if the symlink executable 'genprotimg' was used. If so use the
|
|
// `pvimg create` command directly.
|
|
Some(val) if val.ends_with("genprotimg") => (
|
|
GenprotimgCliOptions::own_parse(),
|
|
GenprotimgCliOptions::command(),
|
|
),
|
|
_ => (CliOptions::parse(), CliOptions::command()),
|
|
};
|
|
|
|
let verbosity = opts.verbose.to_level_filter();
|
|
if let Err(e) = LOGGER.start(verbosity) {
|
|
unreachable!("Logger error: {e:?}");
|
|
}
|
|
|
|
match validate_cli(&opts) {
|
|
Ok(opts) => opts,
|
|
Err(e) => {
|
|
let _ = print_cli_error(e, cmd);
|
|
return OwnExitCode::UsageError.into();
|
|
}
|
|
};
|
|
|
|
// NOTE trace verbosity is disabled in release builds
|
|
trace!("Trace verbosity, may leak secrets to command-line");
|
|
trace!("Options {opts:?}");
|
|
|
|
let res = match &opts.cmd {
|
|
SubCommands::Create(opt) => cmd::create(opt),
|
|
SubCommands::Info(opt) => cmd::info(opt),
|
|
SubCommands::Test(opt) => cmd::test(opt),
|
|
SubCommands::Version => cmd::version(verbosity),
|
|
};
|
|
|
|
match res {
|
|
Ok(own_exit_code) => own_exit_code.into(),
|
|
Err(e) => print_error(&e, verbosity),
|
|
}
|
|
}
|