123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- # 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/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,25 @@ static const base::FilePath::CharType kReadOnlyCertDB[] =
- 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()) {
- +#if defined(OS_LINUX)
- + LOG(ERROR) << "Failed to get $HOME or $XDG_DATA_HOME directory.";
- +#else
- LOG(ERROR) << "Failed to get home directory.";
- +#endif
- 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();
- --- a/base/nix/xdg_util.cc
- +++ b/base/nix/xdg_util.cc
- @@ -41,6 +41,9 @@ std::optional<std::string>& GetXdgActivationToken() {
- namespace base::nix {
- +const char kDotDataDir[] = ".local/share";
- +const char kXdgDataHomeEnvVar[] = "XDG_DATA_HOME";
- +
- const char kDotConfigDir[] = ".config";
- const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME";
- const char kXdgCurrentDesktopEnvVar[] = "XDG_CURRENT_DESKTOP";
- --- a/base/nix/xdg_util.h
- +++ b/base/nix/xdg_util.h
- @@ -72,6 +72,12 @@ BASE_EXPORT extern const char kXdgConfigHomeEnvVar[];
- // The XDG current desktop environment variable.
- BASE_EXPORT extern const char kXdgCurrentDesktopEnvVar[];
- +// The default XDG data directory name.
- +BASE_EXPORT extern const char kDotDataDir[];
- +
- +// The XDG data directory environment variable.
- +BASE_EXPORT extern const char kXdgDataHomeEnvVar[];
- +
- // The XDG session type environment variable.
- BASE_EXPORT extern const char kXdgSessionTypeEnvVar[];
|