mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-05-13 02:10:15 +00:00

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>
37 lines
1.0 KiB
Rust
37 lines
1.0 KiB
Rust
use proxmox_router::{
|
|
cli::{init_cli_logger, run_cli_command, CliCommandMap, CliEnvironment},
|
|
RpcEnvironment,
|
|
};
|
|
|
|
mod proxmox_backup_debug;
|
|
use proxmox_backup_debug::*;
|
|
|
|
fn main() {
|
|
init_cli_logger("PBS_LOG", "info");
|
|
|
|
let cmd_def = CliCommandMap::new()
|
|
.insert("inspect", inspect::inspect_commands())
|
|
.insert("recover", recover::recover_commands())
|
|
.insert("api", api::api_commands())
|
|
.insert("diff", diff::diff_commands());
|
|
|
|
let uid = nix::unistd::Uid::current();
|
|
let username = match nix::unistd::User::from_uid(uid) {
|
|
Ok(Some(user)) => user.name,
|
|
_ => "root@pam".to_string(),
|
|
};
|
|
let mut rpcenv = CliEnvironment::new();
|
|
rpcenv.set_auth_id(Some(format!("{}@pam", username)));
|
|
|
|
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,
|
|
rpcenv,
|
|
Some(|future| proxmox_async::runtime::main(future)),
|
|
);
|
|
}
|