summaryrefslogtreecommitdiffstats
path: root/bus/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'bus/main.c')
-rw-r--r--bus/main.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/bus/main.c b/bus/main.c
index 8757af5..7e53144 100644
--- a/bus/main.c
+++ b/bus/main.c
@@ -19,6 +19,8 @@
*/
#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
#include <stdlib.h>
#include <locale.h>
#include "server.h"
@@ -106,6 +108,19 @@ main (gint argc, gchar **argv)
exit (-1);
}
+ /* check uid */
+ {
+ gchar *username = ibus_get_user_name ();
+ uid_t uid = getuid ();
+ struct passwd *pwd = getpwuid (uid);
+
+ if (pwd == NULL || strcmp (pwd->pw_name, username) != 0) {
+ g_printerr ("Please run ibus-daemon with login user! Do not run ibus-daemon with sudo or su.\n");
+ exit (-1);
+ }
+ }
+
+ /* daemonize process */
if (daemonize) {
if (daemon (1, 0) != 0) {
g_printerr ("Can not daemonize ibus.\n");