Author: jsuchome Date: Mon Oct 10 12:54:07 2011 New Revision: 66356 URL: http://svn.opensuse.org/viewcvs/yast?rev=66356&view=rev Log: - agent: pass map refereces as arguments - quote strings passed to bash commands - fixed testsuite - 2.21.13 Modified: trunk/snapper/VERSION trunk/snapper/agent-snapper/src/SnapperAgent.cc trunk/snapper/agent-snapper/src/SnapperAgent.h trunk/snapper/package/yast2-snapper.changes trunk/snapper/src/Snapper.ycp trunk/snapper/src/dialogs.ycp trunk/snapper/testsuite/tests/GetFileMode.out trunk/snapper/testsuite/tests/GetFileModification.out Modified: trunk/snapper/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/VERSION?rev=66356&r1=66355&r2=66356&view=diff ============================================================================== --- trunk/snapper/VERSION (original) +++ trunk/snapper/VERSION Mon Oct 10 12:54:07 2011 @@ -1 +1 @@ -2.21.12 +2.21.13 Modified: trunk/snapper/agent-snapper/src/SnapperAgent.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/src/SnapperAgent.cc?rev=66356&r1=66355&r2=66356&view=diff ============================================================================== --- trunk/snapper/agent-snapper/src/SnapperAgent.cc (original) +++ trunk/snapper/agent-snapper/src/SnapperAgent.cc Mon Oct 10 12:54:07 2011 @@ -18,7 +18,7 @@ /* * search the map for value of given key; both key and value have to be strings */ -string SnapperAgent::getValue (const YCPMap map, const string key, string deflt) +string SnapperAgent::getValue (const YCPMap &map, const string key, const string deflt) { if (!map->value(YCPString(key)).isNull() && map->value(YCPString(key))->isString()) @@ -33,7 +33,7 @@ * @param key key we are looking for * @param deflt the default value to be returned if key is not found */ -int SnapperAgent::getIntValue (const YCPMap map, const string key, int deflt) +int SnapperAgent::getIntValue (const YCPMap &map, const string key, const int deflt) { if (!map->value(YCPString(key)).isNull() && map->value(YCPString(key))->isInteger()) { return map->value(YCPString(key))->asInteger()->value(); @@ -50,7 +50,7 @@ * Search the map for value of given key; * key is string and value is YCPList */ -YCPList SnapperAgent::getListValue (const YCPMap map, const string key) +YCPList SnapperAgent::getListValue (const YCPMap &map, const string key) { if (!map->value(YCPString(key)).isNull() && map->value(YCPString(key))->isList()) return map->value(YCPString(key))->asList(); Modified: trunk/snapper/agent-snapper/src/SnapperAgent.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/src/SnapperAgent.h?rev=66356&r1=66355&r2=66356&view=diff ============================================================================== --- trunk/snapper/agent-snapper/src/SnapperAgent.h (original) +++ trunk/snapper/agent-snapper/src/SnapperAgent.h Mon Oct 10 12:54:07 2011 @@ -37,7 +37,7 @@ * search the map for value of given key; both key and value have to be strings * when key is not present, default value is returned */ - string getValue (const YCPMap map, const string key, string deflt); + string getValue (const YCPMap &map, const string key, const string deflt); /** * Search the map for value of given key @@ -45,13 +45,13 @@ * @param key key we are looking for * @param deflt the default value to be returned if key is not found */ - int getIntValue ( const YCPMap map, const string key, int deflt); + int getIntValue ( const YCPMap &map, const string key, const int deflt); /** * Search the map for value of given key; * key is string and value is YCPList */ - YCPList getListValue (const YCPMap map, const string key); + YCPList getListValue (const YCPMap &map, const string key); public: /** Modified: trunk/snapper/package/yast2-snapper.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/package/yast2-snapper.changes?rev=66356&r1=66355&r2=66356&view=diff ============================================================================== --- trunk/snapper/package/yast2-snapper.changes (original) +++ trunk/snapper/package/yast2-snapper.changes Mon Oct 10 12:54:07 2011 @@ -1,4 +1,12 @@ ------------------------------------------------------------------- +Mon Oct 10 12:44:44 CEST 2011 - jsuchome@suse.cz + +- agent: pass map refereces as arguments +- quote strings passed to bash commands +- fixed testsuite +- 2.21.13 + +------------------------------------------------------------------- Fri Oct 7 14:36:51 CEST 2011 - jsuchome@suse.cz - removed conflicting statusToString Modified: trunk/snapper/src/Snapper.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/Snapper.ycp?rev=66356&r1=66355&r2=66356&view=diff ============================================================================== --- trunk/snapper/src/Snapper.ycp (original) +++ trunk/snapper/src/Snapper.ycp Mon Oct 10 12:54:07 2011 @@ -38,7 +38,7 @@ import "Label"; import "Progress"; import "Report"; - +import "String"; // global list of all snapshot global list<map> snapshots = []; @@ -116,7 +116,7 @@ { list<string> status = [ "no_change" ]; map out = (map) SCR::Execute (.target.bash_output, - sformat ("/usr/bin/diff -u %1 %2", file1, file2)); + sformat ("/usr/bin/diff -u '%1' '%2'", String::Quote (file1), String::Quote (file2))); if (out["stderr"]:"" != "") { y2warning ("out: %1", out); @@ -131,7 +131,8 @@ // check mode and ownerships out = (map) SCR::Execute (.target.bash_output, - sformat ("ls -ld %1 %2 | cut -f 1,3,4 -d ' '", file1, file2)); + sformat ("ls -ld -- '%1' '%2' | cut -f 1,3,4 -d ' '", + String::Quote (file1), String::Quote (file2))); list<string> parts = splitstring (out["stdout"]:""," \n"); if (parts[0]:"" != parts[3]:"") @@ -284,8 +285,12 @@ */ integer GetFileMode (string file) { - map out = (map) SCR::Execute (.target.bash_output, "/bin/stat --printf=%a " + file); - return tointeger (out["stdout"]:"755"); + map out = (map) SCR::Execute (.target.bash_output, + sformat ("/bin/stat --printf=%%a '%1'", String::Quote (file))); + string mode = out["stdout"]:""; + if (mode == nil || mode == "") + return 644; + return tointeger (mode); } /** @@ -332,12 +337,15 @@ { SCR::Execute (.target.mkdir, full_path); } - SCR::Execute (.target.bash, sformat ("/bin/chown %1:%2 '%3'", stat["uid"]:0, stat["gid"]:0, full_path)); - SCR::Execute (.target.bash, sformat ("/bin/chmod %1 '%2'", GetFileMode (orig), full_path)); + SCR::Execute (.target.bash, sformat ("/bin/chown -- %1:%2 '%3'", + stat["uid"]:0, stat["gid"]:0, String::Quote (full_path))); + SCR::Execute (.target.bash, sformat ("/bin/chmod -- %1 '%2'", + GetFileMode (orig), String::Quote (full_path))); } else { - SCR::Execute (.target.bash, sformat ("/bin/cp -a '%1' '%2'", orig, full_path)); + SCR::Execute (.target.bash, sformat ("/bin/cp -a -- '%1' '%2'", + String::Quote (orig), String::Quote (full_path))); } UI::ChangeWidget (`id (`log), `LastLine, full_path + "\n"); } Modified: trunk/snapper/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/dialogs.ycp?rev=66356&r1=66355&r2=66356&view=diff ============================================================================== --- trunk/snapper/src/dialogs.ycp (original) +++ trunk/snapper/src/dialogs.ycp Mon Oct 10 12:54:07 2011 @@ -37,6 +37,7 @@ import "Popup"; import "Wizard"; import "Snapper"; +import "String"; include "snapper/helps.ycp"; @@ -636,7 +637,7 @@ files = filter (string file, files, { if (haskey (files_index, file)) { - to_restore = add (to_restore, Snapper::GetFileFullPath (file)); + to_restore = add (to_restore, String::Quote (Snapper::GetFileFullPath (file))); return true; } else Modified: trunk/snapper/testsuite/tests/GetFileMode.out URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/testsuite/tests/GetFileMode.out?rev=66356&r1=66355&r2=66356&view=diff ============================================================================== --- trunk/snapper/testsuite/tests/GetFileMode.out (original) +++ trunk/snapper/testsuite/tests/GetFileMode.out Mon Oct 10 12:54:07 2011 @@ -1,4 +1,4 @@ -Execute .target.bash_output "/bin/stat --printf=%a /tmp/1" $["stdout":"755"] +Execute .target.bash_output "/bin/stat --printf=%a '/tmp/1'" $["stdout":"755"] Return 755 -Execute .target.bash_output "/bin/stat --printf=%a /tmp/2" $["stderr":"/bin/stat: cannot stat `/tmp/2': No such file or directory\n", "stdout":""] +Execute .target.bash_output "/bin/stat --printf=%a '/tmp/2'" $["stderr":"/bin/stat: cannot stat `/tmp/2': No such file or directory\n", "stdout":""] Return 644 Modified: trunk/snapper/testsuite/tests/GetFileModification.out URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/testsuite/tests/GetFileModification.out?rev=66356&r1=66355&r2=66356&view=diff ============================================================================== --- trunk/snapper/testsuite/tests/GetFileModification.out (original) +++ trunk/snapper/testsuite/tests/GetFileModification.out Mon Oct 10 12:54:07 2011 @@ -1,12 +1,13 @@ Read .snapper.path $["num":1] "/snapshots/1/snapshot" -Execute .target.bash_output "/usr/bin/diff -u /snapshots/1/snapshot/etc/passwd /etc/passwd" $["stderr":"error while diffing"] +Read .snapper.path $["num":0] "/snapshots/1/snapshot" +Execute .target.bash_output "/usr/bin/diff -u '/snapshots/1/snapshot/etc/passwd' '/etc/passwd'" $["stderr":"error while diffing"] Log out: $["stderr":"error while diffing"] -Execute .target.bash_output "ls -ld /snapshots/1/snapshot/etc/passwd /etc/passwd | cut -f 1,3,4 -d ' '" $["stderr":"error while diffing"] +Execute .target.bash_output "ls -ld -- '/snapshots/1/snapshot/etc/passwd' '/etc/passwd' | cut -f 1,3,4 -d ' '" $["stderr":"error while diffing"] Return $["diff":"error while diffing", "status":["no_change"]] Read .snapper.path $["num":1] "/snapshots/1/snapshot" Read .snapper.path $["num":2] "/snapshots/1/snapshot" -Execute .target.bash_output "/usr/bin/diff -u /snapshots/1/snapshot/etc/passwd /snapshots/1/snapshot/etc/passwd" $["stdout":"+new user line"] -Execute .target.bash_output "ls -ld /snapshots/1/snapshot/etc/passwd /snapshots/1/snapshot/etc/passwd | cut -f 1,3,4 -d ' '" $["stdout":"+new user line"] +Execute .target.bash_output "/usr/bin/diff -u '/snapshots/1/snapshot/etc/passwd' '/snapshots/1/snapshot/etc/passwd'" $["stdout":"+new user line"] +Execute .target.bash_output "ls -ld -- '/snapshots/1/snapshot/etc/passwd' '/snapshots/1/snapshot/etc/passwd' | cut -f 1,3,4 -d ' '" $["stdout":"+new user line"] Return $["diff":"+new user line", "group1":"line", "group2":"", "mode1":"+new", "mode2":"", "status":["diff", "mode", "user", "group"], "user1":"user", "user2":""] Read .snapper.path $["num":1] "/snapshots/1/snapshot" Read .snapper.path $["num":2] "/snapshots/1/snapshot" -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org