public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Hannes Laimer <h.laimer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] chunk_store: fix problem with permission checking
Date: Wed, 13 Nov 2024 13:40:47 +0100	[thread overview]
Message-ID: <20241113124047.97456-1-h.laimer@proxmox.com> (raw)

Permissions are stored in the lower 9 bits (rwxrwxrwx),
so we have to mask `st_mode` with 0o777.
The datastore root dir is created with 755, the `.chunks` dir and its
contents with 750 and the `.lock` file with 644, this changes the
expected permissions accordingly.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
 pbs-datastore/src/chunk_store.rs | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs
index 38a88584..29d5874a 100644
--- a/pbs-datastore/src/chunk_store.rs
+++ b/pbs-datastore/src/chunk_store.rs
@@ -576,7 +576,7 @@ impl ChunkStore {
             Ok(stat) => {
                 if stat.st_uid != u32::from(pbs_config::backup_user()?.uid)
                     || stat.st_gid != u32::from(pbs_config::backup_group()?.gid)
-                    || stat.st_mode != file_mode
+                    || stat.st_mode & 0o777 != file_mode
                 {
                     bail!(
                             "unable to open existing chunk store path {:?} - permissions or owner not correct",
@@ -598,22 +598,22 @@ impl ChunkStore {
     /// subdirectories and the lock file.
     pub fn verify_chunkstore<T: AsRef<Path>>(path: T) -> Result<(), Error> {
         // Check datastore root path perm/owner
-        ChunkStore::check_permissions(path.as_ref(), 0o700)?;
+        ChunkStore::check_permissions(path.as_ref(), 0o755)?;
 
         let chunk_dir = Self::chunk_dir(path.as_ref());
         // Check datastore .chunks path perm/owner
-        ChunkStore::check_permissions(&chunk_dir, 0o700)?;
+        ChunkStore::check_permissions(&chunk_dir, 0o750)?;
 
         // Check all .chunks subdirectories
         for i in 0..64 * 1024 {
             let mut l1path = chunk_dir.clone();
             l1path.push(format!("{:04x}", i));
-            ChunkStore::check_permissions(&l1path, 0o700)?;
+            ChunkStore::check_permissions(&l1path, 0o750)?;
         }
 
         // Check .lock file
         let lockfile_path = Self::lockfile_path(path.as_ref());
-        ChunkStore::check_permissions(lockfile_path, 0o600)?;
+        ChunkStore::check_permissions(lockfile_path, 0o644)?;
         Ok(())
     }
 }
-- 
2.39.5



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


             reply	other threads:[~2024-11-13 12:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-13 12:40 Hannes Laimer [this message]
2024-11-13 14:20 ` Gabriel Goller
2024-11-13 14:42   ` Wolfgang Bumiller
2024-11-14  9:45     ` Gabriel Goller
2024-11-22  8:01 ` [pbs-devel] applied-series: " Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241113124047.97456-1-h.laimer@proxmox.com \
    --to=h.laimer@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal