Move privilege checker to gesture-server
[platform/core/api/gesture.git] / client / gesture_client_dbus.c
index ce5eec6..532ac88 100644 (file)
@@ -34,6 +34,7 @@ static int g_sensitivity = 1;
 static char *g_engine_app_id;
 static char *g_engine_name;
 
+
 static void _server_appeared_cb(GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data)
 {
        LOGD("name : %s, name_owner : %s", name, name_owner);
@@ -338,19 +339,22 @@ static int gdbus_send_message_with_async(GDBusConnection *gdbus_connection, GVar
        return ret;
 }
 
-static int _monitor_register(GDBusConnection *gdbus_connection)
+static int _monitor_register(GDBusConnection *gdbus_connection, const char *uid, const char *smack_label)
 {
        int ret;
        GDBusMessage *reply = NULL;
        GVariant *client_body = NULL;
 
        char appid[1024] = {0, };
-       ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
+       int pid = getpid();
+       ret = aul_app_get_appid_bypid(pid, appid, sizeof(appid));
        if (ret != 0) {
                LOGE("aul_app_get_appid_bypid() failed : %d", ret);
        }
 
-       client_body = g_variant_new("(iis)", 11, GESTURE_CLIENT_LIB_GESTURE, appid);
+       LOGI("[INFO] appid(%s), pid(%d), uid(%s), smack_label(%s)", appid, pid, uid, smack_label);
+
+       client_body = g_variant_new("(iisiss)", 11, GESTURE_CLIENT_LIB_GESTURE, appid, pid, uid, smack_label);
 
        ret = gdbus_send_message_with_sync(gdbus_connection, client_body, &reply, GESTURE_MSG_SERVICE_REGISTER);
        if (reply)
@@ -373,8 +377,12 @@ static void _on_name_appeared(GDBusConnection *connection,
                const gchar     *name_owner,
                gpointer         user_data)
 {
-       if (is_server_started == 0)
-       _monitor_register(connection);
+       struct hand_gesture_s *_struct = user_data;
+
+       if (is_server_started == 0) {
+               LOGI("uid(%s), smack_label(%s)", _struct->uid, _struct->smack_label);
+               _monitor_register(connection, _struct->uid, _struct->smack_label);
+       }
 }
 
 static void _on_name_vanished(GDBusConnection *connection,
@@ -385,7 +393,7 @@ static void _on_name_vanished(GDBusConnection *connection,
 }
 
 int gesture_client_dbus_init(GDBusConnection **gdbus_connection, guint *server_watcher_id,
-                               int *monitor_id, int *server_monitor_id, CLIENT_LIB lib, void *data)
+                               int *monitor_id, int *server_monitor_id, CLIENT_LIB lib, const char *uid, const char *smack_label, void *data)
 {
        LOGD("gesture_client_dbus_init start");
 
@@ -403,7 +411,7 @@ int gesture_client_dbus_init(GDBusConnection **gdbus_connection, guint *server_w
                return ret;
        }
 
-       ret = _monitor_register(*gdbus_connection);
+       ret = _monitor_register(*gdbus_connection, uid, smack_label);
        if (ret != HAND_GESTURE_ERROR_NONE) {
                LOGE("_monitor_register() failed : %d", ret);
                return ret;
@@ -416,7 +424,7 @@ int gesture_client_dbus_init(GDBusConnection **gdbus_connection, guint *server_w
                                G_BUS_NAME_WATCHER_FLAGS_NONE,
                                _on_name_appeared,
                                _on_name_vanished,
-                               NULL,
+                               data,
                                NULL);
                if (*server_monitor_id == 0) {
                        g_dbus_connection_signal_unsubscribe(*gdbus_connection, *monitor_id);