]> git.proxmox.com Git - proxmox-backup.git/commitdiff
fix permissions set in create_run_dir
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 4 May 2021 07:45:27 +0000 (09:45 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 4 May 2021 10:11:35 +0000 (12:11 +0200)
This directory needs to be owned by the backup user instead
of root.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/tools.rs

index 25323881a5d3f27d69c5496939fe5f7ed931e584..c58569a6279805dbec45fcd2a00a40ff08a36931 100644 (file)
@@ -16,6 +16,7 @@ use openssl::hash::{hash, DigestBytes, MessageDigest};
 use percent_encoding::{utf8_percent_encode, AsciiSet};
 
 pub use proxmox::tools::fd::Fd;
+use proxmox::tools::fs::{create_path, CreateOptions};
 
 pub mod acl;
 pub mod apt;
@@ -569,7 +570,11 @@ pub fn compute_file_csum(file: &mut File) -> Result<([u8; 32], u64), Error> {
 /// This exists to fixate the permissions for the run *base* directory while allowing intermediate
 /// directories after it to have different permissions.
 pub fn create_run_dir() -> Result<(), Error> {
-    let _: bool = proxmox::tools::fs::create_path(PROXMOX_BACKUP_RUN_DIR_M!(), None, None)?;
+    let backup_user = crate::backup::backup_user()?;
+    let opts = CreateOptions::new()
+        .owner(backup_user.uid)
+        .group(backup_user.gid);
+    let _: bool = create_path(PROXMOX_BACKUP_RUN_DIR_M!(), None, Some(opts))?;
     Ok(())
 }