Commit eb1e7864 authored by Michael Terry's avatar Michael Terry

switch to libsecret

parents 4f57e30c 0cbe76e9
Déjà Dup 25.1 (GNOME 3.7.1)
---------------------------
Packaging:
• Switch from libgnome-keyring to libsecret
Déjà Dup 24.0 (GNOME 3.6.0)
---------------------------
Translations:
......
......@@ -89,31 +89,27 @@ public class BackendRackspace : Backend
if (id != "") {
// First, try user's keyring
secret_key = null;
GnomeKeyring.find_network_password(id, null, RACKSPACE_SERVER, null, "https",
null, 0, found_password);
try {
secret_key = yield Secret.password_lookup(Secret.SCHEMA_COMPAT_NETWORK,
null,
"user", id,
"server", RACKSPACE_SERVER,
"protocol", "https");
if (secret_key != null) {
got_secret_key();
return;
}
}
catch (Error e) {
// fall through to ask_password below
}
}
else
ask_password();
}
void found_password(GnomeKeyring.Result result,
GLib.List<GnomeKeyring.NetworkPasswordData>? list)
{
if (result == GnomeKeyring.Result.OK && list != null) {
secret_key = list.data.password;
got_secret_key();
}
else {
ask_password();
}
}
void save_password_callback(GnomeKeyring.Result result, uint32 val)
{
// Didn't find it, so ask user
ask_password();
}
void got_password_reply(MountOperation mount_op, MountOperationResult result)
async void got_password_reply(MountOperation mount_op, MountOperationResult result)
{
if (result != MountOperationResult.HANDLED) {
envp_ready(false, new List<string>(), _("Permission denied"));
......@@ -127,10 +123,15 @@ public class BackendRackspace : Backend
var remember = mount_op.password_save;
if (remember != PasswordSave.NEVER) {
string where = (remember == PasswordSave.FOR_SESSION) ?
"session" : GnomeKeyring.DEFAULT;
GnomeKeyring.set_network_password(where, id, null, RACKSPACE_SERVER, null,
"https", null, 0, secret_key,
save_password_callback);
Secret.COLLECTION_SESSION : Secret.COLLECTION_DEFAULT;
yield Secret.password_store(Secret.SCHEMA_COMPAT_NETWORK,
where,
"%s@%s".printf(id, RACKSPACE_SERVER),
secret_key,
null,
"user", id,
"server", RACKSPACE_SERVER,
"protocol", "https");
}
got_secret_key();
......
......@@ -142,31 +142,27 @@ public class BackendS3 : Backend
if (id != "") {
// First, try user's keyring
secret_key = null;
GnomeKeyring.find_network_password(id, null, S3_SERVER, null, "https",
null, 0, found_password);
try {
secret_key = yield Secret.password_lookup(Secret.SCHEMA_COMPAT_NETWORK,
null,
"user", id,
"server", S3_SERVER,
"protocol", "https");
if (secret_key != null) {
got_secret_key();
return;
}
}
catch (Error e) {
// fall through to ask_password below
}
}
else
ask_password();
}
void found_password(GnomeKeyring.Result result,
GLib.List<GnomeKeyring.NetworkPasswordData>? list)
{
if (result == GnomeKeyring.Result.OK && list != null) {
secret_key = list.data.password;
got_secret_key();
}
else {
ask_password();
}
}
void save_password_callback(GnomeKeyring.Result result, uint32 val)
{
// Didn't find it, so ask user
ask_password();
}
void got_password_reply(MountOperation mount_op, MountOperationResult result)
async void got_password_reply(MountOperation mount_op, MountOperationResult result)
{
if (result != MountOperationResult.HANDLED) {
envp_ready(false, new List<string>(), _("Permission denied"));
......@@ -180,12 +176,17 @@ public class BackendS3 : Backend
var remember = mount_op.password_save;
if (remember != PasswordSave.NEVER) {
string where = (remember == PasswordSave.FOR_SESSION) ?
"session" : GnomeKeyring.DEFAULT;
GnomeKeyring.set_network_password(where, id, null, S3_SERVER, null,
"https", null, 0, secret_key,
save_password_callback);
Secret.COLLECTION_SESSION : Secret.COLLECTION_DEFAULT;
yield Secret.password_store(Secret.SCHEMA_COMPAT_NETWORK,
where,
"%s@%s".printf(id, S3_SERVER),
secret_key,
null,
"user", id,
"server", S3_SERVER,
"protocol", "https");
}
got_secret_key();
}
......
......@@ -521,5 +521,14 @@ public Date get_full_backup_threshold_date()
return date;
}
public Secret.Schema get_passphrase_schema()
{
// Use freedesktop's schema id for historical reasons
return new Secret.Schema("org.freedesktop.Secret.Generic",
Secret.SchemaFlags.NONE,
"owner", Secret.SchemaAttributeType.STRING,
"type", Secret.SchemaAttributeType.STRING);
}
} // end namespace
......@@ -31,7 +31,6 @@ libcommon_la_LIBADD = \
@INTLLIBS@
noinst_HEADERS = \
chacks.h \
uriutils.h
libcommon_la_VALASOURCES = \
......@@ -60,7 +59,6 @@ libcommon_la_VALASOURCES = \
ToolPlugin.vala
libcommon_la_SOURCES = \
chacks.c \
uriutils.c \
$(libcommon_la_VALASOURCES)
......@@ -72,7 +70,8 @@ AM_VALAFLAGS = \
$(NETWORKMONITOR_VALAFLAGS) \
--pkg gio-2.0 \
--pkg gio-unix-2.0 \
--pkg gnome-keyring-1 \
--pkg libsecret-1 \
--pkg secret \
--pkg libpeas-1.0 \
--pkg uriutils \
--pkg posix \
......
/* -*- Mode: C; indent-tabs-mode: nil; tab-width: 2 -*- */
/*
This file is part of Déjà Dup.
For copyright information, see AUTHORS.
Déjà Dup is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Déjà Dup is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
*/
#include "chacks.h"
static const GnomeKeyringPasswordSchema PASSPHRASE_SCHEMA_DEF = {
GNOME_KEYRING_ITEM_GENERIC_SECRET,
{
{"owner", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING},
{"type", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING},
{NULL, 0}
}
};
const GnomeKeyringPasswordSchema *PASSPHRASE_SCHEMA = &PASSPHRASE_SCHEMA_DEF;
/* -*- Mode: C; indent-tabs-mode: nil; tab-width: 2 -*- */
/*
This file is part of Déjà Dup.
For copyright information, see AUTHORS.
Déjà Dup is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Déjà Dup is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
*/
/* This file is for whatever we can't currently do in Vala. */
#ifndef __CHACKS_H__
#define __CHACKS_H__
#include <gnome-keyring.h>
extern const GnomeKeyringPasswordSchema *PASSPHRASE_SCHEMA;
#endif
libpeas-1.0
libsecret-1
......@@ -76,7 +76,7 @@ PKG_CHECK_MODULES(DUP,
$GTK_MODULE >= $GTK_REQ_VER
gio-2.0 >= $GIO_REQ_VER
gio-unix-2.0 >= $GIO_REQ_VER
gnome-keyring-1
libsecret-1
libpeas-1.0
gmodule-2.0 >= $GLIB_REQ_VER
libnotify >= $NOTIFY_REQ_VER)
......@@ -84,23 +84,26 @@ PKG_CHECK_MODULES(DUP,
PKG_CHECK_MODULES(PREF,
$GTK_MODULE >= $GTK_REQ_VER
gio-2.0 >= $GIO_REQ_VER
libsecret-1
libpeas-1.0)
PKG_CHECK_MODULES(COMMON,
gio-2.0 >= $GIO_REQ_VER
gio-unix-2.0 >= $GIO_REQ_VER
gnome-keyring-1
libsecret-1
libpeas-1.0
gmodule-2.0 >= $GLIB_REQ_VER)
PKG_CHECK_MODULES(WIDGETS,
gmodule-2.0 >= $GLIB_REQ_VER
$GTK_MODULE >= $GTK_REQ_VER
libsecret-1
libpeas-1.0
libnotify >= $NOTIFY_REQ_VER)
PKG_CHECK_MODULES(MONITOR,
gio-2.0 >= $GIO_REQ_VER
libsecret-1
libpeas-1.0
libnotify >= $NOTIFY_REQ_VER)
......
......@@ -55,7 +55,6 @@ public abstract class AssistantOperation : Assistant
protected bool nagged;
List<Gtk.Widget> first_password_widgets;
MainLoop password_ask_loop;
MainLoop password_find_loop;
DejaDup.ToggleGroup password_toggles;
Gtk.Label question_label;
......@@ -648,7 +647,7 @@ public abstract class AssistantOperation : Assistant
timeout_id = Timeout.add(250, pulse);
if (op != null && op.needs_password) {
// Operation is waiting for password
provide_password();
provide_password.begin();
}
else if (op == null)
do_apply.begin();
......@@ -728,43 +727,47 @@ public abstract class AssistantOperation : Assistant
}
}
void found_passphrase(GnomeKeyring.Result result, string? str)
async string? lookup_keyring()
{
if (str != null) {
op.set_passphrase(str);
try {
return yield Secret.password_lookup(DejaDup.get_passphrase_schema(),
null,
"owner", Config.PACKAGE,
"type", "passphrase");
}
else {
ask_passphrase();
catch (Error e) {
warning("%s\n", e.message);
return null;
}
password_find_loop.quit();
password_find_loop = null;
}
protected void get_passphrase()
{
if (!searched_for_passphrase && !DejaDup.in_testing_mode() &&
op.use_cached_password) {
// First, try user's keyring
GnomeKeyring.find_password(PASSPHRASE_SCHEMA,
found_passphrase,
"owner", Config.PACKAGE,
"type", "passphrase");
// If we get asked for passphrase again, it is because a
// saved or entered passphrase didn't work. So don't bother
// searching a second time.
searched_for_passphrase = true;
// block until found
password_find_loop = new MainLoop(null);
password_find_loop.run();
}
else {
// just jump straight to asking user
ask_passphrase();
string str = null;
// First, try user's keyring
var loop = new MainLoop(null);
lookup_keyring.begin((obj, res) => {
str = lookup_keyring.end(res);
loop.quit();
});
loop.run();
// Did we get anything?
if (str != null) {
op.set_passphrase(str);
return;
}
}
}
void save_password_callback(GnomeKeyring.Result result)
{
ask_passphrase();
}
void check_password_validity()
......@@ -849,7 +852,7 @@ public abstract class AssistantOperation : Assistant
password_ask_loop.run();
}
protected void provide_password()
protected async void provide_password()
{
var passphrase = "";
......@@ -863,12 +866,18 @@ public abstract class AssistantOperation : Assistant
if (passphrase != "") {
// Save it
if (encrypt_remember.active) {
GnomeKeyring.store_password(PASSPHRASE_SCHEMA,
GnomeKeyring.DEFAULT,
_("Backup encryption password"),
passphrase, save_password_callback,
"owner", Config.PACKAGE,
"type", "passphrase");
try {
yield Secret.password_store(DejaDup.get_passphrase_schema(),
Secret.COLLECTION_DEFAULT,
_("Backup encryption password"),
passphrase,
null,
"owner", Config.PACKAGE,
"type", "passphrase");
}
catch (Error e) {
warning("%s\n", e.message);
}
}
}
}
......
......@@ -491,7 +491,7 @@ public class AssistantRestore : AssistantOperation
query_timeout_id = Timeout.add(250, query_pulse);
if (query_op != null && query_op.needs_password) {
// Operation is waiting for password
provide_password();
provide_password.begin();
}
else if (query_op == null)
do_query.begin();
......
......@@ -234,10 +234,10 @@ public class AssistantRestoreMissing : AssistantRestore {
}
else {
if (query_op != null && query_op.needs_password) {
provide_password();
provide_password.begin();
}
else if (query_op_files != null && query_op_files.needs_password) {
provide_password();
provide_password.begin();
}
else if (!backups_queue_filled) {
do_query.begin();
......
......@@ -56,12 +56,10 @@ AM_VALAFLAGS = \
--pkg @GTK_MODULE@ \
--pkg gio-2.0 \
--pkg gio-unix-2.0 \
--pkg gnome-keyring-1 \
--pkg libpeas-1.0 \
--pkg libsecret-1 \
--pkg libnotify \
--pkg libcommon \
--pkg libwidgets \
--pkg keyring \
--pkg config
deja_dup_vala.stamp: $(top_srcdir)/config.h
......
......@@ -18,6 +18,6 @@
EXTRA_DIST = \
config.vapi \
keyring.vapi \
secret.vapi \
uriutils.vapi
......@@ -17,5 +17,10 @@
along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
*/
[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "chacks.h")]
public GnomeKeyring.PasswordSchema PASSPHRASE_SCHEMA;
/* TODO: libsecret-1.vapi does not have SECRET_SCHEMA_COMPAT_NETWORK yet */
[CCode (cprefix = "Secret", gir_namespace = "Secret", gir_version = "1", lower_case_cprefix = "secret_")]
namespace Secret {
[CCode (cheader_filename = "libsecret/secret.h", cname = "SECRET_SCHEMA_COMPAT_NETWORK")]
public Secret.Schema SCHEMA_COMPAT_NETWORK;
}
......@@ -80,7 +80,6 @@ AM_VALAFLAGS = \
$(UNITY_VALAFLAGS) \
--pkg libcommon \
--pkg @GTK_MODULE@ \
--pkg libpeas-1.0 \
--pkg uriutils \
--pkg libnotify \
--pkg config
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment