]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
socket: don't log errors on removing socket
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 17 Jun 2020 09:24:15 +0000 (11:24 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 17 Jun 2020 13:24:55 +0000 (15:24 +0200)
Call unlink() directly to avoid an error log message when a Unix domain
socket cannot be removed (e.g. SOCK refclock created for gpsd in
/var/run).

socket.c

index 65befc7ac9ca00609fb694ef8c688e274f1e28aa..952b0d8731fc7d60feb14335ca91557f97aa094a 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -476,8 +476,8 @@ bind_unix_address(int sock_fd, const char *addr, int flags)
   }
   saddr.un.sun_family = AF_UNIX;
 
-  if (!UTI_RemoveFile(NULL, addr, NULL))
-    ;
+  if (unlink(addr) < 0)
+    DEBUG_LOG("Could not remove %s : %s", addr, strerror(errno));
 
   /* PRV_BindSocket() doesn't support Unix sockets yet */
   if (bind(sock_fd, &saddr.sa, sizeof (saddr.un)) < 0) {
@@ -1440,8 +1440,10 @@ SCK_RemoveSocket(int sock_fd)
       saddr.sa.sa_family != AF_UNIX)
     return 0;
 
-  if (!UTI_RemoveFile(NULL, saddr.un.sun_path, NULL))
+  if (unlink(saddr.un.sun_path) < 0) {
+    DEBUG_LOG("Could not remove %s : %s", saddr.un.sun_path, strerror(errno));
     return 0;
+  }
 
   return 1;
 }