Re: [PATCH] text: Respawn input method process if it exits

2013-05-14 Thread Eduardo Lima (Etrunko)
On 05/14/2013 12:47 PM, Michael Hasselmann wrote:
> On Tue, 2013-05-14 at 12:16 -0300, Eduardo Lima (Etrunko) wrote:
>> +static void launch_input_method(struct text_backend *text_backend);
>> +
>>  static void
>>  handle_input_method_sigchld(struct weston_process *process, int status)
>>  {
>> +uint32_t time;
>>  struct text_backend *text_backend =
>>  container_of(process, struct text_backend, 
>> input_method.process);
>>  
>>  text_backend->input_method.process.pid = 0;
>>  text_backend->input_method.client = NULL;
>> +
>> +/* if input_method dies more than 5 times in 10 seconds, give up */
>> +time = weston_compositor_get_time();
>> +if (time - text_backend->input_method.deathstamp > 1) {
>> +text_backend->input_method.deathstamp = time;
>> +text_backend->input_method.deathcount = 0;
>> +}
>> +
>> +text_backend->input_method.deathcount++;
>> +if (text_backend->input_method.deathcount > 5) {
>> +weston_log("weston-desktop-shell died, giving up.\n");
> 
> Wrong log message, should be "input_method died, giving up.\n"
>  

Ah the wonders of copy and paste, thanks for the spot. :) I am sending
the patch with the proper message again.

>> +return;
>> +}
>> +
>> +weston_log("input_method died, respawning...\n");
>> +launch_input_method(text_backend);
> 
> I am not smart enough to figure out whether this could be abused to
> launch a (possibly untrusted) 3rd party input method at runtime, say by
> manipulating some cached config and then triggering a crash in the input
> method.
> 

Yes, this is something that should concern not only the input method,
but also other plugins, such as the desktop shell itself.

Regards, Etrunko

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer, Open Source Technology Center
Intel Corporation
São Paulo, Brazil
eduardo.l...@linux.intel.com
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] text: Respawn input method process if it exits

2013-05-14 Thread Michael Hasselmann
On Tue, 2013-05-14 at 12:16 -0300, Eduardo Lima (Etrunko) wrote:
> +static void launch_input_method(struct text_backend *text_backend);
> +
>  static void
>  handle_input_method_sigchld(struct weston_process *process, int status)
>  {
> + uint32_t time;
>   struct text_backend *text_backend =
>   container_of(process, struct text_backend, 
> input_method.process);
>  
>   text_backend->input_method.process.pid = 0;
>   text_backend->input_method.client = NULL;
> +
> + /* if input_method dies more than 5 times in 10 seconds, give up */
> + time = weston_compositor_get_time();
> + if (time - text_backend->input_method.deathstamp > 1) {
> + text_backend->input_method.deathstamp = time;
> + text_backend->input_method.deathcount = 0;
> + }
> +
> + text_backend->input_method.deathcount++;
> + if (text_backend->input_method.deathcount > 5) {
> + weston_log("weston-desktop-shell died, giving up.\n");

Wrong log message, should be "input_method died, giving up.\n"

> + return;
> + }
> +
> + weston_log("input_method died, respawning...\n");
> + launch_input_method(text_backend);

I am not smart enough to figure out whether this could be abused to
launch a (possibly untrusted) 3rd party input method at runtime, say by
manipulating some cached config and then triggering a crash in the input
method.

ciao Michael

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH] text: Respawn input method process if it exits

2013-05-14 Thread Eduardo Lima (Etrunko)
From: "Eduardo Lima (Etrunko)" 

Just the same as it is done in shell.c, if the input method process exits
for any reason, we relaunch it automatically, as it is not possible to
launch a standalone application outside of the weston process.

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/text-backend.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/src/text-backend.c b/src/text-backend.c
index d7ce31c..52c0814 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -23,6 +23,7 @@
 
 #include 
 #include 
+#include 
 
 #include "compositor.h"
 #include "text-server-protocol.h"
@@ -91,6 +92,9 @@ struct text_backend {
struct wl_resource *binding;
struct weston_process process;
struct wl_client *client;
+
+   unsigned deathcount;
+   uint32_t deathstamp;
} input_method;
 
struct wl_listener seat_created_listener;
@@ -819,14 +823,33 @@ input_method_init_seat(struct weston_seat *seat)
seat->input_method->focus_listener_initialized = 1;
 }
 
+static void launch_input_method(struct text_backend *text_backend);
+
 static void
 handle_input_method_sigchld(struct weston_process *process, int status)
 {
+   uint32_t time;
struct text_backend *text_backend =
container_of(process, struct text_backend, 
input_method.process);
 
text_backend->input_method.process.pid = 0;
text_backend->input_method.client = NULL;
+
+   /* if input_method dies more than 5 times in 10 seconds, give up */
+   time = weston_compositor_get_time();
+   if (time - text_backend->input_method.deathstamp > 1) {
+   text_backend->input_method.deathstamp = time;
+   text_backend->input_method.deathcount = 0;
+   }
+
+   text_backend->input_method.deathcount++;
+   if (text_backend->input_method.deathcount > 5) {
+   weston_log("weston-desktop-shell died, giving up.\n");
+   return;
+   }
+
+   weston_log("input_method died, respawning...\n");
+   launch_input_method(text_backend);
 }
 
 static void
-- 
1.8.1.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel