Author: lslezak
Date: Tue Jul 7 15:34:15 2009
New Revision: 57908
URL: http://svn.opensuse.org/viewcvs/yast?rev=57908&view=rev
Log:
- write correct IP address to SLP config file when there is no eth0
device (bnc#475676)
- fixed SLP config - escape special characters and use [] brackets
instead of (), they have special meaning (bnc#492367)
- 2.13.18
Modified:
branches/SuSE-SLE-10-SP2-Branch/instserver/VERSION
branches/SuSE-SLE-10-SP2-Branch/instserver/package/yast2-instserver.changes
branches/SuSE-SLE-10-SP2-Branch/instserver/src/Instserver.ycp
branches/SuSE-SLE-10-SP2-Branch/instserver/testsuite/tests/Instserver.out
branches/SuSE-SLE-10-SP2-Branch/instserver/testsuite/tests/Instserver.ycp
Modified: branches/SuSE-SLE-10-SP2-Branch/instserver/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP2-Branch/instserver/VERSION?rev=57908&r1=57907&r2=57908&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/instserver/VERSION (original)
+++ branches/SuSE-SLE-10-SP2-Branch/instserver/VERSION Tue Jul 7 15:34:15 2009
@@ -1 +1 @@
-2.13.17
+2.13.18
Modified: branches/SuSE-SLE-10-SP2-Branch/instserver/package/yast2-instserver.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP2-Branch/instserver/package/yast2-instserver.changes?rev=57908&r1=57907&r2=57908&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/instserver/package/yast2-instserver.changes (original)
+++ branches/SuSE-SLE-10-SP2-Branch/instserver/package/yast2-instserver.changes Tue Jul 7 15:34:15 2009
@@ -1,4 +1,13 @@
-------------------------------------------------------------------
+Wed Apr 8 15:18:39 CEST 2009 - lslezak@suse.cz
+
+- write correct IP address to SLP config file when there is no eth0
+ device (bnc#475676)
+- fixed SLP config - escape special characters and use [] brackets
+ instead of (), they have special meaning (bnc#492367)
+- 2.13.18
+
+-------------------------------------------------------------------
Thu Mar 13 07:20:45 CET 2008 - lslezak@suse.cz
- added missing translation mark (bnc#366082)
Modified: branches/SuSE-SLE-10-SP2-Branch/instserver/src/Instserver.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP2-Branch/instserver/src/Instserver.ycp?rev=57908&r1=57907&r2=57908&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/instserver/src/Instserver.ycp (original)
+++ branches/SuSE-SLE-10-SP2-Branch/instserver/src/Instserver.ycp Tue Jul 7 15:34:15 2009
@@ -27,6 +27,7 @@
import "IP";
import "Message";
import "SuSEFirewall";
+import "String";
include "instserver/routines.ycp";
@@ -489,6 +490,39 @@
return true;
}
+// some values are not allowed in SLP attributes
+// and must be escaped ('\' followed by two hex numbers)
+// see RFC2614 (http://www.openslp.org/doc/rfc/rfc2614.txt)
+map EscapeSLPData(map a)
+{
+ map ret = $[];
+
+ foreach(string key, string value, a,
+ {
+ // String::Replace() enters endless loop in '\' -> '\5c' conversion
+ // use splitstring() and mergestring() builtins instead
+ string new_key = mergestring(splitstring(key, "\\"), "\\5c");
+ new_key = String::Replace(new_key, ".", "\\2e");
+ new_key = String::Replace(new_key, "=", "\\3d");
+ new_key = String::Replace(new_key, "#", "\\23");
+ new_key = String::Replace(new_key, ";", "\\3b");
+
+ string new_value = mergestring(splitstring(value, "\\"), "\\5c");
+ new_value = String::Replace(new_value, "(", "\\28");
+ new_value = String::Replace(new_value, ")", "\\29");
+ new_value = String::Replace(new_value, ",", "\\2c");
+ new_value = String::Replace(new_value, "#", "\\23");
+ new_value = String::Replace(new_value, ";", "\\3b");
+
+ ret[new_key] = new_value;
+ }
+ );
+
+ y2milestone("Escaped SLP attributes: %1 -> %2", a, ret);
+
+ return ret;
+}
+
/*
* Return the IP address of the local machine
* @return string IP Address
@@ -496,8 +530,16 @@
global string GetIPAddr()
{
list<map> ifconfig =(list<map>)SCR::Read(.run.ifconfig);
- ifconfig = filter(map iface, ifconfig, ``( iface["name"]:"" == "eth0"));
- integer ip = ifconfig[0,"value", "inet", "addr"]:0;
+ list<map> ifc = filter(map iface, ifconfig, ``( iface["name"]:"" == "eth0"));
+ integer ip = ifc[0,"value", "inet", "addr"]:0;
+ if (ip == 0)
+ {
+ ifc = filter(map iface, ifconfig, ``( iface["name"]:"" != "lo" && !issubstring(iface["name"]:"", "dummy") && iface["value", "inet", "addr"]:0 != 0));
+ if (ifc != nil)
+ {
+ ip = ifc[0,"value", "inet", "addr"]:0;
+ }
+ }
return (IP::ToString(ip));
}
@@ -564,7 +606,12 @@
hostname_reg = hostname + ": ";
}
- string descr = hostname_reg + sformat("%1 (%2)", cm["LABEL"]:"" , cm["DISTPRODUCT"]:"" );
+ string descr = hostname_reg + cm["LABEL"]:"";
+ if (cm["DISTPRODUCT"]:"" != "")
+ {
+ descr = descr + sformat(" [%2]", cm["DISTPRODUCT"]:"");
+ }
+
attr["description"] = descr;
string read_file = targetfile;
@@ -628,6 +675,9 @@
*/
}
+ // escape invalid characters
+ attr = EscapeSLPData(attr);
+
y2milestone("registering SLP service: serv: %1, attr: %2, regfile: %3", serv, attr, regfile);
boolean ret = SLP::RegFile(serv, attr, regfile );
Modified: branches/SuSE-SLE-10-SP2-Branch/instserver/testsuite/tests/Instserver.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP2-Branch/instserver/testsuite/tests/Instserver.out?rev=57908&r1=57907&r2=57908&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/instserver/testsuite/tests/Instserver.out (original)
+++ branches/SuSE-SLE-10-SP2-Branch/instserver/testsuite/tests/Instserver.out Tue Jul 7 15:34:15 2009
@@ -1,2 +1,6 @@
Dump Instserver::Modified
Return false
+Dump Instserver::EscapeSLPData()
+Return $["description":"No need to escpace anything."]
+Return $["description":"Rounded brackets \\28\\29\\2c \\5c backslash and comma \\2c must be escpaced."]
+Return $["escaped\\2e\\3dname":"value\\5c\\5c\\5c."]
Modified: branches/SuSE-SLE-10-SP2-Branch/instserver/testsuite/tests/Instserver.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP2-Branch/instserver/testsuite/tests/Instserver.ycp?rev=57908&r1=57907&r2=57908&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/instserver/testsuite/tests/Instserver.ycp (original)
+++ branches/SuSE-SLE-10-SP2-Branch/instserver/testsuite/tests/Instserver.ycp Tue Jul 7 15:34:15 2009
@@ -10,4 +10,8 @@
DUMP("Instserver::Modified");
TEST(``(Instserver::Modified()), [], nil);
+DUMP("Instserver::EscapeSLPData()");
+TEST(``(Instserver::EscapeSLPData($["description" : "No need to escpace anything."])), [], nil);
+TEST(``(Instserver::EscapeSLPData($["description" : "Rounded brackets (), \\ backslash and comma , must be escpaced."])), [], nil);
+TEST(``(Instserver::EscapeSLPData($["escaped.=name" : "value\\\\\\."])), [], nil);
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org