From 2cb8f8c872b09f76e8557af852e7847e4523913d Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 8 Apr 2024 21:02:18 +0900 Subject: [PATCH] e_keyrouter: remove duplicated smack check code Change-Id: I26f1b80078d44a0d2cfdea1a4d58bb38a09f8f47 Signed-off-by: Jihoon Kim --- src/bin/e_devicemgr_wl.c | 14 ++------------ src/bin/e_keyrouter_wl.c | 25 ++++++------------------- 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/src/bin/e_devicemgr_wl.c b/src/bin/e_devicemgr_wl.c index 9fc26bcaff..440a460e11 100644 --- a/src/bin/e_devicemgr_wl.c +++ b/src/bin/e_devicemgr_wl.c @@ -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; diff --git a/src/bin/e_keyrouter_wl.c b/src/bin/e_keyrouter_wl.c index 47af80c976..6f67135eef 100644 --- a/src/bin/e_keyrouter_wl.c +++ b/src/bin/e_keyrouter_wl.c @@ -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 -- 2.34.1