diff options
| -rw-r--r-- | avahi-autoipd/main.c | 4 | ||||
| -rw-r--r-- | avahi-client/client.c | 204 | ||||
| -rw-r--r-- | avahi-common/address.c | 16 | ||||
| -rw-r--r-- | avahi-common/thread-watch.c | 26 | ||||
| -rw-r--r-- | avahi-core/server.c | 304 | ||||
| -rwxr-xr-x | avahi-dnsconfd/avahi-dnsconfd.action | 22 | ||||
| -rw-r--r-- | avahi-ui/.gitignore | 2 | ||||
| -rw-r--r-- | avahi-ui/Makefile.am | 12 | ||||
| -rw-r--r-- | avahi-ui/avahi-ui.h | 3 | ||||
| -rw-r--r-- | avahi-ui/bssh.desktop.in.in (renamed from avahi-ui/bssh.desktop.in) | 0 | ||||
| -rw-r--r-- | avahi-ui/bvnc.desktop.in.in (renamed from avahi-ui/bvnc.desktop.in) | 0 | ||||
| -rw-r--r-- | initscript/fedora/avahi-daemon.in | 11 | ||||
| -rw-r--r-- | initscript/fedora/avahi-dnsconfd.in | 2 | ||||
| -rw-r--r-- | man/avahi-daemon.conf.5.xml.in | 2 | ||||
| -rw-r--r-- | po/POTFILES.in | 4 | ||||
| -rw-r--r-- | po/POTFILES.skip | 2 | ||||
| -rw-r--r-- | service-type-database/service-types | 3 | 
17 files changed, 332 insertions, 285 deletions
| diff --git a/avahi-autoipd/main.c b/avahi-autoipd/main.c index 01ccc79..ef529b9 100644 --- a/avahi-autoipd/main.c +++ b/avahi-autoipd/main.c @@ -1144,9 +1144,13 @@ static int loop(int iface, uint32_t addr) {          for (i = 0; i < ETHER_ADDRLEN; i++)              a += hw_address[i]*i; +        a = (a % 0xFE00) + 0x0100; +          addr = htonl(IPV4LL_NETWORK | (uint32_t) a);      } +    assert(is_ll_address(addr)); +      set_state(st, 1, addr);      daemon_log(LOG_INFO, "Starting with address %s", inet_ntop(AF_INET, &addr, buf, sizeof(buf))); diff --git a/avahi-client/client.c b/avahi-client/client.c index f665613..389a3d1 100644 --- a/avahi-client/client.c +++ b/avahi-client/client.c @@ -2,17 +2,17 @@  /***    This file is part of avahi. -  +    avahi is free software; you can redistribute it and/or modify it    under the terms of the GNU Lesser General Public License as    published by the Free Software Foundation; either version 2.1 of the    License, or (at your option) any later version. -  +    avahi is distributed in the hope that it will be useful, but WITHOUT    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY    or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General    Public License for more details. -  +    You should have received a copy of the GNU Lesser General Public    License along with avahi; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -75,9 +75,9 @@ static void client_set_state (AvahiClient *client, AvahiServerState state) {                  dbus_connection_unref(client->bus);                  client->bus = NULL;              } -             +              /* Fall through */ -             +          case AVAHI_CLIENT_S_COLLISION:          case AVAHI_CLIENT_S_REGISTERING: @@ -94,9 +94,9 @@ static void client_set_state (AvahiClient *client, AvahiServerState state) {          case AVAHI_CLIENT_S_RUNNING:          case AVAHI_CLIENT_CONNECTING:              break; -             +      } -     +      if (client->callback)          client->callback (client, state, client->userdata);  } @@ -107,7 +107,7 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,      assert(bus);      assert(message); -     +      dbus_error_init(&error);  /*     fprintf(stderr, "dbus: interface=%s, path=%s, member=%s\n", */ @@ -124,10 +124,10 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,      } else if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameAcquired")) {          /* Ignore this message */ -         +      } else if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {          char *name, *old, *new; -         +          if (!dbus_message_get_args(                    message, &error,                    DBUS_TYPE_STRING, &name, @@ -149,12 +149,12 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,                   * available, so we disconnect ourselves */                  avahi_client_set_errno(client, AVAHI_ERR_DISCONNECTED);                  goto fail; -                 +              } else if (client->state == AVAHI_CLIENT_CONNECTING && (!old || *old == 0)) {                  int ret; -                 +                  /* Server appeared */ -                 +                  if ((ret = init_server(client, NULL)) < 0) {                      avahi_client_set_errno(client, ret);                      goto fail; @@ -163,14 +163,14 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,          }      } else if (!avahi_client_is_connected(client)) { -         +          /* Ignore messages we get in unconnected state */ -         +      } else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_SERVER, "StateChanged")) {          int32_t state;          char *e = NULL;          int c; -         +          if (!dbus_message_get_args(                    message, &error,                    DBUS_TYPE_INT32, &state, @@ -184,7 +184,7 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,          if ((c = avahi_error_dbus_to_number(e)) != AVAHI_OK)              avahi_client_set_errno(client, c); -         +          client_set_state(client, (AvahiClientState) state);      } else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "StateChanged")) { @@ -195,12 +195,12 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,          for (g = client->groups; g; g = g->groups_next)              if (strcmp(g->path, path) == 0)                  break; -         +          if (g) {              int32_t state;              char *e;              int c; -             +              if (!dbus_message_get_args(                        message, &error,                        DBUS_TYPE_INT32, &state, @@ -215,79 +215,79 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,              if ((c = avahi_error_dbus_to_number(e)) != AVAHI_OK)                  avahi_client_set_errno(client, c); -             +              avahi_entry_group_set_state(g, state);          } -         +      } else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "ItemNew"))          return avahi_domain_browser_event(client, AVAHI_BROWSER_NEW, message); -    else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "ItemRemove"))  +    else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "ItemRemove"))          return avahi_domain_browser_event(client, AVAHI_BROWSER_REMOVE, message); -    else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "CacheExhausted"))  +    else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "CacheExhausted"))          return avahi_domain_browser_event(client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); -    else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "AllForNow"))  +    else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "AllForNow"))          return avahi_domain_browser_event(client, AVAHI_BROWSER_ALL_FOR_NOW, message); -    else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Failure"))  +    else if (dbus_message_is_signal (message, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Failure"))          return avahi_domain_browser_event(client, AVAHI_BROWSER_FAILURE, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemNew"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemNew"))          return avahi_service_type_browser_event (client, AVAHI_BROWSER_NEW, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemRemove"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "ItemRemove"))          return avahi_service_type_browser_event (client, AVAHI_BROWSER_REMOVE, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "CacheExhausted"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "CacheExhausted"))          return avahi_service_type_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "AllForNow"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "AllForNow"))          return avahi_service_type_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Failure"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Failure"))          return avahi_service_type_browser_event (client, AVAHI_BROWSER_FAILURE, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemNew"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemNew"))          return avahi_service_browser_event (client, AVAHI_BROWSER_NEW, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemRemove"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "ItemRemove"))          return avahi_service_browser_event (client, AVAHI_BROWSER_REMOVE, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "CacheExhausted"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "CacheExhausted"))          return avahi_service_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "AllForNow"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "AllForNow"))          return avahi_service_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Failure"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Failure"))          return avahi_service_browser_event (client, AVAHI_BROWSER_FAILURE, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Found"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Found"))          return avahi_service_resolver_event (client, AVAHI_RESOLVER_FOUND, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Failure"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Failure"))          return avahi_service_resolver_event (client, AVAHI_RESOLVER_FAILURE, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Found"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Found"))          return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FOUND, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Failure"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Failure"))          return avahi_host_name_resolver_event (client, AVAHI_RESOLVER_FAILURE, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Found"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Found"))          return avahi_address_resolver_event (client, AVAHI_RESOLVER_FOUND, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Failure"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Failure"))          return avahi_address_resolver_event (client, AVAHI_RESOLVER_FAILURE, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemNew"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemNew"))          return avahi_record_browser_event (client, AVAHI_BROWSER_NEW, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemRemove"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "ItemRemove"))          return avahi_record_browser_event (client, AVAHI_BROWSER_REMOVE, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "CacheExhausted"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "CacheExhausted"))          return avahi_record_browser_event (client, AVAHI_BROWSER_CACHE_EXHAUSTED, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "AllForNow"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "AllForNow"))          return avahi_record_browser_event (client, AVAHI_BROWSER_ALL_FOR_NOW, message); -    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "Failure"))  +    else if (dbus_message_is_signal(message, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "Failure"))          return avahi_record_browser_event (client, AVAHI_BROWSER_FAILURE, message);      else {          fprintf(stderr, "WARNING: Unhandled message: interface=%s, path=%s, member=%s\n", -               dbus_message_get_interface(message),  +               dbus_message_get_interface(message),                 dbus_message_get_path(message),                 dbus_message_get_member(message)); -         +          return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;      } -     +      return DBUS_HANDLER_RESULT_HANDLED;  fail: @@ -298,7 +298,7 @@ fail:      }      client_set_state(client, AVAHI_CLIENT_FAILURE); -     +      return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;  } @@ -307,7 +307,7 @@ static int get_server_state(AvahiClient *client, int *ret_error) {      DBusError error;      int32_t state;      int e = AVAHI_ERR_NO_MEMORY; -     +      assert(client);      dbus_error_init(&error); @@ -328,15 +328,15 @@ static int get_server_state(AvahiClient *client, int *ret_error) {      dbus_message_unref(message);      dbus_message_unref(reply); -     +      return AVAHI_OK;  fail:      if (dbus_error_is_set(&error)) {          e = avahi_error_dbus_to_number (error.name);          dbus_error_free(&error); -    }  -     +    } +      if (ret_error)          *ret_error = e; @@ -344,7 +344,7 @@ fail:          dbus_message_unref(message);      if (reply)          dbus_message_unref(reply); -     +      return e;  } @@ -353,7 +353,7 @@ static int check_version(AvahiClient *client, int *ret_error) {      DBusError error;      uint32_t version;      int e = AVAHI_ERR_NO_MEMORY; -     +      assert(client);      dbus_error_init(&error); @@ -372,7 +372,7 @@ static int check_version(AvahiClient *client, int *ret_error) {          /* If the method GetAPIVersion is not known, we look if           * GetVersionString matches "avahi 0.6" which is the only           * version we support which doesn't have GetAPIVersion() .*/ -         +          dbus_message_unref(message);          if (reply) dbus_message_unref(reply);          dbus_error_free(&error); @@ -381,25 +381,25 @@ static int check_version(AvahiClient *client, int *ret_error) {              goto fail;          reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error); -             +          if (!reply || dbus_error_is_set (&error))              goto fail; -         +          if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &version_str, DBUS_TYPE_INVALID) ||              dbus_error_is_set (&error))              goto fail;          version = strcmp(version_str, "avahi 0.6") == 0 ? 0x0201 : 0x0000; -             +      } else { -         +          if (!dbus_message_get_args (reply, &error, DBUS_TYPE_UINT32, &version, DBUS_TYPE_INVALID) ||              dbus_error_is_set(&error))              goto fail;      }      /*fprintf(stderr, "API Version 0x%04x\n", version);*/ -     +      if ((version & 0xFF00) != (AVAHI_CLIENT_DBUS_API_SUPPORTED & 0xFF00) ||          (version & 0x00FF) < (AVAHI_CLIENT_DBUS_API_SUPPORTED & 0x00FF)) {          e = AVAHI_ERR_VERSION_MISMATCH; @@ -408,14 +408,14 @@ static int check_version(AvahiClient *client, int *ret_error) {      dbus_message_unref(message);      dbus_message_unref(reply); -                +      return AVAHI_OK;  fail:      if (dbus_error_is_set(&error)) {          e = avahi_error_dbus_to_number (error.name);          dbus_error_free(&error); -    }  +    }      if (ret_error)          *ret_error = e; @@ -424,13 +424,13 @@ fail:          dbus_message_unref(message);      if (reply)          dbus_message_unref(reply); -     +      return e;  }  static int init_server(AvahiClient *client, int *ret_error) {      int r; -     +      if ((r = check_version(client, ret_error)) < 0)          return r; @@ -448,14 +448,14 @@ static DBusConnection* avahi_dbus_bus_get(DBusError *error) {  #ifdef HAVE_DBUS_BUS_GET_PRIVATE      if (!(c = dbus_bus_get_private(DBUS_BUS_SYSTEM, error)))          return NULL; -     +      dbus_connection_set_exit_on_disconnect(c, FALSE);  #else      const char *a; -     +      if (!(a = getenv("DBUS_SYSTEM_BUS_ADDRESS")) || !*a)          a = DBUS_SYSTEM_BUS_DEFAULT_ADDRESS; -     +      if (!(c = dbus_connection_open_private(a, error)))          return NULL; @@ -479,6 +479,8 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,      AvahiClient *client = NULL;      DBusError error; +    avahi_init_i18n(); +      dbus_error_init(&error);      if (!(client = avahi_new(AvahiClient, 1))) { @@ -493,13 +495,13 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,      client->userdata = userdata;      client->state = (AvahiClientState) -1;      client->flags = flags; -     +      client->host_name = NULL;      client->host_name_fqdn = NULL;      client->domain_name = NULL;      client->version_string = NULL;      client->local_service_cookie_valid = 0; -     +      AVAHI_LLIST_HEAD_INIT(AvahiEntryGroup, client->groups);      AVAHI_LLIST_HEAD_INIT(AvahiDomainBrowser, client->domain_browsers);      AVAHI_LLIST_HEAD_INIT(AvahiServiceBrowser, client->service_browsers); @@ -523,10 +525,10 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,      if (!dbus_connection_add_filter (client->bus, filter_func, client, NULL)) {          if (ret_error) -            *ret_error = AVAHI_ERR_NO_MEMORY;  +            *ret_error = AVAHI_ERR_NO_MEMORY;          goto fail;      } -         +      dbus_bus_add_match(          client->bus,          "type='signal', " @@ -567,17 +569,17 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,          dbus_error_free(&error);          if (!(flags & AVAHI_CLIENT_NO_FAIL)) { -             +              if (ret_error)                  *ret_error = AVAHI_ERR_NO_DAEMON; -         +              goto fail;          }          /* The user doesn't want this call to fail if the daemon is not           * available, so let's return succesfully */          client_set_state(client, AVAHI_CLIENT_CONNECTING); -         +      } else {          if (init_server(client, ret_error) < 0) @@ -600,10 +602,10 @@ fail:              else                  *ret_error = avahi_error_dbus_to_number(error.name);          } -         +          dbus_error_free(&error);      } -         +      return NULL;  } @@ -618,7 +620,7 @@ void avahi_client_free(AvahiClient *client) {  #else          dbus_connection_disconnect(client->bus);  #endif -     +      while (client->groups)          avahi_entry_group_free(client->groups); @@ -642,7 +644,7 @@ void avahi_client_free(AvahiClient *client) {      while (client->record_browsers)          avahi_record_browser_free(client->record_browsers); -     +      if (client->bus)          dbus_connection_unref(client->bus); @@ -650,7 +652,7 @@ void avahi_client_free(AvahiClient *client) {      avahi_free(client->host_name);      avahi_free(client->host_name_fqdn);      avahi_free(client->domain_name); -     +      avahi_free(client);  } @@ -675,7 +677,7 @@ static char* avahi_client_get_string_reply_and_block (AvahiClient *client, const              goto fail;          }      } -     +      reply = dbus_connection_send_with_reply_and_block (client->bus, message, -1, &error);      if (!reply || dbus_error_is_set (&error)) @@ -684,7 +686,7 @@ static char* avahi_client_get_string_reply_and_block (AvahiClient *client, const      if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &ret, DBUS_TYPE_INVALID) ||          dbus_error_is_set (&error))          goto fail; -     +      if (!(n = avahi_strdup(ret))) {          avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);          goto fail; @@ -692,7 +694,7 @@ static char* avahi_client_get_string_reply_and_block (AvahiClient *client, const      dbus_message_unref(message);      dbus_message_unref(reply); -     +      return n;  fail: @@ -701,7 +703,7 @@ fail:          dbus_message_unref(message);      if (reply)          dbus_message_unref(reply); -     +      if (dbus_error_is_set(&error)) {          avahi_client_set_dbus_error(client, &error);          dbus_error_free(&error); @@ -734,13 +736,13 @@ const char* avahi_client_get_domain_name(AvahiClient *client) {      if (!client->domain_name)          client->domain_name = avahi_client_get_string_reply_and_block(client, "GetDomainName", NULL); -     +      return client->domain_name;  }  const char* avahi_client_get_host_name(AvahiClient *client) {      assert(client); -     +      if (!avahi_client_is_connected(client)) {          avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);          return NULL; @@ -748,7 +750,7 @@ const char* avahi_client_get_host_name(AvahiClient *client) {      if (!client->host_name)          client->host_name = avahi_client_get_string_reply_and_block(client, "GetHostName", NULL); -     +      return client->host_name;  } @@ -759,7 +761,7 @@ const char* avahi_client_get_host_name_fqdn (AvahiClient *client) {          avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE);          return NULL;      } -     +      if (!client->host_name_fqdn)          client->host_name_fqdn = avahi_client_get_string_reply_and_block(client, "GetHostNameFqdn", NULL); @@ -774,7 +776,7 @@ AvahiClientState avahi_client_get_state(AvahiClient *client) {  int avahi_client_errno(AvahiClient *client) {      assert(client); -     +      return client->error;  } @@ -783,25 +785,25 @@ int avahi_client_simple_method_call(AvahiClient *client, const char *path, const      DBusMessage *message = NULL, *reply = NULL;      DBusError error;      int r = AVAHI_OK; -     +      dbus_error_init(&error);      assert(client);      assert(path);      assert(interface);      assert(method); -     +      if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, path, interface, method))) {          r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);          goto fail;      } -         +      if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) ||          dbus_error_is_set (&error)) {          r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);          goto fail;      } -     +      if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) ||          dbus_error_is_set (&error)) {          r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR); @@ -812,7 +814,7 @@ int avahi_client_simple_method_call(AvahiClient *client, const char *path, const      dbus_message_unref(reply);      return AVAHI_OK; -     +  fail:      if (dbus_error_is_set(&error)) {          r = avahi_client_set_dbus_error(client, &error); @@ -856,7 +858,7 @@ uint32_t avahi_client_get_local_service_cookie(AvahiClient *client) {      if (!dbus_message_get_args (reply, &error, DBUS_TYPE_UINT32, &client->local_service_cookie, DBUS_TYPE_INVALID) ||          dbus_error_is_set (&error))          goto fail; -     +      dbus_message_unref(message);      dbus_message_unref(reply); @@ -869,7 +871,7 @@ fail:          dbus_message_unref(message);      if (reply)          dbus_message_unref(reply); -     +      if (dbus_error_is_set(&error)) {          avahi_client_set_dbus_error(client, &error);          dbus_error_free(&error); @@ -892,7 +894,7 @@ int avahi_client_set_host_name(AvahiClient* client, const char *name) {      DBusError error;      assert(client); -     +      if (!avahi_client_is_connected(client))          return avahi_client_set_errno(client, AVAHI_ERR_BAD_STATE); @@ -907,7 +909,7 @@ int avahi_client_set_host_name(AvahiClient* client, const char *name) {          avahi_client_set_errno (client, AVAHI_ERR_NO_MEMORY);          goto fail;      } -     +      reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error);      if (!reply || dbus_error_is_set (&error)) @@ -924,7 +926,7 @@ int avahi_client_set_host_name(AvahiClient* client, const char *name) {      client->host_name = NULL;      avahi_free(client->host_name_fqdn);      client->host_name_fqdn = NULL; -     +      return 0;  fail: @@ -933,7 +935,7 @@ fail:          dbus_message_unref(message);      if (reply)          dbus_message_unref(reply); -     +      if (dbus_error_is_set(&error)) {          avahi_client_set_dbus_error(client, &error);          dbus_error_free(&error); diff --git a/avahi-common/address.c b/avahi-common/address.c index c8ddf7f..270292c 100644 --- a/avahi-common/address.c +++ b/avahi-common/address.c @@ -2,17 +2,17 @@  /***    This file is part of avahi. -  +    avahi is free software; you can redistribute it and/or modify it    under the terms of the GNU Lesser General Public License as    published by the Free Software Foundation; either version 2.1 of the    License, or (at your option) any later version. -  +    avahi is distributed in the hope that it will be useful, but WITHOUT    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY    or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General    Public License for more details. -  +    You should have received a copy of the GNU Lesser General Public    License along with avahi; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -48,7 +48,7 @@ static size_t address_get_size(const AvahiAddress *a) {  int avahi_address_cmp(const AvahiAddress *a, const AvahiAddress *b) {      assert(a);      assert(b); -     +      if (a->proto != b->proto)          return -1; @@ -59,10 +59,10 @@ char *avahi_address_snprint(char *s, size_t length, const AvahiAddress *a) {      assert(s);      assert(length);      assert(a); -     +      if (!(inet_ntop(avahi_proto_to_af(a->proto), a->data.data, s, length)))          return NULL; -     +      return s;  } @@ -119,10 +119,10 @@ AvahiAddress *avahi_address_parse(const char *s, AvahiProtocol proto, AvahiAddre      } else {          if (inet_pton(avahi_proto_to_af(proto), s, ret_addr->data.data) <= 0)              return NULL; -         +          ret_addr->proto = proto;      } -     +      return ret_addr;  } diff --git a/avahi-common/thread-watch.c b/avahi-common/thread-watch.c index 1a5d9d2..4f23608 100644 --- a/avahi-common/thread-watch.c +++ b/avahi-common/thread-watch.c @@ -2,17 +2,17 @@  /***    This file is part of avahi. -  +    avahi is free software; you can redistribute it and/or modify it    under the terms of the GNU Lesser General Public License as    published by the Free Software Foundation; either version 2.1 of the    License, or (at your option) any later version. -  +    avahi is distributed in the hope that it will be useful, but WITHOUT    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY    or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General    Public License for more details. -  +    You should have received a copy of the GNU Lesser General Public    License along with avahi; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -53,7 +53,7 @@ static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *      /* Before entering poll() we unlock the mutex, so that       * avahi_simple_poll_quit() can succeed from another thread. */ -     +      pthread_mutex_unlock(mutex);      r = poll(ufds, nfds, timeout);      pthread_mutex_lock(mutex); @@ -68,11 +68,11 @@ static void* thread(void *userdata){      /* Make sure that signals are delivered to the main thread */      sigfillset(&mask);      pthread_sigmask(SIG_BLOCK, &mask, NULL); -     +      pthread_mutex_lock(&p->mutex);      p->retval = avahi_simple_poll_loop(p->simple_poll);      pthread_mutex_unlock(&p->mutex); -     +      return NULL;  } @@ -81,14 +81,14 @@ AvahiThreadedPoll *avahi_threaded_poll_new(void) {      if (!(p = avahi_new(AvahiThreadedPoll, 1)))          goto fail; /* OOM */ -     +      if (!(p->simple_poll = avahi_simple_poll_new()))          goto fail; -         +      pthread_mutex_init(&p->mutex, NULL);      avahi_simple_poll_set_func(p->simple_poll, poll_func, &p->mutex); -     +      p->thread_running = 0;      return p; @@ -136,6 +136,8 @@ int avahi_threaded_poll_start(AvahiThreadedPoll *p) {      if (pthread_create(&p->thread_id, NULL, thread, p) < 0)          return -1; +    p->thread_running = 1; +      return 0;  } @@ -151,7 +153,7 @@ int avahi_threaded_poll_stop(AvahiThreadedPoll *p) {      pthread_mutex_lock(&p->mutex);      avahi_simple_poll_quit(p->simple_poll);      pthread_mutex_unlock(&p->mutex); -     +      pthread_join(p->thread_id, NULL);      p->thread_running = 0; @@ -172,7 +174,7 @@ void avahi_threaded_poll_lock(AvahiThreadedPoll *p) {      /* Make sure that this function is not called from the helper thread */      assert(!p->thread_running || !pthread_equal(pthread_self(), p->thread_id)); -     +      pthread_mutex_lock(&p->mutex);  } @@ -181,6 +183,6 @@ void avahi_threaded_poll_unlock(AvahiThreadedPoll *p) {      /* Make sure that this function is not called from the helper thread */      assert(!p->thread_running || !pthread_equal(pthread_self(), p->thread_id)); -     +      pthread_mutex_unlock(&p->mutex);  } diff --git a/avahi-core/server.c b/avahi-core/server.c index 453db09..02c343f 100644 --- a/avahi-core/server.c +++ b/avahi-core/server.c @@ -2,17 +2,17 @@  /***    This file is part of avahi. -  +    avahi is free software; you can redistribute it and/or modify it    under the terms of the GNU Lesser General Public License as    published by the Free Software Foundation; either version 2.1 of the    License, or (at your option) any later version. -  +    avahi is distributed in the hope that it will be useful, but WITHOUT    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY    or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General    Public License for more details. -  +    You should have received a copy of the GNU Lesser General Public    License along with avahi; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -59,7 +59,7 @@ static void enum_aux_records(AvahiServer *s, AvahiInterface *i, const char *name      if (type == AVAHI_DNS_TYPE_ANY) {          AvahiEntry *e; -         +          for (e = s->entries; e; e = e->entries_next)              if (!e->dead &&                  avahi_entry_is_registered(s, e, i) && @@ -70,14 +70,14 @@ static void enum_aux_records(AvahiServer *s, AvahiInterface *i, const char *name      } else {          AvahiEntry *e;          AvahiKey *k; -         +          if (!(k = avahi_key_new(name, AVAHI_DNS_CLASS_IN, type)))              return; /** OOM */ -         +          for (e = avahi_hashmap_lookup(s->entries_by_key, k); e; e = e->by_key_next) -            if (!e->dead && avahi_entry_is_registered(s, e, i))  +            if (!e->dead && avahi_entry_is_registered(s, e, i))                  callback(s, e->record, e->flags & AVAHI_PUBLISH_UNIQUE, userdata); -         +          avahi_key_unref(k);      }  } @@ -89,7 +89,7 @@ void avahi_server_enumerate_aux_records(AvahiServer *s, AvahiInterface *i, Avahi      assert(callback);      /* Call the specified callback far all records referenced by the one specified in *r */ -     +      if (r->key->clazz == AVAHI_DNS_CLASS_IN) {          if (r->key->type == AVAHI_DNS_TYPE_PTR) {              enum_aux_records(s, i, r->data.ptr.name, AVAHI_DNS_TYPE_SRV, callback, userdata); @@ -121,7 +121,7 @@ void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i,          AvahiEntry *e;          /* Handle ANY query */ -         +          for (e = s->entries; e; e = e->entries_next)              if (!e->dead && avahi_key_pattern_match(k, e->record->key) && avahi_entry_is_registered(s, e, i))                  avahi_server_prepare_response(s, i, e, unicast_response, 0); @@ -130,7 +130,7 @@ void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i,          AvahiEntry *e;          /* Handle all other queries */ -         +          for (e = avahi_hashmap_lookup(s->entries_by_key, k); e; e = e->by_key_next)              if (!e->dead && avahi_entry_is_registered(s, e, i))                  avahi_server_prepare_response(s, i, e, unicast_response, 0); @@ -145,7 +145,7 @@ void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i,          if (!(cname_key = avahi_key_new(k->name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_CNAME)))              return; -         +          avahi_server_prepare_matching_responses(s, i, cname_key, unicast_response);          avahi_key_unref(cname_key);      } @@ -160,11 +160,11 @@ static void withdraw_entry(AvahiServer *s, AvahiEntry *e) {      if (e->dead)          return; -     +      if (e->group) {          AvahiEntry *k; -         -        for (k = e->group->entries; k; k = k->by_group_next)  + +        for (k = e->group->entries; k; k = k->by_group_next)              if (!k->dead) {                  avahi_goodbye_entry(s, k, 0, 1);                  k->dead = 1; @@ -183,12 +183,12 @@ static void withdraw_entry(AvahiServer *s, AvahiEntry *e) {  static void withdraw_rrset(AvahiServer *s, AvahiKey *key) {      AvahiEntry *e; -     +      assert(s);      assert(key);      /* Withdraw an entry RRSset */ -     +      for (e = avahi_hashmap_lookup(s->entries_by_key, key); e; e = e->by_key_next)          withdraw_entry(s, e);  } @@ -196,25 +196,25 @@ static void withdraw_rrset(AvahiServer *s, AvahiKey *key) {  static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface *i) {      AvahiEntry *e, *n;      int ours = 0, won = 0, lost = 0; -     +      assert(s);      assert(record);      assert(i);      /* Handle incoming probes and check if they conflict our own probes */ -     +      for (e = avahi_hashmap_lookup(s->entries_by_key, record->key); e; e = n) {          int cmp;          n = e->by_key_next;          if (e->dead)              continue; -         +          if ((cmp = avahi_record_lexicographical_compare(e->record, record)) == 0) {              ours = 1;              break;          } else { -             +              if (avahi_entry_is_probing(s, e, i)) {                  if (cmp > 0)                      won = 1; @@ -226,14 +226,14 @@ static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface *      if (!ours) {          char *t = avahi_record_to_string(record); -         +          if (won)              avahi_log_debug("Received conflicting probe [%s]. Local host won.", t);          else if (lost) {              avahi_log_debug("Received conflicting probe [%s]. Local host lost. Withdrawing.", t);              withdraw_rrset(s, record->key);          } -         +          avahi_free(t);      }  } @@ -241,13 +241,13 @@ static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface *  static int handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *record, int unique) {      int valid = 1, ours = 0, conflict = 0, withdraw_immediately = 0;      AvahiEntry *e, *n, *conflicting_entry = NULL; -     +      assert(s);      assert(i);      assert(record);      /* Check whether an incoming record conflicts with one of our own */ -     +      for (e = avahi_hashmap_lookup(s->entries_by_key, record->key); e; e = n) {          n = e->by_key_next; @@ -261,7 +261,7 @@ static int handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *recor                  char *t;                  /* Refresh */ -                t = avahi_record_to_string(record);  +                t = avahi_record_to_string(record);                  avahi_log_debug("Received goodbye record for one of our records [%s]. Refreshing.", t);                  avahi_server_prepare_matching_responses(s, i, e->record->key, 0); @@ -273,36 +273,36 @@ static int handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *recor              /* If the goodybe packet doesn't match one of our own RRs, we simply ignore it. */              continue;          } -         +          if (!(e->flags & AVAHI_PUBLISH_UNIQUE) && !unique)              continue;          /* Either our entry or the other is intended to be unique, so let's check */ -         +          if (avahi_record_equal_no_ttl(e->record, record)) {              ours = 1; /* We have an identical record, so this is no conflict */ -             +              /* Check wheter there is a TTL conflict */              if (record->ttl <= e->record->ttl/2 &&                  avahi_entry_is_registered(s, e, i)) {                  char *t;                  /* Refresh */ -                t = avahi_record_to_string(record);  -                 +                t = avahi_record_to_string(record); +                  avahi_log_debug("Received record with bad TTL [%s]. Refreshing.", t);                  avahi_server_prepare_matching_responses(s, i, e->record->key, 0);                  valid = 0; -                 +                  avahi_free(t);              } -                 +              /* There's no need to check the other entries of this RRset */              break;          } else { -             +              if (avahi_entry_is_registered(s, e, i)) { -                 +                  /* A conflict => we have to return to probe mode */                  conflict = 1;                  conflicting_entry = e; @@ -320,11 +320,11 @@ static int handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *recor      if (!ours && conflict) {          char *t; -  +          valid = 0; -        t = avahi_record_to_string(record);  -  +        t = avahi_record_to_string(record); +          if (withdraw_immediately) {              avahi_log_debug("Received conflicting record [%s] with local record to be. Withdrawing.", t);              withdraw_rrset(s, record->key); @@ -349,7 +349,7 @@ static void append_aux_callback(AvahiServer *s, AvahiRecord *r, int flush_cache,      assert(s);      assert(r);      assert(unicast_response); -     +      avahi_record_list_push(s->record_list, r, flush_cache, *unicast_response, 1);  } @@ -372,11 +372,11 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP          if (!(reply = avahi_dns_packet_new_reply(p, 512 + AVAHI_DNS_PACKET_EXTRA_SIZE /* unicast DNS maximum packet size is 512 */ , 1, 1)))              return; /* OOM */ -         +          while ((r = avahi_record_list_next(s->record_list, NULL, NULL, NULL))) {              append_aux_records_to_list(s, i, r, 0); -             +              if (avahi_dns_packet_append_record(reply, r, 0, 10))                  avahi_dns_packet_inc_field(reply, AVAHI_DNS_FIELD_ANCOUNT);              else { @@ -402,7 +402,7 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP          immediately, because known answer suppression records might be          contained in later packets */          int tc = p && !!(avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & AVAHI_DNS_FLAG_TC); -         +          while ((r = avahi_record_list_next(s->record_list, &flush_cache, &unicast_response, &auxiliary))) {              int im = immediately; @@ -411,7 +411,7 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP               * unique entry AND it is not in reply to a truncated               * packet AND it is not an auxiliary record AND all other               * responses for this record are unique too. */ -             +              if (flush_cache && !tc && !auxiliary && avahi_record_list_all_flush_cache(s->record_list))                  im = 1; @@ -422,21 +422,21 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP                   * case. Therefore we prepare such a response */                  append_aux_records_to_list(s, i, r, unicast_response); -                 +                  for (;;) { -                 +                      if (!reply) {                          assert(p);                          if (!(reply = avahi_dns_packet_new_reply(p, i->hardware->mtu, 0, 0)))                              break; /* OOM */                      } -                 +                      if (avahi_dns_packet_append_record(reply, r, flush_cache, 0)) {                          /* Appending this record succeeded, so incremeant                           * the specific header field, and return to the caller */ -                         +                          avahi_dns_packet_inc_field(reply, AVAHI_DNS_FIELD_ANCOUNT);                          break;                      } @@ -456,7 +456,7 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP                              /* Appending this record succeeded, so incremeant                               * the specific header field, and return to the caller */ -                             +                              avahi_dns_packet_inc_field(reply, AVAHI_DNS_FIELD_ANCOUNT);                              break; @@ -465,7 +465,7 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP                              /* We completely fucked up, there's                               * nothing we can do. The RR just doesn't                               * fit in. Let's ignore it. */ -                             +                              char *t;                              avahi_dns_packet_free(reply);                              reply = NULL; @@ -487,7 +487,7 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP          }          if (reply) { -            if (avahi_dns_packet_get_field(reply, AVAHI_DNS_FIELD_ANCOUNT) != 0)  +            if (avahi_dns_packet_get_field(reply, AVAHI_DNS_FIELD_ANCOUNT) != 0)                  avahi_interface_send_packet_unicast(i, reply, a, port);              avahi_dns_packet_free(reply);          } @@ -498,7 +498,7 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP  static void reflect_response(AvahiServer *s, AvahiInterface *i, AvahiRecord *r, int flush_cache) {      AvahiInterface *j; -     +      assert(s);      assert(i);      assert(r); @@ -525,7 +525,7 @@ static void* reflect_cache_walk_callback(AvahiCache *c, AvahiKey *pattern, Avahi  static void reflect_query(AvahiServer *s, AvahiInterface *i, AvahiKey *k) {      AvahiInterface *j; -     +      assert(s);      assert(i);      assert(k); @@ -547,7 +547,7 @@ static void reflect_query(AvahiServer *s, AvahiInterface *i, AvahiKey *k) {  static void reflect_probe(AvahiServer *s, AvahiInterface *i, AvahiRecord *r) {      AvahiInterface *j; -     +      assert(s);      assert(i);      assert(r); @@ -563,7 +563,7 @@ static void reflect_probe(AvahiServer *s, AvahiInterface *i, AvahiRecord *r) {  static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, const AvahiAddress *a, uint16_t port, int legacy_unicast, int from_local_iface) {      size_t n;      int is_probe; -     +      assert(s);      assert(p);      assert(i); @@ -572,7 +572,7 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac      assert(avahi_record_list_is_empty(s->record_list));      is_probe = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) > 0; -     +      /* Handle the questions */      for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT); n > 0; n --) {          AvahiKey *key; @@ -594,7 +594,7 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac              /* Allow our own queries to be suppressed by incoming               * queries only when they do not include known answers */              avahi_query_scheduler_incoming(i->query_scheduler, key); -         +          avahi_server_prepare_matching_responses(s, i, key, unicast_response);          avahi_key_unref(key);      } @@ -605,35 +605,35 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac          for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT); n > 0; n --) {              AvahiRecord *record;              int unique = 0; -             +              if (!(record = avahi_dns_packet_consume_record(p, &unique))) {                  avahi_log_warn(__FILE__": Packet too short or invalid while reading known answer record. (Maybe a UTF-8 problem?)");                  goto fail;              } -             +              avahi_response_scheduler_suppress(i->response_scheduler, record, a);              avahi_record_list_drop(s->record_list, record);              avahi_cache_stop_poof(i->cache, record, a); -             +              avahi_record_unref(record);          } -         +          /* Probe record */          for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT); n > 0; n --) {              AvahiRecord *record;              int unique = 0; -             +              if (!(record = avahi_dns_packet_consume_record(p, &unique))) {                  avahi_log_warn(__FILE__": Packet too short or invalid while reading probe record. (Maybe a UTF-8 problem?)");                  goto fail;              } -             +              if (!avahi_key_is_pattern(record->key)) {                  if (!from_local_iface)                      reflect_probe(s, i, record);                  incoming_probe(s, record, i);              } -             +              avahi_record_unref(record);          }      } @@ -642,14 +642,14 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac          avahi_server_generate_response(s, i, p, a, port, legacy_unicast, is_probe);      return; -     +  fail:      avahi_record_list_flush(s->record_list);  }  static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, const AvahiAddress *a, int from_local_iface) {      unsigned n; -     +      assert(s);      assert(p);      assert(i); @@ -660,7 +660,7 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter          AvahiRecord *record;          int cache_flush = 0;  /*         char *txt; */ -         +          if (!(record = avahi_dns_packet_consume_record(p, &cache_flush))) {              avahi_log_warn(__FILE__": Packet too short or invalid while reading response record. (Maybe a UTF-8 problem?)");              break; @@ -675,7 +675,7 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter                  avahi_response_scheduler_incoming(i->response_scheduler, record, cache_flush);              }          } -             +          avahi_record_unref(record);      } @@ -689,7 +689,7 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter  static AvahiLegacyUnicastReflectSlot* allocate_slot(AvahiServer *s) {      unsigned n, idx = (unsigned) -1;      AvahiLegacyUnicastReflectSlot *slot; -     +      assert(s);      if (!s->legacy_unicast_reflect_slots) @@ -697,7 +697,7 @@ static AvahiLegacyUnicastReflectSlot* allocate_slot(AvahiServer *s) {      for (n = 0; n < AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX; n++, s->legacy_unicast_reflect_id++) {          idx = s->legacy_unicast_reflect_id % AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX; -         +          if (!s->legacy_unicast_reflect_slots[idx])              break;      } @@ -711,7 +711,7 @@ static AvahiLegacyUnicastReflectSlot* allocate_slot(AvahiServer *s) {      s->legacy_unicast_reflect_slots[idx] = slot;      slot->id = s->legacy_unicast_reflect_id++;      slot->server = s; -     +      return slot;  } @@ -726,7 +726,7 @@ static void deallocate_slot(AvahiServer *s, AvahiLegacyUnicastReflectSlot *slot)      assert(s->legacy_unicast_reflect_slots[idx] == slot);      avahi_time_event_free(slot->time_event); -     +      avahi_free(slot);      s->legacy_unicast_reflect_slots[idx] = NULL;  } @@ -748,12 +748,12 @@ static void free_slots(AvahiServer *s) {  static AvahiLegacyUnicastReflectSlot* find_slot(AvahiServer *s, uint16_t id) {      unsigned idx; -     +      assert(s);      if (!s->legacy_unicast_reflect_slots)          return NULL; -     +      idx = id % AVAHI_LEGACY_UNICAST_REFLECT_SLOTS_MAX;      if (!s->legacy_unicast_reflect_slots[idx] || s->legacy_unicast_reflect_slots[idx]->id != id) @@ -782,7 +782,7 @@ static void reflect_legacy_unicast_query_packet(AvahiServer *s, AvahiDnsPacket *      assert(a);      assert(port > 0);      assert(i->protocol == a->proto); -     +      if (!s->config.enable_reflector)          return; @@ -810,7 +810,7 @@ static void reflect_legacy_unicast_query_packet(AvahiServer *s, AvahiDnsPacket *      /* Patch the packet with our new locally generatet id */      avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ID, slot->id); -     +      for (j = s->monitor->interfaces; j; j = j->interface_next)          if (j->announcing &&              j != i && @@ -833,14 +833,14 @@ static int originates_from_local_legacy_unicast_socket(AvahiServer *s, const Ava      if (!s->config.enable_reflector)          return 0; -     +      if (!avahi_address_is_local(s->monitor, address))          return 0; -     +      if (address->proto == AVAHI_PROTO_INET && s->fd_legacy_unicast_ipv4 >= 0) {          struct sockaddr_in lsa;          socklen_t l = sizeof(lsa); -         +          if (getsockname(s->fd_legacy_unicast_ipv4, (struct sockaddr*) &lsa, &l) != 0)              avahi_log_warn("getsockname(): %s", strerror(errno));          else @@ -884,7 +884,7 @@ static int originates_from_local_iface(AvahiServer *s, AvahiIfIndex iface, const  static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddress *src_address, uint16_t port, const AvahiAddress *dst_address, AvahiIfIndex iface, int ttl) {      AvahiInterface *i;      int from_local_iface = 0; -     +      assert(s);      assert(p);      assert(src_address); @@ -898,6 +898,12 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres          return;      } +    if (port <= 0) { +        /* This fixes RHBZ #475394 */ +        avahi_log_warn("Received packet from invalid source port %u.", (unsigned) port); +        return; +    } +      if (avahi_address_is_ipv4_in_ipv6(src_address))          /* This is an IPv4 address encapsulated in IPv6, so let's ignore it. */          return; @@ -931,36 +937,40 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres                  avahi_log_warn("Invalid legacy unicast query packet.");                  return;              } -         +              legacy_unicast = 1;          }          if (legacy_unicast)              reflect_legacy_unicast_query_packet(s, p, i, src_address, port); -         +          handle_query_packet(s, p, i, src_address, port, legacy_unicast, from_local_iface); -         +      } else { +        char t[AVAHI_ADDRESS_STR_MAX]; +          if (port != AVAHI_MDNS_PORT) { -            avahi_log_warn("Received response with invalid source port %u on interface '%s.%i'", port, i->hardware->name, i->protocol); +            avahi_log_warn("Received response from host %s with invalid source port %u on interface '%s.%i'", avahi_address_snprint(t, sizeof(t), src_address), port, i->hardware->name, i->protocol);              return;          }          if (ttl != 255 && s->config.check_response_ttl) { -            avahi_log_warn("Received response with invalid TTL %u on interface '%s.%i'.", ttl, i->hardware->name, i->protocol); +            avahi_log_warn("Received response from host %s with invalid TTL %u on interface '%s.%i'.", avahi_address_snprint(t, sizeof(t), src_address), ttl, i->hardware->name, i->protocol);              return;          }          if (!is_mdns_mcast_address(dst_address) &&              !avahi_interface_address_on_link(i, src_address)) { -            avahi_log_warn("Received non-local response on interface '%s.%i'.", i->hardware->name, i->protocol); + +            avahi_log_warn("Received non-local response from host %s on interface '%s.%i'.", avahi_address_snprint(t, sizeof(t), src_address), i->hardware->name, i->protocol);              return;          } -         +          if (avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT) != 0 ||              avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) == 0 ||              avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) != 0) { -            avahi_log_warn("Invalid response packet."); + +            avahi_log_warn("Invalid response packet from host %s.", avahi_address_snprint(t, sizeof(t), src_address));              return;          } @@ -971,7 +981,7 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres  static void dispatch_legacy_unicast_packet(AvahiServer *s, AvahiDnsPacket *p) {      AvahiInterface *j;      AvahiLegacyUnicastReflectSlot *slot; -     +      assert(s);      assert(p); @@ -1001,7 +1011,7 @@ static void dispatch_legacy_unicast_packet(AvahiServer *s, AvahiDnsPacket *p) {  static void cleanup_dead(AvahiServer *s) {      assert(s); -     +      avahi_cleanup_dead_entries(s);      avahi_browser_cleanup(s);  } @@ -1017,7 +1027,7 @@ static void mcast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent events, vo      assert(w);      assert(fd >= 0);      assert(events & AVAHI_WATCH_IN); -     +      if (fd == s->fd_ipv4) {          dest.proto = src.proto = AVAHI_PROTO_INET;          p = avahi_recv_dns_packet_ipv4(s->fd_ipv4, &src.data.ipv4, &port, &dest.data.ipv4, &iface, &ttl); @@ -1026,11 +1036,11 @@ static void mcast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent events, vo          dest.proto = src.proto = AVAHI_PROTO_INET6;          p = avahi_recv_dns_packet_ipv6(s->fd_ipv6, &src.data.ipv6, &port, &dest.data.ipv6, &iface, &ttl);      } -         +      if (p) { -        if (iface == AVAHI_IF_UNSPEC)  +        if (iface == AVAHI_IF_UNSPEC)              iface = avahi_find_interface_for_address(s->monitor, &dest); -         +          if (iface != AVAHI_IF_UNSPEC)              dispatch_packet(s, p, &src, port, &dest, iface, ttl);          else @@ -1049,7 +1059,7 @@ static void legacy_unicast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent e      assert(w);      assert(fd >= 0);      assert(events & AVAHI_WATCH_IN); -     +      if (fd == s->fd_legacy_unicast_ipv4)          p = avahi_recv_dns_packet_ipv4(s->fd_legacy_unicast_ipv4, NULL, NULL, NULL, NULL, NULL);      else { @@ -1070,11 +1080,11 @@ static void server_set_state(AvahiServer *s, AvahiServerState state) {      if (s->state == state)          return; -     +      s->state = state;      avahi_interface_monitor_update_rrs(s->monitor, 0); -     +      if (s->callback)          s->callback(s, state, s->userdata);  } @@ -1094,7 +1104,7 @@ static void withdraw_host_rrs(AvahiServer *s) {  void avahi_server_decrease_host_rr_pending(AvahiServer *s) {      assert(s); -     +      assert(s->n_host_rr_pending > 0);      if (--s->n_host_rr_pending == 0) @@ -1108,12 +1118,12 @@ void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, Ava      if (state == AVAHI_ENTRY_GROUP_REGISTERING &&          s->state == AVAHI_SERVER_REGISTERING)          s->n_host_rr_pending ++; -     +      else if (state == AVAHI_ENTRY_GROUP_COLLISION &&          (s->state == AVAHI_SERVER_REGISTERING || s->state == AVAHI_SERVER_RUNNING)) {          withdraw_host_rrs(s);          server_set_state(s, AVAHI_SERVER_COLLISION); -         +      } else if (state == AVAHI_ENTRY_GROUP_ESTABLISHED &&                 s->state == AVAHI_SERVER_REGISTERING)          avahi_server_decrease_host_rr_pending(s); @@ -1122,9 +1132,9 @@ void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, Ava  static void register_hinfo(AvahiServer *s) {      struct utsname utsname;      AvahiRecord *r; -     +      assert(s); -     +      if (!s->config.publish_hinfo)          return; @@ -1137,19 +1147,19 @@ static void register_hinfo(AvahiServer *s) {          avahi_log_warn("Failed to create HINFO entry group: %s", avahi_strerror(s->error));          return;      } -     +      /* Fill in HINFO rr */      if ((r = avahi_record_new_full(s->host_name_fqdn, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_HINFO, AVAHI_DEFAULT_TTL_HOST_NAME))) {          if (uname(&utsname) < 0)              avahi_log_warn("uname() failed: %s\n", avahi_strerror(errno));          else { -             +              r->data.hinfo.cpu = avahi_strdup(avahi_strup(utsname.machine));              r->data.hinfo.os = avahi_strdup(avahi_strup(utsname.sysname)); -             +              avahi_log_info("Registering HINFO record with values '%s'/'%s'.", r->data.hinfo.cpu, r->data.hinfo.os); -             +              if (avahi_server_add(s, s->hinfo_entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_UNIQUE, r) < 0) {                  avahi_log_warn("Failed to add HINFO RR: %s", avahi_strerror(s->error));                  return; @@ -1167,7 +1177,7 @@ static void register_hinfo(AvahiServer *s) {  static void register_localhost(AvahiServer *s) {      AvahiAddress a;      assert(s); -     +      /* Add localhost entries */      avahi_address_parse("127.0.0.1", AVAHI_PROTO_INET, &a);      avahi_server_add_address(s, NULL, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_NO_PROBE|AVAHI_PUBLISH_NO_ANNOUNCE, "localhost", &a); @@ -1194,7 +1204,7 @@ static void register_browse_domain(AvahiServer *s) {          avahi_log_warn("Failed to create browse domain entry group: %s", avahi_strerror(s->error));          return;      } -     +      if (avahi_server_add_ptr(s, s->browse_domain_entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, AVAHI_DEFAULT_TTL, "b._dns-sd._udp.local", s->domain_name) < 0) {          avahi_log_warn("Failed to add browse domain RR: %s", avahi_strerror(s->error));          return; @@ -1215,14 +1225,14 @@ static void register_stuff(AvahiServer *s) {      avahi_interface_monitor_update_rrs(s->monitor, 0);      s->n_host_rr_pending --; -     +      if (s->n_host_rr_pending == 0)          server_set_state(s, AVAHI_SERVER_RUNNING);  }  static void update_fqdn(AvahiServer *s) {      char *n; -     +      assert(s);      assert(s->host_name);      assert(s->domain_name); @@ -1237,7 +1247,7 @@ static void update_fqdn(AvahiServer *s) {  int avahi_server_set_host_name(AvahiServer *s, const char *host_name) {      char *hn = NULL;      assert(s); -     +      AVAHI_CHECK_VALIDITY(s, !host_name || avahi_is_valid_host_name(host_name), AVAHI_ERR_INVALID_HOST_NAME);      if (!host_name) { @@ -1250,12 +1260,12 @@ int avahi_server_set_host_name(AvahiServer *s, const char *host_name) {          avahi_free(hn);          return avahi_server_set_errno(s, AVAHI_ERR_NO_CHANGE);      } -     +      withdraw_host_rrs(s);      avahi_free(s->host_name);      s->host_name = hn ? hn : avahi_strdup(host_name); -     +      update_fqdn(s);      register_stuff(s); @@ -1272,7 +1282,7 @@ int avahi_server_set_domain_name(AvahiServer *s, const char *domain_name) {          dn = avahi_strdup("local");          domain_name = dn;      } -     +      if (avahi_domain_equal(s->domain_name, domain_name)) {          avahi_free(dn);          return avahi_server_set_errno(s, AVAHI_ERR_NO_CHANGE); @@ -1297,10 +1307,10 @@ static int valid_server_config(const AvahiServerConfig *sc) {      if (sc->n_wide_area_servers > AVAHI_WIDE_AREA_SERVERS_MAX)          return AVAHI_ERR_INVALID_CONFIG; -     +      if (sc->host_name && !avahi_is_valid_host_name(sc->host_name))          return AVAHI_ERR_INVALID_HOST_NAME; -     +      if (sc->domain_name && !avahi_is_valid_domain_name(sc->domain_name))          return AVAHI_ERR_INVALID_DOMAIN_NAME; @@ -1313,10 +1323,10 @@ static int valid_server_config(const AvahiServerConfig *sc) {  static int setup_sockets(AvahiServer *s) {      assert(s); -     +      s->fd_ipv4 = s->config.use_ipv4 ? avahi_open_socket_ipv4(s->config.disallow_other_stacks) : -1;      s->fd_ipv6 = s->config.use_ipv6 ? avahi_open_socket_ipv6(s->config.disallow_other_stacks) : -1; -     +      if (s->fd_ipv6 < 0 && s->fd_ipv4 < 0)          return AVAHI_ERR_NO_NETWORK; @@ -1327,35 +1337,35 @@ static int setup_sockets(AvahiServer *s) {      s->fd_legacy_unicast_ipv4 = s->fd_ipv4 >= 0 && s->config.enable_reflector ? avahi_open_unicast_socket_ipv4() : -1;      s->fd_legacy_unicast_ipv6 = s->fd_ipv6 >= 0 && s->config.enable_reflector ? avahi_open_unicast_socket_ipv6() : -1; -     +      s->watch_ipv4 =          s->watch_ipv6 =          s->watch_legacy_unicast_ipv4 =          s->watch_legacy_unicast_ipv6 = NULL; -     +      if (s->fd_ipv4 >= 0)          s->watch_ipv4 = s->poll_api->watch_new(s->poll_api, s->fd_ipv4, AVAHI_WATCH_IN, mcast_socket_event, s);      if (s->fd_ipv6 >= 0)          s->watch_ipv6 = s->poll_api->watch_new(s->poll_api, s->fd_ipv6, AVAHI_WATCH_IN, mcast_socket_event, s); -     +      if (s->fd_legacy_unicast_ipv4 >= 0)          s->watch_legacy_unicast_ipv4 = s->poll_api->watch_new(s->poll_api, s->fd_legacy_unicast_ipv4, AVAHI_WATCH_IN, legacy_unicast_socket_event, s);      if (s->fd_legacy_unicast_ipv6 >= 0)          s->watch_legacy_unicast_ipv6 = s->poll_api->watch_new(s->poll_api, s->fd_legacy_unicast_ipv6, AVAHI_WATCH_IN, legacy_unicast_socket_event, s); -             +      return 0;  }  AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig *sc, AvahiServerCallback callback, void* userdata, int *error) {      AvahiServer *s;      int e; -     +      if (sc && (e = valid_server_config(sc)) < 0) {          if (error)              *error = e;          return NULL;      } -     +      if (!(s = avahi_new(AvahiServer, 1))) {          if (error)              *error = AVAHI_ERR_NO_MEMORY; @@ -1376,10 +1386,10 @@ AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig          avahi_server_config_free(&s->config);          avahi_free(s); -         +          return NULL;      } -     +      s->n_host_rr_pending = 0;      s->need_entry_cleanup = 0;      s->need_group_cleanup = 0; @@ -1412,7 +1422,7 @@ AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig      s->legacy_unicast_reflect_id = 0;      s->record_list = avahi_record_list_new(); -     +      /* Get host name */      s->host_name = s->config.host_name ? avahi_normalize_name_strdup(s->config.host_name) : avahi_get_host_name_strdup();      s->host_name[strcspn(s->host_name, ".")] = 0; @@ -1431,13 +1441,13 @@ AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig          s->wide_area_lookup_engine = NULL;      s->multicast_lookup_engine = avahi_multicast_lookup_engine_new(s); -     +      s->monitor = avahi_interface_monitor_new(s);      avahi_interface_monitor_sync(s->monitor);      register_localhost(s);      register_stuff(s); -     +      return s;  } @@ -1462,7 +1472,7 @@ void avahi_server_free(AvahiServer* s) {          avahi_s_service_resolver_free(s->service_resolvers);      while (s->record_browsers)          avahi_s_record_browser_destroy(s->record_browsers); -     +      /* Remove all locally rgeistered stuff */      while(s->entries) @@ -1484,33 +1494,33 @@ void avahi_server_free(AvahiServer* s) {      avahi_multicast_lookup_engine_free(s->multicast_lookup_engine);      avahi_time_event_queue_free(s->time_event_queue); -     +      /* Free watches */ -     +      if (s->watch_ipv4)          s->poll_api->watch_free(s->watch_ipv4);      if (s->watch_ipv6)          s->poll_api->watch_free(s->watch_ipv6); -     +      if (s->watch_legacy_unicast_ipv4)          s->poll_api->watch_free(s->watch_legacy_unicast_ipv4);      if (s->watch_legacy_unicast_ipv6)          s->poll_api->watch_free(s->watch_legacy_unicast_ipv6);      /* Free sockets */ -     +      if (s->fd_ipv4 >= 0)          close(s->fd_ipv4);      if (s->fd_ipv6 >= 0)          close(s->fd_ipv6); -     +      if (s->fd_legacy_unicast_ipv4 >= 0)          close(s->fd_legacy_unicast_ipv4);      if (s->fd_legacy_unicast_ipv6 >= 0)          close(s->fd_legacy_unicast_ipv6); -     +      /* Free other stuff */ -     +      avahi_free(s->host_name);      avahi_free(s->domain_name);      avahi_free(s->host_name_fqdn); @@ -1581,7 +1591,7 @@ AvahiServerConfig* avahi_server_config_init(AvahiServerConfig *c) {      c->allow_point_to_point = 0;      c->publish_aaaa_on_ipv4 = 1;      c->publish_a_on_ipv6 = 0; -     +      return c;  } @@ -1614,7 +1624,7 @@ AvahiServerConfig* avahi_server_config_copy(AvahiServerConfig *ret, const AvahiS          avahi_free(d);          return NULL;      } -     +      *ret = *c;      ret->host_name = h;      ret->domain_name = d; @@ -1625,7 +1635,7 @@ AvahiServerConfig* avahi_server_config_copy(AvahiServerConfig *ret, const AvahiS  int avahi_server_errno(AvahiServer *s) {      assert(s); -     +      return s->error;  } @@ -1644,7 +1654,7 @@ uint32_t avahi_server_get_local_service_cookie(AvahiServer *s) {  static AvahiEntry *find_entry(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiKey *key) {      AvahiEntry *e; -     +      assert(s);      assert(key); @@ -1664,7 +1674,7 @@ int avahi_server_get_group_of_service(AvahiServer *s, AvahiIfIndex interface, Av      AvahiEntry *e;      int ret;      char n[AVAHI_DOMAIN_NAME_MAX]; -     +      assert(s);      assert(name);      assert(type); @@ -1678,7 +1688,7 @@ int avahi_server_get_group_of_service(AvahiServer *s, AvahiIfIndex interface, Av      if ((ret = avahi_service_name_join(n, sizeof(n), name, type, domain) < 0))          return avahi_server_set_errno(s, ret); -         +      if (!(key = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV)))          return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY); @@ -1702,7 +1712,7 @@ int avahi_server_is_service_local(AvahiServer *s, AvahiIfIndex interface, AvahiP      if (!s->host_name_fqdn)          return 0; -     +      if (!(key = avahi_key_new(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV)))          return 0; @@ -1711,7 +1721,7 @@ int avahi_server_is_service_local(AvahiServer *s, AvahiIfIndex interface, AvahiP      if (!e)          return 0; -     +      return avahi_domain_equal(s->host_name_fqdn, e->record->data.srv.name);  } @@ -1720,7 +1730,7 @@ int avahi_server_is_record_local(AvahiServer *s, AvahiIfIndex interface, AvahiPr      assert(s);      assert(record); -     +      for (e = avahi_hashmap_lookup(s->entries_by_key, record->key); e; e = e->by_key_next)          if ((e->interface == interface || e->interface <= 0 || interface <= 0) && @@ -1752,13 +1762,13 @@ const AvahiServerConfig* avahi_server_get_config(AvahiServer *s) {  /** Set the browsing domains */  int avahi_server_set_browse_domains(AvahiServer *s, AvahiStringList *domains) {      AvahiStringList *l; -     +      assert(s);      for (l = s->config.browse_domains; l; l = l->next)          if (!avahi_is_valid_domain_name((char*) l->text))              return avahi_server_set_errno(s, AVAHI_ERR_INVALID_DOMAIN_NAME); -     +      avahi_string_list_free(s->config.browse_domains);      s->config.browse_domains = avahi_string_list_copy(domains); diff --git a/avahi-dnsconfd/avahi-dnsconfd.action b/avahi-dnsconfd/avahi-dnsconfd.action index 9337a6d..f7d3aa4 100755 --- a/avahi-dnsconfd/avahi-dnsconfd.action +++ b/avahi-dnsconfd/avahi-dnsconfd.action @@ -35,7 +35,27 @@ test "x$AVAHI_INTERFACE" != "x"  #   $AVAHI_INTERFACE_DNS_SERVERS   A whitespace seperated list of DNS servers on $AVAHI_INTERFACE  #   $AVAHI_DNS_SERVERS             The complete list of all DNS servers found on all interfaces -if [ -x /sbin/resolvconf ] ; then +if [ -x /sbin/netconfig ]; then +    # SUSE method on 11.1+ +    if [ -n "$AVAHI_INTERFACE_DNS_SERVERS" ]; then +	/sbin/netconfig modify -s avahi -i "$AVAHI_INTERFACE" <<-EOF +	INTERFACE='$AVAHI_INTERFACE' +	DNSSERVERS='$AVAHI_INTERFACE_DNS_SERVERS' +	EOF +    else +	/sbin/netconfig remove -s avahi -i "$AVAHI_INTERFACE" +    fi +elif [ -x /sbin/modify_resolvconf ] ; then +    # method for SUSE <= 11.0 +    if [ -n "$AVAHI_DNS_SERVERS" ]; then +	/sbin/modify_resolvconf modify -s avahi -t - -p avahi-dnsconfd -n "$AVAHI_DNS_SERVERS" <<-EOF +	if you don't like avahi to update your Nameservers +	disable the avahi-dnsconfd init script +	EOF +    else +	/sbin/modify_resolvconf restore -s avahi +    fi +elif [ -x /sbin/resolvconf ] ; then      # We have Debian's resolvconf tool diff --git a/avahi-ui/.gitignore b/avahi-ui/.gitignore index 9d9493a..b942010 100644 --- a/avahi-ui/.gitignore +++ b/avahi-ui/.gitignore @@ -2,6 +2,8 @@ bssh  bvnc  bssh.desktop  bvnc.desktop +bssh.desktop.in +bvnc.desktop.in  *.o  *.lo  *.la diff --git a/avahi-ui/Makefile.am b/avahi-ui/Makefile.am index 2d687ed..910dc6b 100644 --- a/avahi-ui/Makefile.am +++ b/avahi-ui/Makefile.am @@ -24,8 +24,10 @@ AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'  desktopdir = $(datadir)/applications  desktop_DATA =  +desktop_DATA_in = $(desktop_DATA_in_in:.in.in=.in) +desktop_DATA_in_in = bssh.desktop.in.in bvnc.desktop.in.in -EXTRA_DIST = bssh.desktop.in bvnc.desktop.in +EXTRA_DIST = $(desktop_DATA_in_in)  if HAVE_GTK @@ -70,14 +72,16 @@ install-exec-local:  		$(LN_S) bssh bvnc && \  		$(LN_S) bssh bshell -bssh.desktop: bssh.desktop.in +bssh.desktop.in: bssh.desktop.in.in  	sed -e 's,@bindir\@,$(bindir),g' $< > $@ -bvnc.desktop: bvnc.desktop.in +bvnc.desktop.in: bvnc.desktop.in.in  	sed -e 's,@bindir\@,$(bindir),g' $< > $@  endif # HAVE_GLIB  endif  endif -CLEANFILES = $(desktop_DATA) +@INTLTOOL_DESKTOP_RULE@ + +CLEANFILES = $(desktop_DATA) $(desktop_DATA_in) diff --git a/avahi-ui/avahi-ui.h b/avahi-ui/avahi-ui.h index eee0b34..d780f83 100644 --- a/avahi-ui/avahi-ui.h +++ b/avahi-ui/avahi-ui.h @@ -22,8 +22,7 @@    USA.  ***/ -#include <gtk/gtkwidget.h> -#include <gtk/gtkdialog.h> +#include <gtk/gtk.h>  #include <avahi-client/client.h> diff --git a/avahi-ui/bssh.desktop.in b/avahi-ui/bssh.desktop.in.in index 69f56b6..69f56b6 100644 --- a/avahi-ui/bssh.desktop.in +++ b/avahi-ui/bssh.desktop.in.in diff --git a/avahi-ui/bvnc.desktop.in b/avahi-ui/bvnc.desktop.in.in index 799c7d2..799c7d2 100644 --- a/avahi-ui/bvnc.desktop.in +++ b/avahi-ui/bvnc.desktop.in.in diff --git a/initscript/fedora/avahi-daemon.in b/initscript/fedora/avahi-daemon.in index d309866..c5b3230 100644 --- a/initscript/fedora/avahi-daemon.in +++ b/initscript/fedora/avahi-daemon.in @@ -2,19 +2,19 @@  #  # avahi-daemon:       Starts the Avahi Daemon  # -# chkconfig: 345 96 02 +# chkconfig: 345 24 02  # description: This is a daemon which runs on client machines to perform \  #              Zeroconf service discovery on a network. avahi-daemon must be \  #              running on systems  that use Avahi for service discovery. \  #              Avahi-daemon should not be running otherwise.  # processname: avahi-daemon -# config:  +# config:  AVAHI_BIN=@sbindir@/avahi-daemon -if [ "$1" == 'status' ]; then +if [ "$1" = 'status' ]; then      test -x $AVAHI_BIN || exit 4 -else  +else      test -x $AVAHI_BIN || exit 5  fi @@ -91,7 +91,7 @@ case "$1" in  	restart  	;;    reload) -        reload  +        reload  	;;    condrestart)    	if [ -f $LOCKFILE ]; then @@ -105,4 +105,3 @@ case "$1" in  esac  exit $RETVAL - diff --git a/initscript/fedora/avahi-dnsconfd.in b/initscript/fedora/avahi-dnsconfd.in index 284c10b..de49d7f 100644 --- a/initscript/fedora/avahi-dnsconfd.in +++ b/initscript/fedora/avahi-dnsconfd.in @@ -12,7 +12,7 @@  AVAHI_BIN=@sbindir@/avahi-dnsconfd -if [ "$1" == 'status' ]; then +if [ "$1" = 'status' ]; then      test -x $AVAHI_BIN || exit 4  else      test -x $AVAHI_BIN || exit 5 diff --git a/man/avahi-daemon.conf.5.xml.in b/man/avahi-daemon.conf.5.xml.in index 8cc3450..e00a911 100644 --- a/man/avahi-daemon.conf.5.xml.in +++ b/man/avahi-daemon.conf.5.xml.in @@ -112,7 +112,7 @@          to bind to UDP port 5353. This effectively impedes other mDNS          stacks from running on the host. Use this as a security          measure to make sure that only Avahi is responsible for mDNS -        traffic. Please note that we do no recommend running multiple +        traffic. Please note that we do not recommend running multiple          mDNS stacks on the same host simultaneously. This hampers          reliability and is a waste of resources. However, to not annoy          people this option defaults to "no".</p> diff --git a/po/POTFILES.in b/po/POTFILES.in index 83961a6..80b5a29 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -2,8 +2,8 @@  avahi-common/error.c  avahi-ui/avahi-ui.c  avahi-ui/bssh.c -avahi-ui/bssh.desktop.in -avahi-ui/bvnc.desktop.in +avahi-ui/bssh.desktop.in.in +avahi-ui/bvnc.desktop.in.in  avahi-utils/avahi-browse.c  avahi-utils/avahi-publish.c  avahi-utils/avahi-resolve.c diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 8bedfdf..cbfd41b 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -1,3 +1,5 @@  avahi-discover-standalone/avahi-discover.glade +avahi-ui/bssh.desktop.in +avahi-ui/bvnc.desktop.in  tests/c-plus-plus-test-gen.py diff --git a/service-type-database/service-types b/service-type-database/service-types index 7456a6e..97e6858 100644 --- a/service-type-database/service-types +++ b/service-type-database/service-types @@ -149,6 +149,9 @@ _pulse-source._tcp:PulseAudio Sound Source  _mpd._tcp:Music Player Daemon +# DAAP share provided by iTunes on behalf of an iPod Touch +_touch-able._tcp:iPod Touch Music Library +  _vlc-http._tcp:VLC Streaming | 
