[syslinux:lwip] pxe, dns: add the local domain to unqualified hostnames

syslinux-bot for H. Peter Anvin hpa at zytor.com
Sun May 8 15:39:19 PDT 2011


Commit-ID:  50629fda7e1ff723c8e72d0b726693be9f0e9970
Gitweb:     http://syslinux.zytor.com/commit/50629fda7e1ff723c8e72d0b726693be9f0e9970
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sat, 7 May 2011 08:15:54 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Sat, 7 May 2011 08:17:40 -0700

pxe, dns: add the local domain to unqualified hostnames

For unqualified hostnames (lacking dot), add the local hostname.  This
matches previous PXELINUX behavior.  Arguably we should really
implement the whole domain search stuff.

Reported-by: Gene Cumm <gene.cumm at gmail.com>
Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 core/fs/pxe/dnsresolv.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/core/fs/pxe/dnsresolv.c b/core/fs/pxe/dnsresolv.c
index 350dfe3..8dc1793 100644
--- a/core/fs/pxe/dnsresolv.c
+++ b/core/fs/pxe/dnsresolv.c
@@ -82,15 +82,17 @@ static bool parse_dotquad(const char *ip_str, uint32_t *res)
 }
 
 /*
- * Actual resolver function
- * Points to a null-terminated or :-terminated string in _name_
- * and returns the ip addr in _ip_ if it exists and can be found.
- * If _ip_ = 0 on exit, the lookup failed. _name_ will be updated
+ * Actual resolver function.
+ *
+ * Points to a null-terminated in _name_ and returns the ip addr in
+ * _ip_ if it exists and can be found.  If _ip_ = 0 on exit, the
+ * lookup failed. _name_ will be updated
  */
 uint32_t dns_resolv(const char *name)
 {
     err_t err;
     struct ip_addr ip;
+    char fullname[512];
 
     /*
      * Return failure on an empty input... this can happen during
@@ -108,6 +110,12 @@ uint32_t dns_resolv(const char *name)
     if (!dns_getserver(0).addr)
 	return 0;
 
+    /* Is it a local (unqualified) domain name? */
+    if (!strchr(name, '.') && LocalDomain[0]) {
+	snprintf(fullname, sizeof fullname, "%s.%s", name, LocalDomain);
+	name = fullname;
+    }
+
     err = netconn_gethostbyname(name, &ip);
     if (err)
 	return 0;



More information about the Syslinux-commits mailing list