]> git.meshlink.io Git - catta/blobdiff - avahi-daemon/simple-protocol.c
bump sonames
[catta] / avahi-daemon / simple-protocol.c
index a3b48cce4c3991765cb863ad94229521849ec28c..33e5db333f9fcd419d67e414e6b18fc3dff28110 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
+
+#ifndef AF_LOCAL
+#define AF_LOCAL AF_UNIX
+#endif
+#ifndef PF_LOCAL
+#define PF_LOCAL PF_UNIX
+#endif
+
 #define BUFFER_SIZE (20*1024)
 
 #define CLIENTS_MAX 50
@@ -319,7 +332,7 @@ static void handle_line(Client *c, const char *s) {
             goto fail;
         client_output_printf(c, "+ Browsing ...\n");
 
-        avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg);
+        avahi_log_debug(__FILE__": Got %s request.", cmd);
 
     } else if (strcmp(cmd, "BROWSE-DNS-SERVERS-IPV6") == 0 && n_args == 1) {
         c->state = CLIENT_BROWSE_DNS_SERVERS;
@@ -327,7 +340,7 @@ static void handle_line(Client *c, const char *s) {
             goto fail;
         client_output_printf(c, "+ Browsing ...\n");
 
-        avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg);
+        avahi_log_debug(__FILE__": Got %s request.", cmd);
 
     } else if (strcmp(cmd, "BROWSE-DNS-SERVERS") == 0 && n_args == 1) {
         c->state = CLIENT_BROWSE_DNS_SERVERS;
@@ -335,7 +348,7 @@ static void handle_line(Client *c, const char *s) {
             goto fail;
         client_output_printf(c, "+ Browsing ...\n");
 
-        avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg);
+        avahi_log_debug(__FILE__": Got %s request.", cmd);
 
     } else {
         client_output_printf(c, "%+i Invalid command \"%s\", try \"HELP\".\n", AVAHI_ERR_INVALID_OPERATION, cmd);
@@ -459,13 +472,13 @@ int simple_protocol_setup(const AvahiPoll *poll_api) {
     strncpy(sa.sun_path, AVAHI_SOCKET, sizeof(sa.sun_path)-1);
 
     /* We simply remove existing UNIX sockets under this name. The
-       Avahi daemons makes sure that it runs only once on a host,
+       Avahi daemon makes sure that it runs only once on a host,
        therefore sockets that already exist are stale and may be
        removed without any ill effects */
 
     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 +509,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);