Commit b013c15b authored by cfroussios's avatar cfroussios Committed by Commit bot

Implement gnome-keyring for OSCrypt

OSCrypt can now save its encryption password in gnome-keyring, where
that library exists.

BUG=602624

Review-Url: https://codereview.chromium.org/2297573002
Cr-Commit-Position: refs/heads/master@{#416423}
parent 28274a46
...@@ -81,10 +81,13 @@ static_library("os_crypt") { ...@@ -81,10 +81,13 @@ static_library("os_crypt") {
if (use_gnome_keyring) { if (use_gnome_keyring) {
sources += [ sources += [
"key_storage_keyring.cc",
"key_storage_keyring.h",
"keyring_util_linux.cc", "keyring_util_linux.cc",
"keyring_util_linux.h", "keyring_util_linux.h",
] ]
configs += [ ":gnome_keyring" ] configs += [ ":gnome_keyring" ]
defines += [ "USE_KEYRING" ]
} }
if (use_glib) { if (use_glib) {
sources += [ sources += [
...@@ -127,6 +130,9 @@ static_library("test_support") { ...@@ -127,6 +130,9 @@ static_library("test_support") {
"os_crypt_mocker_linux.h", "os_crypt_mocker_linux.h",
] ]
defines = [] defines = []
if (use_gnome_keyring) {
defines += [ "USE_KEYRING" ]
}
if (use_glib) { if (use_glib) {
defines += [ "USE_LIBSECRET" ] defines += [ "USE_LIBSECRET" ]
} }
...@@ -156,6 +162,12 @@ source_set("unit_tests") { ...@@ -156,6 +162,12 @@ source_set("unit_tests") {
sources += [ "os_crypt_linux_unittest.cc" ] sources += [ "os_crypt_linux_unittest.cc" ]
defines = [] defines = []
if (use_gnome_keyring) {
sources += [ "key_storage_keyring_unittest.cc" ]
configs += [ ":gnome_keyring" ]
deps += [ "//base/test:test_support" ]
defines += [ "USE_KEYRING" ]
}
if (use_glib) { if (use_glib) {
sources += [ "key_storage_libsecret_unittest.cc" ] sources += [ "key_storage_libsecret_unittest.cc" ]
deps += [ "//third_party/libsecret" ] deps += [ "//third_party/libsecret" ]
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/os_crypt/key_storage_keyring.h"
#include <gnome-keyring.h>
#include "base/base64.h"
#include "base/bind.h"
#include "base/rand_util.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "components/os_crypt/keyring_util_linux.h"
namespace {
#if defined(GOOGLE_CHROME_BUILD)
const char kApplicationName[] = "chrome";
#else
const char kApplicationName[] = "chromium";
#endif
const GnomeKeyringPasswordSchema kSchema = {
GNOME_KEYRING_ITEM_GENERIC_SECRET,
{{"application", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING}, {nullptr}}};
} // namespace
KeyStorageKeyring::KeyStorageKeyring(
scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner)
: main_thread_runner_(main_thread_runner) {}
KeyStorageKeyring::~KeyStorageKeyring() {}
bool KeyStorageKeyring::Init() {
return GnomeKeyringLoader::LoadGnomeKeyring();
}
std::string KeyStorageKeyring::GetKey() {
std::string password;
// Ensure GetKeyDelegate() is executed on the main thread.
if (main_thread_runner_->BelongsToCurrentThread()) {
GetKeyDelegate(&password, nullptr);
} else {
base::WaitableEvent password_loaded(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
main_thread_runner_->PostTask(
FROM_HERE,
base::Bind(&KeyStorageKeyring::GetKeyDelegate, base::Unretained(this),
&password, &password_loaded));
password_loaded.Wait();
}
return password;
}
void KeyStorageKeyring::GetKeyDelegate(
std::string* password_ptr,
base::WaitableEvent* password_loaded_ptr) {
gchar* password = nullptr;
GnomeKeyringResult result =
GnomeKeyringLoader::gnome_keyring_find_password_sync_ptr(
&kSchema, &password, "application", kApplicationName, nullptr);
if (result == GNOME_KEYRING_RESULT_OK) {
*password_ptr = password;
GnomeKeyringLoader::gnome_keyring_free_password_ptr(password);
} else if (result == GNOME_KEYRING_RESULT_NO_MATCH) {
*password_ptr = KeyStorageKeyring::AddRandomPasswordInKeyring();
VLOG(1) << "OSCrypt generated a new password";
} else {
password_ptr->clear();
VLOG(1) << "OSCrypt failed to use gnome-keyring";
}
if (password_loaded_ptr)
password_loaded_ptr->Signal();
}
std::string KeyStorageKeyring::AddRandomPasswordInKeyring() {
// Generate password
std::string password;
base::Base64Encode(base::RandBytesAsString(16), &password);
// Store generated password
GnomeKeyringResult result =
GnomeKeyringLoader::gnome_keyring_store_password_sync_ptr(
&kSchema, nullptr /* default keyring */, KeyStorageLinux::kKey,
password.c_str(), "application", kApplicationName, nullptr);
if (result != GNOME_KEYRING_RESULT_OK) {
VLOG(1) << "Failed to store generated password to gnome-keyring";
return std::string();
}
return password;
}
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_OS_CRYPT_KEY_STORAGE_KEYRING_H_
#define COMPONENTS_OS_CRYPT_KEY_STORAGE_KEYRING_H_
#include <string>
#include "base/macros.h"
#include "components/os_crypt/key_storage_linux.h"
namespace base {
class SingleThreadTaskRunner;
class WaitableEvent;
} // namespace base
// Specialisation of KeyStorageLinux that uses Libsecret.
class KeyStorageKeyring : public KeyStorageLinux {
public:
explicit KeyStorageKeyring(
scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner);
~KeyStorageKeyring() override;
// KeyStorageLinux
std::string GetKey() override;
protected:
// KeyStorageLinux
bool Init() override;
private:
// Gnome keyring requires calls to originate from the main thread.
// This is the part of GetKey() that gets dispatched to the main thread.
// The password is stored in |password_ptr|. If |password_loaded_ptr| is not
// null, it will be signaled when |password_ptr| is safe to read.
void GetKeyDelegate(std::string* password_ptr,
base::WaitableEvent* password_loaded_ptr);
// Generate a random string and store it as OScrypt's new password.
std::string AddRandomPasswordInKeyring();
// Keyring calls need to originate from the main thread.
scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_;
DISALLOW_COPY_AND_ASSIGN(KeyStorageKeyring);
};
#endif // COMPONENTS_OS_CRYPT_KEY_STORAGE_KEYRING_H_
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <cstdarg> // Needed to mock ellipsis
#include <string>
#include "base/macros.h"
#include "base/test/test_simple_task_runner.h"
#include "components/os_crypt/key_storage_keyring.h"
#include "components/os_crypt/keyring_util_linux.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
#if defined(GOOGLE_CHROME_BUILD)
const char kApplicationName[] = "chrome";
#else
const char kApplicationName[] = "chromium";
#endif
// Replaces some of GnomeKeyringLoader's methods with mocked ones.
class MockGnomeKeyringLoader : public GnomeKeyringLoader {
public:
static void ResetForOSCrypt() {
GnomeKeyringLoader::gnome_keyring_find_password_sync_ptr =
&mock_gnome_keyring_find_password_sync;
GnomeKeyringLoader::gnome_keyring_store_password_sync_ptr =
&mock_gnome_keyring_store_password_sync;
GnomeKeyringLoader::gnome_keyring_free_password_ptr =
&mock_gnome_keyring_free_password;
delete s_password_ptr_;
s_password_ptr_ = nullptr;
// GnomeKeyringLoader does not (re)load keyring is this is true.
GnomeKeyringLoader::keyring_loaded = true;
}
static void SetOSCryptPassword(const char* password) {
delete s_password_ptr_;
s_password_ptr_ = new std::string(password);
}
static void TearDown() {
delete s_password_ptr_;
s_password_ptr_ = nullptr;
// Function pointers will be reset the next time loading is requested.
GnomeKeyringLoader::keyring_loaded = false;
}
private:
// These methods are used to redirect calls through GnomeKeyringLoader.
static GnomeKeyringResult mock_gnome_keyring_find_password_sync(
const GnomeKeyringPasswordSchema* schema,
gchar** password,
...);
static GnomeKeyringResult mock_gnome_keyring_store_password_sync(
const GnomeKeyringPasswordSchema* schema,
const gchar* keyring,
const gchar* display_name,
const gchar* password,
...);
static void mock_gnome_keyring_free_password(gchar* password);
static std::string* s_password_ptr_;
};
std::string* MockGnomeKeyringLoader::s_password_ptr_ = nullptr;
// static
GnomeKeyringResult
MockGnomeKeyringLoader::mock_gnome_keyring_find_password_sync(
const GnomeKeyringPasswordSchema* schema,
gchar** password,
...) {
va_list attrs;
va_start(attrs, password);
EXPECT_STREQ("application", va_arg(attrs, const char*));
EXPECT_STREQ(kApplicationName, va_arg(attrs, const char*));
EXPECT_EQ(nullptr, va_arg(attrs, const char*));
va_end(attrs);
if (!s_password_ptr_)
return GNOME_KEYRING_RESULT_NO_MATCH;
*password = strdup(s_password_ptr_->c_str());
return GNOME_KEYRING_RESULT_OK;
}
// static
GnomeKeyringResult
MockGnomeKeyringLoader::mock_gnome_keyring_store_password_sync(
const GnomeKeyringPasswordSchema* schema,
const gchar* keyring,
const gchar* display_name,
const gchar* password,
...) {
va_list attrs;
va_start(attrs, password);
EXPECT_STREQ("application", va_arg(attrs, const char*));
EXPECT_STREQ(kApplicationName, va_arg(attrs, const char*));
EXPECT_EQ(nullptr, va_arg(attrs, const char*));
va_end(attrs);
delete s_password_ptr_;
s_password_ptr_ = new std::string(password);
return GNOME_KEYRING_RESULT_OK;
}
// static
void MockGnomeKeyringLoader::mock_gnome_keyring_free_password(gchar* password) {
free(password); // We are mocking a C function.
}
class GnomeKeyringTest : public testing::Test {
public:
GnomeKeyringTest();
~GnomeKeyringTest() override;
protected:
scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
KeyStorageKeyring keyring_;
private:
DISALLOW_COPY_AND_ASSIGN(GnomeKeyringTest);
};
GnomeKeyringTest::GnomeKeyringTest()
: task_runner_(new base::TestSimpleTaskRunner()), keyring_(task_runner_) {
MockGnomeKeyringLoader::ResetForOSCrypt();
}
GnomeKeyringTest::~GnomeKeyringTest() {
MockGnomeKeyringLoader::TearDown();
}
TEST_F(GnomeKeyringTest, KeyringRepeats) {
std::string password = keyring_.GetKey();
EXPECT_FALSE(password.empty());
std::string password_repeat = keyring_.GetKey();
EXPECT_EQ(password, password_repeat);
}
TEST_F(GnomeKeyringTest, KeyringCreatesRandomised) {
std::string password = keyring_.GetKey();
MockGnomeKeyringLoader::ResetForOSCrypt();
std::string password_new = keyring_.GetKey();
EXPECT_NE(password, password_new);
}
} // namespace
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <string> #include <string>
#include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "components/os_crypt/key_storage_libsecret.h" #include "components/os_crypt/key_storage_libsecret.h"
#include "components/os_crypt/libsecret_util_linux.h" #include "components/os_crypt/libsecret_util_linux.h"
......
...@@ -8,12 +8,15 @@ ...@@ -8,12 +8,15 @@
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/nix/xdg_util.h" #include "base/nix/xdg_util.h"
#include "base/single_thread_task_runner.h"
#include "components/os_crypt/key_storage_util_linux.h" #include "components/os_crypt/key_storage_util_linux.h"
#if defined(USE_LIBSECRET) #if defined(USE_LIBSECRET)
#include "components/os_crypt/key_storage_libsecret.h" #include "components/os_crypt/key_storage_libsecret.h"
#endif #endif
#if defined(USE_KEYRING)
#include "components/os_crypt/key_storage_keyring.h"
#endif
#if defined(USE_KWALLET) #if defined(USE_KWALLET)
#include "components/os_crypt/key_storage_kwallet.h" #include "components/os_crypt/key_storage_kwallet.h"
#endif #endif
...@@ -67,19 +70,34 @@ std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() { ...@@ -67,19 +70,34 @@ std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() {
os_crypt::SelectBackend(g_config.Get().store, desktop_env); os_crypt::SelectBackend(g_config.Get().store, desktop_env);
// Try initializing the selected backend. // Try initializing the selected backend.
// In case of GNOME_ANY, prefer Libsecret
std::unique_ptr<KeyStorageLinux> key_storage; std::unique_ptr<KeyStorageLinux> key_storage;
#if defined(USE_LIBSECRET)
if (selected_backend == os_crypt::SelectedLinuxBackend::GNOME_ANY || if (selected_backend == os_crypt::SelectedLinuxBackend::GNOME_ANY ||
selected_backend == os_crypt::SelectedLinuxBackend::GNOME_LIBSECRET) { selected_backend == os_crypt::SelectedLinuxBackend::GNOME_LIBSECRET) {
#if defined(USE_LIBSECRET)
key_storage.reset(new KeyStorageLibsecret()); key_storage.reset(new KeyStorageLibsecret());
if (key_storage->Init()) { if (key_storage->Init()) {
VLOG(1) << "OSCrypt using Libsecret as backend."; VLOG(1) << "OSCrypt using Libsecret as backend.";
return key_storage; return key_storage;
} }
}
#endif
#if defined(USE_KEYRING)
if (selected_backend == os_crypt::SelectedLinuxBackend::GNOME_ANY ||
selected_backend == os_crypt::SelectedLinuxBackend::GNOME_KEYRING) {
key_storage.reset(new KeyStorageKeyring(g_config.Get().main_thread_runner));
if (key_storage->Init()) {
VLOG(1) << "OSCrypt using Keyring as backend.";
return key_storage;
}
}
#endif #endif
} else if (selected_backend == os_crypt::SelectedLinuxBackend::KWALLET ||
selected_backend == os_crypt::SelectedLinuxBackend::KWALLET5) {
#if defined(USE_KWALLET) #if defined(USE_KWALLET)
if (selected_backend == os_crypt::SelectedLinuxBackend::KWALLET ||
selected_backend == os_crypt::SelectedLinuxBackend::KWALLET5) {
DCHECK(!g_config.Get().product_name.empty()); DCHECK(!g_config.Get().product_name.empty());
base::nix::DesktopEnvironment used_desktop_env = base::nix::DesktopEnvironment used_desktop_env =
selected_backend == os_crypt::SelectedLinuxBackend::KWALLET selected_backend == os_crypt::SelectedLinuxBackend::KWALLET
...@@ -91,8 +109,8 @@ std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() { ...@@ -91,8 +109,8 @@ std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() {
VLOG(1) << "OSCrypt using KWallet as backend."; VLOG(1) << "OSCrypt using KWallet as backend.";
return key_storage; return key_storage;
} }
#endif
} }
#endif
// The appropriate store was not available. // The appropriate store was not available.
VLOG(1) << "OSCrypt could not initialize a backend."; VLOG(1) << "OSCrypt could not initialize a backend.";
......
...@@ -10,7 +10,10 @@ ...@@ -10,7 +10,10 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
namespace base {
class SingleThreadTaskRunner;
} // namespace base
// An API for retrieving OSCrypt's password from the system's password storage // An API for retrieving OSCrypt's password from the system's password storage
// service. // service.
......
...@@ -16,6 +16,11 @@ decltype(&::gnome_keyring_delete_password) ...@@ -16,6 +16,11 @@ decltype(&::gnome_keyring_delete_password)
GnomeKeyringLoader::gnome_keyring_delete_password_ptr; GnomeKeyringLoader::gnome_keyring_delete_password_ptr;
decltype(&::gnome_keyring_find_items) decltype(&::gnome_keyring_find_items)
GnomeKeyringLoader::gnome_keyring_find_items_ptr; GnomeKeyringLoader::gnome_keyring_find_items_ptr;
decltype(&::gnome_keyring_find_password_sync)
GnomeKeyringLoader::gnome_keyring_find_password_sync_ptr;
decltype(&::gnome_keyring_store_password_sync)
GnomeKeyringLoader::gnome_keyring_store_password_sync_ptr;
decltype(&::gnome_keyring_result_to_message) decltype(&::gnome_keyring_result_to_message)
GnomeKeyringLoader::gnome_keyring_result_to_message_ptr; GnomeKeyringLoader::gnome_keyring_result_to_message_ptr;
decltype(&::gnome_keyring_attribute_list_free) decltype(&::gnome_keyring_attribute_list_free)
...@@ -26,6 +31,8 @@ decltype(&::gnome_keyring_attribute_list_append_string) ...@@ -26,6 +31,8 @@ decltype(&::gnome_keyring_attribute_list_append_string)
GnomeKeyringLoader::gnome_keyring_attribute_list_append_string_ptr; GnomeKeyringLoader::gnome_keyring_attribute_list_append_string_ptr;
decltype(&::gnome_keyring_attribute_list_append_uint32) decltype(&::gnome_keyring_attribute_list_append_uint32)
GnomeKeyringLoader::gnome_keyring_attribute_list_append_uint32_ptr; GnomeKeyringLoader::gnome_keyring_attribute_list_append_uint32_ptr;
decltype(&::gnome_keyring_free_password)
GnomeKeyringLoader::gnome_keyring_free_password_ptr;
bool GnomeKeyringLoader::keyring_loaded = false; bool GnomeKeyringLoader::keyring_loaded = false;
...@@ -38,6 +45,11 @@ const GnomeKeyringLoader::FunctionInfo GnomeKeyringLoader::functions[] = { ...@@ -38,6 +45,11 @@ const GnomeKeyringLoader::FunctionInfo GnomeKeyringLoader::functions[] = {
reinterpret_cast<void**>(&gnome_keyring_delete_password_ptr)}, reinterpret_cast<void**>(&gnome_keyring_delete_password_ptr)},
{"gnome_keyring_find_items", {"gnome_keyring_find_items",
reinterpret_cast<void**>(&gnome_keyring_find_items_ptr)}, reinterpret_cast<void**>(&gnome_keyring_find_items_ptr)},
{"gnome_keyring_find_password_sync",
reinterpret_cast<void**>(&gnome_keyring_find_password_sync_ptr)},
{"gnome_keyring_store_password_sync",
reinterpret_cast<void**>(&gnome_keyring_store_password_sync_ptr)},
{"gnome_keyring_result_to_message", {"gnome_keyring_result_to_message",
reinterpret_cast<void**>(&gnome_keyring_result_to_message_ptr)}, reinterpret_cast<void**>(&gnome_keyring_result_to_message_ptr)},
{"gnome_keyring_attribute_list_free", {"gnome_keyring_attribute_list_free",
...@@ -47,8 +59,9 @@ const GnomeKeyringLoader::FunctionInfo GnomeKeyringLoader::functions[] = { ...@@ -47,8 +59,9 @@ const GnomeKeyringLoader::FunctionInfo GnomeKeyringLoader::functions[] = {
{"gnome_keyring_attribute_list_append_string", {"gnome_keyring_attribute_list_append_string",
reinterpret_cast<void**>(&gnome_keyring_attribute_list_append_string_ptr)}, reinterpret_cast<void**>(&gnome_keyring_attribute_list_append_string_ptr)},
{"gnome_keyring_attribute_list_append_uint32", {"gnome_keyring_attribute_list_append_uint32",
reinterpret_cast<void**>( reinterpret_cast<void**>(&gnome_keyring_attribute_list_append_uint32_ptr)},
&gnome_keyring_attribute_list_append_uint32_ptr)}}; {"gnome_keyring_free_password",
reinterpret_cast<void**>(&gnome_keyring_free_password_ptr)}};
/* Load the library and initialize the function pointers. */ /* Load the library and initialize the function pointers. */
bool GnomeKeyringLoader::LoadGnomeKeyring() { bool GnomeKeyringLoader::LoadGnomeKeyring() {
......
...@@ -27,16 +27,23 @@ ...@@ -27,16 +27,23 @@
// from GnomeKeyringLoader will use its versions of the gnome_keyring_* // from GnomeKeyringLoader will use its versions of the gnome_keyring_*
// functions. Note that it has only static fields. // functions. Note that it has only static fields.
class GnomeKeyringLoader { class GnomeKeyringLoader {
protected: public:
static bool LoadGnomeKeyring(); static bool LoadGnomeKeyring();
// Declare the actual function pointers that we'll use in client code. // Declare the actual function pointers that we'll use in client code.
// These functions will contact the service.
static decltype(&::gnome_keyring_is_available) gnome_keyring_is_available_ptr; static decltype(&::gnome_keyring_is_available) gnome_keyring_is_available_ptr;
static decltype( static decltype(
&::gnome_keyring_store_password) gnome_keyring_store_password_ptr; &::gnome_keyring_store_password) gnome_keyring_store_password_ptr;
static decltype( static decltype(
&::gnome_keyring_delete_password) gnome_keyring_delete_password_ptr; &::gnome_keyring_delete_password) gnome_keyring_delete_password_ptr;
static decltype(&::gnome_keyring_find_items) gnome_keyring_find_items_ptr; static decltype(&::gnome_keyring_find_items) gnome_keyring_find_items_ptr;
static decltype(
&::gnome_keyring_find_password_sync) gnome_keyring_find_password_sync_ptr;
static decltype(&::gnome_keyring_store_password_sync)
gnome_keyring_store_password_sync_ptr;
// These functions do not contact the service.
static decltype( static decltype(
&::gnome_keyring_result_to_message) gnome_keyring_result_to_message_ptr; &::gnome_keyring_result_to_message) gnome_keyring_result_to_message_ptr;
static decltype(&::gnome_keyring_attribute_list_free) static decltype(&::gnome_keyring_attribute_list_free)
...@@ -47,9 +54,12 @@ class GnomeKeyringLoader { ...@@ -47,9 +54,12 @@ class GnomeKeyringLoader {
gnome_keyring_attribute_list_append_string_ptr; gnome_keyring_attribute_list_append_string_ptr;
static decltype(&::gnome_keyring_attribute_list_append_uint32) static decltype(&::gnome_keyring_attribute_list_append_uint32)
gnome_keyring_attribute_list_append_uint32_ptr; gnome_keyring_attribute_list_append_uint32_ptr;
static decltype(
&::gnome_keyring_free_password) gnome_keyring_free_password_ptr;
// We also use gnome_keyring_attribute_list_index(), which is a macro and // We also use gnome_keyring_attribute_list_index(), which is a macro and
// can't be referenced. // can't be referenced.
protected:
// Set to true if LoadGnomeKeyring() has already succeeded. // Set to true if LoadGnomeKeyring() has already succeeded.
static bool keyring_loaded; static bool keyring_loaded;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
void OSCryptMocker::SetUpWithSingleton() { void OSCryptMocker::SetUpWithSingleton() {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
OSCrypt::UseMockKeychain(true); OSCrypt::UseMockKeychain(true);
#elif defined(USE_LIBSECRET) #elif defined(USE_LIBSECRET) || defined(USE_KEYRING) || defined(USE_KWALLET)
OSCryptMockerLinux::SetUpWithSingleton(); OSCryptMockerLinux::SetUpWithSingleton();
#endif #endif
} }
...@@ -23,7 +23,7 @@ void OSCryptMocker::SetUpWithSingleton() { ...@@ -23,7 +23,7 @@ void OSCryptMocker::SetUpWithSingleton() {
void OSCryptMocker::TearDown() { void OSCryptMocker::TearDown() {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
OSCrypt::UseMockKeychain(false); OSCrypt::UseMockKeychain(false);
#elif defined(USE_LIBSECRET) #elif defined(USE_LIBSECRET) || defined(USE_KEYRING) || defined(USE_KWALLET)
OSCryptMockerLinux::TearDown(); OSCryptMockerLinux::TearDown();
#endif #endif
} }
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