From 60ca7600c77a13d6a1eb33b0a21a4e8abf9014c5 Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau@redhat.com>
Date: Thu, 28 Aug 2014 15:18:24 +0200
Subject: [PATCH 3/3] Fix hostname lookup if multiple domains are listed in
resolv.conf
---
lbdb_lib.sh.in | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/lbdb_lib.sh.in b/lbdb_lib.sh.in
index 4c4827f..e860951 100644
--- a/lbdb_lib.sh.in
+++ b/lbdb_lib.sh.in
@@ -55,21 +55,18 @@ lbdb_hostname()
if test "x$MAIL_DOMAIN_NAME" != "x" ; then
hn=$MAIL_DOMAIN_NAME
elif test -f /etc/mailname; then
- hn=`cat /etc/mailname`
+ read hn < /etc/mailname
else
hn=""
if test -r /etc/resolv.conf ; then
- hn="`sed -n -e 's/^[ ]*domain[ ]\{1,\}\([^ ]*\)/\1/p' /etc/resolv.conf`"
- if test "x$hn" = "x" ; then
- hn="`sed -n -e 's/^[ ]*search[ ]\{1,\}\([^ ]*\)/\1/p' /etc/resolv.conf`"
- fi
+ hn=`awk '/^#/{next}($1 == "search" || $1 == "domain" ) && $2 != "" {print $2;exit}' < /etc/resolv.conf`
fi
if test "x$hn" = "x" ; then
hn=`lbdb_hn_sendmail`
if test "x$hn" = "xNONE" ; then
for i in /etc/HOSTNAME /etc/hostname ; do
if test -f $i ; then
- hn="`cat $i`"
+ read hn < $i
break;
fi
done
--
1.9.3