1 |
commit: fc7858caf393bf3d2c1463c0bf65c61b65bb7cab |
2 |
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org> |
3 |
AuthorDate: Mon Dec 23 20:35:11 2019 +0000 |
4 |
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Dec 29 19:31:31 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fc7858ca |
7 |
|
8 |
app-i18n/mozc: Fix server path check. |
9 |
|
10 |
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org> |
11 |
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org> |
12 |
|
13 |
.../mozc-2.23.2815.102-server_path_check.patch | 95 ++++++++++++++++++++++ |
14 |
app-i18n/mozc/mozc-2.23.2815.102.ebuild | 1 + |
15 |
app-i18n/mozc/mozc-9999.ebuild | 1 + |
16 |
3 files changed, 97 insertions(+) |
17 |
|
18 |
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 |
19 |
new file mode 100644 |
20 |
index 00000000000..dd606e27fb5 |
21 |
--- /dev/null |
22 |
+++ b/app-i18n/mozc/files/mozc-2.23.2815.102-server_path_check.patch |
23 |
@@ -0,0 +1,95 @@ |
24 |
+https://github.com/google/mozc/issues/471 |
25 |
+ |
26 |
+--- /src/ipc/ipc_path_manager.cc |
27 |
++++ /src/ipc/ipc_path_manager.cc |
28 |
+@@ -332,9 +332,21 @@ |
29 |
+ return false; |
30 |
+ } |
31 |
+ |
32 |
++ // Expand symbolic links in the expected server path to avoid false negatives |
33 |
++ // during comparisons of the expected server path and the actual server path. |
34 |
++ string real_server_path = server_path; |
35 |
++#ifndef OS_WIN |
36 |
++ char real_server_path_[PATH_MAX]; |
37 |
++ if (realpath(server_path.c_str(), real_server_path_) == NULL) { |
38 |
++ LOG(ERROR) << "realpath failed: " << strerror(errno); |
39 |
++ return false; |
40 |
++ } |
41 |
++ real_server_path = real_server_path_; |
42 |
++#endif |
43 |
++ |
44 |
+ // compare path name |
45 |
+ if (pid == server_pid_) { |
46 |
+- return (server_path == server_path_); |
47 |
++ return (real_server_path == server_path_); |
48 |
+ } |
49 |
+ |
50 |
+ server_pid_ = 0; |
51 |
+@@ -344,17 +356,17 @@ |
52 |
+ { |
53 |
+ std::wstring expected_server_ntpath; |
54 |
+ const std::map<string, std::wstring>::const_iterator it = |
55 |
+- expected_server_ntpath_cache_.find(server_path); |
56 |
++ expected_server_ntpath_cache_.find(real_server_path); |
57 |
+ if (it != expected_server_ntpath_cache_.end()) { |
58 |
+ expected_server_ntpath = it->second; |
59 |
+ } else { |
60 |
+ std::wstring wide_server_path; |
61 |
+- Util::UTF8ToWide(server_path, &wide_server_path); |
62 |
++ Util::UTF8ToWide(real_server_path, &wide_server_path); |
63 |
+ if (WinUtil::GetNtPath(wide_server_path, &expected_server_ntpath)) { |
64 |
+- // Caches the relationship from |server_path| to |
65 |
+- // |expected_server_ntpath| in case |server_path| is renamed later. |
66 |
++ // Caches the relationship from |real_server_path| to |
67 |
++ // |expected_server_ntpath| in case |real_server_path| is renamed later. |
68 |
+ // (This can happen during the updating). |
69 |
+- expected_server_ntpath_cache_[server_path] = expected_server_ntpath; |
70 |
++ expected_server_ntpath_cache_[real_server_path] = expected_server_ntpath; |
71 |
+ } |
72 |
+ } |
73 |
+ |
74 |
+@@ -371,9 +383,9 @@ |
75 |
+ return false; |
76 |
+ } |
77 |
+ |
78 |
+- // Here we can safely assume that |server_path| (expected one) should be |
79 |
++ // Here we can safely assume that |real_server_path| (expected one) should be |
80 |
+ // the same to |server_path_| (actual one). |
81 |
+- server_path_ = server_path; |
82 |
++ server_path_ = real_server_path; |
83 |
+ server_pid_ = pid; |
84 |
+ } |
85 |
+ #endif // OS_WIN |
86 |
+@@ -399,7 +411,7 @@ |
87 |
+ #ifdef OS_LINUX |
88 |
+ // load from /proc/<pid>/exe |
89 |
+ char proc[128]; |
90 |
+- char filename[512]; |
91 |
++ char filename[PATH_MAX]; |
92 |
+ snprintf(proc, sizeof(proc) - 1, "/proc/%u/exe", pid); |
93 |
+ const ssize_t size = readlink(proc, filename, sizeof(filename) - 1); |
94 |
+ if (size == -1) { |
95 |
+@@ -412,18 +424,18 @@ |
96 |
+ server_pid_ = pid; |
97 |
+ #endif // OS_LINUX |
98 |
+ |
99 |
+- VLOG(1) << "server path: " << server_path << " " << server_path_; |
100 |
+- if (server_path == server_path_) { |
101 |
++ VLOG(1) << "server path: " << real_server_path << " " << server_path_; |
102 |
++ if (real_server_path == server_path_) { |
103 |
+ return true; |
104 |
+ } |
105 |
+ |
106 |
+ #ifdef OS_LINUX |
107 |
+- if ((server_path + " (deleted)") == server_path_) { |
108 |
+- LOG(WARNING) << server_path << " on disk is modified"; |
109 |
++ if ((real_server_path + " (deleted)") == server_path_) { |
110 |
++ LOG(WARNING) << real_server_path << " on disk is modified"; |
111 |
+ // If a user updates the server binary on disk during the server is running, |
112 |
+ // "readlink /proc/<pid>/exe" returns a path with the " (deleted)" suffix. |
113 |
+ // We allow the special case. |
114 |
+- server_path_ = server_path; |
115 |
++ server_path_ = real_server_path; |
116 |
+ return true; |
117 |
+ } |
118 |
+ #endif // OS_LINUX |
119 |
|
120 |
diff --git a/app-i18n/mozc/mozc-2.23.2815.102.ebuild b/app-i18n/mozc/mozc-2.23.2815.102.ebuild |
121 |
index f2300b60324..425b785cbfa 100644 |
122 |
--- a/app-i18n/mozc/mozc-2.23.2815.102.ebuild |
123 |
+++ b/app-i18n/mozc/mozc-2.23.2815.102.ebuild |
124 |
@@ -110,6 +110,7 @@ src_prepare() { |
125 |
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch" |
126 |
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-environmental_variables.patch" |
127 |
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-reiwa.patch" |
128 |
+ eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-server_path_check.patch" |
129 |
eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_build.patch" |
130 |
eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_skipping.patch" |
131 |
|
132 |
|
133 |
diff --git a/app-i18n/mozc/mozc-9999.ebuild b/app-i18n/mozc/mozc-9999.ebuild |
134 |
index f1d9151c265..d7c66b558d9 100644 |
135 |
--- a/app-i18n/mozc/mozc-9999.ebuild |
136 |
+++ b/app-i18n/mozc/mozc-9999.ebuild |
137 |
@@ -110,6 +110,7 @@ src_prepare() { |
138 |
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch" |
139 |
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-environmental_variables.patch" |
140 |
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-reiwa.patch" |
141 |
+ eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-server_path_check.patch" |
142 |
eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_build.patch" |
143 |
eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_skipping.patch" |