summaryrefslogtreecommitdiff
path: root/net-dns/avahi-qt/files/avahi-0.6.31-host-name-from-machine-id.patch
diff options
context:
space:
mode:
authorBlackNoxis <steven.darklight@gmail.com>2015-06-21 10:41:46 +0300
committerBlackNoxis <steven.darklight@gmail.com>2015-06-21 10:41:46 +0300
commit67cfaa660d1918e67e9ae1c7d9b4fa30a15eb4b1 (patch)
tree174cfa24b4c4b919c83465761b38699ead693341 /net-dns/avahi-qt/files/avahi-0.6.31-host-name-from-machine-id.patch
parenta3c6ae3d3ccd28d1dc8e87733845d4e72af6479b (diff)
[avahi*] splited packages for avahi, so that avahi won`t get all of the repo installed
Diffstat (limited to 'net-dns/avahi-qt/files/avahi-0.6.31-host-name-from-machine-id.patch')
-rw-r--r--net-dns/avahi-qt/files/avahi-0.6.31-host-name-from-machine-id.patch85
1 files changed, 85 insertions, 0 deletions
diff --git a/net-dns/avahi-qt/files/avahi-0.6.31-host-name-from-machine-id.patch b/net-dns/avahi-qt/files/avahi-0.6.31-host-name-from-machine-id.patch
new file mode 100644
index 00000000..17ecba52
--- /dev/null
+++ b/net-dns/avahi-qt/files/avahi-0.6.31-host-name-from-machine-id.patch
@@ -0,0 +1,85 @@
+From: David Zeuthen <zeuthen@chromium.org>
+Date: Tue, 5 Mar 2013 19:52:38 +0000 (-0800)
+Subject: avahi-daemon: add option "host-name-from-machine-id="
+X-Git-Url: http://git.0pointer.de/?p=avahi.git;a=commitdiff_plain;h=147cdce70b22ae7cee9fb4fe123db40952f31c9e
+
+avahi-daemon: add option "host-name-from-machine-id="
+
+Signed-off-by: David Zeuthen <zeuthen@chromium.org>
+---
+
+diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c
+index d46f40a..8c28fd6 100644
+--- a/avahi-daemon/main.c
++++ b/avahi-daemon/main.c
+@@ -65,6 +65,7 @@
+ #include <avahi-core/publish.h>
+ #include <avahi-core/dns-srv-rr.h>
+ #include <avahi-core/log.h>
++#include <avahi-core/util.h>
+
+ #ifdef ENABLE_CHROOT
+ #include "chroot.h"
+@@ -576,6 +577,29 @@ static int parse_usec(const char *s, AvahiUsec *u) {
+ return 0;
+ }
+
++static char *get_machine_id(void) {
++ int fd;
++ char buf[32];
++
++ fd = open("/etc/machine-id", O_RDONLY|O_CLOEXEC|O_NOCTTY);
++ if (fd == -1 && errno == ENOENT)
++ fd = open("/var/lib/dbus/machine-id", O_RDONLY|O_CLOEXEC|O_NOCTTY);
++ if (fd == -1)
++ return NULL;
++
++ /* File is on a filesystem so we never get EINTR or partial reads */
++ if (read(fd, buf, sizeof buf) != sizeof buf) {
++ close(fd);
++ return NULL;
++ }
++ close(fd);
++
++ /* Contents can be lower, upper and even mixed case so normalize */
++ avahi_strdown(buf);
++
++ return avahi_strndup(buf, sizeof buf);
++}
++
+ static int load_config_file(DaemonConfig *c) {
+ int r = -1;
+ AvahiIniFile *f;
+@@ -631,6 +655,15 @@ 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, "host-name-from-machine-id") == 0) {
++ if (*(p->value) == 'y' || *(p->value) == 'Y') {
++ char *machine_id = get_machine_id();
++ if (machine_id != NULL) {
++ avahi_free(c->server_config.host_name);
++ c->server_config.host_name = machine_id;
++ }
++ }
++ }
+ #ifdef HAVE_DBUS
+ else if (strcasecmp(p->key, "enable-dbus") == 0) {
+
+diff --git a/man/avahi-daemon.conf.5.xml.in b/man/avahi-daemon.conf.5.xml.in
+index bea7ed5..2d15017 100644
+--- a/man/avahi-daemon.conf.5.xml.in
++++ b/man/avahi-daemon.conf.5.xml.in
+@@ -40,6 +40,12 @@
+ </option>
+
+ <option>
++ <p><opt>host-name-from-machine-id=</opt> Takes a boolean
++ value ("yes" or "no"). If set to "yes" avahi-daemon
++ will use the machine-id as name on the LAN.</p>
++ </option>
++
++ <option>
+ <p><opt>domain-name=</opt> Set the default domain name avahi-daemon
+ tries to register its host name and services on the LAN in. If
+ omitted defaults to ".local".</p>