Skip to content

Commit

Permalink
minor file path fix
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 ed6c395 commit 4a2b158
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ pub fn handle_auth(ssh_host_username: &str, ssh_key: &str) -> Result<()> {

//file name is pam_tty
let file_name = pam_tty.replace("/", "_");
fs::write("/opt/watchdog/ssh_env/file_name", data)

let path = format!("/opt/watchdog/ssh_env/{}", file_name);

fs::write(&path, data)
.chain_err(|| "Cannot write temporary environment file. Please check if the watchdog `auth_keys_cmd` is run by the root user")?;

println!("{}", ssh_key);
Expand Down
6 changes: 4 additions & 2 deletions src/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ pub fn handle_ssh() -> Result<()> {

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 path = format!("/opt/watchdog/ssh_env/{}", file_name);

let env = read_temp_env(&path)?; //read appropriate env file
let name = get_name(&config, &env.ssh_key)?;

match fork() {
Ok(ForkResult::Parent { .. }) => {
clear_file("/opt/watchdog/ssh_env/file_name")?;
clear_file(&path)?;
}
Ok(ForkResult::Child) => {
notifier::post_ssh_summary(&config, true, name, pam_ruser)?;
Expand Down

0 comments on commit 4a2b158

Please sign in to comment.