1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
#![deny(warnings)] #![warn(unused_extern_crates)] #![deny(clippy::unwrap_used)] #![deny(clippy::expect_used)] #![deny(clippy::panic)] #![deny(clippy::unreachable)] #![deny(clippy::await_holding_lock)] #![deny(clippy::needless_pass_by_value)] #![deny(clippy::trivially_copy_pass_by_ref)] #[macro_use] extern crate log; use log::debug; use structopt::StructOpt; use futures::executor::block_on; use kanidm_unix_common::client::call_daemon; use kanidm_unix_common::unix_config::KanidmUnixdConfig; use kanidm_unix_common::unix_proto::{ClientRequest, ClientResponse}; include!("./opt/cache_clear.rs"); #[tokio::main] async fn main() { let opt = CacheClearOpt::from_args(); if opt.debug { ::std::env::set_var("RUST_LOG", "kanidm=debug,kanidm_client=debug"); } else { ::std::env::set_var("RUST_LOG", "kanidm=info,kanidm_client=info"); } env_logger::init(); debug!("Starting cache invalidate tool ..."); let cfg = match KanidmUnixdConfig::new().read_options_from_optional_config("/etc/kanidm/unixd") { Ok(c) => c, Err(_e) => { error!("Failed to parse /etc/kanidm/unixd"); std::process::exit(1); } }; if !opt.really { error!("Are you sure you want to proceed? If so use --really"); return; } let req = ClientRequest::ClearCache; match block_on(call_daemon(cfg.sock_path.as_str(), req)) { Ok(r) => match r { ClientResponse::Ok => info!("success"), _ => { error!("Error: unexpected response -> {:?}", r); } }, Err(e) => { error!("Error -> {:?}", e); } } }