|
@ -19,7 +19,9 @@ use symbols::tls::SelfSignedTlsCert; |
|
|
use symbols::{Symbol, SymbolRunner};
|
|
|
use symbols::{Symbol, SymbolRunner};
|
|
|
|
|
|
|
|
|
pub trait Policy {
|
|
|
pub trait Policy {
|
|
|
fn user_name_for_host(&self, host_name: &'static str) -> String;
|
|
|
|
|
|
|
|
|
fn user_name_for_host(&self, host_name: &'static str) -> String {
|
|
|
|
|
|
host_name.split('.').rev().fold(String::new(), |result, part| if result.is_empty() { result } else { result + "_" } + part)
|
|
|
|
|
|
}
|
|
|
fn home_for_user(&self, user_name: &str) -> String {
|
|
|
fn home_for_user(&self, user_name: &str) -> String {
|
|
|
format!("/home/{}", user_name)
|
|
|
format!("/home/{}", user_name)
|
|
|
}
|
|
|
}
|
|
@ -27,11 +29,7 @@ pub trait Policy { |
|
|
|
|
|
|
|
|
pub struct DefaultPolicy;
|
|
|
pub struct DefaultPolicy;
|
|
|
|
|
|
|
|
|
impl Policy for DefaultPolicy {
|
|
|
|
|
|
fn user_name_for_host(&self, host_name: &'static str) -> String {
|
|
|
|
|
|
host_name.split('.').rev().fold(String::new(), |result, part| if result.is_empty() { result } else { result + "_" } + part)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
impl Policy for DefaultPolicy {}
|
|
|
|
|
|
|
|
|
pub struct SymbolFactory<'a, C: 'a + CommandRunner, R: 'a + SymbolRunner, P: 'a + Policy> {
|
|
|
pub struct SymbolFactory<'a, C: 'a + CommandRunner, R: 'a + SymbolRunner, P: 'a + Policy> {
|
|
|
command_runner: &'a C,
|
|
|
command_runner: &'a C,
|
|
|