1 //! Client side interface to the proxmox backup server
3 //! This library implements the client side to access the backups
4 //! server using https.
8 use pbs_api_types
::{Authid, Userid}
;
9 use pbs_tools
::ticket
::Ticket
;
10 use pbs_tools
::cert
::CertInfo
;
11 use pbs_tools
::auth
::private_auth_key
;
13 mod merge_known_chunks
;
14 pub mod pipe_to_stream
;
17 pub use http_client
::*;
20 pub use vsock_client
::*;
26 pub use backup_reader
::*;
29 pub use backup_writer
::*;
31 mod remote_chunk_reader
;
32 pub use remote_chunk_reader
::*;
34 mod pxar_backup_stream
;
35 pub use pxar_backup_stream
::*;
38 pub use backup_repo
::*;
40 mod backup_specification
;
41 pub use backup_specification
::*;
43 pub const PROXMOX_BACKUP_TCP_KEEPALIVE_TIME
: u32 = 120;
45 /// Connect to localhost:8007 as root@pam
47 /// This automatically creates a ticket if run as 'root' user.
48 pub fn connect_to_localhost() -> Result
<HttpClient
, Error
> {
50 let uid
= nix
::unistd
::Uid
::current();
52 let client
= if uid
.is_root() {
53 let ticket
= Ticket
::new("PBS", Userid
::root_userid())?
54 .sign(private_auth_key(), None
)?
;
55 let fingerprint
= CertInfo
::new()?
.fingerprint()?
;
56 let options
= HttpClientOptions
::new_non_interactive(ticket
, Some(fingerprint
));
58 HttpClient
::new("localhost", 8007, Authid
::root_auth_id(), options
)?
60 let options
= HttpClientOptions
::new_interactive(None
, None
);
62 HttpClient
::new("localhost", 8007, Authid
::root_auth_id(), options
)?