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

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

Issue 1929573002: Changed location of LibsecretLoader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed compilation error Created 4 years, 7 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/os_crypt/libsecret_loader.h"
6
7 #include <dlfcn.h>
8
9 #include "base/logging.h"
10
11 decltype(&::secret_password_store_sync)
12 LibsecretLoader::secret_password_store_sync;
13 decltype(&::secret_service_search_sync)
14 LibsecretLoader::secret_service_search_sync;
15 decltype(&::secret_password_clear_sync)
16 LibsecretLoader::secret_password_clear_sync;
17 decltype(&::secret_item_get_secret) LibsecretLoader::secret_item_get_secret;
18 decltype(&::secret_value_get_text) LibsecretLoader::secret_value_get_text;
19 decltype(&::secret_item_get_attributes)
20 LibsecretLoader::secret_item_get_attributes;
21 decltype(&::secret_item_load_secret_sync)
22 LibsecretLoader::secret_item_load_secret_sync;
23 decltype(&::secret_value_unref) LibsecretLoader::secret_value_unref;
24
25 bool LibsecretLoader::libsecret_loaded = false;
26
27 const LibsecretLoader::FunctionInfo LibsecretLoader::functions[] = {
28 {"secret_password_store_sync",
29 reinterpret_cast<void**>(&secret_password_store_sync)},
30 {"secret_service_search_sync",
31 reinterpret_cast<void**>(&secret_service_search_sync)},
32 {"secret_password_clear_sync",
33 reinterpret_cast<void**>(&secret_password_clear_sync)},
34 {"secret_item_get_secret",
35 reinterpret_cast<void**>(&secret_item_get_secret)},
36 {"secret_value_get_text", reinterpret_cast<void**>(&secret_value_get_text)},
37 {"secret_item_get_attributes",
38 reinterpret_cast<void**>(&secret_item_get_attributes)},
39 {"secret_item_load_secret_sync",
40 reinterpret_cast<void**>(&secret_item_load_secret_sync)},
41 {"secret_value_unref", reinterpret_cast<void**>(&secret_value_unref)}};
42
43 //static
vabr (Chromium) 2016/04/28 12:44:25 nit: The style requires a space between the "//" a
cfroussios 2016/04/28 14:33:43 Done.
44 bool LibsecretLoader::LoadLibsecret() {
45 if (libsecret_loaded)
46 return true;
47
48 void* handle = dlopen("libsecret-1.so.0", RTLD_NOW | RTLD_GLOBAL);
49 if (!handle) {
50 // We wanted to use libsecret, but we couldn't load it. Warn, because
51 // either the user asked for this, or we autodetected it incorrectly. (Or
52 // the system has broken libraries, which is also good to warn about.)
53 // TODO(crbug.com/607435)
vabr (Chromium) 2016/04/28 12:44:25 nit: Please also add the TODO message itself, like
cfroussios 2016/04/28 14:33:43 Done.
54 VLOG(1) << "Could not load libsecret-1.so.0: " << dlerror();
55 return false;
56 }
57
58 for (const auto& function : functions) {
59 dlerror();
60 *function.pointer = dlsym(handle, function.name);
61 const char* error = dlerror();
62 if (error) {
63 VLOG(1) << "Unable to load symbol " << function.name << ": " << error;
64 dlclose(handle);
65 return false;
66 }
67 }
68
69 libsecret_loaded = true;
70 // We leak the library handle. That's OK: this function is called only once.
71 return true;
72 }
73
OLDNEW
« components/os_crypt/libsecret_loader.h ('K') | « components/os_crypt/libsecret_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698