e_keyrouter: remove duplicated smack check code 45/309345/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 8 Apr 2024 12:02:18 +0000 (21:02 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 9 Apr 2024 04:54:42 +0000 (13:54 +0900)
Change-Id: I26f1b80078d44a0d2cfdea1a4d58bb38a09f8f47
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/e_devicemgr_wl.c
src/bin/e_keyrouter_wl.c

index 9fc26bcaffb6c7080a3fae0cb36ab68a9a115752..440a460e1131d222bd06f4ffcfda79b59e994b3c 100644 (file)
@@ -32,32 +32,22 @@ static Eina_Bool
 _e_devicemgr_util_do_privilege_check(struct wl_client *client, int socket_fd, const char *rule)
 {
    int ret, pid;
-   char *clientSmack=NULL, *uid=NULL, *client_session=NULL;
+   char *uid = NULL;
    Eina_Bool res = EINA_FALSE;
 
    /* If initialization of cynara has been failed, let's not to do further permission checks. */
    if (e_devicemgr->wl_data->p_cynara == NULL && e_devicemgr->wl_data->cynara_initialized) return EINA_TRUE;
    if (socket_fd < 0) return EINA_FALSE;
 
-   ret = cynara_creds_socket_get_client(socket_fd, CLIENT_METHOD_SMACK, &clientSmack);
-   E_DEVMGR_CYNARA_ERROR_CHECK_GOTO("cynara_creds_socket_get_client", ret, finish);
-
    ret = cynara_creds_socket_get_user(socket_fd, USER_METHOD_UID, &uid);
    E_DEVMGR_CYNARA_ERROR_CHECK_GOTO("cynara_creds_socket_get_user", ret, finish);
 
    ret = cynara_creds_socket_get_pid(socket_fd, &pid);
    E_DEVMGR_CYNARA_ERROR_CHECK_GOTO("cynara_creds_socket_get_pid", ret, finish);
 
-   client_session = cynara_session_from_pid(pid);
-
-   ret = e_security_privilege_check(pid, atoi(uid), rule);
-
-   if (CYNARA_API_ACCESS_ALLOWED == ret)
-        res = EINA_TRUE;
+   res = e_security_privilege_check(pid, atoi(uid), rule);
 
 finish:
-   E_FREE(client_session);
-   E_FREE(clientSmack);
    E_FREE(uid);
 
    return res;
index 47af80c976ee94df523f151c8e1f21ce613302d1..6f67135eef75b647546fea2300d7146740ebd389 100644 (file)
@@ -561,8 +561,7 @@ _e_keyrouter_wl_util_cynara_log(const char *func_name, int err)
 Eina_Bool
 e_keyrouter_wl_util_do_privilege_check(struct wl_client *client, uint32_t mode, uint32_t keycode)
 {
-   int ret, retry_cnt=0, len=0;
-   char *clientSmack=NULL, *client_session=NULL, uid2[16]={0, };
+   int ret, retry_cnt=0;
    Eina_Bool res = EINA_FALSE;
    Eina_List *l;
    struct wl_client *wc_data;
@@ -581,7 +580,7 @@ e_keyrouter_wl_util_do_privilege_check(struct wl_client *client, uint32_t mode,
 
    if (!client) return EINA_FALSE;
 
-   /* If initialize cynara is failed, allow keygrabs regardless of the previlege permition. */
+   /* If initialize cynara is failed, allow keygrabs regardless of the privilege permission. */
    if (krt->p_cynara == NULL)
      {
         if (retried == EINA_FALSE)
@@ -617,25 +616,13 @@ e_keyrouter_wl_util_do_privilege_check(struct wl_client *client, uint32_t mode,
 
    wl_client_get_credentials(client, &pid, &uid, &gid);
 
-   len = smack_new_label_from_process((int)pid, &clientSmack);
-   if (len <= 0) goto finish;
-
-   snprintf(uid2, 15, "%d", (int)uid);
-   client_session = cynara_session_from_pid(pid);
-
-   ret = e_security_privilege_check(pid, uid, "http://tizen.org/privilege/keygrab");
-   if (CYNARA_API_ACCESS_ALLOWED == ret)
+   res = e_security_privilege_check(pid, uid, "http://tizen.org/privilege/keygrab");
+   if (!res)
      {
-        res = EINA_TRUE;
+        KLINF("Fail to check cynara,  (pid : %d)", pid);
      }
-   else
-     {
-        KLINF("Fail to check cynara,  error : %d (pid : %d)", ret, pid);
-     }
-finish:
-   if (client_session) E_FREE(client_session);
-   if (clientSmack) E_FREE(clientSmack);
 
+finish:
    return res;
 }
 #endif