diff --git a/src/data/version/mozc_version_template.bzl b/src/data/version/mozc_version_template.bzl index 5063f0e..bbeacca 100644 --- a/src/data/version/mozc_version_template.bzl +++ b/src/data/version/mozc_version_template.bzl @@ -30,7 +30,7 @@ MAJOR=2 MINOR=23 -BUILD=2810 +BUILD=2811 REVISION=102 # This version represents the version of Mozc IME engine (converter, predictor, # etc.). This version info is included both in the Mozc server and in the Mozc diff --git a/src/ipc/ipc.gyp b/src/ipc/ipc.gyp index 0c237fd..bdbaca3 100644 --- a/src/ipc/ipc.gyp +++ b/src/ipc/ipc.gyp @@ -55,6 +55,11 @@ 'sources!': [ 'ipc_path_manager.cc', 'process_watch_dog.cc', + ], + }], + ['target_platform=="Windows"', { + 'dependencies': [ + '../base/base.gyp:obfuscator_support', ], }], ], diff --git a/src/ipc/ipc_path_manager.cc b/src/ipc/ipc_path_manager.cc index fd9766b..aceb0d4 100644 --- a/src/ipc/ipc_path_manager.cc +++ b/src/ipc/ipc_path_manager.cc @@ -57,6 +57,9 @@ #include "base/const.h" #include "base/file_stream.h" #include "base/file_util.h" +#ifdef OS_WIN +#include "base/unverified_sha1.h" +#endif // OS_WIN #include "base/logging.h" #include "base/mac_util.h" #include "base/mutex.h" @@ -108,22 +111,15 @@ return true; } -void CreateIPCKey(char *value) { - char buf[16]; // key is 128 bit - -#ifdef OS_WIN - // LUID guaranties uniqueness - LUID luid = { 0 }; // LUID is 64bit value - - DCHECK_EQ(sizeof(luid), sizeof(uint64)); - - // first 64 bit is random sequence and last 64 bit is LUID - if (::AllocateLocallyUniqueId(&luid)) { - Util::GetRandomSequence(buf, sizeof(buf) / 2); - ::memcpy(buf + sizeof(buf) / 2, &luid, sizeof(buf) / 2); - } else { - // use random value for failsafe - Util::GetRandomSequence(buf, sizeof(buf)); +string CreateIPCKey() { + char buf[16] = {}; // key is 128 bit + char value[kKeySize + 1] = {}; + +#ifdef OS_WIN + const string sid = SystemUtil::GetUserSidAsString(); + const string sha1 = internal::UnverifiedSHA1::MakeDigest(sid); + for (int i = 0; i < sizeof(buf) && i < sha1.size(); ++i) { + buf[i] = sha1.at(i); } #else // get 128 bit key: Note that collision will happen. @@ -139,6 +135,7 @@ } value[kKeySize] = '\0'; + return string(value); } class IPCPathManagerMap { @@ -191,9 +188,7 @@ bool IPCPathManager::CreateNewPathName() { scoped_lock l(mutex_.get()); if (ipc_path_info_->key().empty()) { - char ipc_key[kKeySize + 1]; - CreateIPCKey(ipc_key); - ipc_path_info_->set_key(ipc_key); + ipc_path_info_->set_key(CreateIPCKey()); } return true; } @@ -244,13 +239,30 @@ // On Windows, ShouldReload() always returns false. // On other platform, it returns true when timestamp of the file is different // from that of previous one. - if (ShouldReload() || ipc_path_info_->key().empty()) { - if (!LoadPathNameInternal()) { - LOG(ERROR) << "LoadPathName failed"; - return false; - } - } - return true; + const bool should_load = (ShouldReload() || ipc_path_info_->key().empty()); + if (!should_load) { + return true; + } + + if (LoadPathNameInternal()) { + return true; + } + +#if defined(OS_WIN) + // Fill the default values as fallback. + // Applications conerted by Desktop App Converter (DAC) does not read + // a file of ipc session name in the LocalLow directory. + // For a workaround, let applications to connect the named pipe directly. + // See: b/71338191. + CreateNewPathName(); + DCHECK(!ipc_path_info_->key().empty()); + ipc_path_info_->set_protocol_version(IPC_PROTOCOL_VERSION); + ipc_path_info_->set_product_version(Version::GetMozcVersion()); + return true; +#else + LOG(ERROR) << "LoadPathName failed"; + return false; +#endif } bool IPCPathManager::GetPathName(string *ipc_name) const {