After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 694606 - Add a shell search provider for passwords and keys
Add a shell search provider for passwords and keys
Status: RESOLVED FIXED
Product: seahorse
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Seahorse Maintainer
Seahorse Maintainer
Depends on:
Blocks:
 
 
Reported: 2013-02-24 17:50 UTC by Giovanni Campagna
Modified: 2013-04-21 22:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add a shell search provider for passwords and keys (29.29 KB, patch)
2013-02-24 17:50 UTC, Giovanni Campagna
needs-work Details | Review
Add a shell search provider for passwords and keys (29.87 KB, patch)
2013-03-06 19:07 UTC, Giovanni Campagna
none Details | Review
Add a shell search provider for passwords and keys (30.89 KB, patch)
2013-03-16 13:45 UTC, Giovanni Campagna
none Details | Review
Add a shell search provider for passwords and keys (30.80 KB, patch)
2013-04-19 14:12 UTC, Giovanni Campagna
committed Details | Review
Patch to include Makefile.decl in data/Makefile.am (1.49 KB, patch)
2013-04-21 21:54 UTC, Hashem Nasarat
none Details | Review

Description Giovanni Campagna 2013-02-24 17:50:11 UTC
Turn the seahorse application into a dbus activate service, and install
a handler for the search provider interface. This will allow to search
passwords from the overview, which is useful when using seahorse to
store personal passwords not created by applications.
Comment 1 Giovanni Campagna 2013-02-24 17:50:13 UTC
Created attachment 237293 [details] [review]
Add a shell search provider for passwords and keys
Comment 2 Stef Walter 2013-02-26 10:21:07 UTC
Sounds pretty cool. I haven't had a chance to try out or review the patch yet, as I'm travelling. But just a feature question:

Should we only be searching passwords for now, and only those stored by the user through seahorse? Do you think it makes sense to show application stored passwords and keys in the shell? Those seem like things the user shouldn't really be bothered with.

FWIW, relatedly I do need to do work to make it easier to store a simple password in seahorse, and become more useful as a place to add a password or something you want to keep secret.
Comment 3 Giovanni Campagna 2013-03-06 17:49:06 UTC
I agree that showing application passwords is not useful. But I think that showing keys and certificates is nice. After all, they are user visible content.
Comment 4 Stef Walter 2013-03-06 18:53:55 UTC
Giovanni. That makes sense. (In reply to comment #3)
> I agree that showing application passwords is not useful. But I think that
> showing keys and certificates is nice. After all, they are user visible
> content.

I agree.

So let's filter out application stored passwords for now. These are passwords that don't have the SECRET_SCHEMA_NOTE schema, as returned by secret_item_get_schema_name().

https://developer.gnome.org/libsecret/0.13/SecretItem.html#secret-item-get-schema-name

In addition we should only show personal items, not things like CA certificates and so on. You can do this by setting SeahorsePredicate.flags to SEAHORSE_FLAG_PERSONAL.
Comment 5 Giovanni Campagna 2013-03-06 19:07:10 UTC
Created attachment 238231 [details] [review]
Add a shell search provider for passwords and keys

Turn the seahorse application into a dbus activate service, and install
a handler for the search provider interface. This will allow to search
passwords from the overview, which is useful when using seahorse to
store personal passwords not created by applications.

There is one problem with this patch: passwords stored before the
introduction of libsecret are not matched, because they use the generic
schema.
Comment 6 Stef Walter 2013-03-06 19:25:57 UTC
Review of attachment 237293 [details] [review]:

Overall looks well done. 

Hmmm, looks like I reviewed the last patch, and you were quick on the draw with an update. I hope the comments are useful anyway.

::: data/Makefile.am
@@ +22,3 @@
+
+org.gnome.seahorse.Application.service: org.gnome.seahorse.Application.service.in Makefile
+	$(AM_V_GEN) sed -e "s|\@bindir\@|$(bindir)|" $< > $@

We have SED_SUBST (see Makefile.decl) for this. Or does it not work in this case?

@@ +25,3 @@
+
+searchproviderdir = $(datadir)/gnome-shell/search-providers
+

Where does this file come from? I get: 

make[2]: Entering directory `/data/projects/seahorse/data'
make[2]: *** No rule to make target `seahorse-search-provider.ini', needed by `distdir'.  Stop.

::: libseahorse/seahorse-application.c
@@ +138,2 @@
 	context = g_option_context_new (N_("- System Settings"));
+	g_option_context_set_ignore_unknown_options (context, TRUE);

Is this really necessary? Can't we put --no-window in the options?

::: libseahorse/seahorse-search-provider.c
@@ +6,3 @@
+ * Copyright (C) 2011 Collabora Ltd.
+ * Copyright (C) 2012 Stefan Walter
+ * Copyright (C) 2013 Giovanni Campagna

I doubt all these guys wrote this :)

@@ +95,3 @@
+
+	predicate->custom = object_contains_filtered_text;
+	predicate->custom_target = g_strjoinv (" ", terms);

Are we supposed to be doing an 'and' search on the terms, or searching for them as adjacent words. It seems this does the latter.

@@ +123,3 @@
+
+	for (l = objects; l; l = l->next) {
+		if (SEAHORSE_IS_VIEWABLE(l->data) &&

Missing space here.

@@ +176,3 @@
+
+	g_ptr_array_add (array, NULL);
+	results = (char**) g_ptr_array_free (array, FALSE);

Missing space in the pointer type.

@@ +341,3 @@
+seahorse_search_provider_init (SeahorseSearchProvider *self)
+{
+	self->skeleton = seahorse_shell_search_provider2_skeleton_new ();

Would prefer it if you derived this class from SeahorseShellSearchProvider2Skeleton and used virtual functions instead if possible. This signal stuff is really pretty unreadable, and was a big workaround for tedious subclassing in GObject C code, and inability of some bindings to subclass. But since we have a GObject class here anyway, let's just do it the sane way :)

@@ +354,3 @@
+			  G_CALLBACK (handle_launch_search), self);
+
+	self->collection = GCR_COLLECTION (gcr_union_collection_new ());

This might be were you use seahorse_collection_new_for_predicate() to filter out application keyring items, and only include personal items.

::: libseahorse/seahorse-search-provider.h
@@ +6,3 @@
+ * Copyright (C) 2011 Collabora Ltd.
+ * Copyright (C) 2012 Stefan Walter
+ * Copyright (C) 2013 Giovanni Campagna

Ditto here.

::: src/seahorse-key-manager.xml
@@ +7,3 @@
     <property name="default_width">640</property>
     <property name="default_height">476</property>
+    <signal name="delete-event" handler="on_widget_delete_event" swapped="no"/>

Did this sneak in? Should it be a separate commit?
Comment 7 Stef Walter 2013-03-06 19:26:52 UTC
Oh, and could you update .gitignore for the new generated files?
Comment 8 Giovanni Campagna 2013-03-16 13:45:08 UTC
(In reply to comment #6)
> Review of attachment 237293 [details] [review]:
> 
> ::: libseahorse/seahorse-application.c
> @@ +138,2 @@
>      context = g_option_context_new (N_("- System Settings"));
> +    g_option_context_set_ignore_unknown_options (context, TRUE);
> 
> Is this really necessary? Can't we put --no-window in the options?

Yes, it's necessary: GOptionContext filters away all options that it knows about, and we need --no-window to be sent to the primary instance.

> ::: src/seahorse-key-manager.xml
> @@ +7,3 @@
>      <property name="default_width">640</property>
>      <property name="default_height">476</property>
> +    <signal name="delete-event" handler="on_widget_delete_event"
> swapped="no"/>
> 
> Did this sneak in? Should it be a separate commit?

It is necessary to handle window deletion correctly: otherwise, the destroyed window is not removed from SeahorseWidget tracking table, and thus the window is shown again with no content when activating the app.
Comment 9 Giovanni Campagna 2013-03-16 13:45:51 UTC
Created attachment 239025 [details] [review]
Add a shell search provider for passwords and keys

Turn the seahorse application into a dbus activate service, and install
a handler for the search provider interface. This will allow to search
passwords from the overview, which is useful when using seahorse to
store personal passwords not created by applications.
Comment 10 Stef Walter 2013-04-19 07:48:19 UTC
Fixing build of org.gnome.seahorse.Application.service

Getting this:

(seahorse:30907): GLib-GIO-CRITICAL **: g_dbus_interface_skeleton_export: assertion `G_IS_DBUS_INTERFACE_SKELETON (interface_)' failed

(seahorse:30907): GLib-GIO-CRITICAL **: g_dbus_interface_skeleton_has_connection: assertion `G_IS_DBUS_INTERFACE_SKELETON (interface_)' failed
Comment 11 Giovanni Campagna 2013-04-19 14:12:27 UTC
Created attachment 241906 [details] [review]
Add a shell search provider for passwords and keys

Turn the seahorse application into a dbus activate service, and install
a handler for the search provider interface. This will allow to search
passwords from the overview, which is useful when using seahorse to
store personal passwords not created by applications.

Ops, sorry, I had this fixed locally, but I forgot to attach it...
Comment 12 Stef Walter 2013-04-19 18:44:42 UTC
Thanks. Merged to master with the following changes:

 * Use GOptionContext to parse --no-window (want to eventually do this better
   but this is a start).
 * Don't set application inactivity timeout unless --no-window
 * Gracefully handle null values in handle_get_result_metas()
 * Whitespace fixes
Comment 13 Stef Walter 2013-04-19 18:45:11 UTC
Attachment 241906 [details] pushed as 6c43f3d - Add a shell search provider for passwords and keys
Comment 14 Hashem Nasarat 2013-04-21 21:54:26 UTC
Created attachment 242106 [details] [review]
Patch to include Makefile.decl in data/Makefile.am

I wanted to open this once more because the patch pushed (attachment 241906 [details] [review]) does not compile. The problem is a missing include of Makefile.decl in data/Makefile.am. This patch fixes the issue.
Comment 15 Hashem Nasarat 2013-04-21 22:43:40 UTC
Drat. I saw this was fixed in master earlier today. Disregard the previous patch.