Author: kmachalkova Date: Thu Mar 11 19:16:48 2010 New Revision: 61279 URL: http://svn.opensuse.org/viewcvs/yast?rev=61279&view=rev Log: During installation (normal or AY), prefer hostname from install.inf Modified: branches/SuSE-Code-11-SP1-Branch/network/src/modules/DNS.ycp Modified: branches/SuSE-Code-11-SP1-Branch/network/src/modules/DNS.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/network/src/modules/DNS.ycp?rev=61279&r1=61278&r2=61279&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/network/src/modules/DNS.ycp (original) +++ branches/SuSE-Code-11-SP1-Branch/network/src/modules/DNS.ycp Thu Mar 11 19:16:48 2010 @@ -52,8 +52,6 @@ // fully qualified string oldhostname = ""; -/* install.inf from linuxrc */ -map install_inf = $[]; /** * Data was modified? */ @@ -109,6 +107,24 @@ return ret; } +//Copied from former Detection.ycp +/** + * Resolve IP to hostname + * @param ip given IP address + * @return resolved host + */ +string ResolveIP(string ip) { + string command = "/usr/bin/getent hosts \"%1\" | sed \"s/^[0-9.: \t]\\+//g\""; + map getent = (map) SCR::Execute(.target.bash_output, sformat(command, ip)); + string hnent = getent["stdout"]:""; + y2debug("%1", hnent); + hnent = String::FirstChunk (hnent, " \t\n"); + if(hnent == nil) hnent = ""; + y2debug("'%1'", hnent); + return String::CutBlanks(hnent); +} + + global boolean DefaultWriteHostname() { // FaTe#303875: Introduce a switch regarding 127.0.0.2 entry in /etc/hosts boolean whth = ProductFeatures::GetBooleanFeature ("globals", "write_hostname_to_hosts"); @@ -118,13 +134,20 @@ global void ReadHostname() { - // prefer /etc/install.inf + string fqhostname = ""; + // In installation (standard, or AutoYaST one), prefer /etc/install.inf // (because HOSTNAME comes with netcfg.rpm already, #144687) - string fqhostname = install_inf["Hostname"]:""; // Machinename never existed?? - // if the name is actually an IP only, we discard it too - if (IP::Check (fqhostname)) - { - fqhostname = ""; + if( (Mode::installation() || Mode::autoinst()) && + SCR::Read(.target.size, "/etc/install.inf") > 0) { + string install_inf_hostname = (string) SCR::Read(.etc.install_inf.Hostname); + + //if the name is actually IP, try to resolve it (bnc#556613, bnc#435649) + if (IP::Check (install_inf_hostname)) + { + fqhostname = ResolveIP( install_inf_hostname ); + } + else + fqhostname = install_inf_hostname; } // /etc/HOSTNAME @@ -183,15 +206,10 @@ string tmp2 = (string) SCR::Read(.sysconfig.network.dhcp.WRITE_HOSTNAME_TO_HOSTS); write_hostname = ( tmp2 == "yes"); - if(SCR::Read(.target.size, "/etc/install.inf") > 0) - install_inf = (map) SCR::Read(.etc.install_inf); - // bogus?! - y2milestone ("install.inf: %1", install_inf); - resolv_conf_policy = (string)SCR::Read(.sysconfig.network.config.NETCONFIG_DNS_POLICY); list<string> resolvlist = splitstring((string)SCR::Read(.sysconfig.network.config.NETCONFIG_DNS_STATIC_SERVERS), " "); if(resolvlist == nil) { - ReadNameserver (install_inf["Nameserver"]:""); + /* ReadNameserver (install_inf["Nameserver"]:"");*/ } else nameservers = resolvlist; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org