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

Unified Diff: components/os_crypt/key_storage_util_linux.cc

Issue 2948783002: Create setting that disables password stores (Closed)
Patch Set: lint Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: components/os_crypt/key_storage_util_linux.cc
diff --git a/components/os_crypt/key_storage_util_linux.cc b/components/os_crypt/key_storage_util_linux.cc
index 5be4252e58c11fb257763ecf4ef164d95c77fc64..713e772db84fc8d187c81158163859520749cec3 100644
--- a/components/os_crypt/key_storage_util_linux.cc
+++ b/components/os_crypt/key_storage_util_linux.cc
@@ -4,11 +4,34 @@
#include "components/os_crypt/key_storage_util_linux.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/logging.h"
+#include "base/pickle.h"
vabr (Chromium) 2017/07/03 19:27:14 Unused?
cfroussios 2017/07/04 09:58:15 Done.
+
+namespace {
+// OSCrypt has a setting that determines whether a backend will be used.
+// The presense of this file in the file system means that the backend
+// should be ignored. It's absence means we should use the backend.
+const char kPreferencesFileName[] = "Disable OSCrypt";
vabr (Chromium) 2017/07/03 19:27:14 nit: constexpr?
cfroussios 2017/07/04 09:58:15 Done.
+}
+
+namespace {
vabr (Chromium) 2017/07/03 19:27:14 nit: Why not merge the two consecutive anonymous n
cfroussios 2017/07/04 09:58:15 Done.
+
+bool ReadBackendUse(const base::FilePath& user_data_dir, bool* use) {
+ if (user_data_dir.empty())
+ return false;
+ base::FilePath pref_path = user_data_dir.Append(kPreferencesFileName);
+ *use = !base::PathExists(pref_path);
+ return true;
+}
+
+} // namespace
namespace os_crypt {
SelectedLinuxBackend SelectBackend(const std::string& type,
+ bool use_backend,
base::nix::DesktopEnvironment desktop_env) {
if (type == "kwallet")
return SelectedLinuxBackend::KWALLET;
@@ -23,6 +46,9 @@ SelectedLinuxBackend SelectBackend(const std::string& type,
if (type == "basic")
return SelectedLinuxBackend::BASIC_TEXT;
+ if (!use_backend)
vabr (Chromium) 2017/07/03 19:27:14 nit: Please comment on the need to place this unde
cfroussios 2017/07/04 09:58:15 Done.
+ return SelectedLinuxBackend::BASIC_TEXT;
+
const char* name = base::nix::GetDesktopEnvironmentName(desktop_env);
VLOG(1) << "Password storage detected desktop environment: "
<< (name ? name : "(unknown)");
@@ -47,4 +73,22 @@ SelectedLinuxBackend SelectBackend(const std::string& type,
return SelectedLinuxBackend::BASIC_TEXT;
}
+bool WriteBackendUse(const base::FilePath& user_data_dir, bool use) {
+ if (user_data_dir.empty())
+ return false;
+ base::FilePath pref_path = user_data_dir.Append(kPreferencesFileName);
+ if (use) {
+ return base::DeleteFile(pref_path, false);
+ }
+ FILE* f = base::OpenFile(pref_path, "w");
+ return f != nullptr && base::CloseFile(f);
+}
+
+bool GetBackendUse(const base::FilePath& user_data_dir) {
+ bool setting;
+ if (ReadBackendUse(user_data_dir, &setting))
+ return setting;
+ return true;
+}
+
} // namespace os_crypt

Powered by Google App Engine
This is Rietveld 408576698