enable privilege checks 20/216620/2
authorjeon <jhyuni.kang@samsung.com>
Tue, 29 Oct 2019 11:43:30 +0000 (20:43 +0900)
committerjeon <jhyuni.kang@samsung.com>
Wed, 30 Oct 2019 07:23:01 +0000 (16:23 +0900)
Change-Id: I63d973e167477c03281a07e328c78e38d79a55d0

src/e_mod_main.c

index 1146b81..5f57047 100644 (file)
@@ -11,6 +11,20 @@ static void _e_gesture_init_handlers(void);
 static void _e_gesture_wl_client_cb_destroy(struct wl_listener *l, void *data);
 static void _e_gesture_wl_surface_cb_destroy(struct wl_listener *l, void *data);
 
+
+static Eina_Bool
+_e_gesture_privilege_check(struct wl_client *client, const char *privilege)
+{
+   Eina_Bool res;
+   pid_t pid = 0;
+   uid_t uid = 0;
+
+   wl_client_get_credentials(client, &pid, &uid, NULL);
+   res = e_security_privilege_check(pid, uid, privilege);
+
+   return res;
+}
+
 static Eina_Bool
 _e_gesture_edge_boundary_check(E_Gesture_Event_Edge_Finger *fingers, unsigned int edge, int sp, int ep)
 {
@@ -1431,7 +1445,12 @@ _e_gesture_cb_grab_edge_swipe(struct wl_client *client,
 {
    int ret = TIZEN_GESTURE_ERROR_NONE;
 
-   ret = _e_gesture_grab_edge_swipe(client, resource, fingers, edge, edge_size, start_point, end_point);
+   if (_e_gesture_privilege_check(client, E_PRIVILEGE_GESTURE_GRAB))
+     {
+        ret = _e_gesture_grab_edge_swipe(client, resource, fingers, edge, edge_size, start_point, end_point);
+     }
+   else
+     ret = TIZEN_GESTURE_ERROR_NO_PERMISSION;
 
    tizen_gesture_send_grab_edge_swipe_notify(resource, fingers, edge, edge_size, start_point, end_point, ret);
 }
@@ -1444,7 +1463,12 @@ _e_gesture_cb_ungrab_edge_swipe(struct wl_client *client,
 {
    int ret = TIZEN_GESTURE_ERROR_NONE;
 
-   ret = _e_gesture_ungrab_edge_swipe(client, resource, fingers, edge, edge_size, start_point, end_point);
+   if (_e_gesture_privilege_check(client, E_PRIVILEGE_GESTURE_GRAB))
+     {
+        ret = _e_gesture_ungrab_edge_swipe(client, resource, fingers, edge, edge_size, start_point, end_point);
+     }
+   else
+     ret = TIZEN_GESTURE_ERROR_NO_PERMISSION;
 
    tizen_gesture_send_grab_edge_swipe_notify(resource, fingers, edge, edge_size, start_point, end_point, ret);
 }
@@ -1457,7 +1481,12 @@ _e_gesture_cb_grab_edge_drag(struct wl_client *client,
 {
    int ret = TIZEN_GESTURE_ERROR_NONE;
 
-   ret = _e_gesture_grab_edge_drag(client, resource, fingers, edge, edge_size, start_point, end_point);
+   if (_e_gesture_privilege_check(client, E_PRIVILEGE_GESTURE_GRAB))
+     {
+        ret = _e_gesture_grab_edge_drag(client, resource, fingers, edge, edge_size, start_point, end_point);
+     }
+   else
+     ret = TIZEN_GESTURE_ERROR_NO_PERMISSION;
 
    tizen_gesture_send_grab_edge_swipe_notify(resource, fingers, edge, edge_size, start_point, end_point, ret);
 }
@@ -1470,7 +1499,12 @@ _e_gesture_cb_ungrab_edge_drag(struct wl_client *client,
 {
    int ret = TIZEN_GESTURE_ERROR_NONE;
 
-   ret = _e_gesture_ungrab_edge_drag(client, resource, fingers, edge, edge_size, start_point, end_point);
+   if (_e_gesture_privilege_check(client, E_PRIVILEGE_GESTURE_GRAB))
+     {
+        ret = _e_gesture_ungrab_edge_drag(client, resource, fingers, edge, edge_size, start_point, end_point);
+     }
+   else
+     ret = TIZEN_GESTURE_ERROR_NO_PERMISSION;
 
    tizen_gesture_send_grab_edge_swipe_notify(resource, fingers, edge, edge_size, start_point, end_point, ret);
 }
@@ -1482,7 +1516,12 @@ _e_gesture_cb_grab_tap(struct wl_client *client,
 {
    int ret = TIZEN_GESTURE_ERROR_NONE;
 
-   ret = _e_gesture_grab_tap(client, resource, fingers, repeats);
+   if (_e_gesture_privilege_check(client, E_PRIVILEGE_GESTURE_GRAB))
+     {
+        ret = _e_gesture_grab_tap(client, resource, fingers, repeats);
+     }
+   else
+     ret = TIZEN_GESTURE_ERROR_NO_PERMISSION;
 
    tizen_gesture_send_tap_notify(resource, fingers, repeats, ret);
 }
@@ -1494,7 +1533,12 @@ _e_gesture_cb_ungrab_tap(struct wl_client *client,
 {
    int ret = TIZEN_GESTURE_ERROR_NONE;
 
-   ret = _e_gesture_ungrab_tap(client, resource, fingers, repeats);
+   if (_e_gesture_privilege_check(client, E_PRIVILEGE_GESTURE_GRAB))
+     {
+        ret = _e_gesture_ungrab_tap(client, resource, fingers, repeats);
+     }
+   else
+     ret = TIZEN_GESTURE_ERROR_NO_PERMISSION;
 
    tizen_gesture_send_tap_notify(resource, fingers, repeats, ret);
 }
@@ -1505,7 +1549,12 @@ _e_gesture_cb_grab_palm_cover(struct wl_client *client,
 {
    int ret = TIZEN_GESTURE_ERROR_NONE;
 
-   ret = _e_gesture_grab_palm_cover(client, resource);
+   if (_e_gesture_privilege_check(client, E_PRIVILEGE_GESTURE_GRAB))
+     {
+        ret = _e_gesture_grab_palm_cover(client, resource);
+     }
+   else
+     ret = TIZEN_GESTURE_ERROR_NO_PERMISSION;
 
    tizen_gesture_send_palm_cover_notify(resource, NULL, ret);
 }
@@ -1516,7 +1565,12 @@ _e_gesture_cb_ungrab_palm_cover(struct wl_client *client,
 {
    int ret = TIZEN_GESTURE_ERROR_NONE;
 
-   ret = _e_gesture_ungrab_palm_cover(client, resource);
+   if (_e_gesture_privilege_check(client, E_PRIVILEGE_GESTURE_GRAB))
+     {
+        ret = _e_gesture_ungrab_palm_cover(client, resource);
+     }
+   else
+     ret = TIZEN_GESTURE_ERROR_NO_PERMISSION;
 
    tizen_gesture_send_palm_cover_notify(resource, NULL, ret);
 }
@@ -1553,11 +1607,21 @@ _e_gesture_cb_activate_set(struct wl_client *client,
 {
    int ret = TIZEN_GESTURE_ERROR_NONE;
 
+   if (!surface)
+     {
+        if (!_e_gesture_privilege_check(client, E_PRIVILEGE_GESTURE_ACTIVATE))
+          {
+             ret = TIZEN_GESTURE_ERROR_NO_PERMISSION;
+             goto notify;
+          }
+     }
+
    if (!active)
      ret = _e_gesture_deactivate_set(client, resource, surface, type);
    else
      ret = _e_gesture_deactivate_unset(client, resource, surface, type);
 
+notify:
    tizen_gesture_send_activate_notify(resource, surface, type, active, ret);
 }