diff options
author | Ratan Gupta <ratagupt@in.ibm.com> | 2018-03-20 22:04:08 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-04-18 23:38:21 +0300 |
commit | 8f852d2b9484202118e382a31d16e659b91789ee (patch) | |
tree | fd70ce5e30dc257e2e76b12729c1b3630c6aeb0a /meta-phosphor | |
parent | 1739501db9d7a241ae61479e8c83591c33ece0aa (diff) | |
download | openbmc-8f852d2b9484202118e382a31d16e659b91789ee.tar.xz |
Avahi: Don't start the avahi-daemon if dot local domain is there
More info is at the following link
https://web.archive.org/web/20150228130344/http://avahi.org/wiki/AvahiAndUnicastDotLocal
This commit creates the avahi user and avahi group,as there may be cases
where one of them don't exist due to code update.
for example a BMC image that has additional user accounts
(and therefore a bigger /etc/group file) is installed on the BMC,
the /etc/group or /etc/passwd file would not be updated because is part of the
persistent files, so the old /etc/group or /etc/passwd file would remain.
Tested: 1) System which doesn't have avahi group,With this fix creates the
group and start the avahi daemon.
2) Verified on the system where there is a zone
.local is being used by the DNS server,avahi-daemon was not started.
Resolves openbmc/openbmc#2788
Change-Id: I23b7a6cdd21bcefbea3d854fec8faa21c70378e9
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'meta-phosphor')
5 files changed, 61 insertions, 0 deletions
diff --git a/meta-phosphor/common/recipes-connectivity/avahi/avahi/avahi.conf b/meta-phosphor/common/recipes-connectivity/avahi/avahi/avahi.conf new file mode 100644 index 000000000..946e267d4 --- /dev/null +++ b/meta-phosphor/common/recipes-connectivity/avahi/avahi/avahi.conf @@ -0,0 +1,2 @@ +[Unit] +ConditionPathExists=/tmp/avahi diff --git a/meta-phosphor/common/recipes-connectivity/avahi/avahi/check-avahi-pre-cond.service b/meta-phosphor/common/recipes-connectivity/avahi/avahi/check-avahi-pre-cond.service new file mode 100644 index 000000000..f4548a75b --- /dev/null +++ b/meta-phosphor/common/recipes-connectivity/avahi/avahi/check-avahi-pre-cond.service @@ -0,0 +1,13 @@ +[Unit] +Description=Check the precondition before starting avahi +Before=avahi-daemon.service + +[Service] +RemainAfterExit=no +Type=oneshot +ExecStart=/usr/sbin/check-local-domain +ExecStart=/usr/sbin/create-user +ExecStart=/bin/touch /tmp/avahi + +[Install] +WantedBy=obmc-standby.target diff --git a/meta-phosphor/common/recipes-connectivity/avahi/avahi/check-local-domain b/meta-phosphor/common/recipes-connectivity/avahi/avahi/check-local-domain new file mode 100644 index 000000000..978b8b6dc --- /dev/null +++ b/meta-phosphor/common/recipes-connectivity/avahi/avahi/check-local-domain @@ -0,0 +1,9 @@ +#!/bin/sh + +if !(host -t SOA local. > /dev/null 2> /dev/null); then + # Return 1 to tell that local domain is present + exit 1 +else + # Return 0 to tell local domain is not being used + exit 0 +fi diff --git a/meta-phosphor/common/recipes-connectivity/avahi/avahi/create-user b/meta-phosphor/common/recipes-connectivity/avahi/avahi/create-user new file mode 100644 index 000000000..322f1cdf3 --- /dev/null +++ b/meta-phosphor/common/recipes-connectivity/avahi/avahi/create-user @@ -0,0 +1,6 @@ +#!/bin/sh + +# Create avahi group and user +deluser avahi ; addgroup --system avahi ; adduser --system --no-create-home --ingroup avahi avahi + +exit $? diff --git a/meta-phosphor/common/recipes-connectivity/avahi/avahi_%.bbappend b/meta-phosphor/common/recipes-connectivity/avahi/avahi_%.bbappend new file mode 100644 index 000000000..0458b8245 --- /dev/null +++ b/meta-phosphor/common/recipes-connectivity/avahi/avahi_%.bbappend @@ -0,0 +1,31 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +SRC_URI += "file://avahi.conf" +SRC_URI += "file://check-avahi-pre-cond.service" +SRC_URI += "file://create-user" +SRC_URI += "file://check-local-domain" + +RRECOMMENDS_${PN}-daemon += "bind-utils" + +AVAHI_SVC = "avahi-daemon.service" + +AVAHI_DROPIN_DIR = "${AVAHI_SVC}.d" + +FILES_${PN}-daemon_append += "${systemd_system_unitdir}/${AVAHI_DROPIN_DIR}/avahi.conf" + +PACKAGE_BEFORE_PN += "${PN}-daemon-preconditions" + +FILES_${PN}-daemon-preconditions += "${systemd_system_unitdir}/check-avahi-pre-cond.service" +FILES_${PN}-daemon-preconditions += "${sbindir}/create-user" +FILES_${PN}-daemon-preconditions += "${sbindir}/check-local-domain" + +RRECOMMENDS_${PN}-daemon += "${PN}-daemon-preconditions" + +do_install_append() { + + mkdir -p ${D}/${systemd_system_unitdir}/${AVAHI_DROPIN_DIR} + install -m 0755 ${WORKDIR}/avahi.conf ${D}/${systemd_system_unitdir}/${AVAHI_DROPIN_DIR}/avahi.conf + install -m 0755 ${WORKDIR}/check-avahi-pre-cond.service ${D}/${systemd_system_unitdir}/check-avahi-pre-cond.service + install -m 0755 ${WORKDIR}/check-local-domain ${D}/${sbindir}/check-local-domain + install -m 0755 ${WORKDIR}/create-user ${D}/${sbindir}/create-user +} |