-
Notifications
You must be signed in to change notification settings - Fork 0
/
xdg-basedir.patch
68 lines (60 loc) · 2.39 KB
/
xdg-basedir.patch
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
# 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 kXdgDataHomeEnvVar[] = "XDG_DATA_HOME";
+const char kXdgDataHomeDefaultFallback[] = ".local/share";
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 XDG data directory environment variable.
+BASE_EXPORT extern const char kXdgDataHomeEnvVar[];
+
+// The default/fallback XDG data directory.
+BASE_EXPORT extern const char kXdgDataHomeDefaultFallback[];
+
// 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,23 @@
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::kXdgDataHomeDefaultFallback);
+#else
base::PathService::Get(base::DIR_HOME, &dir);
+#endif
if (dir.empty()) {
LOG(ERROR) << "Failed to get home directory.";
return dir;
}
+#if defined(OS_LINUX)
+ dir = dir.Append(chrome::kBrowserProcessExecutableName).AppendASCII("pki").
+ ppendASCII("nssdb");
+#else
dir = dir.AppendASCII(".pki").AppendASCII("nssdb");
+#endif
if (!base::CreateDirectory(dir)) {
LOG(ERROR) << "Failed to create " << dir.value() << " directory.";
dir.clear();