]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sys: don't start privops helper for NTS-KE helper
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 5 Oct 2020 16:14:23 +0000 (18:14 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 5 Oct 2020 16:56:37 +0000 (18:56 +0200)
The NTS-KE helper doesn't need to bind sockets or adjust the clock.
Don't start the privops helper, or keep the capabilities, when dropping
root privileges in its context.

sys_linux.c
sys_macosx.c
sys_netbsd.c
sys_solaris.c

index 2f7fa9fe7ae33fc01af928a040b92f36edb5c9b2..0b24445e173d1ccab9eb0b111663bc75b239e0fb 100644 (file)
@@ -450,6 +450,10 @@ SYS_Linux_DropRoot(uid_t uid, gid_t gid, SYS_ProcessContext context, int clock_c
                clock_control ? "cap_sys_time=ep" : "") >= sizeof (cap_text))
     assert(0);
 
+  /* Helpers don't need any capabilities */
+  if (context != SYS_MAIN_PROCESS)
+    cap_text[0] = '\0';
+
   if ((cap = cap_from_text(cap_text)) == NULL) {
     LOG_FATAL("cap_from_text() failed");
   }
index eb7297d64a73cfbeb5d50cb1397fa28491a4c0c8..e3a38ed1891b973ad85656f66ef8022eb5918682 100644 (file)
@@ -417,7 +417,8 @@ SYS_MacOSX_SetScheduler(int SchedPriority)
 #ifdef FEAT_PRIVDROP
 void SYS_MacOSX_DropRoot(uid_t uid, gid_t gid, SYS_ProcessContext context)
 {
-  PRV_StartHelper();
+  if (context == SYS_MAIN_PROCESS)
+    PRV_StartHelper();
 
   UTI_DropRoot(uid, gid);
 }
index 350f569926067f0e3130c8367fc932640a1eb56e..36ffa182aa5c0569c361b5fb8e3b94e4732c2ccd 100644 (file)
@@ -139,7 +139,8 @@ SYS_NetBSD_DropRoot(uid_t uid, gid_t gid, SYS_ProcessContext context)
 
   /* On NetBSD the helper is used only for socket binding, but on FreeBSD
      it's used also for setting and adjusting the system clock */
-  PRV_StartHelper();
+  if (context == SYS_MAIN_PROCESS)
+    PRV_StartHelper();
 
   UTI_DropRoot(uid, gid);
 
index 9585100e1c2ff47524a734ad0541bafacc08c4c8..ba86c11adff9d6df9f1028a7daad2cf072333cf6 100644 (file)
@@ -57,7 +57,8 @@ SYS_Solaris_Finalise(void)
 void
 SYS_Solaris_DropRoot(uid_t uid, gid_t gid, SYS_ProcessContext context)
 {
-  PRV_StartHelper();
+  if (context == SYS_MAIN_PROCESS)
+    PRV_StartHelper();
   UTI_DropRoot(uid, gid);
 }
 #endif