[pbs-devel] possible problem in get_user_run_dir()

Stefan Reiter s.reiter at proxmox.com
Thu May 6 09:26:02 CEST 2021


On 06/05/2021 08:39, Dietmar Maurer wrote:
> The code get_user_run_dir() looks wrong, because a normal user does not have
> permissions required for tools::create_run_dir().
> 
> Please can you take a look at that?
> 

Yes, already had an off-list discussion with Fabian about this, the 
problem here is that /run/proxmox-backup might not exist when this is 
run, but only root can create it - so far, only root calls it (despite 
the misleading comment), so it works, but for the future, we might want 
to fall back to XDG_USER_RUNTIME_DIR (doesn't always exist though), /tmp 
or some other guaranteed-user-writeable temp location.

> --- from src/bin/proxmox_client_tools/mod.rs---
> 
> pub fn get_user_run_dir() -> Result<std::path::PathBuf, Error> {
>      let uid = nix::unistd::Uid::current();
>      let mut path: std::path::PathBuf = buildcfg::PROXMOX_BACKUP_RUN_DIR.into();
>      path.push(uid.to_string());
>      tools::create_run_dir()?;
>      std::fs::create_dir_all(&path)?;
>      Ok(path)
> }
> 





More information about the pbs-devel mailing list