cli: manager, tape, debug: avoid setting up auth context for printdoc

as otherwise build fails in a clean environment, where no API auth
key is available.

This whole printdoc command injection is quite ugly and causes
headache in general though, we'd be better off if we could do away
with that..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2023-03-28 19:02:46 +02:00
parent 15b5e60568
commit 783e88c2df
3 changed files with 11 additions and 3 deletions

View File

@ -23,7 +23,10 @@ fn main() {
let mut rpcenv = CliEnvironment::new();
rpcenv.set_auth_id(Some(format!("{}@pam", username)));
proxmox_backup::auth_helpers::setup_auth_context(true);
let args: Vec<String> = std::env::args().take(2).collect();
if args.len() < 2 || args[1] != "printdoc" {
proxmox_backup::auth_helpers::setup_auth_context(true);
}
run_cli_command(
cmd_def,

View File

@ -490,7 +490,9 @@ async fn run() -> Result<(), Error> {
let mut rpcenv = CliEnvironment::new();
rpcenv.set_auth_id(Some(String::from("root@pam")));
proxmox_backup::auth_helpers::setup_auth_context(true);
if args.len() < 2 || args[1] != "printdoc" {
proxmox_backup::auth_helpers::setup_auth_context(true);
}
run_async_cli_command(cmd_def, rpcenv).await; // this call exit(-1) on error

View File

@ -1113,7 +1113,10 @@ fn main() {
let mut rpcenv = CliEnvironment::new();
rpcenv.set_auth_id(Some(String::from("root@pam")));
proxmox_backup::auth_helpers::setup_auth_context(true);
let args: Vec<String> = std::env::args().take(2).collect();
if args.len() < 2 || args[1] != "printdoc" {
proxmox_backup::auth_helpers::setup_auth_context(true);
}
proxmox_async::runtime::main(run_async_cli_command(cmd_def, rpcenv));
}