[chrony-dev] shm permissions

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]



Hi,

ntpd creates the shm refclock segments 2 and 3 with permissions 0666 (previously 0777), allowing also non-root users to provide synchronisation data when these segments are set up. The attached patch changes chrony to do that to (currently 0700 for all segments). It also changes the permissions from 7 to 6, i.e. removing the useless execute-bits.

Cheers,
Håkan
diff --git a/refclock_shm.c b/refclock_shm.c
index b3b689b..9f46a0c 100644
--- a/refclock_shm.c
+++ b/refclock_shm.c
@@ -56,12 +56,18 @@ struct shmTime {
 };
 
 static int shm_initialise(RCL_Instance instance) {
-  int id, param;
+  int id, param, perm;
   struct shmTime *shm;
 
   param = atoi(RCL_GetDriverParameter(instance));
 
-  id = shmget(SHMKEY + param, sizeof (struct shmTime), IPC_CREAT | 0700);
+  if (param < 2) {
+    perm = 0700;
+  } else {
+    perm = 0777;
+  }
+
+  id = shmget(SHMKEY + param, sizeof (struct shmTime), IPC_CREAT | perm);
   if (id == -1) {
     LOG_FATAL(LOGF_Refclock, "shmget() failed");
     return 0;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/