]>
git.proxmox.com Git - proxmox-backup.git/blob - src/client/mod.rs
8a4e45567ce317a49d624991334ba02ff69e6335
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
;
12 tools
::cert
::CertInfo
,
13 auth_helpers
::private_auth_key
,
16 mod merge_known_chunks
;
17 pub mod pipe_to_stream
;
20 pub use http_client
::*;
23 pub use vsock_client
::*;
29 pub use backup_reader
::*;
32 pub use backup_writer
::*;
34 mod remote_chunk_reader
;
35 pub use remote_chunk_reader
::*;
37 mod pxar_backup_stream
;
38 pub use pxar_backup_stream
::*;
41 pub use backup_repo
::*;
43 mod backup_specification
;
44 pub use backup_specification
::*;
46 /// Connect to localhost:8007 as root@pam
48 /// This automatically creates a ticket if run as 'root' user.
49 pub fn connect_to_localhost() -> Result
<HttpClient
, Error
> {
51 let uid
= nix
::unistd
::Uid
::current();
53 let client
= if uid
.is_root() {
54 let ticket
= Ticket
::new("PBS", Userid
::root_userid())?
55 .sign(private_auth_key(), None
)?
;
56 let fingerprint
= CertInfo
::new()?
.fingerprint()?
;
57 let options
= HttpClientOptions
::new_non_interactive(ticket
, Some(fingerprint
));
59 HttpClient
::new("localhost", 8007, Authid
::root_auth_id(), options
)?
61 let options
= HttpClientOptions
::new_interactive(None
, None
);
63 HttpClient
::new("localhost", 8007, Authid
::root_auth_id(), options
)?