3 use pbs_api_types
::{Authid, Userid}
;
4 use pbs_client
::{HttpClient, HttpClientOptions}
;
5 use pbs_tools
::ticket
::Ticket
;
7 use crate::auth_helpers
::private_auth_key
;
9 /// Connect to localhost:8007 as root@pam
11 /// This automatically creates a ticket if run as 'root' user.
12 pub fn connect_to_localhost() -> Result
<pbs_client
::HttpClient
, Error
> {
13 let options
= if nix
::unistd
::Uid
::current().is_root() {
14 let auth_key
= private_auth_key();
15 let ticket
= Ticket
::new("PBS", Userid
::root_userid())?
.sign(auth_key
, None
)?
;
16 let fingerprint
= crate::cert_info()?
.fingerprint()?
;
17 HttpClientOptions
::new_non_interactive(ticket
, Some(fingerprint
))
19 HttpClientOptions
::new_interactive(None
, None
)
22 HttpClient
::new("localhost", 8007, Authid
::root_auth_id(), options
)