text: Only allow input-method started by weston to bind
authorJan Arne Petersen <jpetersen@openismus.com>
Thu, 18 Apr 2013 14:47:31 +0000 (16:47 +0200)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 2 May 2013 20:41:48 +0000 (16:41 -0400)
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
src/text-backend.c

index 07a066c..53aa92c 100644 (file)
@@ -759,17 +759,24 @@ bind_input_method(struct wl_client *client,
                                        NULL,
                                        id, input_method);
 
-       if (input_method->input_method_binding == NULL) {
-               resource->destroy = unbind_input_method;
-               input_method->input_method_binding = resource;
+       if (input_method->input_method_binding != NULL) {
+               wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
+                                      "interface object already bound");
+               wl_resource_destroy(resource);
+               return;
+       }
 
-               text_backend->input_method.binding = resource;
+       if (text_backend->input_method.client != client) {
+               wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
+                                      "permission to bind desktop_shell denied");
+               wl_resource_destroy(resource);
                return;
        }
 
-       wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
-                              "interface object already bound");
-       wl_resource_destroy(resource);
+       resource->destroy = unbind_input_method;
+       input_method->input_method_binding = resource;
+
+       text_backend->input_method.binding = resource;
 }
 
 static void