mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 20:47:01 +01:00
This commit is contained in:
parent
87c6b45fbd
commit
eb4b25719b
|
@ -49,6 +49,7 @@ impl ClientCodec {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Makes a call to kanidm_unixd via a unix socket at `path`
|
||||||
pub async fn call_daemon(path: &str, req: ClientRequest) -> Result<ClientResponse, Box<dyn Error>> {
|
pub async fn call_daemon(path: &str, req: ClientRequest) -> Result<ClientResponse, Box<dyn Error>> {
|
||||||
let stream = UnixStream::connect(path).await?;
|
let stream = UnixStream::connect(path).await?;
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ pub async fn call_daemon(path: &str, req: ClientRequest) -> Result<ClientRespons
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
error!("Error");
|
error!("Error making request to kanidm_unixd");
|
||||||
Err(Box::new(IoError::new(ErrorKind::Other, "oh no!")))
|
Err(Box::new(IoError::new(ErrorKind::Other, "oh no!")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
use std::path::PathBuf;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
use futures::executor::block_on;
|
use futures::executor::block_on;
|
||||||
|
@ -37,12 +38,25 @@ async fn main() {
|
||||||
let cfg = match KanidmUnixdConfig::new().read_options_from_optional_config("/etc/kanidm/unixd")
|
let cfg = match KanidmUnixdConfig::new().read_options_from_optional_config("/etc/kanidm/unixd")
|
||||||
{
|
{
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(_e) => {
|
Err(e) => {
|
||||||
error!("Failed to parse /etc/kanidm/unixd");
|
error!("Failed to parse /etc/kanidm/unixd: {:?}", e);
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"Using kanidm_unixd socket path: {:?}",
|
||||||
|
cfg.sock_path.as_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
// see if the kanidm_unixd socket exists and quit if not
|
||||||
|
if !PathBuf::from(&cfg.sock_path).exists() {
|
||||||
|
error!(
|
||||||
|
"Failed to find unix socket at {}, quitting!",
|
||||||
|
cfg.sock_path.as_str()
|
||||||
|
);
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
let req = ClientRequest::SshKey(opt.account_id);
|
let req = ClientRequest::SshKey(opt.account_id);
|
||||||
|
|
||||||
match block_on(call_daemon(cfg.sock_path.as_str(), req)) {
|
match block_on(call_daemon(cfg.sock_path.as_str(), req)) {
|
||||||
|
@ -51,11 +65,11 @@ async fn main() {
|
||||||
println!("{}", k);
|
println!("{}", k);
|
||||||
}),
|
}),
|
||||||
_ => {
|
_ => {
|
||||||
error!("Error: unexpected response -> {:?}", r);
|
error!("Error calling kanidm_unixd: unexpected response -> {:?}", r);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Error -> {:?}", e);
|
error!("Error calling kanidm_unixd -> {:?}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue