summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Huang <shawn.p.huang@gmail.com>2009-02-25 11:03:31 +0800
committerPeng Huang <shawn.p.huang@gmail.com>2009-02-25 11:03:31 +0800
commit957b778d361fa270e37bc403c2640698f4718e29 (patch)
tree0dfddf3d0ce57d16443b7a635916c4303b5891de
parent9ec145ef02562f9f42618e86c751141d860d3db6 (diff)
downloadibus-957b778d361fa270e37bc403c2640698f4718e29.tar.gz
ibus-957b778d361fa270e37bc403c2640698f4718e29.tar.xz
ibus-957b778d361fa270e37bc403c2640698f4718e29.zip
Check current uid during startup.
-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");