]> git.proxmox.com Git - proxmox-backup.git/blame - pbs-client/src/lib.rs
move remaining client tools to pbs-tools/datastore
[proxmox-backup.git] / pbs-client / src / lib.rs
CommitLineData
151c6ce2
DM
1//! Client side interface to the proxmox backup server
2//!
3//! This library implements the client side to access the backups
4//! server using https.
5
6b68e5d5
DM
6use anyhow::Error;
7
9eb78407
WB
8use pbs_api_types::{Authid, Userid};
9use pbs_tools::ticket::Ticket;
4805edc4
WB
10use pbs_tools::cert::CertInfo;
11use pbs_tools::auth::private_auth_key;
6b68e5d5 12
2b7f8dd5 13pub mod catalog_shell;
eb5e0ae6 14pub mod dynamic_index;
2b7f8dd5
WB
15pub mod pxar;
16pub mod tools;
17
aa1b2e04 18mod merge_known_chunks;
c443f58b 19pub mod pipe_to_stream;
e3dbd41b 20
151c6ce2 21mod http_client;
c443f58b 22pub use http_client::*;
151c6ce2 23
89d25b19
SR
24mod vsock_client;
25pub use vsock_client::*;
26
5a0b484b
DM
27mod task_log;
28pub use task_log::*;
29
9e490a74
DM
30mod backup_reader;
31pub use backup_reader::*;
32
cf9271e2
DM
33mod backup_writer;
34pub use backup_writer::*;
35
7f99bf69
DM
36mod remote_chunk_reader;
37pub use remote_chunk_reader::*;
38
8968258b
DM
39mod pxar_backup_stream;
40pub use pxar_backup_stream::*;
151c6ce2
DM
41
42mod backup_repo;
43pub use backup_repo::*;
07ad6470 44
7cc3473a
DM
45mod backup_specification;
46pub use backup_specification::*;
47
38629c39
WB
48mod chunk_stream;
49pub use chunk_stream::{ChunkStream, FixedChunkStream};
50
4805edc4
WB
51pub const PROXMOX_BACKUP_TCP_KEEPALIVE_TIME: u32 = 120;
52
6b68e5d5
DM
53/// Connect to localhost:8007 as root@pam
54///
55/// This automatically creates a ticket if run as 'root' user.
56pub fn connect_to_localhost() -> Result<HttpClient, Error> {
57
58 let uid = nix::unistd::Uid::current();
59
6b68e5d5
DM
60 let client = if uid.is_root() {
61 let ticket = Ticket::new("PBS", Userid::root_userid())?
62 .sign(private_auth_key(), None)?;
9eb78407 63 let fingerprint = CertInfo::new()?.fingerprint()?;
93e3581c
FG
64 let options = HttpClientOptions::new_non_interactive(ticket, Some(fingerprint));
65
6b68e5d5
DM
66 HttpClient::new("localhost", 8007, Authid::root_auth_id(), options)?
67 } else {
93e3581c
FG
68 let options = HttpClientOptions::new_interactive(None, None);
69
6b68e5d5
DM
70 HttpClient::new("localhost", 8007, Authid::root_auth_id(), options)?
71 };
72
73 Ok(client)
74}