2019-02-14 10:11:39 +00:00
|
|
|
//! Client side interface to the proxmox backup server
|
|
|
|
//!
|
|
|
|
//! This library implements the client side to access the backups
|
|
|
|
//! server using https.
|
|
|
|
|
2020-12-09 10:59:50 +00:00
|
|
|
use anyhow::Error;
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
api2::types::{Userid, Authid},
|
|
|
|
tools::ticket::Ticket,
|
|
|
|
auth_helpers::private_auth_key,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-05-23 10:29:33 +00:00
|
|
|
mod merge_known_chunks;
|
2020-03-23 14:03:18 +00:00
|
|
|
pub mod pipe_to_stream;
|
2019-05-14 12:54:21 +00:00
|
|
|
|
2019-02-14 10:11:39 +00:00
|
|
|
mod http_client;
|
2020-03-23 14:03:18 +00:00
|
|
|
pub use http_client::*;
|
2019-02-14 10:11:39 +00:00
|
|
|
|
2021-02-16 17:07:02 +00:00
|
|
|
mod vsock_client;
|
|
|
|
pub use vsock_client::*;
|
|
|
|
|
2019-12-08 10:27:15 +00:00
|
|
|
mod task_log;
|
|
|
|
pub use task_log::*;
|
|
|
|
|
2019-10-12 10:57:08 +00:00
|
|
|
mod backup_reader;
|
|
|
|
pub use backup_reader::*;
|
|
|
|
|
2019-10-12 11:53:11 +00:00
|
|
|
mod backup_writer;
|
|
|
|
pub use backup_writer::*;
|
|
|
|
|
2019-07-03 12:39:13 +00:00
|
|
|
mod remote_chunk_reader;
|
|
|
|
pub use remote_chunk_reader::*;
|
|
|
|
|
2019-03-14 09:54:09 +00:00
|
|
|
mod pxar_backup_stream;
|
|
|
|
pub use pxar_backup_stream::*;
|
2019-02-14 10:11:39 +00:00
|
|
|
|
|
|
|
mod backup_repo;
|
|
|
|
pub use backup_repo::*;
|
2020-05-22 06:04:20 +00:00
|
|
|
|
2020-05-30 08:54:38 +00:00
|
|
|
mod backup_specification;
|
|
|
|
pub use backup_specification::*;
|
|
|
|
|
2020-05-22 06:04:20 +00:00
|
|
|
pub mod pull;
|
2020-12-09 10:59:50 +00:00
|
|
|
|
|
|
|
/// Connect to localhost:8007 as root@pam
|
|
|
|
///
|
|
|
|
/// This automatically creates a ticket if run as 'root' user.
|
|
|
|
pub fn connect_to_localhost() -> Result<HttpClient, Error> {
|
|
|
|
|
|
|
|
let uid = nix::unistd::Uid::current();
|
|
|
|
|
|
|
|
let client = if uid.is_root() {
|
|
|
|
let ticket = Ticket::new("PBS", Userid::root_userid())?
|
|
|
|
.sign(private_auth_key(), None)?;
|
2021-01-25 13:42:57 +00:00
|
|
|
let fingerprint = crate::tools::cert::CertInfo::new()?.fingerprint()?;
|
|
|
|
let options = HttpClientOptions::new_non_interactive(ticket, Some(fingerprint));
|
|
|
|
|
2020-12-09 10:59:50 +00:00
|
|
|
HttpClient::new("localhost", 8007, Authid::root_auth_id(), options)?
|
|
|
|
} else {
|
2021-01-25 13:42:57 +00:00
|
|
|
let options = HttpClientOptions::new_interactive(None, None);
|
|
|
|
|
2020-12-09 10:59:50 +00:00
|
|
|
HttpClient::new("localhost", 8007, Authid::root_auth_id(), options)?
|
|
|
|
};
|
|
|
|
|
|
|
|
Ok(client)
|
|
|
|
}
|