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

Unified Diff: crypto/nss_util.cc

Issue 1989753002: crypto: Enable overriding NSS DB location. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@long-file-name-test
Patch Set: Fixing wrong depends. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/nss_util.cc
diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc
index 359f78fb87a89b172245fb6f127344547efb5dc0..4d97bbf99d597ea9e949691fd0a08ede48c398c8 100644
--- a/crypto/nss_util.cc
+++ b/crypto/nss_util.cc
@@ -89,12 +89,22 @@ std::string GetNSSErrorMessage() {
#if !defined(OS_CHROMEOS)
base::FilePath GetDefaultConfigDirectory() {
base::FilePath dir;
- PathService::Get(base::DIR_HOME, &dir);
- if (dir.empty()) {
- LOG(ERROR) << "Failed to get home directory.";
- return dir;
+
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
+ static const char kUseCacheEnvVar[] = "NSS_DEFAULT_DB_DIR";
+ std::string default_db_file;
+ if (env->GetVar(kUseCacheEnvVar, &default_db_file) &&
+ default_db_file.length() > 0) {
+ dir = base::FilePath(default_db_file);
+ } else {
+ PathService::Get(base::DIR_HOME, &dir);
+ if (dir.empty()) {
+ LOG(ERROR) << "Failed to get home directory.";
+ return dir;
+ }
+ dir = dir.AppendASCII(".pki").AppendASCII("nssdb");
}
- dir = dir.AppendASCII(".pki").AppendASCII("nssdb");
+
if (!base::CreateDirectory(dir)) {
LOG(ERROR) << "Failed to create " << dir.value() << " directory.";
dir.clear();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698