remove pbs_client::connect_to_localhost
It also used `CertInfo` from pbs-tools which is also server specific. The original helper is now in the main crate's client_helpers instead. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
67678ec39c
commit
b62edce929
|
@ -3,13 +3,6 @@
|
||||||
//! This library implements the client side to access the backups
|
//! This library implements the client side to access the backups
|
||||||
//! server using https.
|
//! server using https.
|
||||||
|
|
||||||
use anyhow::Error;
|
|
||||||
use openssl::pkey::{PKey, Private};
|
|
||||||
|
|
||||||
use pbs_api_types::{Authid, Userid};
|
|
||||||
use pbs_tools::ticket::Ticket;
|
|
||||||
use pbs_tools::cert::CertInfo;
|
|
||||||
|
|
||||||
pub mod catalog_shell;
|
pub mod catalog_shell;
|
||||||
pub mod dynamic_index;
|
pub mod dynamic_index;
|
||||||
pub mod pxar;
|
pub mod pxar;
|
||||||
|
@ -49,19 +42,3 @@ mod chunk_stream;
|
||||||
pub use chunk_stream::{ChunkStream, FixedChunkStream};
|
pub use chunk_stream::{ChunkStream, FixedChunkStream};
|
||||||
|
|
||||||
pub const PROXMOX_BACKUP_TCP_KEEPALIVE_TIME: u32 = 120;
|
pub const PROXMOX_BACKUP_TCP_KEEPALIVE_TIME: u32 = 120;
|
||||||
|
|
||||||
/// Connect to localhost:8007 as root@pam
|
|
||||||
///
|
|
||||||
/// This automatically creates a ticket if run as 'root' user.
|
|
||||||
pub fn connect_to_localhost(auth_key: Option<&PKey<Private>>) -> Result<HttpClient, Error> {
|
|
||||||
let options = if let Some(auth_key) = auth_key {
|
|
||||||
let ticket = Ticket::new("PBS", Userid::root_userid())?
|
|
||||||
.sign(auth_key, None)?;
|
|
||||||
let fingerprint = CertInfo::new()?.fingerprint()?;
|
|
||||||
HttpClientOptions::new_non_interactive(ticket, Some(fingerprint))
|
|
||||||
} else {
|
|
||||||
HttpClientOptions::new_interactive(None, None)
|
|
||||||
};
|
|
||||||
|
|
||||||
HttpClient::new("localhost", 8007, Authid::root_auth_id(), options)
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,13 +1,24 @@
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
|
|
||||||
|
use pbs_api_types::{Authid, Userid};
|
||||||
|
use pbs_client::{HttpClient, HttpClientOptions};
|
||||||
|
use pbs_tools::cert::CertInfo;
|
||||||
|
use pbs_tools::ticket::Ticket;
|
||||||
|
|
||||||
use crate::auth_helpers::private_auth_key;
|
use crate::auth_helpers::private_auth_key;
|
||||||
|
|
||||||
/// As root we have access to the private key file and can use it directly. Otherwise the connect
|
/// Connect to localhost:8007 as root@pam
|
||||||
/// call will interactively query the password.
|
///
|
||||||
|
/// This automatically creates a ticket if run as 'root' user.
|
||||||
pub fn connect_to_localhost() -> Result<pbs_client::HttpClient, Error> {
|
pub fn connect_to_localhost() -> Result<pbs_client::HttpClient, Error> {
|
||||||
pbs_client::connect_to_localhost(if nix::unistd::Uid::current().is_root() {
|
let options = if nix::unistd::Uid::current().is_root() {
|
||||||
Some(private_auth_key())
|
let auth_key = private_auth_key();
|
||||||
|
let ticket = Ticket::new("PBS", Userid::root_userid())?.sign(auth_key, None)?;
|
||||||
|
let fingerprint = CertInfo::new()?.fingerprint()?;
|
||||||
|
HttpClientOptions::new_non_interactive(ticket, Some(fingerprint))
|
||||||
} else {
|
} else {
|
||||||
None
|
HttpClientOptions::new_interactive(None, None)
|
||||||
})
|
};
|
||||||
|
|
||||||
|
HttpClient::new("localhost", 8007, Authid::root_auth_id(), options)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue