Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(745)

Side by Side Diff: components/os_crypt/keyring_util_linux.cc

Issue 2297573002: Implement gnome-keyring for OSCrypt (Closed)
Patch Set: removed thread checker Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/os_crypt/keyring_util_linux.h ('k') | components/os_crypt/os_crypt_mocker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/os_crypt/keyring_util_linux.h" 5 #include "components/os_crypt/keyring_util_linux.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 decltype(&::gnome_keyring_is_available) 11 decltype(&::gnome_keyring_is_available)
12 GnomeKeyringLoader::gnome_keyring_is_available_ptr; 12 GnomeKeyringLoader::gnome_keyring_is_available_ptr;
13 decltype(&::gnome_keyring_store_password) 13 decltype(&::gnome_keyring_store_password)
14 GnomeKeyringLoader::gnome_keyring_store_password_ptr; 14 GnomeKeyringLoader::gnome_keyring_store_password_ptr;
15 decltype(&::gnome_keyring_delete_password) 15 decltype(&::gnome_keyring_delete_password)
16 GnomeKeyringLoader::gnome_keyring_delete_password_ptr; 16 GnomeKeyringLoader::gnome_keyring_delete_password_ptr;
17 decltype(&::gnome_keyring_find_items) 17 decltype(&::gnome_keyring_find_items)
18 GnomeKeyringLoader::gnome_keyring_find_items_ptr; 18 GnomeKeyringLoader::gnome_keyring_find_items_ptr;
19 decltype(&::gnome_keyring_find_password_sync)
20 GnomeKeyringLoader::gnome_keyring_find_password_sync_ptr;
21 decltype(&::gnome_keyring_store_password_sync)
22 GnomeKeyringLoader::gnome_keyring_store_password_sync_ptr;
23
19 decltype(&::gnome_keyring_result_to_message) 24 decltype(&::gnome_keyring_result_to_message)
20 GnomeKeyringLoader::gnome_keyring_result_to_message_ptr; 25 GnomeKeyringLoader::gnome_keyring_result_to_message_ptr;
21 decltype(&::gnome_keyring_attribute_list_free) 26 decltype(&::gnome_keyring_attribute_list_free)
22 GnomeKeyringLoader::gnome_keyring_attribute_list_free_ptr; 27 GnomeKeyringLoader::gnome_keyring_attribute_list_free_ptr;
23 decltype(&::gnome_keyring_attribute_list_new) 28 decltype(&::gnome_keyring_attribute_list_new)
24 GnomeKeyringLoader::gnome_keyring_attribute_list_new_ptr; 29 GnomeKeyringLoader::gnome_keyring_attribute_list_new_ptr;
25 decltype(&::gnome_keyring_attribute_list_append_string) 30 decltype(&::gnome_keyring_attribute_list_append_string)
26 GnomeKeyringLoader::gnome_keyring_attribute_list_append_string_ptr; 31 GnomeKeyringLoader::gnome_keyring_attribute_list_append_string_ptr;
27 decltype(&::gnome_keyring_attribute_list_append_uint32) 32 decltype(&::gnome_keyring_attribute_list_append_uint32)
28 GnomeKeyringLoader::gnome_keyring_attribute_list_append_uint32_ptr; 33 GnomeKeyringLoader::gnome_keyring_attribute_list_append_uint32_ptr;
34 decltype(&::gnome_keyring_free_password)
35 GnomeKeyringLoader::gnome_keyring_free_password_ptr;
29 36
30 bool GnomeKeyringLoader::keyring_loaded = false; 37 bool GnomeKeyringLoader::keyring_loaded = false;
31 38
32 const GnomeKeyringLoader::FunctionInfo GnomeKeyringLoader::functions[] = { 39 const GnomeKeyringLoader::FunctionInfo GnomeKeyringLoader::functions[] = {
33 {"gnome_keyring_is_available", 40 {"gnome_keyring_is_available",
34 reinterpret_cast<void**>(&gnome_keyring_is_available_ptr)}, 41 reinterpret_cast<void**>(&gnome_keyring_is_available_ptr)},
35 {"gnome_keyring_store_password", 42 {"gnome_keyring_store_password",
36 reinterpret_cast<void**>(&gnome_keyring_store_password_ptr)}, 43 reinterpret_cast<void**>(&gnome_keyring_store_password_ptr)},
37 {"gnome_keyring_delete_password", 44 {"gnome_keyring_delete_password",
38 reinterpret_cast<void**>(&gnome_keyring_delete_password_ptr)}, 45 reinterpret_cast<void**>(&gnome_keyring_delete_password_ptr)},
39 {"gnome_keyring_find_items", 46 {"gnome_keyring_find_items",
40 reinterpret_cast<void**>(&gnome_keyring_find_items_ptr)}, 47 reinterpret_cast<void**>(&gnome_keyring_find_items_ptr)},
48 {"gnome_keyring_find_password_sync",
49 reinterpret_cast<void**>(&gnome_keyring_find_password_sync_ptr)},
50 {"gnome_keyring_store_password_sync",
51 reinterpret_cast<void**>(&gnome_keyring_store_password_sync_ptr)},
52
41 {"gnome_keyring_result_to_message", 53 {"gnome_keyring_result_to_message",
42 reinterpret_cast<void**>(&gnome_keyring_result_to_message_ptr)}, 54 reinterpret_cast<void**>(&gnome_keyring_result_to_message_ptr)},
43 {"gnome_keyring_attribute_list_free", 55 {"gnome_keyring_attribute_list_free",
44 reinterpret_cast<void**>(&gnome_keyring_attribute_list_free_ptr)}, 56 reinterpret_cast<void**>(&gnome_keyring_attribute_list_free_ptr)},
45 {"gnome_keyring_attribute_list_new", 57 {"gnome_keyring_attribute_list_new",
46 reinterpret_cast<void**>(&gnome_keyring_attribute_list_new_ptr)}, 58 reinterpret_cast<void**>(&gnome_keyring_attribute_list_new_ptr)},
47 {"gnome_keyring_attribute_list_append_string", 59 {"gnome_keyring_attribute_list_append_string",
48 reinterpret_cast<void**>(&gnome_keyring_attribute_list_append_string_ptr)}, 60 reinterpret_cast<void**>(&gnome_keyring_attribute_list_append_string_ptr)},
49 {"gnome_keyring_attribute_list_append_uint32", 61 {"gnome_keyring_attribute_list_append_uint32",
50 reinterpret_cast<void**>( 62 reinterpret_cast<void**>(&gnome_keyring_attribute_list_append_uint32_ptr)},
51 &gnome_keyring_attribute_list_append_uint32_ptr)}}; 63 {"gnome_keyring_free_password",
64 reinterpret_cast<void**>(&gnome_keyring_free_password_ptr)}};
52 65
53 /* Load the library and initialize the function pointers. */ 66 /* Load the library and initialize the function pointers. */
54 bool GnomeKeyringLoader::LoadGnomeKeyring() { 67 bool GnomeKeyringLoader::LoadGnomeKeyring() {
55 if (keyring_loaded) 68 if (keyring_loaded)
56 return true; 69 return true;
57 70
58 void* handle = dlopen("libgnome-keyring.so.0", RTLD_NOW | RTLD_GLOBAL); 71 void* handle = dlopen("libgnome-keyring.so.0", RTLD_NOW | RTLD_GLOBAL);
59 if (!handle) { 72 if (!handle) {
60 // We wanted to use GNOME Keyring, but we couldn't load it. Warn, because 73 // We wanted to use GNOME Keyring, but we couldn't load it. Warn, because
61 // either the user asked for this, or we autodetected it incorrectly. (Or 74 // either the user asked for this, or we autodetected it incorrectly. (Or
(...skipping 11 matching lines...) Expand all
73 << error; 86 << error;
74 dlclose(handle); 87 dlclose(handle);
75 return false; 88 return false;
76 } 89 }
77 } 90 }
78 91
79 keyring_loaded = true; 92 keyring_loaded = true;
80 // We leak the library handle. That's OK: this function is called only once. 93 // We leak the library handle. That's OK: this function is called only once.
81 return true; 94 return true;
82 } 95 }
OLDNEW
« no previous file with comments | « components/os_crypt/keyring_util_linux.h ('k') | components/os_crypt/os_crypt_mocker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698