]>
git.proxmox.com Git - proxmox-backup.git/blob - src/client.rs
1 //! Client side interface to the proxmox backup server
3 //! This library implements the client side to access the backups
4 //! server using https.
9 api2
::types
::{Userid, Authid}
,
10 tools
::ticket
::Ticket
,
11 auth_helpers
::private_auth_key
,
16 mod merge_known_chunks
;
17 pub mod pipe_to_stream
;
20 pub use http_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
::*;
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 mut options
= HttpClientOptions
::new()
53 .prefix(Some("proxmox-backup".to_string()))
54 .verify_cert(false); // not required for connection to localhost
56 let client
= if uid
.is_root() {
57 let ticket
= Ticket
::new("PBS", Userid
::root_userid())?
58 .sign(private_auth_key(), None
)?
;
59 options
= options
.password(Some(ticket
));
60 HttpClient
::new("localhost", 8007, Authid
::root_auth_id(), options
)?
62 options
= options
.ticket_cache(true).interactive(true);
63 HttpClient
::new("localhost", 8007, Authid
::root_auth_id(), options
)?