From 56968f1b9560298667d95908f2773ddec2c04c2a Mon Sep 17 00:00:00 2001 From: Peng Huang Date: Thu, 8 Apr 2010 11:10:02 +0800 Subject: [PATCH] Try to create dir $(HOME)/.config/ibus/bus every time to avoid apps wake up once per second. --- src/ibusbus.c | 13 ++++--------- src/ibusshare.c | 7 ++++++- src/ibusshare.h | 5 ++++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/ibusbus.c b/src/ibusbus.c index d88e188..33573a3 100644 --- a/src/ibusbus.c +++ b/src/ibusbus.c @@ -208,20 +208,15 @@ ibus_bus_init (IBusBus *bus) path = g_path_get_dirname (ibus_get_socket_path ()); + g_mkdir_with_parents (path, 0700); + g_chmod (path, 0700); + if (stat (path, &buf) == 0) { - if (buf.st_uid != ibus_get_daemon_uid ()) { + if (buf.st_uid != getuid ()) { g_warning ("The owner of %s is not %s!", path, ibus_get_user_name ()); return; } } -#if 0 - else { - if (getuid () == ibus_get_daemon_uid ()) { - mkdir (path, 0700); - chmod (path, 0700); - } - } -#endif ibus_bus_connect (bus); diff --git a/src/ibusshare.c b/src/ibusshare.c index aee549f..f66a2d3 100644 --- a/src/ibusshare.c +++ b/src/ibusshare.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "ibusshare.h" @@ -58,6 +57,8 @@ ibus_set_display (const gchar *display) const gchar * ibus_get_user_name (void) { + return g_get_user_name (); +#if 0 static gchar *username = NULL; if (username == NULL) { username = g_strdup (getlogin()); @@ -87,11 +88,14 @@ ibus_get_user_name (void) } return username; +#endif } glong ibus_get_daemon_uid (void) { + return getuid (); +#if 0 struct passwd *pwd; uid_t uid; const gchar *username; @@ -110,6 +114,7 @@ ibus_get_daemon_uid (void) return 0; return pwd->pw_uid; +#endif } const gchar * diff --git a/src/ibusshare.h b/src/ibusshare.h index e622be2..26677a3 100644 --- a/src/ibusshare.h +++ b/src/ibusshare.h @@ -219,8 +219,11 @@ const gchar *ibus_get_user_name (void); * @returns: UID of ibus-daemon; or 0 if UID is not available. * * Get UID of ibus-daemon. + * + * Deprecated: This function has been deprecated and should + * not be used in newly written code. */ -glong ibus_get_daemon_uid (void); +glong ibus_get_daemon_uid (void) G_GNUC_DEPRECATED; /** * ibus_get_socket_path: -- 2.7.4