1 |
matsuu 10/11/25 16:29:57 |
2 |
|
3 |
Added: uim-1.6.0-sandbox-violation.patch |
4 |
Log: |
5 |
Fixed sandbox violation. The patch is submitted by Muneyuki Noguchi, bug #345217. |
6 |
|
7 |
(Portage version: 2.1.9.24/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 app-i18n/uim/files/uim-1.6.0-sandbox-violation.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-i18n/uim/files/uim-1.6.0-sandbox-violation.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-i18n/uim/files/uim-1.6.0-sandbox-violation.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: uim-1.6.0-sandbox-violation.patch |
16 |
=================================================================== |
17 |
diff --git a/scm/custom-rt.scm b/scm/custom-rt.scm |
18 |
index ea94593..967f3c7 100644 |
19 |
--- a/scm/custom-rt.scm |
20 |
+++ b/scm/custom-rt.scm |
21 |
@@ -63,7 +63,10 @@ |
22 |
(define custom-file-path |
23 |
(lambda (gsym) |
24 |
(let* ((group-name (symbol->string gsym)) |
25 |
- (path (string-append (get-config-path! #f) |
26 |
+ (config-path (get-config-path #f)) |
27 |
+ (path (string-append (if config-path |
28 |
+ config-path |
29 |
+ "") |
30 |
"/customs/custom-" |
31 |
group-name |
32 |
".scm"))) |
33 |
diff --git a/scm/dynlib.scm b/scm/dynlib.scm |
34 |
index 991ed55..6b67a77 100644 |
35 |
--- a/scm/dynlib.scm |
36 |
+++ b/scm/dynlib.scm |
37 |
@@ -34,14 +34,15 @@ |
38 |
(define uim-dynlib-load-path |
39 |
(if (setugid?) |
40 |
(list (string-append (sys-pkglibdir) "/plugin")) |
41 |
- (let ((home-dir (or (home-directory (user-name)) "")) |
42 |
- (ld-library-path (getenv "LD_LIBRARY_PATH"))) |
43 |
+ (let* ((ld-library-path (getenv "LD_LIBRARY_PATH")) |
44 |
+ (config-path (get-config-path #f)) |
45 |
+ (user-plugin-path (if config-path |
46 |
+ (string-append config-path "/plugin") |
47 |
+ '()))) |
48 |
(filter string? |
49 |
(append (list (getenv "LIBUIM_PLUGIN_LIB_DIR") |
50 |
- (if home-dir |
51 |
- (string-append (get-config-path! #f) "/plugin") |
52 |
- '()) |
53 |
- (string-append (sys-pkglibdir) "/plugin")) |
54 |
+ user-plugin-path |
55 |
+ (string-append (sys-pkglibdir) "/plugin")) |
56 |
;; XXX |
57 |
(if ld-library-path |
58 |
(string-split ld-library-path ":") |
59 |
diff --git a/scm/plugin.scm b/scm/plugin.scm |
60 |
index 2d5d74a..d187429 100644 |
61 |
--- a/scm/plugin.scm |
62 |
+++ b/scm/plugin.scm |
63 |
@@ -39,12 +39,12 @@ |
64 |
(define uim-plugin-scm-load-path |
65 |
(if (setugid?) |
66 |
(list (sys-pkgdatadir)) |
67 |
- (let ((home-dir (or (home-directory (user-name)) "")) |
68 |
+ (let ((config-path (get-config-path #f)) |
69 |
(scm-paths (string-split (load-path) ":"))) |
70 |
(filter string? |
71 |
(append scm-paths |
72 |
- (if home-dir |
73 |
- (list (string-append (get-config-path! #f) "/plugin")) |
74 |
+ (if config-path |
75 |
+ (list (string-append config-path "/plugin")) |
76 |
'()) |
77 |
(list (sys-pkgdatadir))))))) |
78 |
|
79 |
@@ -71,9 +71,9 @@ |
80 |
;; TODO: write test |
81 |
(define load-module-conf |
82 |
(lambda () |
83 |
- (let* ((home-dir (or (home-directory (user-name)) "")) |
84 |
- (user-module-dir (if home-dir |
85 |
- (string-append (get-config-path! #f) "/plugin/") |
86 |
+ (let* ((config-path (get-config-path #f)) |
87 |
+ (user-module-dir (if config-path |
88 |
+ (string-append config-path "/plugin/") |
89 |
#f)) |
90 |
(conf-file "installed-modules.scm") |
91 |
(user-conf-file (if user-module-dir |
92 |
@@ -100,9 +100,9 @@ |
93 |
;; TODO: write test |
94 |
(define load-enabled-modules |
95 |
(lambda () |
96 |
- (let* ((home-dir (or (home-directory (user-name)) "")) |
97 |
- (user-module-dir (if home-dir |
98 |
- (string-append (get-config-path! #f) "/plugin/") |
99 |
+ (let* ((config-path (get-config-path #f)) |
100 |
+ (user-module-dir (if config-path |
101 |
+ (string-append config-path "/plugin/") |
102 |
#f)) |
103 |
(file "loader.scm") |
104 |
(user-file (if user-module-dir |
105 |
diff --git a/uim/uim-helper.c b/uim/uim-helper.c |
106 |
index e4a558f..882aea6 100644 |
107 |
--- a/uim/uim-helper.c |
108 |
+++ b/uim/uim-helper.c |
109 |
@@ -207,7 +207,11 @@ uim_helper_get_pathname(char *helper_path, int len) |
110 |
return UIM_TRUE; |
111 |
|
112 |
path_error: |
113 |
- uim_fatal_error("uim_helper_get_pathname()"); |
114 |
+#if USE_UIM_NOTIFY && !UIM_NON_LIBUIM_PROG |
115 |
+ uim_notify_fatal("uim_helper_get_pathname() failed"); |
116 |
+#else |
117 |
+ fprintf(stderr, "uim_helper_get_pathname() failed\n"); |
118 |
+#endif |
119 |
helper_path[0] = '\0'; |
120 |
|
121 |
UIM_CATCH_ERROR_END(); |
122 |
diff --git a/uim/uim-posix.c b/uim/uim-posix.c |
123 |
index 83691d8..de8a327 100644 |
124 |
--- a/uim/uim-posix.c |
125 |
+++ b/uim/uim-posix.c |
126 |
@@ -141,21 +141,33 @@ home_directory(uim_lisp user_) |
127 |
return MAKE_STR(home); |
128 |
} |
129 |
|
130 |
-uim_bool |
131 |
-uim_check_dir(const char *dir) |
132 |
+static uim_bool |
133 |
+uim_check_dir_internal(const char *dir, int need_prepare) |
134 |
{ |
135 |
struct stat st; |
136 |
|
137 |
if (stat(dir, &st) < 0) |
138 |
- return (mkdir(dir, 0700) < 0) ? UIM_FALSE : UIM_TRUE; |
139 |
+ if (need_prepare) |
140 |
+ return (mkdir(dir, 0700) < 0) ? UIM_FALSE : UIM_TRUE; |
141 |
+ else |
142 |
+ return UIM_FALSE; |
143 |
else { |
144 |
mode_t mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR; |
145 |
return ((st.st_mode & mode) == mode) ? UIM_TRUE : UIM_FALSE; |
146 |
} |
147 |
} |
148 |
|
149 |
+/* FIXME: use appropriate name for this API */ |
150 |
+uim_bool |
151 |
+uim_check_dir(const char *dir) |
152 |
+{ |
153 |
+ int need_prepare = UIM_TRUE; |
154 |
+ |
155 |
+ return uim_check_dir_internal(dir, need_prepare); |
156 |
+} |
157 |
+ |
158 |
static uim_lisp |
159 |
-c_check_dir(uim_lisp dir_) |
160 |
+c_prepare_dir(uim_lisp dir_) |
161 |
{ |
162 |
if (!uim_check_dir(REFER_C_STR(dir_))) { |
163 |
return uim_scm_f(); |
164 |
@@ -163,8 +175,8 @@ c_check_dir(uim_lisp dir_) |
165 |
return uim_scm_t(); |
166 |
} |
167 |
|
168 |
-uim_bool |
169 |
-uim_get_config_path(char *path, int len, int is_getenv) |
170 |
+static uim_bool |
171 |
+uim_get_config_path_internal(char *path, int len, int is_getenv, int need_prepare) |
172 |
{ |
173 |
char home[MAXPATHLEN]; |
174 |
|
175 |
@@ -174,34 +186,63 @@ uim_get_config_path(char *path, int len, int is_getenv) |
176 |
if (!uim_get_home_directory(home, sizeof(home), getuid()) && is_getenv) { |
177 |
char *home_env = getenv("HOME"); |
178 |
|
179 |
- if (!home_env) |
180 |
+ if (!home_env) { |
181 |
+ path[0] = '\0'; |
182 |
return UIM_FALSE; |
183 |
+ } |
184 |
|
185 |
- if (strlcpy(home, home_env, sizeof(home)) >= sizeof(home)) |
186 |
+ if (strlcpy(home, home_env, sizeof(home)) >= sizeof(home)) { |
187 |
+ path[0] = '\0'; |
188 |
return UIM_FALSE; |
189 |
+ } |
190 |
} |
191 |
|
192 |
- if (snprintf(path, len, "%s/.uim.d", home) == -1) |
193 |
+ if (snprintf(path, len, "%s/.uim.d", home) < 0) { |
194 |
+ path[0] = '\0'; |
195 |
return UIM_FALSE; |
196 |
+ } |
197 |
|
198 |
- if (!uim_check_dir(path)) { |
199 |
+ if (!uim_check_dir_internal(path, need_prepare)) { |
200 |
return UIM_FALSE; |
201 |
} |
202 |
|
203 |
return UIM_TRUE; |
204 |
} |
205 |
|
206 |
+/* FIXME: use appropriate name for this API */ |
207 |
+uim_bool |
208 |
+uim_get_config_path(char *path, int len, int is_getenv) |
209 |
+{ |
210 |
+ int need_prepare = UIM_TRUE; |
211 |
+ |
212 |
+ return uim_get_config_path_internal(path, len, is_getenv, need_prepare); |
213 |
+} |
214 |
+ |
215 |
static uim_lisp |
216 |
-c_get_config_path(uim_lisp is_getenv_) |
217 |
+c_prepare_config_path(uim_lisp is_getenv_) |
218 |
{ |
219 |
char path[MAXPATHLEN]; |
220 |
+ int need_prepare = UIM_TRUE; |
221 |
|
222 |
- if (!uim_get_config_path(path, sizeof(path), C_BOOL(is_getenv_))) |
223 |
+ if (!uim_get_config_path_internal(path, sizeof(path), C_BOOL(is_getenv_), need_prepare)) |
224 |
return uim_scm_f(); |
225 |
return MAKE_STR(path); |
226 |
} |
227 |
|
228 |
static uim_lisp |
229 |
+c_get_config_path(uim_lisp is_getenv_) |
230 |
+{ |
231 |
+ char path[MAXPATHLEN]; |
232 |
+ int need_prepare = UIM_FALSE; |
233 |
+ int exist; |
234 |
+ |
235 |
+ /* No need to check the existence of path in this function */ |
236 |
+ exist = uim_get_config_path_internal(path, sizeof(path), C_BOOL(is_getenv_), need_prepare); |
237 |
+ |
238 |
+ return MAKE_STR(path); |
239 |
+} |
240 |
+ |
241 |
+static uim_lisp |
242 |
file_stat_mode(uim_lisp filename, mode_t mode) |
243 |
{ |
244 |
struct stat st; |
245 |
@@ -391,8 +432,9 @@ uim_init_posix_subrs(void) |
246 |
uim_scm_init_proc0("user-name", user_name); |
247 |
uim_scm_init_proc1("home-directory", home_directory); |
248 |
|
249 |
- uim_scm_init_proc1("create/check-directory!", c_check_dir); |
250 |
- uim_scm_init_proc1("get-config-path!", c_get_config_path); |
251 |
+ uim_scm_init_proc1("create/check-directory!", c_prepare_dir); |
252 |
+ uim_scm_init_proc1("get-config-path!", c_prepare_config_path); |
253 |
+ uim_scm_init_proc1("get-config-path", c_get_config_path); |
254 |
|
255 |
uim_scm_init_proc1("file-readable?", file_readablep); |
256 |
uim_scm_init_proc1("file-writable?", file_writablep); |