Author: lslezak
Date: Thu Jan 10 13:23:17 2008
New Revision: 43522
URL: http://svn.opensuse.org/viewcvs/yast?rev=43522&view=rev
Log:
- added preliminary support for GPG key management (FATE #300754)
Added:
trunk/packager/src/clients/key_manager.ycp
trunk/packager/src/include/key_manager_dialogs.ycp
Modified:
trunk/packager/package/yast2-packager.changes
trunk/packager/src/clients/repositories.ycp
trunk/packager/src/include/Makefile.am
trunk/packager/src/modules/SourceManager.ycp
Modified: trunk/packager/package/yast2-packager.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/package/yast2-packager.changes?rev=43522&r1=43521&r2=43522&view=diff
==============================================================================
--- trunk/packager/package/yast2-packager.changes (original)
+++ trunk/packager/package/yast2-packager.changes Thu Jan 10 13:23:17 2008
@@ -1,4 +1,9 @@
-------------------------------------------------------------------
+Thu Jan 10 13:20:04 CET 2008 - lslezak@suse.cz
+
+- added preliminary support for GPG key management (FATE #300754)
+
+-------------------------------------------------------------------
Fri Jan 4 10:51:33 CET 2008 - lslezak@suse.cz
- PackageCallbacks: do not remove the subprogress widget, try to
Added: trunk/packager/src/clients/key_manager.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/clients/key_manager.ycp?rev=43522&view=auto
==============================================================================
--- trunk/packager/src/clients/key_manager.ycp (added)
+++ trunk/packager/src/clients/key_manager.ycp Thu Jan 10 13:23:17 2008
@@ -0,0 +1,102 @@
+/**
+ * File: key_manager.ycp
+ *
+ * Author: Ladislav Slezak
+ *
+ * Purpose: Manages GPG keys in the package manager
+ *
+ * $Id$
+ */
+
+{
+textdomain "packager";
+
+import "PackageCallbacks";
+import "Wizard";
+import "Label";
+import "Report";
+import "CommandLine";
+import "Popup";
+import "PackageLock";
+import "KeyManager";
+import "Installation";
+import "Sequencer";
+
+include "packager/key_manager_dialogs.ycp";
+
+symbol Read()
+{
+ // TODO: the check dialog contains only [Continue] [Retry] buttons
+ // there is no [Abort] (#293356)
+ if (!PackageLock::Check())
+ {
+ // error message - SW management is already in use, access denied
+ // the yast module cannot be started
+ Report::Error(_("The GPG key management module cannot work
+without access to the software management system."));
+ Wizard::CloseDialog ();
+ return `abort;
+ }
+
+ // init the target - read the keys
+ if (!Pkg::TargetInitialize(Installation::destdir))
+ {
+ y2error("The target cannot be initialized, aborting...");
+ return `abort;
+ }
+
+ // read the current keys
+ if (!KeyManager::Read())
+ {
+ y2error("The key configuration cannot be read, aborting...");
+ return `abort;
+ }
+
+ return `next;
+}
+
+// main function - start the workflow
+symbol Main()
+{
+ Wizard::CreateDialog();
+ Wizard::SetDesktopIcon("sw_source");
+ // dialog caption
+ Wizard::SetContents(_("Initializing..."), `Empty (), "", false, true);
+
+ map aliases = $[
+ "read" : ``(Read()),
+ "edit" : ``(RunGPGKeyMgmt(true)),
+// TODO "write" : Write()
+ ];
+
+ map sequence = $[
+ "ws_start" : "read",
+ "read" : $[
+ `next : "edit"
+ ],
+ "edit" : $[
+ `abort : `abort,
+ `next : `next,
+ ],
+// "write" : $[
+// `next : "summary",
+// `abort : `abort,
+// ],
+ ];
+
+ y2milestone ("Starting the key management sequence");
+ symbol ret = Sequencer::Run (aliases, sequence);
+
+ Wizard::CloseDialog ();
+ return ret;
+}
+
+map cmdline_description = $[
+ "id" : "key_mgmgt",
+ "guihandler" : Main
+];
+
+return CommandLine::Run(cmdline_description);
+
+}
+
Modified: trunk/packager/src/clients/repositories.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/clients/repositories.ycp?rev=43522&r1=43521&r2=43522&view=diff
==============================================================================
--- trunk/packager/src/clients/repositories.ycp (original)
+++ trunk/packager/src/clients/repositories.ycp Thu Jan 10 13:23:17 2008
@@ -39,6 +39,7 @@
import "Product";
include "packager/inst_source_dialogs.ycp";
+ include "packager/key_manager_dialogs.ycp";
integer numSources = 0;
@@ -517,6 +518,8 @@
// store in the persistent libzypp storage
success = success && Pkg::SourceSaveAll(); // #176013
+ success = success && KeyManager::Write();
+
return success;
}
@@ -570,9 +573,9 @@
// label
`Left (`Label (_("Properties"))),
// check box
- `Left (`CheckBox (`id (`enable), `opt (`notify), _("Enabled"))),
+ `Left (`CheckBox (`id (`enable), `opt (`notify), _("&Enabled"))),
// check box
- `Left (`CheckBox (`id (`autorefresh), `opt (`notify), _("Automatically Refresh"))),
+ `Left (`CheckBox (`id (`autorefresh), `opt (`notify), _("Automatically &Refresh"))),
`VSpacing (0.4),
(have_rug) ?
`Left (`CheckBox (`id (`zmdsync),
@@ -604,6 +607,7 @@
`item(`id(`set_alias), setAliasButtonLabel)
])
*/
+ `PushButton (`id (`key_mgr), _("&GPG Keys...")),
`PushButton (`id (`refresh), refreshButtonLabel )
),
`VSpacing( 0.5 )
@@ -749,6 +753,13 @@
}
}
}
+ else if (input == `key_mgr)
+ {
+ exit = true;
+ //return `key_mgr;
+ // start the GPG key manager
+ //RunGPGKeyMgmt();
+ }
else
{
current = (integer) UI::QueryWidget( `id( `table ), `CurrentItem );
@@ -1028,6 +1039,9 @@
}
}
+ // read known GPG keys
+ KeyManager::Read();
+
sourceStatesIn = Pkg::SourceEditGet();
y2milestone( "Found repositories: %1", sourceStatesIn);
sourceStatesOut = sourceStatesIn;
@@ -1036,7 +1050,8 @@
"summary" : ``(SummaryDialog ()),
"type" : ``(TypeDialog()),
"edit" : ``(EditDialog ()),
- "store" : ``(StoreSource ())
+ "store" : ``(StoreSource ()),
+ "keymgr" : [``(RunGPGKeyMgmt(false)), true]
];
map sequence = $[
@@ -1044,9 +1059,14 @@
"summary" : $[
`add : "type",
`edit : "edit",
+ `key_mgr : "keymgr",
`abort : `abort,
`next : `next,
],
+ "keymgr" : $[
+ `next : "summary",
+ `abort : `abort
+ ],
"type" : $[
`next : "edit",
`finish : "store",
Modified: trunk/packager/src/include/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/include/Makefile.am?rev=43522&r1=43521&r2=43522&view=diff
==============================================================================
--- trunk/packager/src/include/Makefile.am (original)
+++ trunk/packager/src/include/Makefile.am Thu Jan 10 13:23:17 2008
@@ -8,7 +8,8 @@
ynclude_DATA = \
inst_source_dialogs.ycp \
storage_include.ycp \
- load_release_notes.ycp
+ load_release_notes.ycp \
+ key_manager_dialogs.ycp
EXTRA_DIST = $(ynclude_DATA)
Added: trunk/packager/src/include/key_manager_dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/include/key_manager_dialogs.ycp?rev=43522&view=auto
==============================================================================
--- trunk/packager/src/include/key_manager_dialogs.ycp (added)
+++ trunk/packager/src/include/key_manager_dialogs.ycp Thu Jan 10 13:23:17 2008
@@ -0,0 +1,321 @@
+/**
+ * File: key_manager.ycp
+ *
+ * Author: Ladislav Slezak
+ *
+ * Purpose: Manages GPG keys in the package manager
+ *
+ * $Id$
+ */
+
+{
+
+textdomain "packager";
+
+import "Wizard";
+import "Label";
+import "Popup";
+import "KeyManager";
+
+
+boolean gpg_mgr_standalone_mode = false;
+
+/**
+ * @return list table contents
+ */
+list createTableItems()
+{
+ list ret = [];
+
+ foreach(map key, KeyManager::GetKeys(),
+ {
+ term item = `item(`id(key["id"]:""),
+ key["trusted"]:false ? UI::Glyph (`CheckMark) : "",
+ key["id"]:"",
+ key["name"]:""
+ );
+
+ ret = add(ret, item);
+ }
+ );
+
+ y2debug("table content: %1", ret);
+
+ return ret;
+}
+
+void RefreshKeyTable(string current_item)
+{
+ list items = createTableItems();
+ UI::ChangeWidget(`id(`table), `Items, items);
+
+ if (current_item != nil)
+ {
+ UI::ChangeWidget(`id(`table), `CurrentItem, current_item);
+ }
+}
+
+map SearchGPGKey(string key_id)
+{
+ map ret = nil;
+
+ // search the properties of the key
+ foreach(map key, KeyManager::GetKeys(),
+ {
+ if (key["id"]:"" == key_id)
+ {
+ ret = key;
+ break;
+ }
+ }
+ );
+
+ return ret;
+}
+
+
+boolean EditKeyProperties(map key)
+{
+ UI::OpenDialog(
+ `MarginBox(1, 0.3,
+ `VBox(
+ `Frame(_("GPG Key Properties"),
+ `VBox(
+ `Left(`Label(sformat(_("Key ID: %1"), key["id"]:""))),
+ `Left(`Label(sformat(_("Name: %1"), key["name"]:""))),
+ `VSpacing(0.3),
+ `Left(`CheckBox(`id(`trusted), _("&Trusted"), key["trusted"]:false)),
+ `VSpacing(0.2)
+ )
+ ),
+ `VSpacing(0.2),
+ `HBox(
+ `PushButton(`id(`ok),`opt(`key_F10, `default), Label::OKButton()),
+ `HSpacing(2),
+ `PushButton(`id(`cancel), `opt(`key_F9), Label::CancelButton())
+ )
+ )
+ )
+ );
+
+ symbol ui = (symbol)UI::UserInput();
+ boolean ret = false;
+
+ if (ui == `ok)
+ {
+ boolean new_value = (boolean)UI::QueryWidget(`id(`trusted), `Value);
+ if (new_value != key["trusted"]:false)
+ {
+ key["trusted"] = new_value;
+ KeyManager::ModifyKey(key);
+ }
+
+ ret = true;
+ }
+
+ UI::CloseDialog();
+
+ return ret;
+}
+
+symbol AddGPGKey()
+{
+ string filename = "";
+
+ term contents = `VBox(
+ `Frame(`id(`fr), _("Select a GPG Key"),
+ `MarginBox(1, 0.3,
+ `VBox(
+ `HBox(
+ `TextEntry(`id(`file), Label::FileName(), filename),
+ `VBox(
+ `Label(""),
+ `PushButton(`id(`browse), Label::BrowseButton())
+ )
+ ),
+ `VSpacing(0.2),
+ `Left(`CheckBox(`id(`trusted), _("&The Key is Trusted"), false)),
+ `VSpacing(0.3)
+ )
+ )
+ )
+ );
+
+ // dialog caption
+ string title = _("Adding a GPG Public Key");
+
+ // help
+ string help_text = _("<p>
+In this dialog, manage known GPG public keys.</p>");
+
+ help_text = help_text + _("<p>
+<b>Adding a New GPG Key</b><br>
+To add a new GPG key, use <b>Add</b> and specify the path to the key file.
+</p>");
+
+ // help, continued
+ help_text = help_text + _("<p>
+<b>Modifying a GPG Key Status</b>
+To modify the trusted flag, use <b>Edit</b>. To remove a GPG key, use
+<b>Delete</b>.
+</p>
+");
+
+ Wizard::SetNextButton(`next, Label::OKButton());
+ Wizard::SetContents(title, contents, help_text, true, true);
+
+ symbol ret = nil;
+
+ do
+ {
+ ret = (symbol) UI::UserInput();
+
+ if (ret == `browse)
+ {
+ string currentfile = (string) UI::QueryWidget(`id(`file), `Value);
+ // header in file selection popup
+ string newfile = (string) UI::AskForExistingFile(currentfile, "*", _("Select the GPG Key To Import"));
+
+ if (newfile != nil)
+ {
+ UI::ChangeWidget(`id(`file), `Value, newfile);
+ }
+ }
+ else if (ret == `next)
+ {
+ // TODO: validate the entered file
+
+ boolean trusted = (boolean) UI::QueryWidget(`id(`trusted), `Value);
+
+ // TODO: add the key
+
+ }
+
+ }
+ while (!contains([`back, `abort, `next], ret));
+
+ Wizard::RestoreNextButton();
+
+ return ret;
+}
+
+
+symbol KeySummary()
+{
+ y2milestone ("Running Summary dialog");
+
+ list items = createTableItems();
+
+ term contents = `VBox(
+ `Table(`id(`table),
+ // table header
+ `header(`Center(_("Trusted")), `Right(_("Key ID")), _("Name")), items
+ ),
+ `VSpacing(0.3),
+ `HBox(
+ `PushButton(`id(`add),`opt(`key_F3), Label::AddButton()),
+ `PushButton(`id(`edit), `opt(`key_F4), Label::EditButton()),
+ `PushButton(`id(`delete), `opt(`key_F5), Label::DeleteButton())
+ ),
+ `VSpacing( 0.5 )
+ );
+
+ // dialog caption
+ string title = _("GPG Public Key Management");
+
+ // help
+ string help_text = _("<p>
+In this dialog, manage known GPG public keys.</p>");
+
+ help_text = help_text + _("<p>
+<b>Adding a New GPG Key</b><br>
+To add a new GPG key, use <b>Add</b> and specify the path to the key file.
+</p>");
+
+ // help, continued
+ help_text = help_text + _("<p>
+<b>Modifying a GPG Key Status</b>
+To modify the trusted flag, use <b>Edit</b>. To remove a GPG key, use
+<b>Delete</b>.
+</p>
+");
+
+ // check the mode
+ Wizard::SetNextButton(`next, gpg_mgr_standalone_mode ? Label::FinishButton() : Label::OKButton());
+ Wizard::SetContents(title, contents, help_text, !gpg_mgr_standalone_mode, true);
+
+ symbol ret = nil;
+
+ do
+ {
+ map event = UI::WaitForEvent();
+ ret = event["ID"]:`nothing;
+
+ string key_id = (string)UI::QueryWidget(`id(`table), `CurrentItem);
+ y2milestone("Selected key: %1, action: %2", key_id, ret);
+
+ // add a new key
+ if (ret == `add)
+ {
+ // add a new key
+ // TODO
+ }
+ // change key properties
+ else if (ret == `edit)
+ {
+ map key = SearchGPGKey(key_id);
+
+ if (key != nil && EditKeyProperties(key))
+ {
+ RefreshKeyTable(key_id);
+ }
+ }
+ // remove the key
+ else if (ret == `delete)
+ {
+ map key = SearchGPGKey(key_id);
+
+ if (Popup::YesNo(sformat(_("Really delete key '%1'
+'%2'?"), key_id, key["name"]:"")))
+ {
+ KeyManager::DeleteKey(key_id);
+ RefreshKeyTable(nil);
+ }
+ }
+ }
+ while (!contains([`back, `abort, `next, `add], ret));
+
+ Wizard::RestoreNextButton();
+
+ return ret;
+}
+
+symbol RunGPGKeyMgmt(boolean standalone)
+{
+ gpg_mgr_standalone_mode = standalone;
+
+ map aliases = $[
+ "summary" : ``(KeySummary()),
+ "add" : [``(AddGPGKey()), true ]
+ ];
+
+ map sequence = $[
+ "ws_start" : "summary",
+ "summary" : $[
+ `abort : `abort,
+ `next : `next,
+ `add : "add"
+ ],
+ "add" : $[
+ `next : "summary",
+ `abort : `abort
+ ]
+ ];
+
+ y2milestone ("Starting the key management sequence (standalone: %1)", standalone);
+ symbol ret = Sequencer::Run (aliases, sequence);
+
+ return ret;
+}
+
+}
Modified: trunk/packager/src/modules/SourceManager.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/modules/SourceManager.ycp?rev=43522&r1=43521&r2=43522&view=diff
==============================================================================
--- trunk/packager/src/modules/SourceManager.ycp (original)
+++ trunk/packager/src/modules/SourceManager.ycp Thu Jan 10 13:23:17 2008
@@ -33,6 +33,7 @@
import "String";
import "SuSEFirewall";
import "Linuxrc";
+import "FileUtils";
global list<integer> newSources = [];
@@ -135,6 +136,11 @@
*/
global boolean ReadSyncFlag()
{
+ if (!FileUtils::Exists(source_config_file))
+ {
+ return false;
+ }
+
map inst_config = (map)SCR::Read(.target.ycp, source_config_file);
zmd_sync = (boolean)inst_config["zmd_sync"]:nil;
y2milestone("Read ZMD sync status: %1", zmd_sync);
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org