diff mbox series

[pseudo,2/6] pseudo_client.h: Make it clear both macros must be updated together

Message ID 1780519148-30836-3-git-send-email-mark.hatle@kernel.crashing.org
State New
Headers show
Series Permission/setuid/setgid handling | expand

Commit Message

Mark Hatle June 3, 2026, 8:39 p.m. UTC
From: Mark Hatle <mark.hatle@amd.com>

Both PSEUDO_FS_MODE and PSEUDO_DB_MODE must be updated together. The
first defined the masking for the mode on the disk, while the second
filters the masking so we know which modes from the disk can be
trusted.

Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
---
 pseudo_client.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/pseudo_client.h b/pseudo_client.h
index e963d95..b5ec204 100644
--- a/pseudo_client.h
+++ b/pseudo_client.h
@@ -87,7 +87,10 @@  extern int read_pidfile(FILE *, int *);
  * When doing anything which actually writes to the filesystem, we add in
  * the user read/write/execute bits.  When storing to the database, though,
  * we mask out any such bits which weren't in the original mode.
+ *
+ * Note: PSEUDO_DB_MODE must be kept in sync with PSEUDO_FS_MODE, as the
+ * former defined which filesystem mode bits must be loaded from the DB.
  */
 #define PSEUDO_FS_MODE(mode, isdir) (((mode) | S_IRUSR | S_IWUSR | ((isdir) ? S_IXUSR : 0)) & ~(S_IWGRP | S_IWOTH))
-#define PSEUDO_DB_MODE(fs_mode, user_mode) (((fs_mode) & ~0722) | ((user_mode & 0722)))
+#define PSEUDO_DB_MODE(fs_mode, user_mode) (((fs_mode) & ~(S_IRUSR | S_IWUSR | S_IXUSR | S_IWGRP | S_IWOTH)) | ((user_mode) & (S_IRUSR | S_IWUSR | S_IXUSR | S_IWGRP | S_IWOTH)))