Mailinglist Archive: yast-commit (190 mails)

< Previous Next >
[yast-commit] r38063 - in /trunk/network: package/yast2-network.changes src/modules/DNS.ycp
  • From: kmachalkova@xxxxxxxxxxxxxxxx
  • Date: Mon, 21 May 2007 12:01:40 -0000
  • Message-id: <20070521120140.79B5747FC7@xxxxxxxxxxxxxxxx>
Author: kmachalkova
Date: Mon May 21 14:01:40 2007
New Revision: 38063

URL: http://svn.opensuse.org/viewcvs/yast?rev=38063&view=rev
Log:
IsHostLocal test extended to include also hostname and/or IP set by
DHCP (#163170)

Modified:
    trunk/network/package/yast2-network.changes
    trunk/network/src/modules/DNS.ycp

Modified: trunk/network/package/yast2-network.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/package/yast2-network.changes?rev=38063&r1=38062&r2=38063&view=diff
==============================================================================
--- trunk/network/package/yast2-network.changes (original)
+++ trunk/network/package/yast2-network.changes Mon May 21 14:01:40 2007
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Mon May 21 13:57:47 CEST 2007 - kmachalkova@xxxxxxx
+
+- IsHostLocal test extended to include also hostname and/or IP set by
+  DHCP (#163170)
+
+-------------------------------------------------------------------
 Mon May 14 10:52:43 CEST 2007 - kmachalkova@xxxxxxx
 
 - Correct comparison of installed and downloaded release notes 

Modified: trunk/network/src/modules/DNS.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/src/modules/DNS.ycp?rev=38063&r1=38062&r2=38063&view=diff
==============================================================================
--- trunk/network/src/modules/DNS.ycp (original)
+++ trunk/network/src/modules/DNS.ycp Mon May 21 14:01:40 2007
@@ -88,6 +88,26 @@
     return true;
 }
 
+/*
+ * Get current hostname and IP Address
+ * if these are set by DHCP
+ * @return map with ip, hostname_short and hostname_fq keys
+ */
+global define map <string, string> GetDHCPHostnameIP () {
+    map <string, string> ret = $[];
+
+    map output = (map) SCR::Execute(.target.bash_output, "hostname -i");
+    ret["ip"] = deletechars(output["stdout"]:"", " \n");
+
+    output = (map) SCR::Execute(.target.bash_output, "hostname");
+    ret["hostname_short"] = deletechars(output["stdout"]:"", " \n");
+
+    output = (map) SCR::Execute(.target.bash_output, "hostname -f");
+    ret["hostname_fq"] = deletechars(output["stdout"]:"", " \n");
+
+    return ret;
+}
+
 /**
  * resolver config file location
  */
@@ -405,10 +425,17 @@
  */
 global define boolean IsHostLocal (string check_host) {
     Read ();
+    NetworkDevices::Read ();
+    map <string, string> dhcp_data = $[];
+
+    if ( (size( NetworkDevices::Locate("BOOTPROTO", "dhcp") ) > 0) || 
+        NetworkConfig::DHCP["DHCLIENT_SET_HOSTNAME"]:false == true ) {
+       dhcp_data = GetDHCPHostnameIP();
+       y2milestone("Got DHCP-configured data: %1", dhcp_data);
+    }
     /* FIXME: May not work properly in following situations:
        - multiple addresses per interface
         - aliases in /etc/hosts
-       - hostname or IP address is set through DHCP
        - IPADDR=IP/24
     */
 
@@ -422,8 +449,9 @@
     // IPv4 address
     if (IP::Check4 (check_host))
     {
-       NetworkDevices::Read ();
-       return 0 != size (NetworkDevices::Locate ("IPADDR", check_host));
+       if ( (size (NetworkDevices::Locate ("IPADDR", check_host)) > 0)
+             || dhcp_data["ip"]:"" == check_host)
+           return true;
     }
     // IPv6 address
     else if (IP::Check6 (check_host))
@@ -433,12 +461,16 @@
     // short hostname
     else if (findfirstof (check_host, ".") == nil)
     {
-       return tolower (check_host) == tolower (hostname);
+       if ( (tolower (check_host) == tolower (hostname))
+            || dhcp_data["hostname_short"]:"" == check_host)
+           return true;
     }
     // fully qualified hostname
     else
     {
-       return tolower (check_host) == tolower (hostname + "." + domain);
+       if ( (tolower (check_host) == tolower (hostname + "." + domain))
+             || dhcp_data["hostname_fq"]:"" == check_host )
+           return true;
     }
     return false;
 }

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages