Get a privilege check option from a configuration file 89/59589/2
authorJengHyun Kang <jhyuni.kang@samsung.com>
Tue, 16 Feb 2016 12:48:04 +0000 (21:48 +0900)
committerJengHyun Kang <jhyuni.kang@samsung.com>
Wed, 17 Feb 2016 05:39:52 +0000 (14:39 +0900)
Change-Id: I08ed062e665dd739d729bb0abd24920bb3d31bba

src/e_mod_keyrouter_conf.c
src/e_mod_main_wl.c
src/e_mod_main_wl.h

index 57dc594..5fc4e0a 100644 (file)
@@ -15,6 +15,7 @@ e_keyrouter_conf_init(E_Keyrouter_Config_Data *kconfig)
 #define D kconfig->conf_hwkeys_edd
    E_CONFIG_VAL(D, T, name, STR);
    E_CONFIG_VAL(D, T, keycode, INT);
+   E_CONFIG_VAL(D, T, no_privcheck, INT);
 
    kconfig->conf_edd = E_CONFIG_DD_NEW("Keyrouter_Config", E_Keyrouter_Conf_Edd);
 #undef T
index f8edad7..5bf34ff 100644 (file)
@@ -22,7 +22,7 @@ static int _e_keyrouter_keygrab_unset(struct wl_client *client, struct wl_resour
 
 #ifdef ENABLE_CYNARA
 static void _e_keyrouter_util_cynara_log(const char *func_name, int err);
-static Eina_Bool _e_keyrouter_util_do_privilege_check(struct wl_client *client, int socket_fd, uint32_t mode);
+static Eina_Bool _e_keyrouter_util_do_privilege_check(struct wl_client *client, int socket_fd, uint32_t mode, uint32_t keycode);
 
 #define E_KEYROUTER_CYNARA_ERROR_CHECK_GOTO(func_name, ret, label) \
   do \
@@ -43,7 +43,7 @@ _e_keyrouter_keygrab_set(struct wl_client *client, struct wl_resource *surface,
 
 #ifdef ENABLE_CYNARA
    if (EINA_FALSE == _e_keyrouter_util_do_privilege_check(client,
-                       wl_client_get_fd(client), mode))
+                       wl_client_get_fd(client), mode, key))
      {
         return TIZEN_KEYROUTER_ERROR_NO_PERMISSION;
      }
@@ -99,7 +99,7 @@ _e_keyrouter_keygrab_unset(struct wl_client *client, struct wl_resource *surface
 
 #ifdef ENABLE_CYNARA
    if (EINA_FALSE == _e_keyrouter_util_do_privilege_check(client,
-                       wl_client_get_fd(client), TIZEN_KEYROUTER_MODE_NONE))
+                       wl_client_get_fd(client), TIZEN_KEYROUTER_MODE_NONE, key))
      {
         return TIZEN_KEYROUTER_ERROR_NONE;
      }
@@ -512,6 +512,7 @@ _e_keyrouter_query_tizen_key_table(void)
 
         krt->HardKeys[data->keycode].keycode = data->keycode;
         krt->HardKeys[data->keycode].keyname = eina_stringshare_add(data->name);
+        krt->HardKeys[data->keycode].no_privcheck = data->no_privcheck ? EINA_TRUE : EINA_FALSE;
      }
 
    TRACE_END();
@@ -635,7 +636,7 @@ _e_keyrouter_util_cynara_log(const char *func_name, int err)
 }
 
 static Eina_Bool
-_e_keyrouter_util_do_privilege_check(struct wl_client *client, int socket_fd, uint32_t mode)
+_e_keyrouter_util_do_privilege_check(struct wl_client *client, int socket_fd, uint32_t mode, uint32_t keycode)
 {
    int ret, pid, retry_cnt=0;
    char *clientSmack=NULL, *uid=NULL, *client_session=NULL;
@@ -648,6 +649,9 @@ _e_keyrouter_util_do_privilege_check(struct wl_client *client, int socket_fd, ui
    if (mode == TIZEN_KEYROUTER_MODE_TOPMOST)
      return EINA_TRUE;
 
+   if (krt->HardKeys[keycode].no_privcheck == EINA_TRUE)
+     return EINA_TRUE;
+
    /* If initialize cynara is failed, allow keygrabs regardless of the previlege permition. */
    if (krt->p_cynara == NULL)
      {
index 57e586e..d66197b 100644 (file)
@@ -86,12 +86,14 @@ struct _E_Keyrouter_Tizen_HWKey
 {
    char *name;
    int keycode;
+   int no_privcheck;
 };
 
 struct _E_Keyrouter_Grabbed_Key
 {
    int keycode;
    char* keyname;
+   Eina_Bool no_privcheck;
 
    Eina_List *excl_ptr;
    Eina_List *or_excl_ptr;