# Description: Use separate constants for file and shared memory permissions
#  At least in theory, the constants can be different
# Author: Damyan Ivanov <dmn@debian.org>
# Forwarded: no
--- a/src/jrd/isc_sync.cpp
+++ b/src/jrd/isc_sync.cpp
@@ -103,7 +103,18 @@ static int process_id;
 #include <sys/mman.h>
 
 #define FTOK_KEY	15
-#define PRIV		0666
+
+#define FILE_PERM       0660
+#if defined(SEM_R) && defined(SEM_A)
+#define SEM_PERM        SEM_R | (SEM_R>>3) | SEM_A | (SEM_A>>3)
+#else
+#define SEM_PERM        FILE_PERM
+#endif
+#if defined(SHM_R) && defined(SHM_W)
+#define SHM_PERM        SHM_R | (SHM_R>>3) | SHM_W | (SHM_W>>3)
+#else
+#define SHM_PERM        FILE_PERM
+#endif
 
 //#ifndef SHMEM_DELTA
 //#define SHMEM_DELTA	(1 << 22)
@@ -4271,7 +4282,7 @@ static SLONG create_semaphores(ISC_STATU
 		}
 
 		// Try to create new semaphore set
-		semid = semget(key, semaphores, IPC_CREAT | IPC_EXCL | PRIV);
+		semid = semget(key, semaphores, IPC_CREAT | IPC_EXCL | SHM_PERM);
 		if (semid != -1)
 		{
 			// We want to limit access to semaphores, created here
