[uim] Create a socket file under XDG_RUNTIME_DIR. (#924005)

Akira TAGOH tagoh at fedoraproject.org
Mon Apr 15 08:41:02 UTC 2013


commit 6308b0393ff52b875bc67132781c6be86e664b3e
Author: Akira TAGOH <tagoh at redhat.com>
Date:   Mon Apr 15 17:40:59 2013 +0900

    Create a socket file under XDG_RUNTIME_DIR. (#924005)

 uim-runtimedir.patch |   66 ++++++++++++++++++++++++++++++++++++++++++++++++++
 uim.spec             |    5 ++++
 2 files changed, 71 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;
+ 
diff --git a/uim.spec b/uim.spec
index 0d4fce3..89c3cac 100644
--- a/uim.spec
+++ b/uim.spec
@@ -26,6 +26,7 @@ Source1:	xinput.d-uim
 Source2:	uim-init.el
 Patch1:		uim-emacs-utf8.patch
 Patch2:		uim-enable-libgcroots.patch
+Patch3:		%{name}-runtimedir.patch
 
 
 Summary:	A multilingual input method library
@@ -223,6 +224,7 @@ many languages using the input table map from m17n-db.
 %setup -q
 %patch1 -p1 -b .1-emacs
 %patch2 -p1 -b .2-libgcroots
+%patch3 -p1 -b .3-runtimedir
 autoconf
 
 
@@ -549,6 +551,9 @@ fi
 %dir %{_datadir}/uim
 
 %changelog
+* Mon Apr 15 2013 Akira TAGOH <tagoh at redhat.com> - 1.8.5-3
+- Create a socket file under XDG_RUNTIME_DIR. (#924005)
+
 * Sun Apr 14 2013 Peter Robinson <pbrobinson at fedoraproject.org> 1.8.5-1
 - Drop gnome-panel support as it's obsolete with gnome 3.8
 


More information about the scm-commits mailing list