[yast-commit] r59592 - /branches/SuSE-Code-11-SP1-Branch/network/src/modules/DNS.ycp
Author: kmachalkova Date: Wed Nov 18 17:01:39 2009 New Revision: 59592 URL: http://svn.opensuse.org/viewcvs/yast?rev=59592&view=rev Log: Library funcs 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=59592&r1=59591&r2=59592&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 Wed Nov 18 17:01:39 2009 @@ -20,6 +20,7 @@ import "Hostname"; import "IP"; import "NetworkInterfaces"; +import "ProductFeatures"; import "Progress"; import "Service"; import "String"; @@ -52,6 +53,8 @@ // fully qualified string oldhostname = ""; +/* install.inf from linuxrc */ +map install_inf = $[]; /** * Data was modified? */ @@ -107,6 +110,55 @@ return ret; } +global boolean DefaultWriteHostname() { + boolean whth = ProductFeatures::GetBooleanFeature ("globals", "write_hostname_to_hosts"); + y2milestone("write_hostname_to_hosts default value: %1", whth); + return whth; +} + +global void ReadHostname() { + + // 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 = ""; + } + + // /etc/HOSTNAME + // the usual location + if (fqhostname == "") + { + if (SCR::Read (.target.size, "/etc/HOSTNAME") > 0) + { + fqhostname = (string) SCR::Read (.target.string, "/etc/HOSTNAME"); + //avoid passing nil argument when we get non-\n-terminated string (#445531) + fqhostname = String::FirstChunk( fqhostname, "\n" ); + } + } + + list<string> split = Hostname::SplitFQ (fqhostname); + hostname = split[0]:""; + domain = split[1]:""; + + // last resort + if (hostname == "") + { + hostname = "linux"; + domain = "site"; + } +} + +global void ProposeHostname() { + if (hostname == "linux") + { + srandom (); + hostname = "linux-" + String::Random (4); // #157107 + } +} + /** * resolver config file location */ @@ -131,8 +183,6 @@ string tmp2 = (string) SCR::Read(.sysconfig.network.dhcp.WRITE_HOSTNAME_TO_HOSTS); write_hostname = ( tmp2 == "yes"); - /* install.inf from linuxrc */ - map install_inf = $[]; if(SCR::Read(.target.size, "/etc/install.inf") > 0) install_inf = (map) SCR::Read(.etc.install_inf); // bogus?! @@ -149,44 +199,7 @@ searchlist = splitstring((string)SCR::Read(.sysconfig.network.config.NETCONFIG_DNS_STATIC_SEARCHLIST), " "); /* hostname and domain */ - // all this is much too intelligent and belongs rather to the proposal - - // 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 = ""; - } - - // /etc/HOSTNAME - // the usual location - if (fqhostname == "") - { - if (SCR::Read (.target.size, "/etc/HOSTNAME") > 0) - { - fqhostname = (string) SCR::Read (.target.string, "/etc/HOSTNAME"); - //avoid passing nil argument when we get non-\n-terminated string (#445531) - fqhostname = String::FirstChunk( fqhostname, "\n" ); - } - } - list<string> split = Hostname::SplitFQ (fqhostname); - hostname = split[0]:""; - domain = split[1]:""; - - // detection - if (hostname == "") - { - hostname = NetHwDetection::result["HOSTNAME"]:""; - domain = NetHwDetection::result["DOMAIN"]:""; - } - // last resort - if (hostname == "") - { - hostname = "linux"; - domain = "site"; - } + ReadHostname(); oldhostname = Hostname::MergeFQ (hostname, domain); y2milestone("nameservers=%1", nameservers); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
kmachalkova@svn.opensuse.org