Merge lp:~mterry/deja-dup/libsecret into lp:deja-dup/26

Proposed by Michael Terry
Status: Merged
Merged at revision: 1388
Proposed branch: lp:~mterry/deja-dup/libsecret
Merge into: lp:deja-dup/26
Diff against target: 541 lines (+135/-169)
15 files modified
common/BackendRackspace.vala (+30/-29)
common/BackendS3.vala (+31/-30)
common/CommonUtils.vala (+9/-0)
common/Makefile.am (+2/-3)
common/chacks.c (+0/-31)
common/chacks.h (+0/-29)
common/libcommon.deps (+2/-0)
configure.ac (+5/-2)
deja-dup/AssistantOperation.vala (+44/-35)
deja-dup/AssistantRestore.vala (+1/-1)
deja-dup/AssistantRestoreMissing.vala (+2/-2)
deja-dup/Makefile.am (+1/-3)
vapi/Makefile.am (+1/-1)
vapi/secret.vapi (+7/-2)
widgets/Makefile.am (+0/-1)
To merge this branch: bzr merge lp:~mterry/deja-dup/libsecret
Reviewer Review Type Date Requested Status
Robert Bruce Park (community) Approve
Review via email: mp+127627@code.launchpad.net

Description of the change

Port from libgnome-keyring to libsecret.

We use keyrings in two places:
1) In non-gio backends, to save the network password
2) To save the encryption password

Both are relatively easy to port over.

I tested manually that it works (and finds old passwords saved with libgnome-keyring). Didn't seem easy or worth it to add unit tests for an inherently integration-oriented branch like this.

To post a comment you must log in.
Revision history for this message
Robert Bruce Park (robru) wrote :

On 12-10-02 10:26 PM, Michael Terry wrote:
> Michael Terry has proposed merging lp:~mterry/deja-dup/libsecret into lp:deja-dup.
>
> Requested reviews:
> Robert Bruce Park (robru)

Hey michael, sorry I didn't get to this sooner, I've been a bit swamped
and it must have gotten buried in the inbox.

I tried to ping you on IRC but you weren't there. I'll read over this
for now, but I'll need a bit of guidance with interactive testing to
make sure it does what you say it does. Just ping me whenever you get
back on IRC.

> I tested manually that it works (and finds old passwords saved with libgnome-keyring). Didn't seem easy or worth it to add unit tests for an inherently integration-oriented branch like this.

Yeah, the code all looks relatively straightforward. Like I said, just
ping me and tell me what steps to take to test this and then I'll
approve it.

lp:~mterry/deja-dup/libsecret updated
1387. By Michael Terry

fix indenting

Revision history for this message
Michael Terry (mterry) wrote :

To manually test:

1) Use current deja-dup to start a new backup with an encryption password (and save it)
2) Use this branch to make another backup and make sure it doesn't ask you for the password (i.e. it found it keyring)

1) Use this branch to start a new backup with an encryption password (and save it)
2) Use seahorse to verify it is saved ("Backup encryption password")
3) Use this branch to make another backup and make sure it doesn't ask you for the password (i.e. it found it in keyring)

And do the above two sequences but for Amazon S3 (or Rackspace) to make sure it saves your S3 secret key and finds it.

Revision history for this message
Robert Bruce Park (robru) wrote :

Hey mterry. Sorry again for the delay. The good news is that friends is really coming along ;-)

Ok, I finally found some time to test this, and it does all look good. password does indeed show up in seahorse, and also when switching from trunk to this branch, it didn't re-ask for the password (eg, it found the old stored password correctly).

Feel free to merge!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'common/BackendRackspace.vala'
2--- common/BackendRackspace.vala 2012-03-21 03:01:36 +0000
3+++ common/BackendRackspace.vala 2012-10-08 19:46:21 +0000
4@@ -89,31 +89,27 @@
5
6 if (id != "") {
7 // First, try user's keyring
8- secret_key = null;
9- GnomeKeyring.find_network_password(id, null, RACKSPACE_SERVER, null, "https",
10- null, 0, found_password);
11- }
12- else
13- ask_password();
14- }
15-
16- void found_password(GnomeKeyring.Result result,
17- GLib.List<GnomeKeyring.NetworkPasswordData>? list)
18- {
19- if (result == GnomeKeyring.Result.OK && list != null) {
20- secret_key = list.data.password;
21- got_secret_key();
22- }
23- else {
24- ask_password();
25- }
26- }
27-
28- void save_password_callback(GnomeKeyring.Result result, uint32 val)
29- {
30- }
31-
32- void got_password_reply(MountOperation mount_op, MountOperationResult result)
33+ try {
34+ secret_key = yield Secret.password_lookup(Secret.SCHEMA_COMPAT_NETWORK,
35+ null,
36+ "user", id,
37+ "server", RACKSPACE_SERVER,
38+ "protocol", "https");
39+ if (secret_key != null) {
40+ got_secret_key();
41+ return;
42+ }
43+ }
44+ catch (Error e) {
45+ // fall through to ask_password below
46+ }
47+ }
48+
49+ // Didn't find it, so ask user
50+ ask_password();
51+ }
52+
53+ async void got_password_reply(MountOperation mount_op, MountOperationResult result)
54 {
55 if (result != MountOperationResult.HANDLED) {
56 envp_ready(false, new List<string>(), _("Permission denied"));
57@@ -127,10 +123,15 @@
58 var remember = mount_op.password_save;
59 if (remember != PasswordSave.NEVER) {
60 string where = (remember == PasswordSave.FOR_SESSION) ?
61- "session" : GnomeKeyring.DEFAULT;
62- GnomeKeyring.set_network_password(where, id, null, RACKSPACE_SERVER, null,
63- "https", null, 0, secret_key,
64- save_password_callback);
65+ Secret.COLLECTION_SESSION : Secret.COLLECTION_DEFAULT;
66+ yield Secret.password_store(Secret.SCHEMA_COMPAT_NETWORK,
67+ where,
68+ "%s@%s".printf(id, RACKSPACE_SERVER),
69+ secret_key,
70+ null,
71+ "user", id,
72+ "server", RACKSPACE_SERVER,
73+ "protocol", "https");
74 }
75
76 got_secret_key();
77
78=== modified file 'common/BackendS3.vala'
79--- common/BackendS3.vala 2012-04-30 00:18:18 +0000
80+++ common/BackendS3.vala 2012-10-08 19:46:21 +0000
81@@ -142,31 +142,27 @@
82
83 if (id != "") {
84 // First, try user's keyring
85- secret_key = null;
86- GnomeKeyring.find_network_password(id, null, S3_SERVER, null, "https",
87- null, 0, found_password);
88- }
89- else
90- ask_password();
91- }
92-
93- void found_password(GnomeKeyring.Result result,
94- GLib.List<GnomeKeyring.NetworkPasswordData>? list)
95- {
96- if (result == GnomeKeyring.Result.OK && list != null) {
97- secret_key = list.data.password;
98- got_secret_key();
99- }
100- else {
101- ask_password();
102- }
103- }
104-
105- void save_password_callback(GnomeKeyring.Result result, uint32 val)
106- {
107- }
108-
109- void got_password_reply(MountOperation mount_op, MountOperationResult result)
110+ try {
111+ secret_key = yield Secret.password_lookup(Secret.SCHEMA_COMPAT_NETWORK,
112+ null,
113+ "user", id,
114+ "server", S3_SERVER,
115+ "protocol", "https");
116+ if (secret_key != null) {
117+ got_secret_key();
118+ return;
119+ }
120+ }
121+ catch (Error e) {
122+ // fall through to ask_password below
123+ }
124+ }
125+
126+ // Didn't find it, so ask user
127+ ask_password();
128+ }
129+
130+ async void got_password_reply(MountOperation mount_op, MountOperationResult result)
131 {
132 if (result != MountOperationResult.HANDLED) {
133 envp_ready(false, new List<string>(), _("Permission denied"));
134@@ -180,12 +176,17 @@
135 var remember = mount_op.password_save;
136 if (remember != PasswordSave.NEVER) {
137 string where = (remember == PasswordSave.FOR_SESSION) ?
138- "session" : GnomeKeyring.DEFAULT;
139- GnomeKeyring.set_network_password(where, id, null, S3_SERVER, null,
140- "https", null, 0, secret_key,
141- save_password_callback);
142+ Secret.COLLECTION_SESSION : Secret.COLLECTION_DEFAULT;
143+ yield Secret.password_store(Secret.SCHEMA_COMPAT_NETWORK,
144+ where,
145+ "%s@%s".printf(id, S3_SERVER),
146+ secret_key,
147+ null,
148+ "user", id,
149+ "server", S3_SERVER,
150+ "protocol", "https");
151 }
152-
153+
154 got_secret_key();
155 }
156
157
158=== modified file 'common/CommonUtils.vala'
159--- common/CommonUtils.vala 2012-08-20 01:16:15 +0000
160+++ common/CommonUtils.vala 2012-10-08 19:46:21 +0000
161@@ -582,5 +582,14 @@
162 return date;
163 }
164
165+public Secret.Schema get_passphrase_schema()
166+{
167+ // Use freedesktop's schema id for historical reasons
168+ return new Secret.Schema("org.freedesktop.Secret.Generic",
169+ Secret.SchemaFlags.NONE,
170+ "owner", Secret.SchemaAttributeType.STRING,
171+ "type", Secret.SchemaAttributeType.STRING);
172+}
173+
174 } // end namespace
175
176
177=== modified file 'common/Makefile.am'
178--- common/Makefile.am 2012-08-10 18:33:29 +0000
179+++ common/Makefile.am 2012-10-08 19:46:21 +0000
180@@ -31,7 +31,6 @@
181 @INTLLIBS@
182
183 noinst_HEADERS = \
184- chacks.h \
185 uriutils.h
186
187 libcommon_la_VALASOURCES = \
188@@ -60,7 +59,6 @@
189 ToolPlugin.vala
190
191 libcommon_la_SOURCES = \
192- chacks.c \
193 uriutils.c \
194 $(libcommon_la_VALASOURCES)
195
196@@ -72,7 +70,8 @@
197 $(NETWORKMONITOR_VALAFLAGS) \
198 --pkg gio-2.0 \
199 --pkg gio-unix-2.0 \
200- --pkg gnome-keyring-1 \
201+ --pkg libsecret-1 \
202+ --pkg secret \
203 --pkg libpeas-1.0 \
204 --pkg uriutils \
205 --pkg posix \
206
207=== removed file 'common/chacks.c'
208--- common/chacks.c 2011-06-28 15:48:17 +0000
209+++ common/chacks.c 1970-01-01 00:00:00 +0000
210@@ -1,31 +0,0 @@
211-/* -*- Mode: C; indent-tabs-mode: nil; tab-width: 2 -*- */
212-/*
213- This file is part of Déjà Dup.
214- For copyright information, see AUTHORS.
215-
216- Déjà Dup is free software: you can redistribute it and/or modify
217- it under the terms of the GNU General Public License as published by
218- the Free Software Foundation, either version 3 of the License, or
219- (at your option) any later version.
220-
221- Déjà Dup is distributed in the hope that it will be useful,
222- but WITHOUT ANY WARRANTY; without even the implied warranty of
223- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
224- GNU General Public License for more details.
225-
226- You should have received a copy of the GNU General Public License
227- along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
228-*/
229-
230-#include "chacks.h"
231-
232-static const GnomeKeyringPasswordSchema PASSPHRASE_SCHEMA_DEF = {
233- GNOME_KEYRING_ITEM_GENERIC_SECRET,
234- {
235- {"owner", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING},
236- {"type", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING},
237- {NULL, 0}
238- }
239-};
240-
241-const GnomeKeyringPasswordSchema *PASSPHRASE_SCHEMA = &PASSPHRASE_SCHEMA_DEF;
242
243=== removed file 'common/chacks.h'
244--- common/chacks.h 2011-06-28 15:48:17 +0000
245+++ common/chacks.h 1970-01-01 00:00:00 +0000
246@@ -1,29 +0,0 @@
247-/* -*- Mode: C; indent-tabs-mode: nil; tab-width: 2 -*- */
248-/*
249- This file is part of Déjà Dup.
250- For copyright information, see AUTHORS.
251-
252- Déjà Dup is free software: you can redistribute it and/or modify
253- it under the terms of the GNU General Public License as published by
254- the Free Software Foundation, either version 3 of the License, or
255- (at your option) any later version.
256-
257- Déjà Dup is distributed in the hope that it will be useful,
258- but WITHOUT ANY WARRANTY; without even the implied warranty of
259- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
260- GNU General Public License for more details.
261-
262- You should have received a copy of the GNU General Public License
263- along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
264-*/
265-
266-/* This file is for whatever we can't currently do in Vala. */
267-#ifndef __CHACKS_H__
268-#define __CHACKS_H__
269-
270-#include <gnome-keyring.h>
271-
272-extern const GnomeKeyringPasswordSchema *PASSPHRASE_SCHEMA;
273-
274-#endif
275-
276
277=== added file 'common/libcommon.deps'
278--- common/libcommon.deps 1970-01-01 00:00:00 +0000
279+++ common/libcommon.deps 2012-10-08 19:46:21 +0000
280@@ -0,0 +1,2 @@
281+libpeas-1.0
282+libsecret-1
283
284=== modified file 'configure.ac'
285--- configure.ac 2012-09-24 16:45:39 +0000
286+++ configure.ac 2012-10-08 19:46:21 +0000
287@@ -76,7 +76,7 @@
288 $GTK_MODULE >= $GTK_REQ_VER
289 gio-2.0 >= $GIO_REQ_VER
290 gio-unix-2.0 >= $GIO_REQ_VER
291- gnome-keyring-1
292+ libsecret-1
293 libpeas-1.0
294 gmodule-2.0 >= $GLIB_REQ_VER
295 libnotify >= $NOTIFY_REQ_VER)
296@@ -84,23 +84,26 @@
297 PKG_CHECK_MODULES(PREF,
298 $GTK_MODULE >= $GTK_REQ_VER
299 gio-2.0 >= $GIO_REQ_VER
300+ libsecret-1
301 libpeas-1.0)
302
303 PKG_CHECK_MODULES(COMMON,
304 gio-2.0 >= $GIO_REQ_VER
305 gio-unix-2.0 >= $GIO_REQ_VER
306- gnome-keyring-1
307+ libsecret-1
308 libpeas-1.0
309 gmodule-2.0 >= $GLIB_REQ_VER)
310
311 PKG_CHECK_MODULES(WIDGETS,
312 gmodule-2.0 >= $GLIB_REQ_VER
313 $GTK_MODULE >= $GTK_REQ_VER
314+ libsecret-1
315 libpeas-1.0
316 libnotify >= $NOTIFY_REQ_VER)
317
318 PKG_CHECK_MODULES(MONITOR,
319 gio-2.0 >= $GIO_REQ_VER
320+ libsecret-1
321 libpeas-1.0
322 libnotify >= $NOTIFY_REQ_VER)
323
324
325=== modified file 'deja-dup/AssistantOperation.vala'
326--- deja-dup/AssistantOperation.vala 2012-08-21 01:19:49 +0000
327+++ deja-dup/AssistantOperation.vala 2012-10-08 19:46:21 +0000
328@@ -55,7 +55,6 @@
329 protected bool nagged;
330 List<Gtk.Widget> first_password_widgets;
331 MainLoop password_ask_loop;
332- MainLoop password_find_loop;
333 DejaDup.ToggleGroup password_toggles;
334
335 Gtk.Label question_label;
336@@ -648,7 +647,7 @@
337 timeout_id = Timeout.add(250, pulse);
338 if (op != null && op.needs_password) {
339 // Operation is waiting for password
340- provide_password();
341+ provide_password.begin();
342 }
343 else if (op == null)
344 do_apply.begin();
345@@ -728,43 +727,47 @@
346 }
347 }
348
349- void found_passphrase(GnomeKeyring.Result result, string? str)
350+ async string? lookup_keyring()
351 {
352- if (str != null) {
353- op.set_passphrase(str);
354- }
355- else {
356- ask_passphrase();
357- }
358- password_find_loop.quit();
359- password_find_loop = null;
360+ try {
361+ return yield Secret.password_lookup(DejaDup.get_passphrase_schema(),
362+ null,
363+ "owner", Config.PACKAGE,
364+ "type", "passphrase");
365+ }
366+ catch (Error e) {
367+ warning("%s\n", e.message);
368+ return null;
369+ }
370 }
371
372 protected void get_passphrase()
373 {
374 if (!searched_for_passphrase && !DejaDup.in_testing_mode() &&
375 op.use_cached_password) {
376- // First, try user's keyring
377- GnomeKeyring.find_password(PASSPHRASE_SCHEMA,
378- found_passphrase,
379- "owner", Config.PACKAGE,
380- "type", "passphrase");
381 // If we get asked for passphrase again, it is because a
382 // saved or entered passphrase didn't work. So don't bother
383 // searching a second time.
384 searched_for_passphrase = true;
385- // block until found
386- password_find_loop = new MainLoop(null);
387- password_find_loop.run();
388- }
389- else {
390- // just jump straight to asking user
391- ask_passphrase();
392- }
393- }
394-
395- void save_password_callback(GnomeKeyring.Result result)
396- {
397+
398+ string str = null;
399+
400+ // First, try user's keyring
401+ var loop = new MainLoop(null);
402+ lookup_keyring.begin((obj, res) => {
403+ str = lookup_keyring.end(res);
404+ loop.quit();
405+ });
406+ loop.run();
407+
408+ // Did we get anything?
409+ if (str != null) {
410+ op.set_passphrase(str);
411+ return;
412+ }
413+ }
414+
415+ ask_passphrase();
416 }
417
418 void check_password_validity()
419@@ -849,7 +852,7 @@
420 password_ask_loop.run();
421 }
422
423- protected void provide_password()
424+ protected async void provide_password()
425 {
426 var passphrase = "";
427
428@@ -863,12 +866,18 @@
429 if (passphrase != "") {
430 // Save it
431 if (encrypt_remember.active) {
432- GnomeKeyring.store_password(PASSPHRASE_SCHEMA,
433- GnomeKeyring.DEFAULT,
434- _("Backup encryption password"),
435- passphrase, save_password_callback,
436- "owner", Config.PACKAGE,
437- "type", "passphrase");
438+ try {
439+ yield Secret.password_store(DejaDup.get_passphrase_schema(),
440+ Secret.COLLECTION_DEFAULT,
441+ _("Backup encryption password"),
442+ passphrase,
443+ null,
444+ "owner", Config.PACKAGE,
445+ "type", "passphrase");
446+ }
447+ catch (Error e) {
448+ warning("%s\n", e.message);
449+ }
450 }
451 }
452 }
453
454=== modified file 'deja-dup/AssistantRestore.vala'
455--- deja-dup/AssistantRestore.vala 2012-08-06 22:41:13 +0000
456+++ deja-dup/AssistantRestore.vala 2012-10-08 19:46:21 +0000
457@@ -491,7 +491,7 @@
458 query_timeout_id = Timeout.add(250, query_pulse);
459 if (query_op != null && query_op.needs_password) {
460 // Operation is waiting for password
461- provide_password();
462+ provide_password.begin();
463 }
464 else if (query_op == null)
465 do_query.begin();
466
467=== modified file 'deja-dup/AssistantRestoreMissing.vala'
468--- deja-dup/AssistantRestoreMissing.vala 2012-08-06 22:41:13 +0000
469+++ deja-dup/AssistantRestoreMissing.vala 2012-10-08 19:46:21 +0000
470@@ -234,10 +234,10 @@
471 }
472 else {
473 if (query_op != null && query_op.needs_password) {
474- provide_password();
475+ provide_password.begin();
476 }
477 else if (query_op_files != null && query_op_files.needs_password) {
478- provide_password();
479+ provide_password.begin();
480 }
481 else if (!backups_queue_filled) {
482 do_query.begin();
483
484=== modified file 'deja-dup/Makefile.am'
485--- deja-dup/Makefile.am 2012-08-08 01:12:17 +0000
486+++ deja-dup/Makefile.am 2012-10-08 19:46:21 +0000
487@@ -56,12 +56,10 @@
488 --pkg @GTK_MODULE@ \
489 --pkg gio-2.0 \
490 --pkg gio-unix-2.0 \
491- --pkg gnome-keyring-1 \
492- --pkg libpeas-1.0 \
493+ --pkg libsecret-1 \
494 --pkg libnotify \
495 --pkg libcommon \
496 --pkg libwidgets \
497- --pkg keyring \
498 --pkg config
499
500 deja_dup_vala.stamp: $(top_srcdir)/config.h
501
502=== modified file 'vapi/Makefile.am'
503--- vapi/Makefile.am 2012-03-22 14:44:44 +0000
504+++ vapi/Makefile.am 2012-10-08 19:46:21 +0000
505@@ -18,6 +18,6 @@
506
507 EXTRA_DIST = \
508 config.vapi \
509- keyring.vapi \
510+ secret.vapi \
511 uriutils.vapi
512
513
514=== renamed file 'vapi/keyring.vapi' => 'vapi/secret.vapi'
515--- vapi/keyring.vapi 2011-06-28 15:48:17 +0000
516+++ vapi/secret.vapi 2012-10-08 19:46:21 +0000
517@@ -17,5 +17,10 @@
518 along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
519 */
520
521-[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "chacks.h")]
522-public GnomeKeyring.PasswordSchema PASSPHRASE_SCHEMA;
523+/* TODO: libsecret-1.vapi does not have SECRET_SCHEMA_COMPAT_NETWORK yet */
524+[CCode (cprefix = "Secret", gir_namespace = "Secret", gir_version = "1", lower_case_cprefix = "secret_")]
525+namespace Secret {
526+ [CCode (cheader_filename = "libsecret/secret.h", cname = "SECRET_SCHEMA_COMPAT_NETWORK")]
527+ public Secret.Schema SCHEMA_COMPAT_NETWORK;
528+}
529+
530
531=== modified file 'widgets/Makefile.am'
532--- widgets/Makefile.am 2012-08-08 01:12:17 +0000
533+++ widgets/Makefile.am 2012-10-08 19:46:21 +0000
534@@ -80,7 +80,6 @@
535 $(UNITY_VALAFLAGS) \
536 --pkg libcommon \
537 --pkg @GTK_MODULE@ \
538- --pkg libpeas-1.0 \
539 --pkg uriutils \
540 --pkg libnotify \
541 --pkg config

Subscribers

People subscribed via source and target branches