summaryrefslogtreecommitdiff
path: root/avahi-core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-06-28 20:13:22 +0200
committerLennart Poettering <lennart@poettering.net>2010-06-28 20:40:01 +0200
commit959f3aa980c6dc4a9d39b311638ca471d7ff310d (patch)
tree2a2d4f1cbfde854afa5287584ddc3f3ce4a4c5e5 /avahi-core
parentd735b5a37d5aa1a0666e43b28a45b3ed4f0490e3 (diff)
downloadavahi-959f3aa980c6dc4a9d39b311638ca471d7ff310d.tar.gz
core: always normalize configure host/domain name
Diffstat (limited to 'avahi-core')
-rw-r--r--avahi-core/server.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/avahi-core/server.c b/avahi-core/server.c
index 558fec9..569b44e 100644
--- a/avahi-core/server.c
+++ b/avahi-core/server.c
@@ -1242,13 +1242,14 @@ int avahi_server_set_host_name(AvahiServer *s, const char *host_name) {
AVAHI_CHECK_VALIDITY(s, !host_name || avahi_is_valid_host_name(host_name), AVAHI_ERR_INVALID_HOST_NAME);
- if (!host_name) {
+ if (!host_name)
hn = avahi_get_host_name_strdup();
- hn[strcspn(hn, ".")] = 0;
- host_name = hn;
- }
+ else
+ hn = avahi_normalize_name_strdup(host_name);
+
+ hn[strcspn(hn, ".")] = 0;
- if (avahi_domain_equal(s->host_name, host_name) && s->state != AVAHI_SERVER_COLLISION) {
+ if (avahi_domain_equal(s->host_name, hn) && s->state != AVAHI_SERVER_COLLISION) {
avahi_free(hn);
return avahi_server_set_errno(s, AVAHI_ERR_NO_CHANGE);
}
@@ -1256,7 +1257,7 @@ int avahi_server_set_host_name(AvahiServer *s, const char *host_name) {
withdraw_host_rrs(s);
avahi_free(s->host_name);
- s->host_name = hn ? hn : avahi_strdup(host_name);
+ s->host_name = hn;
update_fqdn(s);
@@ -1270,10 +1271,10 @@ int avahi_server_set_domain_name(AvahiServer *s, const char *domain_name) {
AVAHI_CHECK_VALIDITY(s, !domain_name || avahi_is_valid_domain_name(domain_name), AVAHI_ERR_INVALID_DOMAIN_NAME);
- if (!domain_name) {
+ if (!domain_name)
dn = avahi_strdup("local");
- domain_name = dn;
- }
+ else
+ dn = avahi_normalize_name_strdup(domain_name);
if (avahi_domain_equal(s->domain_name, domain_name)) {
avahi_free(dn);
@@ -1283,7 +1284,7 @@ int avahi_server_set_domain_name(AvahiServer *s, const char *domain_name) {
withdraw_host_rrs(s);
avahi_free(s->domain_name);
- s->domain_name = avahi_normalize_name_strdup(domain_name);
+ s->domain_name = dn;
update_fqdn(s);
register_stuff(s);