diff --git a/src/auth.rs b/src/auth.rs index 973988c..a68fe48 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -22,8 +22,9 @@ pub fn handle_auth(ssh_host_username: &str, ssh_key: &str) -> Result<()> { "ssh_key = '{}'\n", ssh_key ); - //file name is ssh_host_username_pam_tty - let file_name = ssh_host_username.to_string() + "_" + &pam_tty; //might cause problems due to String and &str + + //file name is pam_tty + let file_name = pam_tty.replace("/", "_"); fs::write("/opt/watchdog/ssh_env/file_name", data) .chain_err(|| "Cannot write temporary environment file. Please check if the watchdog `auth_keys_cmd` is run by the root user")?; diff --git a/src/ssh.rs b/src/ssh.rs index 23d3aee..9bf7f0f 100644 --- a/src/ssh.rs +++ b/src/ssh.rs @@ -25,7 +25,7 @@ pub fn handle_ssh() -> Result<()> { let config = read_config()?; init(&config)?; - let file_name = pam_ruser.to_string() + "_" + &pam_tty; //might cause problems due to String and &str + let file_name = pam_tty.replace("/", "_"); //dev_pts_0 let env = read_temp_env("/opt/watchdog/ssh_env/file_name")?; //read appropriate env file let name = get_name(&config, &env.ssh_key)?;