From: Lennart Poettering Date: Sun, 6 Nov 2005 02:08:32 +0000 (+0000) Subject: * add two new configuration file options: "disable-publishing" and "disable-user... X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=fbce111b069aa1e4c701ed37ee1d9f6d6cefaac5;p=catta * add two new configuration file options: "disable-publishing" and "disable-user-service-publishing" * 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 --- diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c index 802584a..22ca073 100644 --- a/avahi-client/client-test.c +++ b/avahi-client/client-test.c @@ -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"); diff --git a/avahi-common/dbus.c b/avahi-common/dbus.c index cebf56d..3ea7cbd 100644 --- a/avahi-common/dbus.c +++ b/avahi-common/dbus.c @@ -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) { diff --git a/avahi-common/dbus.h b/avahi-common/dbus.h index 86c62f2..fb8a074 100644 --- a/avahi-common/dbus.h +++ b/avahi-common/dbus.h @@ -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); diff --git a/avahi-common/defs.h b/avahi-common/defs.h index 8167f34..18099c7 100644 --- a/avahi-common/defs.h +++ b/avahi-common/defs.h @@ -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 */ diff --git a/avahi-common/error.c b/avahi-common/error.c index c997dc0..864a5bd 100644 --- a/avahi-common/error.c +++ b/avahi-common/error.c @@ -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) diff --git a/avahi-common/error.h b/avahi-common/error.h index 0c3320d..91e32d7 100644 --- a/avahi-common/error.h +++ b/avahi-common/error.h @@ -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 */ diff --git a/avahi-core/core.h b/avahi-core/core.h index 64db69c..fc89eb3 100644 --- a/avahi-core/core.h +++ b/avahi-core/core.h @@ -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. */ diff --git a/avahi-core/entry.c b/avahi-core/entry.c index 855e228..f65f7b1 100644 --- a/avahi-core/entry.c +++ b/avahi-core/entry.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "internal.h" #include "iface.h" @@ -49,6 +50,26 @@ #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); diff --git a/avahi-core/server.c b/avahi-core/server.c index d92afac..0cc4d4e 100644 --- a/avahi-core/server.c +++ b/avahi-core/server.c @@ -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; } diff --git a/avahi-daemon/avahi-daemon.conf b/avahi-daemon/avahi-daemon.conf index ce6b0a2..9572c0a 100644 --- a/avahi-daemon/avahi-daemon.conf +++ b/avahi-daemon/avahi-daemon.conf @@ -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 diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c index 517b954..c6c4a67 100644 --- a/avahi-daemon/dbus-protocol.c +++ b/avahi-daemon/dbus-protocol.c @@ -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; diff --git a/avahi-daemon/dbus-protocol.h b/avahi-daemon/dbus-protocol.h index 0877426..d23b524 100644 --- a/avahi-daemon/dbus-protocol.h +++ b/avahi-daemon/dbus-protocol.h @@ -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); diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c index a903e63..44300ff 100644 --- a/avahi-daemon/main.c +++ b/avahi-daemon/main.c @@ -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; diff --git a/docs/TODO b/docs/TODO index 0aa0293..e8a92ef 100644 --- 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