[uim/f18] Create a socket file under XDG_RUNTIME_DIR. (#924005)
Akira TAGOH
tagoh at fedoraproject.org
Mon Apr 15 09:54:57 UTC 2013
commit 3047622cccf35c88b6719a6cd744af45970da310
Author: Akira TAGOH <tagoh at redhat.com>
Date: Mon Apr 15 18:54:53 2013 +0900
Create a socket file under XDG_RUNTIME_DIR. (#924005)
uim-runtimedir.patch | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/uim-runtimedir.patch b/uim-runtimedir.patch
new file mode 100644
index 0000000..801a79e
--- /dev/null
+++ b/uim-runtimedir.patch
@@ -0,0 +1,66 @@
+diff --git a/uim/uim-helper.c b/uim/uim-helper.c
+index 7614d53..5d07ac2 100644
+--- a/uim/uim-helper.c
++++ b/uim/uim-helper.c
+@@ -165,6 +165,7 @@ uim_bool
+ uim_helper_get_pathname(char *helper_path, int len)
+ {
+ struct passwd *pw;
++ char *runtimedir;
+
+ if (len <= 0)
+ return UIM_FALSE;
+@@ -172,27 +173,39 @@ uim_helper_get_pathname(char *helper_path, int len)
+ if (UIM_CATCH_ERROR_BEGIN())
+ return UIM_FALSE;
+
+- pw = getpwuid(getuid());
+- if (!pw) {
+- endpwent();
+- goto path_error;
+- }
++ runtimedir = getenv("XDG_RUNTIME_DIR");
++ if (runtimedir && runtimedir[0]) {
++ if (strlcpy(helper_path, runtimedir, len) >= (size_t)len)
++ goto path_error;
++ if (strlcat(helper_path, "/uim", len) >= (size_t)len)
++ goto path_error;
++ } else {
++ pw = getpwuid(getuid());
++ if (!pw) {
++ endpwent();
++ goto path_error;
++ }
+
+- if (strlcpy(helper_path, pw->pw_dir, len) >= (size_t)len) {
+- endpwent();
+- goto path_error;
+- }
+- if (strlcat(helper_path, "/.uim.d", len) >= (size_t)len) {
++ if (strlcpy(helper_path, pw->pw_dir, len) >= (size_t)len) {
++ endpwent();
++ goto path_error;
++ }
++ if (strlcat(helper_path, "/.uim.d", len) >= (size_t)len) {
++ endpwent();
++ goto path_error;
++ }
+ endpwent();
+- goto path_error;
+ }
+- endpwent();
+
+- /* check ~/.uim.d/ */
++ /* check $XDG_RUNTIME_DIR/uim/ if $XDG_RUNTIME_DIR is available.
++ * otherwise ~/.uim.d/
++ */
+ if (!check_dir(helper_path))
+ goto path_error;
+
+- /* check ~/.uim.d/socket/ */
++ /* check $XDG_RUNTIME_DIR/uim/socket/ if $XDG_RUNTIME_DIR is available.
++ * otherwise ~/.uim.d/socket/
++ */
+ if (strlcat(helper_path, "/socket", len) >= (size_t)len)
+ goto path_error;
+
More information about the scm-commits
mailing list