e_keyrouter: remove duplicated smack check code accepted/tizen/unified/20240409.135612 accepted/tizen/unified/20240409.155911 accepted/tizen/unified/x/20240411.011835
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 8 Apr 2024 12:02:18 +0000 (21:02 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 9 Apr 2024 01:52:31 +0000 (10:52 +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 f91e126895f475c42eeabdabc141af115300c75e..66d477796be858031f65f0cb980ee6bbd51581df 100644 (file)
@@ -38,32 +38,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 aa397d7cba3d6c41c33ab8922b03caf6a87220ea..2a5b07eabad1a20d96ef41fdb94643d4ef5c66a0 100644 (file)
@@ -607,8 +607,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;
@@ -627,7 +626,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)
@@ -663,25 +662,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