--- fep/udsock.c 2006-12-22 05:32:36.000000000 +0100 +++ fep/udsock.c 2007-06-28 19:09:32.000000000 +0200 @@ -69,21 +69,25 @@ const char *usersockname(const char *file) { static char buf[UNIX_PATH_MAX]; + const char *dir; char filebuf[UNIX_PATH_MAX]; if (file != NULL && file[0] == '/') { return file; } if (file == NULL) { struct passwd *pw = getpwuid(getuid()); - snprintf(filebuf, UNIX_PATH_MAX, "uim-fep-%s", pw->pw_name); + snprintf(filebuf, UNIX_PATH_MAX, ".uim-fep-%s", pw->pw_name); } else { strlcpy(filebuf, file, UNIX_PATH_MAX); } - if (getenv("TMP")) { - snprintf(buf, UNIX_PATH_MAX, "%s/%s", getenv("TMP"), filebuf); - } else { - snprintf(buf, UNIX_PATH_MAX, "/tmp/%s", filebuf); + dir = getenv("TMPDIR"); + if (!dir) { + dir = getenv("TMP"); + } + if (!dir) { + dir = getenv("/tmp"); } + snprintf(buf, UNIX_PATH_MAX, "%s/%s", dir, filebuf); return buf; } --- fep/uim-fep.c 2006-12-22 05:32:36.000000000 +0100 +++ fep/uim-fep.c 2007-06-28 19:32:35.000000000 +0200 @@ -406,7 +406,11 @@ tcgetattr(g_win_in, &s_save_tios); setupterm(NULL, g_win_out, NULL); - if ((tmp_dir = getenv("TMP")) == NULL) { + tmp_dir = getenv("TMPDIR"); + if (!tmp_dir) { + tmp_dir = getenv("TMP"); + } + if (!tmp_dir) { tmp_dir = "/tmp"; } --- uim/prime.c 2006-12-22 05:32:42.000000000 +0100 +++ uim/prime.c 2007-06-28 19:07:29.000000000 +0200 @@ -63,7 +63,6 @@ static char *prime_ud_path; static int prime_fd = -1; static uim_bool use_unix_domain_socket; -#define PRIME_UNIX_SOCKET_PREFIX "/tmp/uim-prime-" static int prime_init_ud(char *path) @@ -109,9 +108,11 @@ static char * prime_get_ud_path(void) { + static const char prefix[] = ".uim-prime-"; + const char *dir; char *path, *login; struct passwd *pw = NULL; - int len; + size_t len; login = getenv("LOGNAME"); @@ -120,9 +121,17 @@ login = strdup(pw->pw_name); } - len = strlen(login) + strlen(PRIME_UNIX_SOCKET_PREFIX) + 1; + dir = getenv("TMPDIR"); + if (!dir) { + dir = getenv("TMP"); + } + if (!dir) { + dir = "/tmp"; + } + + len = strlen(dir) + strlen(prefix) + strlen(login) + 2; path = (char *)malloc(len); - snprintf(path, len, PRIME_UNIX_SOCKET_PREFIX"%s", login); + snprintf(path, len, "%s/%s%s", dir, prefix, login); if (pw) free(login); --- uim/uim-helper.c 2006-12-22 05:32:42.000000000 +0100 +++ uim/uim-helper.c 2007-06-28 18:39:21.000000000 +0200 @@ -123,6 +123,7 @@ char * uim_helper_get_pathname(void) { + const char *dir; char *path; char *login = NULL; struct passwd *pw = NULL; @@ -136,8 +137,13 @@ login = strdup(pw->pw_name); } - path = (char *)malloc(strlen(login)+ 20); - sprintf(path, "/tmp/uimhelper-%s",login); + dir = getenv("TMPDIR"); + if (!dir) { + dir = "/tmp"; + } + + path = (char *)malloc(strlen(dir) + strlen(login)+ 20); + sprintf(path, "%s/.uimhelper-%s",dir,login); if (pw) { free(login); }