mirror of
https://github.com/kanidm/kanidm.git
synced 2025-04-16 15:25:39 +02:00
Review Feedback
This commit is contained in:
parent
f9ca11aca1
commit
f1e70b2422
unix_integration
common/src
nss_kanidm/src
pam_kanidm/src
resolver/src/bin
|
@ -558,28 +558,28 @@ impl UnixdConfig {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
/// This is the parsed configuration that will be used by pam/nss tools that need fast access to
|
/// This is the parsed configuration that will be used by pam/nss tools that need fast access to
|
||||||
/// only the socket and timeout information related to the resolver.
|
/// only the socket and timeout information related to the resolver.
|
||||||
pub struct KanidmUnixdConfig {
|
pub struct PamNssConfig {
|
||||||
pub sock_path: String,
|
pub sock_path: String,
|
||||||
// pub conn_timeout: u64,
|
// pub conn_timeout: u64,
|
||||||
pub unix_sock_timeout: u64,
|
pub unix_sock_timeout: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for KanidmUnixdConfig {
|
impl Default for PamNssConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
KanidmUnixdConfig::new()
|
PamNssConfig::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for KanidmUnixdConfig {
|
impl Display for PamNssConfig {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
writeln!(f, "sock_path: {}", self.sock_path)?;
|
writeln!(f, "sock_path: {}", self.sock_path)?;
|
||||||
writeln!(f, "unix_sock_timeout: {}", self.unix_sock_timeout)
|
writeln!(f, "unix_sock_timeout: {}", self.unix_sock_timeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KanidmUnixdConfig {
|
impl PamNssConfig {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
KanidmUnixdConfig {
|
PamNssConfig {
|
||||||
sock_path: DEFAULT_SOCK_PATH.to_string(),
|
sock_path: DEFAULT_SOCK_PATH.to_string(),
|
||||||
unix_sock_timeout: DEFAULT_CONN_TIMEOUT * 2,
|
unix_sock_timeout: DEFAULT_CONN_TIMEOUT * 2,
|
||||||
}
|
}
|
||||||
|
@ -646,7 +646,7 @@ impl KanidmUnixdConfig {
|
||||||
.unwrap_or(self.unix_sock_timeout);
|
.unwrap_or(self.unix_sock_timeout);
|
||||||
|
|
||||||
// Now map the values into our config.
|
// Now map the values into our config.
|
||||||
Ok(KanidmUnixdConfig {
|
Ok(PamNssConfig {
|
||||||
sock_path: config.sock_path.unwrap_or(self.sock_path),
|
sock_path: config.sock_path.unwrap_or(self.sock_path),
|
||||||
unix_sock_timeout,
|
unix_sock_timeout,
|
||||||
})
|
})
|
||||||
|
@ -660,7 +660,7 @@ impl KanidmUnixdConfig {
|
||||||
.map(|timeout| timeout * 2);
|
.map(|timeout| timeout * 2);
|
||||||
|
|
||||||
// Now map the values into our config.
|
// Now map the values into our config.
|
||||||
Ok(KanidmUnixdConfig {
|
Ok(PamNssConfig {
|
||||||
sock_path: config.sock_path.unwrap_or(self.sock_path),
|
sock_path: config.sock_path.unwrap_or(self.sock_path),
|
||||||
unix_sock_timeout: kanidm_conn_timeout.unwrap_or(self.unix_sock_timeout),
|
unix_sock_timeout: kanidm_conn_timeout.unwrap_or(self.unix_sock_timeout),
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use kanidm_unix_common::client_sync::DaemonClientBlocking;
|
use kanidm_unix_common::client_sync::DaemonClientBlocking;
|
||||||
use kanidm_unix_common::unix_config::KanidmUnixdConfig;
|
use kanidm_unix_common::unix_config::PamNssConfig;
|
||||||
use kanidm_unix_common::unix_passwd::{
|
use kanidm_unix_common::unix_passwd::{
|
||||||
read_etc_group_file, read_etc_passwd_file, EtcGroup, EtcUser,
|
read_etc_group_file, read_etc_passwd_file, EtcGroup, EtcUser,
|
||||||
};
|
};
|
||||||
|
@ -36,7 +36,7 @@ impl RequestOptions {
|
||||||
fn connect_to_daemon(self) -> Source {
|
fn connect_to_daemon(self) -> Source {
|
||||||
match self {
|
match self {
|
||||||
RequestOptions::Main { config_path } => {
|
RequestOptions::Main { config_path } => {
|
||||||
let maybe_client = KanidmUnixdConfig::new()
|
let maybe_client = PamNssConfig::new()
|
||||||
.read_options_from_optional_config(config_path)
|
.read_options_from_optional_config(config_path)
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|cfg| {
|
.and_then(|cfg| {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::constants::PamResultCode;
|
||||||
use crate::module::PamResult;
|
use crate::module::PamResult;
|
||||||
use crate::pam::ModuleOptions;
|
use crate::pam::ModuleOptions;
|
||||||
use kanidm_unix_common::client_sync::DaemonClientBlocking;
|
use kanidm_unix_common::client_sync::DaemonClientBlocking;
|
||||||
use kanidm_unix_common::unix_config::KanidmUnixdConfig;
|
use kanidm_unix_common::unix_config::PamNssConfig;
|
||||||
use kanidm_unix_common::unix_passwd::{
|
use kanidm_unix_common::unix_passwd::{
|
||||||
read_etc_passwd_file, read_etc_shadow_file, EtcShadow, EtcUser,
|
read_etc_passwd_file, read_etc_shadow_file, EtcShadow, EtcUser,
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,7 @@ impl RequestOptions {
|
||||||
fn connect_to_daemon(self) -> Source {
|
fn connect_to_daemon(self) -> Source {
|
||||||
match self {
|
match self {
|
||||||
RequestOptions::Main { config_path } => {
|
RequestOptions::Main { config_path } => {
|
||||||
let maybe_client = KanidmUnixdConfig::new()
|
let maybe_client = PamNssConfig::new()
|
||||||
.read_options_from_optional_config(config_path)
|
.read_options_from_optional_config(config_path)
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|cfg| {
|
.and_then(|cfg| {
|
||||||
|
|
|
@ -36,7 +36,7 @@ use std::convert::TryFrom;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
|
||||||
use kanidm_unix_common::constants::DEFAULT_CONFIG_PATH;
|
use kanidm_unix_common::constants::DEFAULT_CONFIG_PATH;
|
||||||
use kanidm_unix_common::unix_config::KanidmUnixdConfig;
|
use kanidm_unix_common::unix_config::PamNssConfig;
|
||||||
|
|
||||||
use crate::core::{self, RequestOptions};
|
use crate::core::{self, RequestOptions};
|
||||||
use crate::pam::constants::*;
|
use crate::pam::constants::*;
|
||||||
|
@ -50,8 +50,8 @@ use tracing_subscriber::filter::LevelFilter;
|
||||||
use tracing_subscriber::fmt;
|
use tracing_subscriber::fmt;
|
||||||
use tracing_subscriber::prelude::*;
|
use tracing_subscriber::prelude::*;
|
||||||
|
|
||||||
pub fn get_cfg() -> Result<KanidmUnixdConfig, PamResultCode> {
|
pub fn get_cfg() -> Result<PamNssConfig, PamResultCode> {
|
||||||
KanidmUnixdConfig::new()
|
PamNssConfig::new()
|
||||||
.read_options_from_optional_config(DEFAULT_CONFIG_PATH)
|
.read_options_from_optional_config(DEFAULT_CONFIG_PATH)
|
||||||
.map_err(|_| PamResultCode::PAM_SERVICE_ERR)
|
.map_err(|_| PamResultCode::PAM_SERVICE_ERR)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ use std::process::ExitCode;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use kanidm_unix_common::client::DaemonClient;
|
use kanidm_unix_common::client::DaemonClient;
|
||||||
use kanidm_unix_common::constants::DEFAULT_CONFIG_PATH;
|
use kanidm_unix_common::constants::DEFAULT_CONFIG_PATH;
|
||||||
use kanidm_unix_common::unix_config::KanidmUnixdConfig;
|
use kanidm_unix_common::unix_config::PamNssConfig;
|
||||||
use kanidm_unix_common::unix_proto::{
|
use kanidm_unix_common::unix_proto::{
|
||||||
ClientRequest, ClientResponse, PamAuthRequest, PamAuthResponse, PamServiceInfo,
|
ClientRequest, ClientResponse, PamAuthRequest, PamAuthResponse, PamServiceInfo,
|
||||||
};
|
};
|
||||||
|
@ -28,8 +28,7 @@ include!("../opt/tool.rs");
|
||||||
|
|
||||||
macro_rules! setup_client {
|
macro_rules! setup_client {
|
||||||
() => {{
|
() => {{
|
||||||
let Ok(cfg) =
|
let Ok(cfg) = PamNssConfig::new().read_options_from_optional_config(DEFAULT_CONFIG_PATH)
|
||||||
KanidmUnixdConfig::new().read_options_from_optional_config(DEFAULT_CONFIG_PATH)
|
|
||||||
else {
|
else {
|
||||||
error!("Failed to parse {}", DEFAULT_CONFIG_PATH);
|
error!("Failed to parse {}", DEFAULT_CONFIG_PATH);
|
||||||
return ExitCode::FAILURE;
|
return ExitCode::FAILURE;
|
||||||
|
|
|
@ -19,7 +19,7 @@ use std::process::ExitCode;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use kanidm_unix_common::client::DaemonClient;
|
use kanidm_unix_common::client::DaemonClient;
|
||||||
use kanidm_unix_common::constants::DEFAULT_CONFIG_PATH;
|
use kanidm_unix_common::constants::DEFAULT_CONFIG_PATH;
|
||||||
use kanidm_unix_common::unix_config::KanidmUnixdConfig;
|
use kanidm_unix_common::unix_config::PamNssConfig;
|
||||||
use kanidm_unix_common::unix_proto::{ClientRequest, ClientResponse};
|
use kanidm_unix_common::unix_proto::{ClientRequest, ClientResponse};
|
||||||
|
|
||||||
include!("../opt/ssh_authorizedkeys.rs");
|
include!("../opt/ssh_authorizedkeys.rs");
|
||||||
|
@ -44,8 +44,7 @@ async fn main() -> ExitCode {
|
||||||
|
|
||||||
debug!("Starting authorized keys tool ...");
|
debug!("Starting authorized keys tool ...");
|
||||||
|
|
||||||
let cfg = match KanidmUnixdConfig::new().read_options_from_optional_config(DEFAULT_CONFIG_PATH)
|
let cfg = match PamNssConfig::new().read_options_from_optional_config(DEFAULT_CONFIG_PATH) {
|
||||||
{
|
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to parse {}: {:?}", DEFAULT_CONFIG_PATH, e);
|
error!("Failed to parse {}: {:?}", DEFAULT_CONFIG_PATH, e);
|
||||||
|
|
Loading…
Reference in a new issue