]> git.meshlink.io Git - catta/blobdiff - avahi-daemon/simple-protocol.c
proposed patch to close Ticket #20
[catta] / avahi-daemon / simple-protocol.c
index a3b48cce4c3991765cb863ad94229521849ec28c..3cac7134f5c801280fe75a485deef4e090a5c7f8 100644 (file)
 
 #include <assert.h>
 #include <string.h>
+#include <sys/types.h>
 #include <sys/socket.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/un.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <sys/stat.h>
 
 #include <avahi-common/llist.h>
 #include <avahi-common/malloc.h>
 #include "simple-protocol.h"
 #include "main.h"
 
+#ifdef ENABLE_CHROOT
+#include "chroot.h"
+#endif
+
 #define BUFFER_SIZE (20*1024)
 
 #define CLIENTS_MAX 50
@@ -465,7 +471,7 @@ int simple_protocol_setup(const AvahiPoll *poll_api) {
 
     unlink(AVAHI_SOCKET);
     
-    if (bind(server->fd, &sa, sizeof(sa)) < 0) {
+    if (bind(server->fd, (struct sockaddr*) &sa, sizeof(sa)) < 0) {
         avahi_log_warn("bind(): %s", strerror(errno));
         goto fail;
     }
@@ -496,7 +502,11 @@ void simple_protocol_shutdown(void) {
     if (server) {
 
         if (server->bind_successful)
+#ifdef ENABLE_CHROOT
+            avahi_chroot_helper_unlink(AVAHI_SOCKET);
+#else
             unlink(AVAHI_SOCKET);
+#endif
 
         while (server->clients)
             client_free(server->clients);