diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2020-01-15 15:51:32 +0000 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2020-01-15 15:51:32 +0000 |
commit | 21435953e16cda318a82334ddbadb3b5c36d9ea7 (patch) | |
tree | e1810a4b135afce04b34862ef0fab2bfaeb8aeca /app-i18n/mozc/files | |
parent | 7bc9c63c9da678a7e6fceb095d56c634afd22c56 (diff) |
gentoo resync : 15.01.2020
Diffstat (limited to 'app-i18n/mozc/files')
-rw-r--r-- | app-i18n/mozc/files/mozc-2.23.2815.102-environmental_variables.patch | 132 | ||||
-rw-r--r-- | app-i18n/mozc/files/mozc-2.23.2815.102-server_path_check.patch | 95 |
2 files changed, 227 insertions, 0 deletions
diff --git a/app-i18n/mozc/files/mozc-2.23.2815.102-environmental_variables.patch b/app-i18n/mozc/files/mozc-2.23.2815.102-environmental_variables.patch new file mode 100644 index 000000000000..02e522a32e9e --- /dev/null +++ b/app-i18n/mozc/files/mozc-2.23.2815.102-environmental_variables.patch @@ -0,0 +1,132 @@ +https://github.com/google/mozc/issues/470 + +--- /src/base/system_util.cc ++++ /src/base/system_util.cc +@@ -208,28 +208,39 @@ + dir_ = "/"; + return; + #else // MOZC_USE_PEPPER_FILE_IO ++ const char *configuration_directory_env; + string dir; + + #ifdef OS_WIN +- DCHECK(SUCCEEDED(Singleton<LocalAppDataDirectoryCache>::get()->result())); +- dir = Singleton<LocalAppDataDirectoryCache>::get()->path(); ++ configuration_directory_env = ::getenv("MOZC_CONFIGURATION_DIRECTORY"); ++ if (configuration_directory_env) { ++ dir = configuration_directory_env; ++ } else { ++ DCHECK(SUCCEEDED(Singleton<LocalAppDataDirectoryCache>::get()->result())); ++ dir = Singleton<LocalAppDataDirectoryCache>::get()->path(); + #ifdef GOOGLE_JAPANESE_INPUT_BUILD +- dir = FileUtil::JoinPath(dir, kCompanyNameInEnglish); +- FileUtil::CreateDirectory(dir); ++ dir = FileUtil::JoinPath(dir, kCompanyNameInEnglish); ++ FileUtil::CreateDirectory(dir); + #endif // GOOGLE_JAPANESE_INPUT_BUILD +- dir = FileUtil::JoinPath(dir, kProductNameInEnglish); ++ dir = FileUtil::JoinPath(dir, kProductNameInEnglish); ++ } + + #elif defined(OS_MACOSX) +- dir = MacUtil::GetApplicationSupportDirectory(); ++ configuration_directory_env = ::getenv("MOZC_CONFIGURATION_DIRECTORY"); ++ if (configuration_directory_env) { ++ dir = configuration_directory_env; ++ } else { ++ dir = MacUtil::GetApplicationSupportDirectory(); + #ifdef GOOGLE_JAPANESE_INPUT_BUILD +- dir = FileUtil::JoinPath(dir, "Google"); +- // The permission of ~/Library/Application Support/Google seems to be 0755. +- // TODO(komatsu): nice to make a wrapper function. +- ::mkdir(dir.c_str(), 0755); +- dir = FileUtil::JoinPath(dir, "JapaneseInput"); ++ dir = FileUtil::JoinPath(dir, "Google"); ++ // The permission of ~/Library/Application Support/Google seems to be 0755. ++ // TODO(komatsu): nice to make a wrapper function. ++ ::mkdir(dir.c_str(), 0755); ++ dir = FileUtil::JoinPath(dir, "JapaneseInput"); + #else // GOOGLE_JAPANESE_INPUT_BUILD +- dir = FileUtil::JoinPath(dir, "Mozc"); ++ dir = FileUtil::JoinPath(dir, "Mozc"); + #endif // GOOGLE_JAPANESE_INPUT_BUILD ++ } + + #elif defined(OS_ANDROID) + // For android, we do nothing here because user profile directory, +@@ -237,14 +248,24 @@ + // is injected from Java layer. + + #else // !OS_WIN && !OS_MACOSX && !OS_ANDROID +- char buf[1024]; +- struct passwd pw, *ppw; +- const uid_t uid = geteuid(); +- CHECK_EQ(0, getpwuid_r(uid, &pw, buf, sizeof(buf), &ppw)) +- << "Can't get passwd entry for uid " << uid << "."; +- CHECK_LT(0, strlen(pw.pw_dir)) +- << "Home directory for uid " << uid << " is not set."; +- dir = FileUtil::JoinPath(pw.pw_dir, ".mozc"); ++ configuration_directory_env = ::getenv("MOZC_CONFIGURATION_DIRECTORY"); ++ if (configuration_directory_env) { ++ dir = configuration_directory_env; ++ } else { ++ const char *home_env = ::getenv("HOME"); ++ if (home_env) { ++ dir = FileUtil::JoinPath(home_env, ".mozc"); ++ } else { ++ char buf[1024]; ++ struct passwd pw, *ppw; ++ const uid_t uid = geteuid(); ++ CHECK_EQ(0, getpwuid_r(uid, &pw, buf, sizeof(buf), &ppw)) ++ << "Can't get passwd entry for uid " << uid << "."; ++ CHECK_LT(0, strlen(pw.pw_dir)) ++ << "Home directory for uid " << uid << " is not set."; ++ dir = FileUtil::JoinPath(pw.pw_dir, ".mozc"); ++ } ++ } + #endif // !OS_WIN && !OS_MACOSX && !OS_ANDROID + + FileUtil::CreateDirectory(dir); +@@ -356,6 +377,10 @@ + #endif // OS_WIN + + string SystemUtil::GetServerDirectory() { ++ const char *server_directory_env = ::getenv("MOZC_SERVER_DIRECTORY"); ++ if (server_directory_env) { ++ return server_directory_env; ++ } + #ifdef OS_WIN + DCHECK(SUCCEEDED(Singleton<ProgramFilesX86Cache>::get()->result())); + #if defined(GOOGLE_JAPANESE_INPUT_BUILD) +@@ -409,6 +434,10 @@ + } + + string SystemUtil::GetDocumentDirectory() { ++ const char *documents_directory_env = ::getenv("MOZC_DOCUMENTS_DIRECTORY"); ++ if (documents_directory_env) { ++ return documents_directory_env; ++ } + #if defined(OS_MACOSX) + return GetServerDirectory(); + #elif defined(MOZC_DOCUMENT_DIRECTORY) +--- /src/handwriting/zinnia_handwriting.cc ++++ /src/handwriting/zinnia_handwriting.cc +@@ -31,6 +31,7 @@ + + #include "handwriting/zinnia_handwriting.h" + ++#include <cstdlib> + #include <memory> + #include <string> + +@@ -48,6 +49,10 @@ + + // static + string ZinniaHandwriting::GetModelFileName() { ++ const char *zinnia_model_file_env = ::getenv("MOZC_ZINNIA_MODEL_FILE"); ++ if (zinnia_model_file_env) { ++ return zinnia_model_file_env; ++ } + #if defined(MOZC_BUILD) + return MOZC_ZINNIA_MODEL_FILE; + #else diff --git a/app-i18n/mozc/files/mozc-2.23.2815.102-server_path_check.patch b/app-i18n/mozc/files/mozc-2.23.2815.102-server_path_check.patch new file mode 100644 index 000000000000..dd606e27fb56 --- /dev/null +++ b/app-i18n/mozc/files/mozc-2.23.2815.102-server_path_check.patch @@ -0,0 +1,95 @@ +https://github.com/google/mozc/issues/471 + +--- /src/ipc/ipc_path_manager.cc ++++ /src/ipc/ipc_path_manager.cc +@@ -332,9 +332,21 @@ + return false; + } + ++ // Expand symbolic links in the expected server path to avoid false negatives ++ // during comparisons of the expected server path and the actual server path. ++ string real_server_path = server_path; ++#ifndef OS_WIN ++ char real_server_path_[PATH_MAX]; ++ if (realpath(server_path.c_str(), real_server_path_) == NULL) { ++ LOG(ERROR) << "realpath failed: " << strerror(errno); ++ return false; ++ } ++ real_server_path = real_server_path_; ++#endif ++ + // compare path name + if (pid == server_pid_) { +- return (server_path == server_path_); ++ return (real_server_path == server_path_); + } + + server_pid_ = 0; +@@ -344,17 +356,17 @@ + { + std::wstring expected_server_ntpath; + const std::map<string, std::wstring>::const_iterator it = +- expected_server_ntpath_cache_.find(server_path); ++ expected_server_ntpath_cache_.find(real_server_path); + if (it != expected_server_ntpath_cache_.end()) { + expected_server_ntpath = it->second; + } else { + std::wstring wide_server_path; +- Util::UTF8ToWide(server_path, &wide_server_path); ++ Util::UTF8ToWide(real_server_path, &wide_server_path); + if (WinUtil::GetNtPath(wide_server_path, &expected_server_ntpath)) { +- // Caches the relationship from |server_path| to +- // |expected_server_ntpath| in case |server_path| is renamed later. ++ // Caches the relationship from |real_server_path| to ++ // |expected_server_ntpath| in case |real_server_path| is renamed later. + // (This can happen during the updating). +- expected_server_ntpath_cache_[server_path] = expected_server_ntpath; ++ expected_server_ntpath_cache_[real_server_path] = expected_server_ntpath; + } + } + +@@ -371,9 +383,9 @@ + return false; + } + +- // Here we can safely assume that |server_path| (expected one) should be ++ // Here we can safely assume that |real_server_path| (expected one) should be + // the same to |server_path_| (actual one). +- server_path_ = server_path; ++ server_path_ = real_server_path; + server_pid_ = pid; + } + #endif // OS_WIN +@@ -399,7 +411,7 @@ + #ifdef OS_LINUX + // load from /proc/<pid>/exe + char proc[128]; +- char filename[512]; ++ char filename[PATH_MAX]; + snprintf(proc, sizeof(proc) - 1, "/proc/%u/exe", pid); + const ssize_t size = readlink(proc, filename, sizeof(filename) - 1); + if (size == -1) { +@@ -412,18 +424,18 @@ + server_pid_ = pid; + #endif // OS_LINUX + +- VLOG(1) << "server path: " << server_path << " " << server_path_; +- if (server_path == server_path_) { ++ VLOG(1) << "server path: " << real_server_path << " " << server_path_; ++ if (real_server_path == server_path_) { + return true; + } + + #ifdef OS_LINUX +- if ((server_path + " (deleted)") == server_path_) { +- LOG(WARNING) << server_path << " on disk is modified"; ++ if ((real_server_path + " (deleted)") == server_path_) { ++ LOG(WARNING) << real_server_path << " on disk is modified"; + // If a user updates the server binary on disk during the server is running, + // "readlink /proc/<pid>/exe" returns a path with the " (deleted)" suffix. + // We allow the special case. +- server_path_ = server_path; ++ server_path_ = real_server_path; + return true; + } + #endif // OS_LINUX |