X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-daemon%2Fsimple-protocol.c;h=33e5db333f9fcd419d67e414e6b18fc3dff28110;hb=f8f00d3edbecf619548779dc4244f075d6f4b32f;hp=4844ca49f1094bb2e7a5814ec0a75f7185d3f4c3;hpb=81a128c7a13247762b80b3928c20532b914cbd4b;p=catta diff --git a/avahi-daemon/simple-protocol.c b/avahi-daemon/simple-protocol.c index 4844ca4..33e5db3 100644 --- a/avahi-daemon/simple-protocol.c +++ b/avahi-daemon/simple-protocol.c @@ -25,22 +25,37 @@ #include #include +#include #include #include #include #include #include #include +#include #include #include #include + #include #include +#include #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 @@ -165,13 +180,13 @@ static void client_output_printf(Client *c, const char *format, ...) { } static void host_name_resolver_callback( - AvahiSHostNameResolver *r, + AVAHI_GCC_UNUSED AvahiSHostNameResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiResolverEvent event, const char *hostname, const AvahiAddress *a, - AvahiLookupResultFlags flags, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata) { Client *c = userdata; @@ -181,7 +196,7 @@ static void host_name_resolver_callback( if (event == AVAHI_RESOLVER_FAILURE) client_output_printf(c, "%+i %s\n", avahi_server_errno(avahi_server), avahi_strerror(avahi_server_errno(avahi_server))); else if (event == AVAHI_RESOLVER_FOUND) { - char t[64]; + char t[AVAHI_ADDRESS_STR_MAX]; avahi_address_snprint(t, sizeof(t), a); client_output_printf(c, "+ %i %u %s %s\n", iface, protocol, hostname, t); } @@ -190,13 +205,13 @@ static void host_name_resolver_callback( } static void address_resolver_callback( - AvahiSAddressResolver *r, + AVAHI_GCC_UNUSED AvahiSAddressResolver *r, AvahiIfIndex iface, AvahiProtocol protocol, AvahiResolverEvent event, - const AvahiAddress *a, + AVAHI_GCC_UNUSED const AvahiAddress *a, const char *hostname, - AvahiLookupResultFlags flags, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata) { Client *c = userdata; @@ -212,18 +227,18 @@ static void address_resolver_callback( } static void dns_server_browser_callback( - AvahiSDNSServerBrowser *b, + AVAHI_GCC_UNUSED AvahiSDNSServerBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, - const char *host_name, + AVAHI_GCC_UNUSED const char *host_name, const AvahiAddress *a, uint16_t port, - AvahiLookupResultFlags flags, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata) { Client *c = userdata; - char t[64]; + char t[AVAHI_ADDRESS_STR_MAX]; assert(c); @@ -317,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; @@ -325,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; @@ -333,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); @@ -368,7 +383,7 @@ static void handle_input(Client *c) { } } -static void client_work(AvahiWatch *watch, int fd, AvahiWatchEvent events, void *userdata) { +static void client_work(AvahiWatch *watch, AVAHI_GCC_UNUSED int fd, AvahiWatchEvent events, void *userdata) { Client *c = userdata; assert(c); @@ -416,7 +431,7 @@ static void client_work(AvahiWatch *watch, int fd, AvahiWatchEvent events, void (c->inbuf_length < sizeof(c->inbuf) ? AVAHI_WATCH_IN : 0)); } -static void server_work(AvahiWatch *watch, int fd, AvahiWatchEvent events, void *userdata) { +static void server_work(AVAHI_GCC_UNUSED AvahiWatch *watch, int fd, AvahiWatchEvent events, void *userdata) { Server *s = userdata; assert(s); @@ -457,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; } @@ -494,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);