diff --git a/flake.nix b/flake.nix index 90ef311..28b1d4e 100644 --- a/flake.nix +++ b/flake.nix @@ -56,6 +56,7 @@ DATABASE = "database.db"; CSV = "wolves.csv"; HOST_PORT = cfg.host_port; + SSH_ROOT = "/skynet_old/home"; # Email stuff EMAIL_SMTP = cfg.mail.host; diff --git a/src/lib.rs b/src/lib.rs index d1fafa6..7e730dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -188,6 +188,7 @@ pub struct Config { pub mail_smtp: String, pub mail_user: String, pub mail_pass: String, + pub ssh_root: String, } pub fn get_config() -> Config { @@ -205,6 +206,7 @@ pub fn get_config() -> Config { mail_smtp: "".to_string(), mail_user: "".to_string(), mail_pass: "".to_string(), + ssh_root: "/skynet_old/home".to_string(), }; if let Ok(x) = env::var("LDAP_HOST") { @@ -237,6 +239,9 @@ pub fn get_config() -> Config { if let Ok(x) = env::var("EMAIL_PASS") { config.mail_pass = x.trim().to_string(); } + if let Ok(x) = env::var("SSH_ROOT") { + config.ssh_root = x.trim().to_string(); + } config } diff --git a/src/methods/account_recover.rs b/src/methods/account_recover.rs index 68df84c..daddbfa 100644 --- a/src/methods/account_recover.rs +++ b/src/methods/account_recover.rs @@ -458,9 +458,10 @@ pub mod ssh { return Ok(json!({"result": "error", "error": "Skynet email not permitted."}).into()); } + let config = &req.state().config; + // check if //.ssh/authorized_keys exists - //let root = "/skynet_old"; - let root = "."; + let root = &config.ssh_root; let path = format!("{}/{}/.ssh/authorized_keys", root, user); let mut keys = vec![]; if fs::read_to_string(&path).is_ok() {