]> git.meshlink.io Git - catta/commitdiff
* add two new configuration file options: "disable-publishing" and "disable-user...
authorLennart Poettering <lennart@poettering.net>
Sun, 6 Nov 2005 02:08:32 +0000 (02:08 +0000)
committerLennart Poettering <lennart@poettering.net>
Sun, 6 Nov 2005 02:08:32 +0000 (02:08 +0000)
* add two new errors: NOT_PERMITTED and NOT_SUPPORTED
* add two new publishing flags: AVAHI_PUBLISH_USE_MULTICAST, AVAHI_PUBLISH_USE_WIDE_AREA
* return NOT_SUPPORTED when user tries to add RRs in wide area domains - for now

git-svn-id: file:///home/lennart/svn/public/avahi/trunk@930 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

14 files changed:
avahi-client/client-test.c
avahi-common/dbus.c
avahi-common/dbus.h
avahi-common/defs.h
avahi-common/error.c
avahi-common/error.h
avahi-core/core.h
avahi-core/entry.c
avahi-core/server.c
avahi-daemon/avahi-daemon.conf
avahi-daemon/dbus-protocol.c
avahi-daemon/dbus-protocol.h
avahi-daemon/main.c
docs/TODO

index 802584a2bf905210dcaee22687828bdb2e02dce9..22ca07321a44b61541bfcb388755b5e008bc25e6 100644 (file)
@@ -257,8 +257,8 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
     
     printf("Sucessfully created entry group %p\n", (void*) group);
 
-    avahi_entry_group_add_service (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar", NULL);
-    printf ("add_record: %d", avahi_entry_group_add_record (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "TestX", 0x01, 0x10, 120, "\5booya", 6));
+    printf("%s\n", avahi_strerror(avahi_entry_group_add_service (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar", NULL)));
+    printf("add_record: %d\n", avahi_entry_group_add_record (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "TestX", 0x01, 0x10, 120, "\5booya", 6));
 
     avahi_entry_group_commit (group);
 
@@ -314,9 +314,7 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
     avahi_elapse_time(&tv, 30000, 0);
     poll_api->timeout_new(poll_api, &tv, terminate, NULL);
 
-    for (;;)
-        if (avahi_simple_poll_iterate(simple_poll, -1) != 0)
-            break;
+    avahi_simple_poll_loop(simple_poll);
 
     printf("terminating...\n");
     
index cebf56d51a8a288fb4003a2bfc2dd9e16e91d739..3ea7cbd40e2a8e9c5d146e2bc08784704895589b 100644 (file)
@@ -83,7 +83,10 @@ static const char * const table[- AVAHI_ERR_MAX] = {
     AVAHI_DBUS_ERR_DNS_NOTZONE,
     AVAHI_DBUS_ERR_INVALID_RDATA,
     AVAHI_DBUS_ERR_INVALID_DNS_CLASS,
-    AVAHI_DBUS_ERR_INVALID_DNS_TYPE
+    AVAHI_DBUS_ERR_INVALID_DNS_TYPE,
+    AVAHI_DBUS_ERR_NOT_SUPPORTED,
+
+    AVAHI_DBUS_ERR_NOT_PERMITTED
 };
 
 int avahi_error_dbus_to_number(const char *s) {
index 86c62f203fc16c80c1c46715a9099a287d8cf997..fb8a074fbe3e5b81a1215d6907dc194243ee2b87 100644 (file)
@@ -91,8 +91,10 @@ AVAHI_C_DECL_BEGIN
 #define AVAHI_DBUS_ERR_DNS_NOTAUTH "org.freedesktop.Avahi.DNSNOTAUTH"
 #define AVAHI_DBUS_ERR_DNS_NOTZONE "org.freedesktop.Avahi.DNSNOTZONE"
 #define AVAHI_DBUS_ERR_INVALID_RDATA "org.freedesktop.Avahi.InvalidRDataError"
-#define AVAHI_DBUS_ERR_INVALID_DNS_CLASS "org.freedesktop.Avahi.InvalidDNSClass"
-#define AVAHI_DBUS_ERR_INVALID_DNS_TYPE "org.freedesktop.Avahi.InvalidDNSType"
+#define AVAHI_DBUS_ERR_INVALID_DNS_CLASS "org.freedesktop.Avahi.InvalidDNSClassError"
+#define AVAHI_DBUS_ERR_INVALID_DNS_TYPE "org.freedesktop.Avahi.InvalidDNSTypeError"
+#define AVAHI_DBUS_ERR_NOT_SUPPORTED "org.freedesktop.Avahi.NotSupportedError"
+#define AVAHI_DBUS_ERR_NOT_PERMITTED "org.freedesktop.Avahi.NotPermittedError"
 
 /** Convert a DBus error string into an Avahi error number */
 int avahi_error_dbus_to_number(const char *s);
index 8167f34fb26a41748f7a6a823d48d5dd2776e9a4..18099c71b5aba7a9a0f71d44bf4e3c7e2ea66015 100644 (file)
@@ -172,7 +172,9 @@ typedef enum {
     AVAHI_PUBLISH_ALLOW_MULTIPLE = 8,   /**< For raw records: Allow multiple local records of this type, even if they are intended to be unique */
     AVAHI_PUBLISH_NO_REVERSE = 16,      /**< For address records: don't create a reverse (PTR) entry */
     AVAHI_PUBLISH_NO_COOKIE = 32,       /**< For service records: do not implicitly add the local service cookie to TXT data */
-    AVAHI_PUBLISH_UPDATE = 64           /**< Update existing records instead of adding new ones */
+    AVAHI_PUBLISH_UPDATE = 64,          /**< Update existing records instead of adding new ones */
+    AVAHI_PUBLISH_USE_WIDE_AREA = 128,  /**< Register the record using wide area DNS (i.e. unicast DNS update) */
+    AVAHI_PUBLISH_USE_MULTICAST = 256   /**< Register the record using multicast DNS */
 } AvahiPublishFlags;
 
 /** Some flags for lookup functions */
index c997dc05f7d44d89a2799fc5580281d83f982fc9..864a5bd1c992e284d0eeabcf2ec168c53f560b5d 100644 (file)
@@ -80,7 +80,10 @@ const char *avahi_strerror(int error) {
         "DNS failure: NOTZONE",
         "Invalid RDATA",
         "Invalid DNS type",
-        "Invalid DNS class"
+        "Invalid DNS class",
+        "Not supported",
+
+        "Not permitted"
     };
 
     if (-error < 0 || -error >= -AVAHI_ERR_MAX)
index 0c3320d58619011e24d934b8388832dd69825fa6..91e32d7eade56f4abbf92e393af64db2595241e2 100644 (file)
@@ -83,6 +83,9 @@ enum {
     AVAHI_ERR_INVALID_RDATA = -46,           /**< Invalid RDATA */
     AVAHI_ERR_INVALID_DNS_CLASS = -47,       /**< Invalid DNS class */
     AVAHI_ERR_INVALID_DNS_TYPE = -48,        /**< Invalid DNS type */
+    AVAHI_ERR_NOT_SUPPORTED = -49,           /**< Not supported */
+    
+    AVAHI_ERR_NOT_PERMITTED = -50,           /**< Operation not permitted */
     
     /****
      ****    IF YOU ADD A NEW ERROR CODE HERE, PLEASE DON'T FORGET TO ADD
@@ -92,7 +95,7 @@ enum {
      ****    Also remember to update the MAX value below.
      ****/
     
-    AVAHI_ERR_MAX = -49
+    AVAHI_ERR_MAX = -51
 };
 
 /** Return a human readable error string for the specified error code */
index 64db69cb5807640c1ee5d40a269dd0cb6dc6353c..fc89eb33c046f2812ea4ce573b1f769817eb8b2f 100644 (file)
@@ -61,6 +61,7 @@ typedef struct AvahiServerConfig {
     unsigned n_wide_area_servers;     /**< Number of servers in wide_area_servers[] */
     int disallow_other_stacks;        /**< Make sure that only one mDNS responder is run at the same time on the local machine. If this is enable Avahi will not set SO_REUSADDR on its sockets, effectively preventing other stacks from running on the local machine */
     AvahiStringList *browse_domains;  /**< Additional browsing domains */
+    int disable_publishing;           /**< Disable publishing of any record */
 } AvahiServerConfig;
 
 /** Allocate a new mDNS responder object. */
index 855e22840ce6024498a3ee25afaa9fcf4aa3c8a7..f65f7b145e36f5d088a5afe2c48378fb00811440 100644 (file)
@@ -40,6 +40,7 @@
 #include <avahi-common/timeval.h>
 #include <avahi-common/malloc.h>
 #include <avahi-common/error.h>
+#include <avahi-common/domain.h>
 
 #include "internal.h"
 #include "iface.h"
 #include "util.h"
 #include "dns-srv-rr.h"
 #include "rr-util.h"
+#include "domain-util.h"
+
+static void transport_flags_from_domain(AvahiServer *s, AvahiPublishFlags *flags, const char *domain) {
+    assert(flags);
+    assert(domain);
+
+    assert(!((*flags & AVAHI_PUBLISH_USE_MULTICAST) && (*flags & AVAHI_PUBLISH_USE_WIDE_AREA)));
+
+    if (*flags & (AVAHI_PUBLISH_USE_MULTICAST|AVAHI_PUBLISH_USE_WIDE_AREA))
+        return;
+
+    if (!s->wide_area_lookup_engine ||
+        !avahi_wide_area_has_servers(s->wide_area_lookup_engine) ||
+        avahi_domain_ends_with(domain, AVAHI_MDNS_SUFFIX_LOCAL) ||
+        avahi_domain_ends_with(domain, AVAHI_MDNS_SUFFIX_ADDR_IPV4) ||
+        avahi_domain_ends_with(domain, AVAHI_MDNS_SUFFIX_ADDR_IPV6))
+        *flags |= AVAHI_PUBLISH_USE_MULTICAST;
+    else
+        *flags |= AVAHI_PUBLISH_USE_WIDE_AREA;
+}
 
 void avahi_entry_free(AvahiServer*s, AvahiEntry *e) {
     AvahiEntry *t;
@@ -174,7 +195,9 @@ static AvahiEntry * server_add_internal(
                                          AVAHI_PUBLISH_NO_PROBE|
                                          AVAHI_PUBLISH_UNIQUE|
                                          AVAHI_PUBLISH_ALLOW_MULTIPLE|
-                                         AVAHI_PUBLISH_UPDATE), AVAHI_ERR_INVALID_FLAGS);
+                                         AVAHI_PUBLISH_UPDATE|
+                                         AVAHI_PUBLISH_USE_WIDE_AREA|
+                                         AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
     AVAHI_CHECK_VALIDITY_RETURN_NULL(s, avahi_is_valid_domain_name(r->key->name), AVAHI_ERR_INVALID_HOST_NAME);
     AVAHI_CHECK_VALIDITY_RETURN_NULL(s, r->ttl != 0, AVAHI_ERR_INVALID_TTL);
     AVAHI_CHECK_VALIDITY_RETURN_NULL(s, !avahi_key_is_pattern(r->key), AVAHI_ERR_IS_PATTERN);
@@ -189,6 +212,10 @@ static AvahiEntry * server_add_internal(
                                      (r->key->type != AVAHI_DNS_TYPE_IXFR) &&
                                      (r->key->type != AVAHI_DNS_TYPE_AXFR), AVAHI_ERR_INVALID_DNS_TYPE);
 
+    transport_flags_from_domain(s, &flags, r->key->name);
+    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, !s->config.disable_publishing, AVAHI_ERR_NOT_PERMITTED);
+    
     if (flags & AVAHI_PUBLISH_UPDATE) {
         AvahiRecord *old_record;
         int is_first = 1;
@@ -356,7 +383,7 @@ static AvahiEntry *server_add_ptr_internal(
 
     if (!name)
         name = s->host_name_fqdn;
-    
+
     if (!(r = avahi_record_new_full(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR, ttl))) {
         avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
         return NULL;
@@ -407,7 +434,13 @@ int avahi_server_add_address(
 
     AVAHI_CHECK_VALIDITY(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
     AVAHI_CHECK_VALIDITY(s, AVAHI_PROTO_VALID(protocol) && AVAHI_PROTO_VALID(a->proto), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_REVERSE|AVAHI_PUBLISH_NO_ANNOUNCE|AVAHI_PUBLISH_NO_PROBE|AVAHI_PUBLISH_UPDATE), AVAHI_ERR_INVALID_FLAGS);
+    AVAHI_CHECK_VALIDITY(s, AVAHI_FLAGS_VALID(flags,
+                                              AVAHI_PUBLISH_NO_REVERSE|
+                                              AVAHI_PUBLISH_NO_ANNOUNCE|
+                                              AVAHI_PUBLISH_NO_PROBE|
+                                              AVAHI_PUBLISH_UPDATE|
+                                              AVAHI_PUBLISH_USE_WIDE_AREA|
+                                              AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
     AVAHI_CHECK_VALIDITY(s, !name || avahi_is_valid_domain_name(name), AVAHI_ERR_INVALID_HOST_NAME);
 
     /* Prepare the host naem */
@@ -419,6 +452,9 @@ int avahi_server_add_address(
         name = n;
     }
 
+    transport_flags_from_domain(s, &flags, name);
+    AVAHI_CHECK_VALIDITY(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+    
     /* Create the A/AAAA record */
     
     if (a->proto == AVAHI_PROTO_INET) {
@@ -541,7 +577,11 @@ static int server_add_service_strlst_nocopy(
 
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_COOKIE|AVAHI_PUBLISH_UPDATE), AVAHI_ERR_INVALID_FLAGS);
+    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags,
+                                                                AVAHI_PUBLISH_NO_COOKIE|
+                                                                AVAHI_PUBLISH_UPDATE|
+                                                                AVAHI_PUBLISH_USE_WIDE_AREA|
+                                                                AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
@@ -553,6 +593,9 @@ static int server_add_service_strlst_nocopy(
     if (!host)
         host = s->host_name_fqdn;
 
+    transport_flags_from_domain(s, &flags, domain);
+    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+    
     if (!(h = avahi_normalize_name_strdup(host))) {
         ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
         goto fail;
@@ -694,7 +737,10 @@ static int server_update_service_txt_strlst_nocopy(
 
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_NO_COOKIE), AVAHI_ERR_INVALID_FLAGS);
+    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags,
+                                                                AVAHI_PUBLISH_NO_COOKIE|
+                                                                AVAHI_PUBLISH_USE_WIDE_AREA|
+                                                                AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
@@ -702,6 +748,9 @@ static int server_update_service_txt_strlst_nocopy(
     if (!domain)
         domain = s->domain_name;
 
+    transport_flags_from_domain(s, &flags, domain);
+    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+
     if ((ret = avahi_service_name_join(svc_name, sizeof(svc_name), name, type, domain)) < 0) {
         avahi_server_set_errno(s, ret);
         goto fail;
@@ -780,7 +829,7 @@ int avahi_server_add_service_subtype(
 
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags, 0), AVAHI_ERR_INVALID_FLAGS);
+    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_USE_MULTICAST|AVAHI_PUBLISH_USE_WIDE_AREA), AVAHI_ERR_INVALID_FLAGS);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE);
     AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
@@ -789,6 +838,9 @@ int avahi_server_add_service_subtype(
     if (!domain)
         domain = s->domain_name;
 
+    transport_flags_from_domain(s, &flags, domain);
+    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+
     if ((ret = avahi_service_name_join(svc_name, sizeof(svc_name), name, type, domain)) < 0 ||
         (ret = avahi_service_name_join(ptr_name, sizeof(ptr_name), NULL, subtype, domain)) < 0) {
         avahi_server_set_errno(s, ret);
@@ -825,7 +877,7 @@ static void hexstring(char *s, size_t sl, const void *p, size_t pl) {
         *s = 0;
 }
 
-static AvahiEntry * server_add_dns_server_name(
+static AvahiEntry *server_add_dns_server_name(
     AvahiServer *s,
     AvahiSEntryGroup *g,
     AvahiIfIndex interface,
@@ -844,7 +896,7 @@ static AvahiEntry * server_add_dns_server_name(
     assert(s);
     assert(name);
 
-    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, AVAHI_FLAGS_VALID(flags, 0), AVAHI_ERR_INVALID_FLAGS);
+    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_USE_WIDE_AREA|AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
     AVAHI_CHECK_VALIDITY_RETURN_NULL(s, type == AVAHI_DNS_SERVER_UPDATE || type == AVAHI_DNS_SERVER_RESOLVE, AVAHI_ERR_INVALID_FLAGS);
     AVAHI_CHECK_VALIDITY_RETURN_NULL(s, port != 0, AVAHI_ERR_INVALID_PORT);
     AVAHI_CHECK_VALIDITY_RETURN_NULL(s, avahi_is_valid_domain_name(name), AVAHI_ERR_INVALID_HOST_NAME);
@@ -853,6 +905,9 @@ static AvahiEntry * server_add_dns_server_name(
     if (!domain)
         domain = s->domain_name;
 
+    transport_flags_from_domain(s, &flags, domain);
+    AVAHI_CHECK_VALIDITY_RETURN_NULL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+
     if (!(n = avahi_normalize_name_strdup(name))) {
         avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
         return NULL;
@@ -898,7 +953,7 @@ int avahi_server_add_dns_server_address(
 
     AVAHI_CHECK_VALIDITY(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
     AVAHI_CHECK_VALIDITY(s, AVAHI_PROTO_VALID(protocol) && AVAHI_PROTO_VALID(address->proto), AVAHI_ERR_INVALID_PROTOCOL);
-    AVAHI_CHECK_VALIDITY(s, AVAHI_FLAGS_VALID(flags, 0), AVAHI_ERR_INVALID_FLAGS);
+    AVAHI_CHECK_VALIDITY(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_USE_MULTICAST|AVAHI_PUBLISH_USE_WIDE_AREA), AVAHI_ERR_INVALID_FLAGS);
     AVAHI_CHECK_VALIDITY(s, type == AVAHI_DNS_SERVER_UPDATE || type == AVAHI_DNS_SERVER_RESOLVE, AVAHI_ERR_INVALID_FLAGS);
     AVAHI_CHECK_VALIDITY(s, port != 0, AVAHI_ERR_INVALID_PORT);
     AVAHI_CHECK_VALIDITY(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
@@ -906,6 +961,9 @@ int avahi_server_add_dns_server_address(
     if (!domain)
         domain = s->domain_name;
 
+    transport_flags_from_domain(s, &flags, domain);
+    AVAHI_CHECK_VALIDITY(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
+    
     if (address->proto == AVAHI_PROTO_INET) {
         hexstring(h, sizeof(h), &address->data, sizeof(AvahiIPv4Address));
         snprintf(n, sizeof(n), "ip-%s.%s", h, domain);
index d92afac7d89ff3d59d55f3e20faf29ac87a5724d..0cc4d4e18c1b93cc5765a007e8b32542fb9451de 100644 (file)
@@ -1529,6 +1529,7 @@ AvahiServerConfig* avahi_server_config_init(AvahiServerConfig *c) {
     c->n_wide_area_servers = 0;
     c->disallow_other_stacks = 0;
     c->browse_domains = NULL;
+    c->disable_publishing = 0;
     
     return c;
 }
index ce6b0a220a8865820b62d4ddee35ae638255b145..9572c0aea56ee62c0c6b1ce2f60446d7f2c9de86 100644 (file)
@@ -8,6 +8,8 @@ check-response-ttl=no
 use-iff-running=no
 enable-dbus=yes
 disallow-other-stacks=no
+disable-publishing=no
+disable-user-service-publishing=no
 
 [wide-area]
 enable-wide-area=yes
index 517b95413223c42e27d0a3bc3c9ee3c7e9da889e..c6c4a676c50c2041ecf05cbbe33d197b13af88ca 100644 (file)
@@ -63,6 +63,8 @@
 
 Server *server = NULL;
 
+static int disable_user_service_publishing = 0;
+
 static void client_free(Client *c) {
     
     assert(server);
@@ -386,6 +388,9 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
             goto fail;
         }
 
+        if (disable_user_service_publishing)
+            return avahi_dbus_respond_error(c, m, AVAHI_ERR_NOT_PERMITTED, NULL);
+        
         if (!(client = client_get(dbus_message_get_sender(m), TRUE))) {
             avahi_log_warn("Too many clients, client request failed.");
             return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
@@ -917,7 +922,7 @@ void dbus_protocol_server_state_changed(AvahiServerState state) {
     dbus_message_unref(m);
 }
 
-int dbus_protocol_setup(const AvahiPoll *poll_api) {
+int dbus_protocol_setup(const AvahiPoll *poll_api, int _disable_user_service_publishing) {
     DBusError error;
 
     static const DBusObjectPathVTable server_vtable = {
@@ -931,6 +936,8 @@ int dbus_protocol_setup(const AvahiPoll *poll_api) {
 
     dbus_error_init(&error);
 
+    disable_user_service_publishing = _disable_user_service_publishing;
+
     server = avahi_new(Server, 1);
     AVAHI_LLIST_HEAD_INIT(Clients, server->clients);
     server->current_id = 0;
index 08774265acffb3036de3ba3bd5781796a7d857ba..d23b5248a47b5d8bab0aa7fc293b2bf308bbe455 100644 (file)
@@ -22,7 +22,7 @@
   USA.
 ***/
 
-int dbus_protocol_setup(const AvahiPoll *poll_api);
+int dbus_protocol_setup(const AvahiPoll *poll_api, int disable_user_service_publishing);
 void dbus_protocol_shutdown(void);
 void dbus_protocol_server_state_changed(AvahiServerState state);
 
index a903e63c8649a9c71fc8c82344a658f9d2e4f1d5..44300ffc0fbc759cf51b5fa3784b3a4ec88994ac 100644 (file)
@@ -101,7 +101,8 @@ typedef struct {
     int use_chroot;
 #endif
     int modify_proc_title;
-    
+
+    int disable_user_service_publishing;
     int publish_resolv_conf;
     char ** publish_dns_servers;
     int debug;
@@ -486,6 +487,10 @@ static int load_config_file(DaemonConfig *c) {
                     c->server_config.use_iff_running = is_yes(p->value);
                 else if (strcasecmp(p->key, "disallow-other-stacks") == 0)
                     c->server_config.disallow_other_stacks = is_yes(p->value);
+                else if (strcasecmp(p->key, "disable-publishing") == 0)
+                    c->server_config.disable_publishing = is_yes(p->value);
+                else if (strcasecmp(p->key, "disable-user-service-publishing") == 0)
+                    c->disable_user_service_publishing = is_yes(p->value);
 #ifdef HAVE_DBUS
                 else if (strcasecmp(p->key, "enable-dbus") == 0) {
 
@@ -723,7 +728,7 @@ static int run_server(DaemonConfig *c) {
 
 #ifdef HAVE_DBUS
     if (c->enable_dbus) {
-        if (dbus_protocol_setup(poll_api) < 0) {
+        if (dbus_protocol_setup(poll_api, config.disable_user_service_publishing) < 0) {
 
             if (c->fail_on_missing_dbus)
                 goto finish;
@@ -1012,7 +1017,8 @@ int main(int argc, char *argv[]) {
     config.use_chroot = 1;
 #endif
     config.modify_proc_title = 1;
-    
+
+    config.disable_user_service_publishing = 0;
     config.publish_dns_servers = NULL;
     config.publish_resolv_conf = 0;
     config.use_syslog = 0;
index 0aa0293957a18394e0c9b21316c3b44c750ca8f1..e8a92ef77972f8bf4d41af38411fbb63491f8e46 100644 (file)
--- a/docs/TODO
+++ b/docs/TODO
@@ -1,12 +1,11 @@
 for 0.6:
 * remove outgoing queries from queue if the browse object they were issued from is destroyed
 * add API to allow user to tell the server that some service is not reachable
-* Add static host configuration like static services [lathiat]
 * introduce AVAHI_CLIENT_FAILURE
+* Add static host configuration like static services [lathiat]
 * Expose AvahiSRecordBrowser over D-BUS and implement in avahi-client [lathiat]
 * fix python scripts
 * update man pages
-* return an error when the user tries to register a service in a domain != .local, for now
 
 later:
 * avahi-client: do something about letting the client know if the daemon comes back from a DISCONNECTED state
@@ -107,3 +106,4 @@ done:
 * add domain browsing to avahi-browse
 * always set source address for outgoing packets
 * add support for defining browsing domains with an option in avahi-daemon.onf
+* return an error when the user tries to register a service in a domain != .local, for now