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@suse.cz
+
+- IsHostLocal test extended to include also hostname and/or IP set by
+ DHCP (#163170)
+
+-------------------------------------------------------------------
Mon May 14 10:52:43 CEST 2007 - kmachalkova@suse.cz
- 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 GetDHCPHostnameIP () {
+ map 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 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@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org