Skip to content

Commit

Permalink
improved file handling by removing machine username
Browse files Browse the repository at this point in the history
Signed-off-by: ayushka11 <[email protected]>
  • Loading branch information
ayushka11 committed Jan 23, 2025
1 parent c7ec822 commit ed6c395
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;

Expand Down
2 changes: 1 addition & 1 deletion src/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit ed6c395

Please sign in to comment.