Merge branch 'collectd-5.4' into collectd-5.5
[collectd.git] / src / unixsock.c
index 664c018..e62ed6c 100644 (file)
@@ -128,7 +128,16 @@ static int us_open_socket (void)
                return (-1);
        }
 
-       chmod (sa.sun_path, sock_perms);
+       status = chmod (sa.sun_path, sock_perms);
+       if (status == -1)
+       {
+               char errbuf[1024];
+               ERROR ("unixsock plugin: chmod failed: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+               close (sock_fd);
+               sock_fd = -1;
+               return (-1);
+       }
 
        status = listen (sock_fd, 8);
        if (status != 0)