summarylogtreecommitdiffstats
path: root/xdg-basedir.patch
blob: 06df859a0cfde9d9a6dc9e1a29e57f7cdfa070c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Move ~/.pki directory to ${XDG_DATA_HOME:-$HOME/.local}/share/pki on linux
# builds to follow the XDG Base Directory Specification. For details, refer to
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

--- a/base/nix/xdg_util.cc
+++ b/base/nix/xdg_util.cc
@@ -29,6 +29,8 @@
 const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME";
 const char kXdgCurrentDesktopEnvVar[] = "XDG_CURRENT_DESKTOP";
 const char kXdgSessionTypeEnvVar[] = "XDG_SESSION_TYPE";
+const char kDotDataDir[] = ".local/share";
+const char kXdgDataHomeEnvVar[] = "XDG_DATA_HOME";
 
 FilePath GetXDGDirectory(Environment* env, const char* env_name,
                          const char* fallback_dir) {

--- a/base/nix/xdg_util.h
+++ b/base/nix/xdg_util.h
@@ -37,6 +37,12 @@
 // The XDG session type environment variable.
 BASE_EXPORT extern const char kXdgSessionTypeEnvVar[];
 
+// The default XDG data directory name.
+BASE_EXPORT extern const char kDotDataDir[];
+ 
+// The XDG data directory environment variable.
+BASE_EXPORT extern const char kXdgDataHomeEnvVar[];
+
 // Utility function for getting XDG directories.
 // |env_name| is the name of an environment variable that we want to use to get
 // a directory path. |fallback_dir| is the directory relative to $HOME that we

--- a/crypto/nss_util.cc
+++ b/crypto/nss_util.cc
@@ -30,6 +30,9 @@
 #include "build/chromeos_buildflags.h"
 #include "crypto/nss_crypto_module_delegate.h"
 #include "crypto/nss_util_internal.h"
+#include "base/environment.h"
+#include "base/nix/xdg_util.h"
+#include "chrome/common/chrome_constants.h"
 
 namespace crypto {
 
@@ -45,12 +48,21 @@
 
 base::FilePath GetDefaultConfigDirectory() {
   base::FilePath dir;
+#if defined(OS_LINUX)
+  std::unique_ptr<base::Environment> env(base::Environment::Create());
+  dir = base::nix::GetXDGDirectory(env.get(), base::nix::kXdgDataHomeEnvVar, base::nix::kDotDataDir);
+#else
   base::PathService::Get(base::DIR_HOME, &dir);
+#endif
   if (dir.empty()) {
-    LOG(ERROR) << "Failed to get home directory.";
+    LOG(ERROR) << "Failed to get $HOME or $XDG_DATA_HOME directory.";
     return dir;
   }
+#if defined(OS_LINUX)
+  dir = dir.Append(chrome::kBrowserProcessExecutableName).AppendASCII("pki").AppendASCII("nssdb");
+#else
   dir = dir.AppendASCII(".pki").AppendASCII("nssdb");
+#endif
   if (!base::CreateDirectory(dir)) {
     LOG(ERROR) << "Failed to create " << dir.value() << " directory.";
     dir.clear();
@@ -136,7 +148,7 @@
   NSSInitSingleton() {
     // Initializing NSS causes us to do blocking IO.
     // Temporarily allow it until we fix
-    //   http://code.google.com/p/chromium/issues/detail?id=59847
+    //   http://code.9oo91e.qjz9zk/p/chromium/issues/detail?id=59847
     base::ThreadRestrictions::ScopedAllowIO allow_io;
 
     EnsureNSPRInit();
@@ -273,7 +285,7 @@
 
   // Shouldn't need to const_cast here, but SECMOD doesn't properly declare
   // input string arguments as const.  Bug
-  // https://bugzilla.mozilla.org/show_bug.cgi?id=642546 was filed on NSS
+  // https://bugzilla.m0z111a.qjz9zk/show_bug.cgi?id=642546 was filed on NSS
   // codebase to address this.
   SECMODModule* module = SECMOD_LoadUserModule(
       const_cast<char*>(modparams.c_str()), nullptr, PR_FALSE);