diff options
author | Peng Huang <shawn.p.huang@gmail.com> | 2009-02-25 11:03:31 +0800 |
---|---|---|
committer | Peng Huang <shawn.p.huang@gmail.com> | 2009-02-25 11:03:31 +0800 |
commit | 957b778d361fa270e37bc403c2640698f4718e29 (patch) | |
tree | 0dfddf3d0ce57d16443b7a635916c4303b5891de | |
parent | 9ec145ef02562f9f42618e86c751141d860d3db6 (diff) | |
download | ibus-957b778d361fa270e37bc403c2640698f4718e29.tar.gz ibus-957b778d361fa270e37bc403c2640698f4718e29.tar.xz ibus-957b778d361fa270e37bc403c2640698f4718e29.zip |
Check current uid during startup.
-rw-r--r-- | bus/main.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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"); |