[yast-commit] r42597 - in /trunk/autoinstallation: package/autoyast2.changes src/include/conftree.ycp src/modules/AutoinstConfig.ycp src/modules/Profile.ycp src/modules/ProfileLocation.ycp
Author: ug Date: Mon Dec 3 14:26:11 2007 New Revision: 42597 URL: http://svn.opensuse.org/viewcvs/yast?rev=42597&view=rev Log: profiles can be stored encrypted Modified: trunk/autoinstallation/package/autoyast2.changes trunk/autoinstallation/src/include/conftree.ycp trunk/autoinstallation/src/modules/AutoinstConfig.ycp trunk/autoinstallation/src/modules/Profile.ycp trunk/autoinstallation/src/modules/ProfileLocation.ycp Modified: trunk/autoinstallation/package/autoyast2.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/autoinstallation/package/autoyast2.changes?rev=42597&r1=42596&r2=42597&view=diff ============================================================================== --- trunk/autoinstallation/package/autoyast2.changes (original) +++ trunk/autoinstallation/package/autoyast2.changes Mon Dec 3 14:26:11 2007 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Mon Dec 3 14:24:55 CET 2007 - ug@suse.de + +- profiles can be stored encrypted + +------------------------------------------------------------------- Tue Nov 27 11:57:17 CET 2007 - ug@suse.de - documentation and UI enhancement for feature #301256 added Modified: trunk/autoinstallation/src/include/conftree.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/autoinstallation/src/include/conftree.ycp?rev=42597&r1=42596&r2=42597&view=diff ============================================================================== --- trunk/autoinstallation/src/include/conftree.ycp (original) +++ trunk/autoinstallation/src/include/conftree.ycp Mon Dec 3 14:26:11 2007 @@ -29,7 +29,7 @@ if ( Profile::Save( AutoinstConfig::currentFile )) { Popup::Message(sformat(_("File %1 was saved successfully."), AutoinstConfig::currentFile)); - Profile::checkProfile(); +// Profile::checkProfile(); Profile::changed=false; list pathComponents = splitstring( (string)filename, "/"); integer s = size(pathComponents) - 1; @@ -232,6 +232,8 @@ "menu_kickstart" ); Menu = Wizard::AddMenuEntry ( Menu , "file-menu" , _("Settin&gs"), "menu_settings" ); + Menu = Wizard::AddMenuEntry ( Menu , "file-menu" , AutoinstConfig::ProfileEncrypted ? _("change to decrypted"):_("change to encrypted"), + "change_encryption" ); Menu = Wizard::AddMenuEntry ( Menu , "file-menu", _("E&xit"), "menu_exit" ); Menu = Wizard::AddMenuEntry ( Menu , "view-menu", _("Configu&ration Tree"), @@ -562,6 +564,11 @@ module_contents(modulename); ret = `menu_new; } + else if (ret == "change_encryption" ) { + AutoinstConfig::ProfileEncrypted = !AutoinstConfig::ProfileEncrypted; + Wizard::DeleteMenus(); // FIXME: sucks sucks sucks sucks sucks + menus(); + } else if (ret == "menu_exit") // EXIT { ret = `menu_exit; Modified: trunk/autoinstallation/src/modules/AutoinstConfig.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/autoinstallation/src/modules/AutoinstConfig.ycp?rev=42597&r1=42596&r2=42597&view=diff ============================================================================== --- trunk/autoinstallation/src/modules/AutoinstConfig.ycp (original) +++ trunk/autoinstallation/src/modules/AutoinstConfig.ycp Mon Dec 3 14:26:11 2007 @@ -24,6 +24,8 @@ // Profile Repository global string Repository = ""; + global boolean ProfileEncrypted = false; + // Package Repository global string PackageRepository = ""; Modified: trunk/autoinstallation/src/modules/Profile.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/autoinstallation/src/modules/Profile.ycp?rev=42597&r1=42596&r2=42597&view=diff ============================================================================== --- trunk/autoinstallation/src/modules/Profile.ycp (original) +++ trunk/autoinstallation/src/modules/Profile.ycp Mon Dec 3 14:26:11 2007 @@ -318,8 +318,44 @@ global define boolean Save (string file) { Prepare(); + boolean ret = false; y2debug("Saving data (%1) to XML file %2", current, file); - return (XML::YCPToXMLFile(`profile, current, file)); + if( true || AutoinstConfig::ProfileEncrypted ) { + string xml = XML::YCPToXMLString(`profile, current); + if( size(xml) > 0 ) { + string p = ""; + string q = ""; + do { + UI::OpenDialog( + `VBox( + `Label("Encrypted AutoYaST profile. Please enter the password twice"), + `Password(`id(`password), ""), + `Password(`id(`password2), ""), + `PushButton(`id(`ok), "&OK") + ) + ); + any button = nil; + repeat { + button = UI::UserInput(); + p = (string) UI::QueryWidget(`id(`password), `Value); + q = (string) UI::QueryWidget(`id(`password2), `Value); + } until ( button == `ok ); + UI::CloseDialog(); + } while( p != q ); + string dir = (string)SCR::Read(.target.tmpdir); + string command = sformat("gpg2 -c --armor --batch --passphrase \"%1\" --output %2/encrypted_autoyast.xml",p,dir); + y2milestone("UWE %1", command); + SCR::Execute(.target.bash_input, command, xml); + if( SCR::Read(.target.size, dir+"/encrypted_autoyast.xml") > 0 ) { + command = sformat( "mv %1/encrypted_autoyast.xml %2", dir, file ); + SCR::Execute(.target.bash, command, $[]); + ret = true; + } + } + } else { + ret = XML::YCPToXMLFile(`profile, current, file); + } + return ret; } @@ -581,8 +617,34 @@ * @return boolean */ global define boolean ReadXML (string file) { - y2debug("Reading %1", file); - current = XML::XMLToYCPFile(file); + string tmp = (string)SCR::Read (.target.string, file); + list<string> l = splitstring (tmp, "\n"); + if( tmp != nil && l[0]:"" == "-----BEGIN PGP MESSAGE-----" ) { + map<string,any> out = $[]; + while( out["stdout"]:"" == "" ) { + UI::OpenDialog( + `VBox( + `Label("Encrypted AutoYaST profile. Please enter the correct password."), + `Password(`id(`password), ""), + `PushButton(`id(`ok), "&OK") + ) + ); + string p = ""; + any button = nil; + repeat { + button = UI::UserInput(); + p = (string) UI::QueryWidget(`id(`password), `Value); + } until ( button == `ok ); + UI::CloseDialog(); + string command = sformat("gpg2 -d --batch --passphrase \"%1\" %2",p, file); + out = (map<string,any>)SCR::Execute(.target.bash_output, command, $[]); + } + current = XML::XMLToYCPString( out["stdout"]:"" ); + AutoinstConfig::ProfileEncrypted = true; + } else { + y2debug("Reading %1", file); + current = XML::XMLToYCPFile(file); + } if ( current != $[] && size(current) == 0 ) { @@ -612,7 +674,6 @@ if( is( tmp[0]:nil, string ) ) { m[i] = setMValue( tmp, v, m[i]:$[] ); } else { - y2milestone("I'm in else"); m[i] = setLValue( tmp, v, m[i]:[] ); } } else { Modified: trunk/autoinstallation/src/modules/ProfileLocation.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/autoinstallation/src/modules/ProfileLocation.ycp?rev=42597&r1=42596&r2=42597&view=diff ============================================================================== --- trunk/autoinstallation/src/modules/ProfileLocation.ycp (original) +++ trunk/autoinstallation/src/modules/ProfileLocation.ycp Mon Dec 3 14:26:11 2007 @@ -93,6 +93,32 @@ Popup::Error( error + GET_error ); return false; } + string tmp = (string)SCR::Read (.target.string, localfile); + list<string> l = splitstring (tmp, "\n"); + while ( tmp != nil && l[0]:"" == "-----BEGIN PGP MESSAGE-----" ) { + y2milestone("encrypted profile found"); + UI::OpenDialog( + `VBox( + `Label("Encrypted AutoYaST profile. Please enter the correct password."), + `Password(`id(`password), ""), + `PushButton(`id(`ok), "&OK") + ) + ); + string p = ""; + any button = nil; + repeat { + button = UI::UserInput(); + p = (string) UI::QueryWidget(`id(`password), `Value); + } until ( button == `ok ); + UI::CloseDialog(); + SCR::Execute( .target.bash, sformat("gpg2 --batch --output \"/tmp/decrypt.xml\" --passphrase \"%1\" %2",p, localfile) ); + if( SCR::Read (.target.size, "/tmp/decrypt.xml") > 0 ) { + SCR::Execute( .target.bash, sformat("mv /tmp/decrypt.xml %1",localfile) ); + y2milestone("decrypted. Moving now /tmp/decrypt.xml to %1",localfile); + tmp = (string)SCR::Read (.target.string, localfile); + l = splitstring (tmp, "\n"); + } + } } else { @@ -149,7 +175,8 @@ } else { - try_default_rules = true; +// try_default_rules = true; + try_default_rules = is_directory; } // Hex IP, MAC Address. -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
ug@svn.opensuse.org