]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sys_linux: don't keep NET_RAW on new kernels
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 15 Sep 2020 09:57:17 +0000 (11:57 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 16 Sep 2020 09:15:29 +0000 (11:15 +0200)
It seems the NET_RAW capability is no longer needed to bind a socket to
a device since Linux 5.7.

sys_linux.c

index af45066d68b94d1427afa3e487b615785e9cdda2..411ceec5eb904724beda2bb99849160ff911a9f0 100644 (file)
@@ -438,12 +438,13 @@ SYS_Linux_DropRoot(uid_t uid, gid_t gid, int clock_control)
   UTI_DropRoot(uid, gid);
 
   /* Keep CAP_NET_BIND_SERVICE if the NTP server sockets may need to be bound.
-     Keep CAP_NET_RAW if an NTP socket may need to be bound to a device.
+     Keep CAP_NET_RAW if an NTP socket may need to be bound to a device on
+     kernels before 5.7.
      Keep CAP_SYS_TIME if the clock control is enabled. */
   if (snprintf(cap_text, sizeof (cap_text), "%s %s %s",
                CNF_GetNTPPort() ? "cap_net_bind_service=ep" : "",
-               CNF_GetBindNtpInterface() || CNF_GetBindAcquisitionInterface() ?
-                 "cap_net_raw=ep" : "",
+               (CNF_GetBindNtpInterface() || CNF_GetBindAcquisitionInterface()) &&
+                 !SYS_Linux_CheckKernelVersion(5, 7) ? "cap_net_raw=ep" : "",
                clock_control ? "cap_sys_time=ep" : "") >= sizeof (cap_text))
     assert(0);