Re: [PATCH weston] compositor-rdp: Correct mouse scrolling direction

2018-02-21 Thread Hardening
Le 09/02/2018 à 17:14, Jason Gerecke a écrit :
> The direction of scrolling in the RDP compositor appears to be inverted.
> When using Weston directly in X, sending X11 button 4 cuases window
> contents to scroll up and button 4 to be reported to xwayland clients.
> Conversely, when using Weston through RDP (xfreerdp client), sending
> X11 button 4 causes window contents to scroll down and button 5 to be
> reported to xwayland clients. The xfreerdp client does not seem to be
> the cause of this since scrolling works correctly when connecting to
> a Windows host.
> 
> Signed-off-by: Jason Gerecke 
> ---
>  libweston/compositor-rdp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
> index 4a4dc696..ee68e969 100644
> --- a/libweston/compositor-rdp.c
> +++ b/libweston/compositor-rdp.c
> @@ -1062,7 +1062,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
> UINT16 y)
>*
>* 
> https://blogs.msdn.microsoft.com/oldnewthing/20130123-00/?p=5473 explains the 
> 120 value
>*/
> - value = (flags & 0xff) / 120.0;
> + value = -(flags & 0xff) / 120.0;
>   if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
>   value = -value;
>  
> 
Looks good.

Reviewed-by: David FORT 

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH weston] compositor-rdp: Correct mouse scrolling direction

2018-02-21 Thread Hardening
Le 21/02/2018 à 11:09, Hardening a écrit :
> Le 09/02/2018 à 17:14, Jason Gerecke a écrit :
>> The direction of scrolling in the RDP compositor appears to be inverted.
>> When using Weston directly in X, sending X11 button 4 cuases window
>> contents to scroll up and button 4 to be reported to xwayland clients.
>> Conversely, when using Weston through RDP (xfreerdp client), sending
>> X11 button 4 causes window contents to scroll down and button 5 to be
>> reported to xwayland clients. The xfreerdp client does not seem to be
>> the cause of this since scrolling works correctly when connecting to
>> a Windows host.
>>
>> Signed-off-by: Jason Gerecke 
>> ---
>>  libweston/compositor-rdp.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
>> index 4a4dc696..ee68e969 100644
>> --- a/libweston/compositor-rdp.c
>> +++ b/libweston/compositor-rdp.c
>> @@ -1062,7 +1062,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
>> UINT16 y)
>>   *
>>   * 
>> https://blogs.msdn.microsoft.com/oldnewthing/20130123-00/?p=5473 explains 
>> the 120 value
>>   */
>> -value = (flags & 0xff) / 120.0;
>> +value = -(flags & 0xff) / 120.0;
>>  if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
>>  value = -value;
>>  
>>
> Looks good.
> 
> Reviewed-by: David FORT 
> 
Pushed:

1f78176..9fc2e46  master -> master

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH 2/3] gl-renderer: read PIXMAN_x8r8g8b8 as GL_BGRA_EXT

2018-04-03 Thread Hardening
Le 06/07/2017 à 12:06, Olivier Blin a écrit :
> This is needed by the RDP backend, which uses PIXMAN_x8r8g8b8 for its
> shadow buffers.
> ---
>  libweston/gl-renderer.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
> index da29b072..b8b120a1 100644
> --- a/libweston/gl-renderer.c
> +++ b/libweston/gl-renderer.c
> @@ -1213,6 +1213,7 @@ gl_renderer_read_pixels(struct weston_output *output,
>  
>   switch (format) {
>   case PIXMAN_a8r8g8b8:
> + case PIXMAN_x8r8g8b8:
>   gl_format = GL_BGRA_EXT;
>   break;
>   case PIXMAN_a8b8g8r8:
> 

Reviewed-by: David Fort 

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH 3/3] rdp-backend.so: OpenGL hardware acceleration

2018-04-03 Thread Hardening
Le 06/07/2017 à 12:06, Olivier Blin a écrit :
> From: DRC 
> 
> ---
>  compositor/main.c  |  23 +++-
>  configure.ac   |   4 +-
>  libweston/compositor-rdp.c | 314 
> +++--
>  libweston/compositor-rdp.h |  24 
>  4 files changed, 352 insertions(+), 13 deletions(-)
> 
> diff --git a/compositor/main.c b/compositor/main.c
> index f8a60e97..125cc0f8 100644
> --- a/compositor/main.c
> +++ b/compositor/main.c
> @@ -601,6 +601,7 @@ usage(int error_code)
>   "  --rdp4-key=FILE\tThe file containing the key for RDP4 
> encryption\n"
>   "  --rdp-tls-cert=FILE\tThe file containing the certificate for 
> TLS encryption\n"
>   "  --rdp-tls-key=FILE\tThe file containing the private key for 
> TLS encryption\n"
> + "  --use-pixman\t\tUse the pixman (CPU) renderer\n"
>   "\n");
>  #endif
>  
> @@ -1331,11 +1332,14 @@ static void
>  rdp_backend_output_configure(struct wl_listener *listener, void *data)
>  {
>   struct weston_output *output = data;
> + struct weston_config *wc = wet_get_config(output->compositor);
>   struct wet_compositor *compositor = 
> to_wet_compositor(output->compositor);
>   struct wet_output_config *parsed_options = compositor->parsed_options;
> + struct weston_config_section *section;
>   const struct weston_rdp_output_api *api = 
> weston_rdp_output_get_api(output->compositor);
>   int width = 640;
>   int height = 480;
> + char *gbm_format = NULL;
>  
>   assert(parsed_options);
>  
> @@ -1344,6 +1348,8 @@ rdp_backend_output_configure(struct wl_listener 
> *listener, void *data)
>   return;
>   }
>  
> + section = weston_config_get_section(wc, "output", "name", output->name);
> +
>   if (parsed_options->width)
>   width = parsed_options->width;
>  
> @@ -1353,6 +1359,12 @@ rdp_backend_output_configure(struct wl_listener 
> *listener, void *data)
>   weston_output_set_scale(output, 1);
>   weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
>  
> + weston_config_section_get_string(section,
> +  "gbm-format", &gbm_format, NULL);
> +
> + api->set_gbm_format(output, gbm_format);
> + free(gbm_format);
> +
>   if (api->output_set_size(output, width, height) < 0) {
>   weston_log("Cannot configure output \"%s\" using 
> weston_rdp_output_api.\n",
>  output->name);
> @@ -1375,6 +1387,7 @@ weston_rdp_backend_config_init(struct 
> weston_rdp_backend_config *config)
>   config->server_key = NULL;
>   config->env_socket = 0;
>   config->no_clients_resize = 0;
> + config->use_pixman = false;
>  }
>  
>  static int
> @@ -1382,6 +1395,7 @@ load_rdp_backend(struct weston_compositor *c,
>   int *argc, char *argv[], struct weston_config *wc)
>  {
>   struct weston_rdp_backend_config config  = {{ 0, }};
> + struct weston_config_section *section;
>   int ret = 0;
>  
>   struct wet_output_config *parsed_options = wet_init_parsed_options(c);
> @@ -1399,11 +1413,17 @@ load_rdp_backend(struct weston_compositor *c,
>   { WESTON_OPTION_BOOLEAN, "no-clients-resize", 0, 
> &config.no_clients_resize },
>   { WESTON_OPTION_STRING,  "rdp4-key", 0, &config.rdp_key },
>   { WESTON_OPTION_STRING,  "rdp-tls-cert", 0, &config.server_cert 
> },
> - { WESTON_OPTION_STRING,  "rdp-tls-key", 0, &config.server_key }
> + { WESTON_OPTION_STRING,  "rdp-tls-key", 0, &config.server_key },
> + { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &config.use_pixman }
>   };
>  
>   parse_options(rdp_options, ARRAY_LENGTH(rdp_options), argc, argv);
>  
> + section = weston_config_get_section(wc, "core", NULL, NULL);
> + weston_config_section_get_string(section,
> +  "gbm-format", &config.gbm_format,
> +  NULL);
> +
>   ret = weston_compositor_load_backend(c, WESTON_BACKEND_RDP,
>&config.base);
>  
> @@ -1417,6 +1437,7 @@ out:
>   free(config.rdp_key);
>   free(config.server_cert);
>   free(config.server_key);
> + free(config.gbm_format);
>  
>   return ret;
>  }
> diff --git a/configure.ac b/configure.ac
> index 53faee34..a7b2d517 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -250,9 +250,9 @@ AM_CONDITIONAL([ENABLE_RDP_COMPOSITOR],
> [test x$enable_rdp_compositor = xyes])
>  if test x$enable_rdp_compositor = xyes; then
>AC_DEFINE([BUILD_RDP_COMPOSITOR], [1], [Build the RDP compositor])
> -  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp2 >= 2.0.0],
> +  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp2 >= 2.0.0 libudev >= 136 gbm],
>  [],
> -[PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0],[])]
> +[PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0 l

Re: [PATCH weston] compositor-rdp: fix compilation with freerdp 2.0.0-rc2

2018-05-23 Thread Hardening
Le 22/05/2018 à 16:12, Pekka Paalanen a écrit :
> On Fri, 11 May 2018 11:47:47 +0200
> Luca Weiss  wrote:
> 
>> See 
>> https://github.com/FreeRDP/FreeRDP/commit/1f7d33a2f22a372c124ce985a394619e186e06b9
>>  for the upstream change.
>>
>> Signed-off-by: Luca Weiss 
>> ---
>>  libweston/compositor-rdp.c | 50 +++---
>>  1 file changed, 25 insertions(+), 25 deletions(-)
>>
> 
> Hi,
> 
> obviously this breaks the build for freerdp 2.0.0-rc1. Personally I'd
> be fine with this change, the distro I use has rc2.
> 
> David, do we want to do this? Have we ever or is it feasible to support
> more than a single freerdp version at a time?
> 
> The patch looks fine and works fine for me, so the very least:
> 
> Tested-by: Pekka Paalanen 
> 

Yeah I've hit the same problem on another project using FreeRDP 2.0,
what about testing the bmp field of the SURFACE_BITS_COMMAND struct in
configure.ac and adjusting code ? I can submit something like that
except if Luca want to do it...

Best regards.

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH] rdp-compositor: fix compilation against last FreeRDP 2.0

2018-05-27 Thread Hardening
Le 25/05/2018 à 16:17, Pekka Paalanen a écrit :
> On Thu, 24 May 2018 14:55:20 +0200
> David Fort  wrote:
> 
>> The SURFACE_BITS_COMMAND struct has changed and some members have been moved 
>> in the
>> bmp field.
>> ---
>>  configure.ac   |  5 ++-

[...]

>>  
> 
> Hi,
> 
> with freerdp-2.0.0_rc1, this results in the following and tons more:
> 
> /home/pq/git/weston/libweston/compositor-rdp.c: In function 
> ‘rdp_peer_refresh_rfx’:
> /home/pq/git/weston/libweston/compositor-rdp.c:70:29: error: 
> ‘SURFACE_BITS_COMMAND {aka struct _SURFACE_BITS_COMMAND}’ has no member named 
> ‘bmp’; did you mean ‘bpp’?
>  #define SURFACE_BPP(cmd) cmd->bmp.bpp
>  ^
> /home/pq/git/weston/libweston/compositor-rdp.c:219:2: note: in expansion of 
> macro ‘SURFACE_BPP’
>   SURFACE_BPP(cmd) = 32;
> 
> 
> However, configure says:
> 
> checking for SURFACE_BITS_COMMAND.bmp... no
> 
> 
> But config.h contains:
> 
> /* SURFACE_BITS_CMD has bmp field */
> #define HAVE_SURFACE_BITS_BMP $have_bmp
> 
> So, something to fix. :-)
> 

Hi Pekka,
the new version should works with older versions.

Best regards.

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: Remote display with 3D acceleration using Wayland/Weston

2017-02-28 Thread Hardening
Le 24/02/2017 à 00:51, DRC a écrit :
> On 12/15/16 3:01 AM, Pekka Paalanen wrote:
>> The current RDP-backed is written to set up and use only the Pixman
>> renderer. Pixman renderer is a software renderer, and will not
>> initialize EGL in the compositor. Therefore no support for hardware
>> accelerated OpenGL gets advertised to clients, and clients fall back to
>> software GL.
>>
>> You can fix this purely by modifying libweston/compositor-rdp.c file,
>> writing the support for initializing the GL-renderer. Then you get
>> hardware accelerated GL support for all Wayland clients without any
>> other modifications anywhere.
>>
>> Why that has not been done already is because it was thought that
>> having clients using hardware OpenGL while the compositor is not cannot
>> be performant enough to justify the effort. Also, it pulls in the
>> dependency to EGL and GL libs, which are huge. Obviously your use case
>> is different and this rationale does not apply.
>>
>> The hardest part in adding the support to the RDP-backend is
>> implementing the buffer content access efficiently. RDP requires pixel
>> data in system memory so the CPU can read it, but GL-renderer has all
>> pixel data in graphics memory which often cannot be directly read by
>> the CPU. Accessing that pixel data requires a copy (glReadPixels), and
>> there is nowadays a helper: weston_surface_copy_content(), however the
>> function is not efficient and is so far meant only for debugging and
>> testing.
> 
> I am attempting to modify the RDP backend to prove the concept that
> hardware-accelerated OpenGL is possible with a remote display backend,
> but my lack of familiarity with the code is making this very
> challenging.  It seems that the RDP backend uses Pixman both for GL
> rendering and also to maintain its framebuffer in main memory
> (shadow_surface.)  Is that correct?  If so, then it seems that I would
> need to continue using the shadow surface but use gl_renderer instead of
> the Pixman renderer, then implement my own method of transferring pixels
> from the GL renderer to the shadow surface at the end of every frame (?)
>  I've been trying to work from compositor-wayland.c as a template, but
> it's unclear how everything connects, which parts of that code I need in
> order to implement hardware acceleration, and which parts are
> unnecessary.  I would appreciate it if someone who has familiarity with
> the RDP backend could give me some targeted advice.

This has been done a quite long time ago, here =>
https://gitorious.org/weston/jonseverinsson-weston/?p=weston:jonseverinsson-weston.git;a=commit;h=9e26d9356255f4af1723700272805f6d356c7d7a

It's clearly outdated, and IIRC people here didn't like the way it was
implemented, but you have the idea. It's using DRI render nodes to do
the rendering.

Best regards.
-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH 1/3] compositor-rdp: fix leak of frame bitmap in raw mode

2017-07-09 Thread Hardening
Le 06/07/2017 à 12:06, Olivier Blin a écrit :
> In rdp_peer_refresh_raw(), cmd->bitmapData was reallocated, but never freed.
> 
> The cmd content (actually peer->update->surface_bits_command) was
> re-initialized to zero at the beginning of the function, losing the
> pointer to the previously allocated bitmap data.
> 
> Move the bitmap data in the peer->context structure instead, so that
> it can be reused for every frame, and freed at destruction.
> ---
>  libweston/compositor-rdp.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
> index 091472b0..7b1ab06d 100644
> --- a/libweston/compositor-rdp.c
> +++ b/libweston/compositor-rdp.c
> @@ -142,6 +142,7 @@ struct rdp_peer_context {
>   wStream *encode_stream;
>   RFX_RECT *rfx_rects;
>   NSC_CONTEXT *nsc_context;
> + BYTE * bitmapData;
>  
>   struct rdp_peers_item item;
>  };
> @@ -312,7 +313,10 @@ rdp_peer_refresh_raw(pixman_region32_t *region, 
> pixman_image_t *image, freerdp_p
>  cmd->destTop = top;
>  cmd->destBottom = top + cmd->height;
>  cmd->bitmapDataLength = cmd->width * cmd->height * 4;
> -cmd->bitmapData = (BYTE *)realloc(cmd->bitmapData, 
> cmd->bitmapDataLength);
> +
> +RdpPeerContext *context = (RdpPeerContext 
> *)peer->context;
> +context->bitmapData = (BYTE 
> *)realloc(context->bitmapData, cmd->bitmapDataLength);
> +cmd->bitmapData = context->bitmapData;
>  
>  subrect.y1 = top;
>  subrect.y2 = top + cmd->height;
> @@ -659,6 +663,7 @@ int rdp_implant_listener(struct rdp_backend *b, 
> freerdp_listener* instance)
>  static FREERDP_CB_RET_TYPE
>  rdp_peer_context_new(freerdp_peer* client, RdpPeerContext* context)
>  {
> + context->bitmapData = NULL;
>   context->item.peer = client;
>   context->item.flags = RDP_PEER_OUTPUT_ENABLED;
>  
> @@ -715,6 +720,8 @@ rdp_peer_context_free(freerdp_peer* client, 
> RdpPeerContext* context)
>* but it would crash on reconnect */
>   }
>  
> + free(context->bitmapData);
> +
>   Stream_Free(context->encode_stream, TRUE);
>   nsc_context_free(context->nsc_context);
>   rfx_context_free(context->rfx_context);
> 

Reviewed-by: David Fort 

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH] Fix API troubles with FreeRDP 2.0

2017-09-25 Thread Hardening
Le 25/09/2017 à 10:49, Pekka Paalanen a écrit :
> On Fri, 22 Sep 2017 11:17:41 +0200
> David Fort  wrote:
> 
>> With FreeRDP 2.0 the crypto needs to be initialized or we fail as soon as we 
>> try to
>> compute a md5. The API also changed for the suppress output callback.
>> ---
>>  libweston/compositor-rdp.c | 15 ++-
>>  1 file changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
>> index 091472b..6706765 100644
>> --- a/libweston/compositor-rdp.c
>> +++ b/libweston/compositor-rdp.c
>> @@ -76,6 +76,10 @@
>>  #include 
>>  #include 
>>  
>> +#if FREERDP_VERSION_MAJOR >= 2
>> +#include 
>> +#endif
>> +
>>  #include "shared/helpers.h"
>>  #include "compositor.h"
>>  #include "compositor-rdp.h"
>> @@ -159,6 +163,7 @@ to_rdp_backend(struct weston_compositor *base)
>>  return container_of(base->backend, struct rdp_backend, base);
>>  }
>>  
>> +
> 
> Stray newline?

Sorry, will fix that

> 
>>  static void
>>  rdp_peer_refresh_rfx(pixman_region32_t *damage, pixman_image_t *image, 
>> freerdp_peer *peer)
>>  {
>> @@ -1013,7 +1018,8 @@ xf_peer_activate(freerdp_peer* client)
>>  return TRUE;
>>  }
>>  
>> -static BOOL xf_peer_post_connect(freerdp_peer *client)
>> +static BOOL
>> +xf_peer_post_connect(freerdp_peer *client)
>>  {
>>  return TRUE;
>>  }
>> @@ -1166,7 +1172,11 @@ xf_input_unicode_keyboard_event(rdpInput *input, 
>> UINT16 flags, UINT16 code)
>>  
>>  
>>  static FREERDP_CB_RET_TYPE
>> +#if FREERDP_VERSION_MAJOR >= 2
>> +xf_suppress_output(rdpContext *context, BYTE allow, const RECTANGLE_16 
>> *area)
>> +#else
>>  xf_suppress_output(rdpContext *context, BYTE allow, RECTANGLE_16 *area)
>> +#endif
>>  {
>>  RdpPeerContext *peerContext = (RdpPeerContext *)context;
>>  
>> @@ -1387,6 +1397,9 @@ weston_backend_init(struct weston_compositor 
>> *compositor,
>>  struct weston_rdp_backend_config config = {{ 0, }};
>>  int major, minor, revision;
>>  
>> +#if FREERDP_VERSION_MAJOR >= 2
>> +winpr_InitializeSSL(0);
>> +#endif
>>  freerdp_get_version(&major, &minor, &revision);
>>  weston_log("using FreeRDP version %d.%d.%d\n", major, minor, revision);
>>  
> 
> Hi,
> 
> I currently have net-misc/freerdp-2.0.0_pre20160722. Without this
> patch, the build runs fine.
> 
> When I apply this patch and build, I get:
> 
>   CC   libweston/rdp_backend_la-compositor-rdp.lo
> /home/pq/git/weston/libweston/compositor-rdp.c: In function ‘rdp_peer_init’:
> /home/pq/git/weston/libweston/compositor-rdp.c:1240:33: warning: assignment 
> from incompatible pointer type
>   client->update->SuppressOutput = xf_suppress_output;
>  ^
> 

A const has been added on the rect parameter, ignoring the warning is
ok, but I will resubmit something to drop it. Except with some
configure.ac tests, I'm not sure there's a way to determine if the const
is there (tests on sub-version aren't reliable).


> What is the FreeRDP version we should be using?
> 
> Is there a reasonable way to make the warning go away, is it a fatal
> problem, or should we just live with it and suggest people to upgrade
> their FreeRDP snapshot to fix it?
> 
> Can/should we have more strict FreeRDP configure.ac tests locking us to
> a compatible FreeRDP version?
> 
> FWIW, the FreeRDP versions I seem to have available in Gentoo are:
> freerdp-1.2.1_pre20150326-r1
> freerdp-2.0.0_pre20160722
> freerdp-2.0.0_pre20161219
> freerdp-2.0.0_rc0
> 
> Fedora 26 seems to have freerdp-2.0.0-34.20170831git3b83526.
> 
> 
IIRC I did some tests on Fedora 25 and Fedora 26 and it was compiling
fine. Anyway I noticed that remote connection does not refresh correctly
when plain bitmap encoding is used (looking at that).

Best regards

PS: I did (multiple time) promised a doc to test the RDP compositor, I'm
on it.

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH weston 05/21] libweston: weston_output_init(..., +name)

2017-09-26 Thread Hardening
Le 22/09/2017 à 16:31, Pekka Paalanen a écrit :
> From: Pekka Paalanen 
> 
> Add 'name' argument to weston_output_init(). This is much more obvious
> than the assert inside weston_output_init() to ensure the caller has set
> a field in weston_output first.
> 
> Now weston_output_init() will strdup() the name itself, which means we
> can drop a whole bunch of strdup()s in the backends. This matches
> weston_output_destroy() which was already calling free() on the name.
> 
> All backends are slightly reordered to call weston_output_init() before
> accessing any fields of weston_output, except the Wayland backend which
> would make it a little awkward to do it in this patch. Mind, that
> weston_output_init() still does not reset the struct to zero - it is
> presumed the caller has done it, since weston_output is embedded in the
> backend output structs.
> 
> Signed-off-by: Pekka Paalanen 

Reviewed-by: David Fort 

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


Re: Wayland/weston, Qt and RDP connection...

2024-07-29 Thread Hardening

Le 13/01/2023 à 13:13, Matti Ristimäki a écrit :

Hi,

Any tips, where/how to debug RDP related problem with Wayland/Weston. 
Not kind of sure if this is Weston problem or Qt problem…


Goal:

Trying to create a RDP connection to a Qt GUI-application.

[Service]

# Requires systemd-notify.so Weston plugin.

Type=notify

EnvironmentFile=/etc/default/weston

ExecStart=/usr/bin/weston --log=${XDG_RUNTIME_DIR}/weston.log 
--modules=systemd-notify.so *--modules=screen.share.so*


Problem:

Seems, that the Qt application doesn't start after adding the 
"--modules=screen.share.so" to services. And it doesn’t start:


Hi,

sorry very late reply, but if the goal is to export a Qt app through 
RDP, you may be interested by qfreerdp_platform 
(https://github.com/hardening/qfreerdp_platform). This a QPA (Qt 
Platform Abstraction module) that expose the screen and inputs through a 
RDP listener (using FreeRDP just like the weston-rdp backend).


Best regards.


--
David FORT
website: https://www.hardening-consulting.com/




Re: [PATCH] clients: Fix compositor version check for WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION

2015-12-23 Thread Hardening
Le 20/12/2015 13:41, Chris Michael a écrit :
> Signed-off-by: Chris Michael 
> ---
>  clients/simple-damage.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/clients/simple-damage.c b/clients/simple-damage.c
> index 37a81f5..24c67cc 100644
> --- a/clients/simple-damage.c
> +++ b/clients/simple-damage.c
> @@ -262,7 +262,8 @@ create_window(struct display *display, int width, int 
> height,
>   exit(1);
>   }
>  
> - if (display->compositor_version < 4 &&
> + if (display->compositor_version <
> +WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION &&
>   (flags & WINDOW_FLAG_USE_DAMAGE_BUFFER)) {
>   fprintf(stderr, "wl_surface.damage_buffer unsupported in "
>   "wl_surface version %d\n",
> 
Reviewed-By: David Fort 

-- 
David FORT
website: http://www.hardening-consulting.com/

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


wayalnd client wants to know the keyboard layout

2016-01-14 Thread Hardening
Hello,

I have worked on having the FreeRDP client have a decent wayland
support. On the graphical part everything is quite straight forward
anyway, I'm hitting some troubles with keyboard support (someone could
say as usual when you code something around keyboard).

In X11, xfreerdp queries X about the keyboard layout using XI. That
allows to announce a RDP keyboard layout to the remote server (using a
map table between xkb files and RDP layout) and get the correct virtual
RDP keycode.

But in wayland, I only get the mmaped xkb file, I can't see a robust and
easy way to discover to which xkb file it corresponds. If someone has an
idea...

Best regards.

PS: I guess I will not be the only one to have the problem, yes VNC I'm
talking of you ;)
-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH wayland] scanner: Print filename on DTD validation error

2016-01-25 Thread Hardening
Le 25/01/2016 10:28, Jonas Ådahl a écrit :
> Don't just print prefix the errors with "protocol", but the actual file
> name, if wayland-scanner was passed with the filename of the protocol
> file. If wayland-scanner is reading from stdin, errors will be prefixed
> with "" instead of "protocol".
> 
> Signed-off-by: Jonas Ådahl 
> ---
>  src/scanner.c | 15 ++-
>  1 file changed, 10 insertions(+), 5 deletions(-)

Reviewed-by: David Fort 

> 
> diff --git a/src/scanner.c b/src/scanner.c
> index 1d626f4..dda5473 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -71,7 +71,7 @@ usage(int ret)
>  }
>  
>  static bool
> -is_dtd_valid(FILE *input)
> +is_dtd_valid(FILE *input, const char *filename)
>  {
>   bool rc = true;
>  #if HAVE_LIBXML
> @@ -101,7 +101,7 @@ is_dtd_valid(FILE *input)
>   abort();
>   }
>  
> - doc = xmlCtxtReadFd(ctx, fd, "protocol", NULL, 0);
> + doc = xmlCtxtReadFd(ctx, fd, filename, NULL, 0);
>   if (!doc) {
>   fprintf(stderr, "Failed to read XML\n");
>   abort();
> @@ -1623,6 +1623,7 @@ int main(int argc, char *argv[])
>   struct parse_context ctx;
>   struct protocol protocol;
>   FILE *input = stdin;
> + char *input_filename = NULL;
>   int len;
>   void *buf;
>   bool help = false, core_headers = false;
> @@ -1678,7 +1679,8 @@ int main(int argc, char *argv[])
>   usage(EXIT_FAILURE);
>  
>   if (argc == 3) {
> - input = fopen(argv[1], "r");
> + input_filename = argv[1];
> + input = fopen(input_filename, "r");
>   if (input == NULL) {
>   fprintf(stderr, "Could not open input file: %s\n",
>   strerror(errno));
> @@ -1700,9 +1702,12 @@ int main(int argc, char *argv[])
>   /* initialize context */
>   memset(&ctx, 0, sizeof ctx);
>   ctx.protocol = &protocol;
> - ctx.loc.filename = "";
> + if (input == stdin)
> + ctx.loc.filename = "";
> + else
> + ctx.loc.filename = input_filename;
>  
> - if (!is_dtd_valid(input)) {
> + if (!is_dtd_valid(input, ctx.loc.filename)) {
>   fprintf(stderr,
>   "***\n"
>   "* *\n"
> 


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH weston] input: Implement wl_seat.release

2016-03-16 Thread Hardening
Le 13/03/2016 17:49, Quentin Glidic a écrit :
> From: Quentin Glidic 
> 
> Avoid a crash because listener is NULL.
> 
> Signed-off-by: Quentin Glidic 
> ---
>  src/input.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/input.c b/src/input.c
> index 8c106dd..5d13b08 100644
> --- a/src/input.c
> +++ b/src/input.c
> @@ -2230,10 +2230,17 @@ seat_get_touch(struct wl_client *client, struct 
> wl_resource *resource,
>  seat, unbind_resource);
>  }
>  
> +static void
> +seat_release(struct wl_client *client, struct wl_resource *resource)
> +{
> + wl_resource_destroy(resource);
> +}
> +
>  static const struct wl_seat_interface seat_interface = {
>   seat_get_pointer,
>   seat_get_keyboard,
>   seat_get_touch,
> + seat_release,
>  };
>  
>  static void
> 
Reviewed-By: David Fort 

Definitely my fault, strange that we have not seen this before (I can't
imagine that seats were never released ;) ).

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH wayland 2/3] server: move include directives before extern "C" wrapper

2016-04-17 Thread Hardening
Le 17/04/2016 13:29, Emil Velikov a écrit :
> Analogous to previous commit but for the server(-core) header.
> 
> Signed-off-by: Emil Velikov 
> ---
>  src/wayland-server-core.h | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
> index e8e1e9c..fa7f394 100644
> --- a/src/wayland-server-core.h
> +++ b/src/wayland-server-core.h
> @@ -26,15 +26,15 @@
>  #ifndef WAYLAND_SERVER_CORE_H
>  #define WAYLAND_SERVER_CORE_H
>  
> -#ifdef  __cplusplus
> -extern "C" {
> -#endif
> -
>  #include 
>  #include 
>  #include "wayland-util.h"
>  #include "wayland-version.h"
>  
> +#ifdef  __cplusplus
> +extern "C" {
> +#endif
> +
>  enum {
>   WL_EVENT_READABLE = 0x01,
>   WL_EVENT_WRITABLE = 0x02,
> 

Shouldn't the extern declaration be moved to surround only the functions
declarations (and so not including type defines) ?
That's just a question, if a C++ specialist have an answer...

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH 1/5] rdp: allow to compile against FreeRDP 2.0

2016-04-22 Thread Hardening
Le 22/04/2016 15:19, David Fort a écrit :
> FreeRDP 2.0 is about to be released, this allows to compile against this 
> version.
> 
> Signed-off-by: David Fort 
> ---
>  configure.ac |  8 +++-
>  src/compositor-rdp.c | 23 ---
>  2 files changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 670200c..9c70b2e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -242,12 +242,18 @@ AM_CONDITIONAL([ENABLE_RDP_COMPOSITOR],
> [test x$enable_rdp_compositor = xyes])
>  if test x$enable_rdp_compositor = xyes; then
>AC_DEFINE([BUILD_RDP_COMPOSITOR], [1], [Build the RDP compositor])
> -  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0])
> +  PKG_CHECK_MODULES(FreeRDP, [freerdp >= 1.1.0],
> +[RDP_COMPOSITOR_CFLAGS=$FreeRDP_CFLAGS; 
> RDP_COMPOSITOR_LIBS=$FreeRDP_LIBS;],
> +[PKG_CHECK_MODULES(FreeRDP2, [freerdp2 >= 
> 2.0.0],[RDP_COMPOSITOR_CFLAGS=$FreeRDP2_CFLAGS; 
> RDP_COMPOSITOR_LIBS=$FreeRDP2_LIBS;])]
> +  )
>  
>SAVED_CPPFLAGS="$CPPFLAGS"
>CPPFLAGS="$CPPFLAGS $RDP_COMPOSITOR_CFLAGS"
>AC_CHECK_HEADERS([freerdp/version.h])
>CPPFLAGS="$SAVED_CPPFLAGS"
> +
> +  AC_SUBST(RDP_COMPOSITOR_CFLAGS)
> +  AC_SUBST(RDP_COMPOSITOR_LIBS)
>  fi
>  
>  AC_ARG_ENABLE([screen-sharing], [  --enable-screen-sharing],,
> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
> index 773b6b5..0649bee 100644
> --- a/src/compositor-rdp.c
> +++ b/src/compositor-rdp.c
> @@ -42,15 +42,24 @@
>  #define FREERDP_VERSION_NUMBER ((FREERDP_VERSION_MAJOR * 0x1) + \
>   (FREERDP_VERSION_MINOR * 0x100) + FREERDP_VERSION_REVISION)
>  
> +
>  #if FREERDP_VERSION_NUMBER >= 0x10201
>  #define HAVE_SKIP_COMPRESSION
>  #endif
>  
>  #if FREERDP_VERSION_NUMBER < 0x10202
> -#define FREERDP_CB_RET_TYPE void
> -#define FREERDP_CB_RETURN(V) return
> +#define FREERDP_CB_RET_TYPE void
> +#define FREERDP_CB_RETURN(V) return
> +#define NSC_RESET(C, W, H)
> +#define RFX_RESET(C, W, H) do { rfx_context_reset(C); C->width = W; 
> C->height = H; } while(0)
> +#else
> +#if FREERDP_VERSION_MAJOR >= 2
> +#define NSC_RESET(C, W, H) nsc_context_reset(C, W, H)
> +#define RFX_RESET(C, W, H) rfx_context_reset(C, W, H)
>  #else
> -#define HAVE_NSC_RESET
> +#define NSC_RESET(C, W, H) do { nsc_context_reset(C); C->width = W; 
> C->height = H; } while(0)
> +#define RFX_RESET(C, W, H) do { rfx_context_reset(C); C->width = W; 
> C->height = H; } while(0)
> +#endif
>  #define FREERDP_CB_RET_TYPE BOOL
>  #define FREERDP_CB_RETURN(V) return TRUE
>  #endif
> @@ -819,6 +828,7 @@ xf_peer_activate(freerdp_peer* client)
>   struct xkb_context *xkbContext;
>   struct xkb_rule_names xkbRuleNames;
>   struct xkb_keymap *keymap;
> + struct weston_output *weston_output;
>   int i;
>   pixman_box32_t box;
>   pixman_region32_t damage;
> @@ -867,10 +877,9 @@ xf_peer_activate(freerdp_peer* client)
>   }
>   }
>  
> - rfx_context_reset(peerCtx->rfx_context);
> -#ifdef HAVE_NSC_RESET
> - nsc_context_reset(peerCtx->nsc_context);
> -#endif
> + weston_output = &output->base;
> + RFX_RESET(peerCtx->rfx_context, weston_output->width, 
> weston_output->height);
> + NSC_RESET(peerCtx->nsc_context, weston_output->width, 
> weston_output->height);
>  
>   if (peersItem->flags & RDP_PEER_ACTIVATED)
>   return TRUE;
> 


I forgot to specify that this one superseeds
https://patchwork.freedesktop.org/patch/76168/.

Best regards.

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH 3/5] rdp: fix presentation for the RDP compositor

2016-04-22 Thread Hardening
Le 22/04/2016 15:55, Pekka Paalanen a écrit :
> On Fri, 22 Apr 2016 15:19:04 +0200
> David Fort  wrote:
> 
>> Set an update delay that is a multiple of the output frequency, or we may do
>> incorrect weston_output_finish_frame calls.
>> ---
>>  src/compositor-rdp.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
>> index 9274674..4cbc1c3 100644
>> --- a/src/compositor-rdp.c
>> +++ b/src/compositor-rdp.c
>> @@ -378,7 +378,7 @@ rdp_output_repaint(struct weston_output *output_base, 
>> pixman_region32_t *damage)
>>  pixman_region32_subtract(&ec->primary_plane.damage,
>>   &ec->primary_plane.damage, damage);
>>  
>> -wl_event_source_timer_update(output->finish_frame_timer, 16);
>> +wl_event_source_timer_update(output->finish_frame_timer, 10);
>>  return 0;
>>  }
>>  
> 
> Hi,
> 
> I'm worried that there are more things wrong. This does not look like a
> fix, it just improves the odds of not failing if any.
> 
> So, you have a 100 Hz output update frequency on RDP?
> 

I think you're right, the frequency is supposed to be 60Hz (as announced
in the output settings), unfortunately 6 is a multiple of both 10
and 16 so that's how you said, it just hides the real bug. I'll have a
deeper look.

Best regards

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH 5/5] desktop shell: resize background and panel when an output switches mode

2016-04-22 Thread Hardening
Le 22/04/2016 16:18, Pekka Paalanen a écrit :
> On Fri, 22 Apr 2016 15:19:06 +0200
> David Fort  wrote:
> 
>> When an output permanently switches mode, the desktop shell must be notified 
>> so
>> that the misc components can resize to the new size of the output. This 
>> patch also
>> fixes the coodinates of "other" outputs when the resize occurs.
>>
>> Signed-off-by: David Fort 
>> ---
>>  desktop-shell/shell.c | 34 ++
>>  desktop-shell/shell.h |  1 +
>>  src/compositor.c  | 33 ++---
>>  src/compositor.h  |  1 +
>>  4 files changed, 58 insertions(+), 11 deletions(-)
>>
>> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
>> index cd269a8..1c1c993 100644
>> --- a/desktop-shell/shell.c
>> +++ b/desktop-shell/shell.c
>> @@ -6368,11 +6368,43 @@ handle_output_destroy(struct wl_listener *listener, 
>> void *data)
>>  shell_for_each_layer(shell, shell_output_destroy_move_layer, output);
>>  
>>  wl_list_remove(&output_listener->destroy_listener.link);
>> +wl_list_remove(&output_listener->resized_listener.link);
>>  wl_list_remove(&output_listener->link);
>>  free(output_listener);
>>  }
>>  
>>  static void
>> +shell_output_resize_layer(struct desktop_shell *shell,
>> +struct weston_layer *layer,
>> +void *data)
>> +{
>> +struct weston_output *output = data;
>> +struct weston_view *view;
>> +
>> +wl_list_for_each(view, &layer->view_list.link, layer_link.link) {
>> +if (view->output != output)
>> +continue;
>> +
>> +weston_desktop_shell_send_configure(shell->child.desktop_shell, 
>> 0,
>> +view->surface->resource,
>> +output->width,
>> +output->height);
> 
> Hi,
> 
> where do you check that the views you are handling are strictly only
> the wallpaper and panel surfaces created by the weston-desktop-shell
> client?
> 
> I have suspicion that this send call can use desktop_shell resource of
> one client with the wl_surface resource of a different client, which is
> illegal. Unfortunately, libwayland-server does not catch that, I
> believe. The result will be messages sent to clients referring random
> object ids that may not even be wl_surfaces.
> 
> I'm surprise this doesn't crash random clients - or does it?
> 
> Hmm... oh, I see. All the messages are sent to the weston-desktop-shell
> client, but rather than referring only the relevant wl_surfaces, they
> are sent for *all* mapped wl_surfaces also from other clients.
> 
> Are you sure weston-desktop-shell doesn't crash? The crash recovery may
> be fast enough that you can only see it in Weston's logs.
> 

It doesn't crash, but adding a breakpoint with the debugger it looks
like you're right and all surfaces are notified. I will change this.

>> +}
>> +}
>> +
>> +
>> +static void
>> +handle_output_resized(struct wl_listener *listener, void *data)
>> +{
>> +struct shell_output *output_listener =
>> +container_of(listener, struct shell_output, resized_listener);
>> +struct weston_output *output = output_listener->output;
>> +struct desktop_shell *shell = output_listener->shell;
>> +
>> +shell_for_each_layer(shell, shell_output_resize_layer, output);
>> +}
>> +
>> +static void
>>  create_shell_output(struct desktop_shell *shell,
>>  struct weston_output *output)
>>  {
>> @@ -6387,6 +6419,8 @@ create_shell_output(struct desktop_shell *shell,
>>  shell_output->destroy_listener.notify = handle_output_destroy;
>>  wl_signal_add(&output->destroy_signal,
>>&shell_output->destroy_listener);
>> +shell_output->resized_listener.notify = handle_output_resized;
>> +wl_signal_add(&output->compositor->output_resized_signal, 
>> &shell_output->resized_listener);
>>  wl_list_insert(shell->output_list.prev, &shell_output->link);
>>  }
>>  
>> diff --git a/desktop-shell/shell.h b/desktop-shell/shell.h
>> index b430fa2..5457923 100644
>> --- a/desktop-shell/shell.h
>> +++ b/desktop-shell/shell.h
>> @@ -112,6 +112,7 @@ struct shell_output {
>>  struct desktop_shell  *shell;
>>  struct weston_output  *output;
>>  struct exposay_output eoutput;
>> +struct wl_listenerresized_listener;
>>  struct wl_listenerdestroy_listener;
>>  struct wl_listlink;
>>  };
>> diff --git a/src/compositor.c b/src/compositor.c
>> index 5500197..a747945 100644
>> --- a/src/compositor.c
>> +++ b/src/compositor.c
>> @@ -143,6 +143,11 @@ static void weston_mode_switch_finish(struct 
>> weston_output *output,
>>  }
>>  }
>>  
>> +
>> +static void
>> +weston_compositor_resize_output(struct weston_compositor *compositor,
>> +struct weston_output *resized_output, int 
>> delta_width);
>> +
>>  WL_EXPORT int
>>  weston_output_mode_set_native(struct westo

Re: [PATCH v1] refactor configuration API of rdp-backend

2016-04-22 Thread Hardening
Le 22/04/2016 17:05, Benoit Gschwind a écrit :
> Implement a "well" defined API to configure the rdp backend.
> Following according to discution about libweston API.
> ---
> v1:
>  - Fix the patch log
> v0:
>   - Nothing particular.
> 
> Signed-off-by: Benoit Gschwind 
> 
>  Makefile.am  |  1 +
>  src/compositor-rdp.c | 71 
> +---
>  src/compositor-rdp.h | 54 +++
>  src/main.c   | 56 +++--
>  4 files changed, 137 insertions(+), 45 deletions(-)
>  create mode 100644 src/compositor-rdp.h
> 
> diff --git a/Makefile.am b/Makefile.am
> index c042c68..a4dcd57 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -73,6 +73,7 @@ weston_SOURCES =\
>   src/compositor.c\
>   src/compositor.h\
>   src/compositor-headless.h   \
> + src/compositor-rdp.h\
>   src/input.c \
>   src/data-device.c   \
>   src/screenshooter.c \
> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
> index 773b6b5..2860556 100644
> --- a/src/compositor-rdp.c
> +++ b/src/compositor-rdp.c
> @@ -67,23 +67,13 @@
>  
>  #include "shared/helpers.h"
>  #include "compositor.h"
> +#include "compositor-rdp.h"
>  #include "pixman-renderer.h"
>  
>  #define MAX_FREERDP_FDS 32
>  #define DEFAULT_AXIS_STEP_DISTANCE 10
>  #define RDP_MODE_FREQ 60 * 1000
>  
> -struct rdp_backend_config {
> - int width;
> - int height;
> - char *bind_address;
> - int port;
> - char *rdp_key;
> - char *server_cert;
> - char *server_key;
> - int env_socket;
> - int no_clients_resize;
> -};
>  
>  struct rdp_output;
>  
> @@ -138,20 +128,6 @@ struct rdp_peer_context {
>  typedef struct rdp_peer_context RdpPeerContext;
>  
>  static void
> -rdp_backend_config_init(struct rdp_backend_config *config)
> -{
> - config->width = 640;
> - config->height = 480;
> - config->bind_address = NULL;
> - config->port = 3389;
> - config->rdp_key = NULL;
> - config->server_cert = NULL;
> - config->server_key = NULL;
> - config->env_socket = 0;
> - config->no_clients_resize = 0;
> -}
> -
> -static void
>  rdp_peer_refresh_rfx(pixman_region32_t *damage, pixman_image_t *image, 
> freerdp_peer *peer)
>  {
>   int width, height, nrects, i;
> @@ -1195,8 +1171,7 @@ rdp_incoming_peer(freerdp_listener *instance, 
> freerdp_peer *client)
>  
>  static struct rdp_backend *
>  rdp_backend_create(struct weston_compositor *compositor,
> -struct rdp_backend_config *config,
> -int *argc, char *argv[], struct weston_config *wconfig)
> +struct weston_rdp_backend_config *config)
>  {
>   struct rdp_backend *b;
>   char *fd_str;
> @@ -1274,39 +1249,49 @@ err_free_strings:
>   return NULL;
>  }
>  
> +static void
> +config_init_to_defaults(struct weston_rdp_backend_config *config)
> +{
> + config->width = 640;
> + config->height = 480;
> + config->bind_address = NULL;
> + config->port = 3389;
> + config->rdp_key = NULL;
> + config->server_cert = NULL;
> + config->server_key = NULL;
> + config->env_socket = 0;
> + config->no_clients_resize = 0;
> +}
> +
>  WL_EXPORT int
>  backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
>struct weston_config *wconfig,
>struct weston_backend_config *config_base)
>  {
>   struct rdp_backend *b;
> - struct rdp_backend_config config;
> - rdp_backend_config_init(&config);
> + struct weston_rdp_backend_config config = {{ 0, }};
>   int major, minor, revision;
>  
>   freerdp_get_version(&major, &minor, &revision);
>   weston_log("using FreeRDP version %d.%d.%d\n", major, minor, revision);
>  
> - const struct weston_option rdp_options[] = {
> - { WESTON_OPTION_BOOLEAN, "env-socket", 0, &config.env_socket },
> - { WESTON_OPTION_INTEGER, "width", 0, &config.width },
> - { WESTON_OPTION_INTEGER, "height", 0, &config.height },
> - { WESTON_OPTION_STRING,  "address", 0, &config.bind_address },
> - { WESTON_OPTION_INTEGER, "port", 0, &config.port },
> - { WESTON_OPTION_BOOLEAN, "no-clients-resize", 0, 
> &config.no_clients_resize },
> - { WESTON_OPTION_STRING,  "rdp4-key", 0, &config.rdp_key },
> - { WESTON_OPTION_STRING,  "rdp-tls-cert", 0, &config.server_cert 
> },
> - { WESTON_OPTION_STRING,  "rdp-tls-key", 0, &config.server_key }
> - };
> -
> - parse_options(rdp_options, ARRAY_LENGTH(rdp_options), argc, argv);
> + if (config_base == NULL ||
> + config_base->struct_version != WESTON_RDP_BACKEND_CONFIG_VERSION ||
> + config_base->str

Re: [PATCH 1/5] rdp: allow to compile against FreeRDP 2.0

2016-04-23 Thread Hardening
Le 23/04/2016 11:50, Quentin Glidic a écrit :
> On 22/04/2016 15:19, David Fort wrote:
>> FreeRDP 2.0 is about to be released, this allows to compile against
>> this version.
>>
>> Signed-off-by: David Fort 
>> ---
>>  configure.ac |  8 +++-
>>  src/compositor-rdp.c | 23 ---
>>  2 files changed, 23 insertions(+), 8 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 670200c..9c70b2e 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -242,12 +242,18 @@ AM_CONDITIONAL([ENABLE_RDP_COMPOSITOR],
>> [test x$enable_rdp_compositor = xyes])
>>  if test x$enable_rdp_compositor = xyes; then
>>AC_DEFINE([BUILD_RDP_COMPOSITOR], [1], [Build the RDP compositor])
>> -  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0])
>> +  PKG_CHECK_MODULES(FreeRDP, [freerdp >= 1.1.0],
>> +[RDP_COMPOSITOR_CFLAGS=$FreeRDP_CFLAGS;
>> RDP_COMPOSITOR_LIBS=$FreeRDP_LIBS;],
>> +[PKG_CHECK_MODULES(FreeRDP2, [freerdp2 >=
>> 2.0.0],[RDP_COMPOSITOR_CFLAGS=$FreeRDP2_CFLAGS;
>> RDP_COMPOSITOR_LIBS=$FreeRDP2_LIBS;])]
>> +  )
> 
> Just use the same prefix ("RDP_COMPOSITOR") in both, it’s safe, and
> easier to read.
> 
It's just that doing so the printed message is "checking RDP_COMPOSITOR"
twice...

> Also, here, you prefer FreeRDP 1 over FreeRDP 2, is that what you want?
> 
> 
Well probably not, I'll change the order.

>>SAVED_CPPFLAGS="$CPPFLAGS"
>>CPPFLAGS="$CPPFLAGS $RDP_COMPOSITOR_CFLAGS"
>>AC_CHECK_HEADERS([freerdp/version.h])
>>CPPFLAGS="$SAVED_CPPFLAGS"
>> +
>> +  AC_SUBST(RDP_COMPOSITOR_CFLAGS)
>> +  AC_SUBST(RDP_COMPOSITOR_LIBS)
> 
> Then you can remove that.
> 
> 
>>  fi
>> [snip]
> 
> Cheers,
> 


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH 1/6] rdp: allow to compile against FreeRDP 2.0

2016-05-01 Thread Hardening
Le 01/05/2016 23:32, David Fort a écrit :
> FreeRDP 2.0 is about to be released, this allows to compile against this 
> version.
> The detection is adjusted to prefer FreeRDP 2 against version 1.x.
> 
> Signed-off-by: David Fort 
> ---
>  configure.ac |  5 -
>  src/compositor-rdp.c | 23 ---
>  2 files changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 4199616..6ab9c99 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -238,7 +238,10 @@ AM_CONDITIONAL([ENABLE_RDP_COMPOSITOR],
> [test x$enable_rdp_compositor = xyes])
>  if test x$enable_rdp_compositor = xyes; then
>AC_DEFINE([BUILD_RDP_COMPOSITOR], [1], [Build the RDP compositor])
> -  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0])
> +  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp2 >= 2.0.0],
> +[],
> +[PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0],[])]
> +  )

So this way it should not bug Quentin Glidic ;)

>  
>SAVED_CPPFLAGS="$CPPFLAGS"
>CPPFLAGS="$CPPFLAGS $RDP_COMPOSITOR_CFLAGS"
> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
> index 2860556..f6778b6 100644
> --- a/src/compositor-rdp.c
> +++ b/src/compositor-rdp.c
> @@ -42,15 +42,24 @@
>  #define FREERDP_VERSION_NUMBER ((FREERDP_VERSION_MAJOR * 0x1) + \
>   (FREERDP_VERSION_MINOR * 0x100) + FREERDP_VERSION_REVISION)
>  
> +
>  #if FREERDP_VERSION_NUMBER >= 0x10201
>  #define HAVE_SKIP_COMPRESSION
>  #endif
>  
>  #if FREERDP_VERSION_NUMBER < 0x10202
> -#define FREERDP_CB_RET_TYPE void
> -#define FREERDP_CB_RETURN(V) return
> +#define FREERDP_CB_RET_TYPE void
> +#define FREERDP_CB_RETURN(V) return
> +#define NSC_RESET(C, W, H)
> +#define RFX_RESET(C, W, H) do { rfx_context_reset(C); C->width = W; 
> C->height = H; } while(0)
> +#else
> +#if FREERDP_VERSION_MAJOR >= 2
> +#define NSC_RESET(C, W, H) nsc_context_reset(C, W, H)
> +#define RFX_RESET(C, W, H) rfx_context_reset(C, W, H)
>  #else
> -#define HAVE_NSC_RESET
> +#define NSC_RESET(C, W, H) do { nsc_context_reset(C); C->width = W; 
> C->height = H; } while(0)
> +#define RFX_RESET(C, W, H) do { rfx_context_reset(C); C->width = W; 
> C->height = H; } while(0)
> +#endif
>  #define FREERDP_CB_RET_TYPE BOOL
>  #define FREERDP_CB_RETURN(V) return TRUE
>  #endif
> @@ -795,6 +804,7 @@ xf_peer_activate(freerdp_peer* client)
>   struct xkb_context *xkbContext;
>   struct xkb_rule_names xkbRuleNames;
>   struct xkb_keymap *keymap;
> + struct weston_output *weston_output;
>   int i;
>   pixman_box32_t box;
>   pixman_region32_t damage;
> @@ -843,10 +853,9 @@ xf_peer_activate(freerdp_peer* client)
>   }
>   }
>  
> - rfx_context_reset(peerCtx->rfx_context);
> -#ifdef HAVE_NSC_RESET
> - nsc_context_reset(peerCtx->nsc_context);
> -#endif
> + weston_output = &output->base;
> + RFX_RESET(peerCtx->rfx_context, weston_output->width, 
> weston_output->height);
> + NSC_RESET(peerCtx->nsc_context, weston_output->width, 
> weston_output->height);
>  
>   if (peersItem->flags & RDP_PEER_ACTIVATED)
>   return TRUE;
> 


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [GSoC] Some questions about wayland clients with no outputs present

2016-05-03 Thread Hardening
Le 03/05/2016 09:52, Pekka Paalanen a écrit :
> On Mon, 2 May 2016 17:33:14 -0700
> Bryce Harrington  wrote:
> 
>> On Mon, May 02, 2016 at 12:49:04PM +0200, Armin Krezović wrote:
>>> On 30.04.2016 22:14, Bryce Harrington wrote:  
 On Sat, Apr 30, 2016 at 05:20:09PM +0200, Armin Krezović wrote:
 But virtual outputs is not a bad idea, it could be useful for testing or
 perhaps to extend one's rendering beyond ordinary hardware capabilities
 or something.  But it should be user-controlled via commandline options
 or config file options.  
>>>
>>> I was thinking about using the virtual outputs when no physical outputs
>>> are present, and keep them out of the way otherwise. Sure, a command
>>> line switch/config option is useful, especially for the test suite (Pekka
>>> proposed something similar).  
>>
>> I wonder what situation would arise where the user would want to use the
>> drm backend when there weren't any physical outputs.  I can see that for
>> testing purposes but am drawing a blank for use cases other than that.
> 
> Say, you have your system running, and you want swap the monitor. Or
> re-route the cable better. Or just close the laptop lid (I hear that
> might cause the LVDS to disconnect). Or have a mechanical video switch
> which causes the display to appear disconnected when not selected.
> 
> But none of that is a reason in itself to have a fake output.
> 

Funny, back 3 years ago I had the same questions with the RDP
compositor. My idea was to create the output (and the seat) when the
first client would connect (because the output would have the size
requested by the RDP peer). So if you manage to have 0 output working
everywhere else (I mean shell plugins), I'll probably consider have the
RDP compositor start with 0 outputs.

Best regards.

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [ANNOUNCE] wayland 1.10.91

2016-05-11 Thread Hardening
Le 11/05/2016 21:11, Bryce Harrington a écrit :
> On Fri, May 06, 2016 at 02:17:23PM +0300, Pekka Paalanen wrote:
>> On Wed, 4 May 2016 11:46:23 -0700
>> Bryce Harrington  wrote:
>>
>>> On Wed, May 04, 2016 at 12:55:16AM -0700, Bryce Harrington wrote:
 Here's the alpha for the upcoming 1.11 release.  I'll summarize the
 major features for this release in the beta announcement, but see below
 for the detailed listing.

 The schedule going forward is:

   √ 1.11-alpha on May 3rd.  Major features done by this point.
> 
> It looks like someone (pq?) has marked some patches we decided to leave
> for post-1.11 as deferred in patchwork.  I've followed suit and moved
> other patchsets there which are new APIs or that sound like feature
> work.
> 
> Following are what remains.  Most of these I think should be deferred
> but am not 100% certain, so would appreciate hearing other people's
> thoughts:
> 
> 
> 1. Detect keyboard capabilities, refactor seat capability [Derek]
>- Awaiting review by jadahl
>- Over a year old now, probably needs rebased too...
> 
> 2. xdg_popup behavior of input devices [Carlos]
>- Protocol additions for xdg-shell, needs review by xdg devels
>- Been in the queue a long time, but no reviews to date
>- No idea about disposition for this
> 
> 3. xwayland drag-and-drop window creation [Carlos]
>- Looks ok to be but xwayland isn't my area
>- Been in the queue a long time, but no reviews to date
>- From the commit description sounds WIP-ish and that there was
>  planned some followup work, but not sure if that happened?
> 
> 4. Pointer locking (3 patches) [Jonas]
>- Was planned to land this feature for 1.11
>- Reviewers requested changes, but I'm not spotting a v2 for this
>- At a minimum needs updated for trunk, since the protocol files are
>  now in wayland-protocols
>- I'll mark it 'Changes Requested' and hope it will return for
>  consideration for 1.12.
> 
> 5. V2 for text input protocol [Jan Arne]
>- This is intended for wayland-protocols so not really pertinent to
>  the release.  But is on v6 and hasn't received further reviews,
>  perhaps it's time to land it?
> 
> 6. FreeRDP fixes (6 patches) [David]
>- Build fixes are suitable for landing now, so I consider at least
>  the first 3 patches here good candidates for including in 1.11
>- No R-b's other than my own; I'd be more comfortable landing if we
>  had another set of R-b's on this.

Just a note: the last 2 patches fix a bug that has been there for year
with output mode switch. As the RDP compositor is the only one that can
use permanent mode switching, it exposes the bug, but the correction
works for all others.

> 
> 7. compositor-drm clone mode + fixes (8 patches) [Emmanuel]
>- The fixes look straightforward and probably ok to land
>- I haven't reviewed the clone mode feature, but offhand judging by
>  the length of the patch it looks like post-1.11 stuff.
> 
> 8. get_subsurface double-buffered protocol [pq]
>- Is getting strong reviews, but also requests for tests &tc.
>- There is debate on its thread as to whether to land vs. leave for
>  1.12
> 
> 9. Don't set_fullscreen on already fullscreen surfaces [Emmanuel]
>- Short fix, might be worth including in 1.11
>- Needs another R-b or two, but may be an easy thing to land
> 
> 10. compositor fixes (2 patches) [pq]
> 11. eventdemo fixes (3 patches) [pq]
>- These sound landable for 1.11 offhand, but I haven't reviewed.
>- Needs R-b's
> 
> 12. ivi_layout_surface API
>- Straightforward patch, looks fine to me
>- Not sure about landing new API during feature freeze though
>- Needs R-b's
> 


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH 2/6] rdp: don't release the seat until it is safe

2016-05-19 Thread Hardening
Le 20/05/2016 00:51, Bryce Harrington a écrit :
> On Tue, Apr 26, 2016 at 11:34:04PM +0200, David Fort wrote:
>> Releasing a seat is not safe, so let's just announce it without keyboard
>> and mouse until this is fixed. Without this patch we just can't reconnect on
>> the RDP compositor as it crashes.
>>
>> Signed-off-by: David Fort 
> 
> I see that this patch disables the weston_seat_release() call (which
> sounds from the changelog works around the issue rather than fixes it).
> 
> I'm not spotting the need for making the seat dynamically allocated, is
> that part of the fix or just refactoring?  Regardless, shouldn't it get
> a corresponding free() 
> 

It's just a workaround. And the need to make it dynamic is that the
RdpPeerContext will be freed by FreeRDP, and we need the seat to live
longer (as it is supposed to live as long as a client is binding it).
For now we're just leaking the seat, but I guess that once seat
releasing will work, we will still need to have the seat dynamically
allocated, as the seat will live longer than the RdpPeerContext.

>> ---
>>  src/compositor-rdp.c | 32 +++-
>>  1 file changed, 19 insertions(+), 13 deletions(-)
>>
>> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
>> index f6778b6..862eedc 100644
>> --- a/src/compositor-rdp.c
>> +++ b/src/compositor-rdp.c
>> @@ -109,7 +109,7 @@ enum peer_item_flags {
>>  struct rdp_peers_item {
>>  int flags;
>>  freerdp_peer *peer;
>> -struct weston_seat seat;
>> +struct weston_seat *seat;
>>  
>>  struct wl_list link;
>>  };
>> @@ -623,9 +623,9 @@ rdp_peer_context_free(freerdp_peer* client, 
>> RdpPeerContext* context)
>>  }
>>  
>>  if (context->item.flags & RDP_PEER_ACTIVATED) {
>> -weston_seat_release_keyboard(&context->item.seat);
>> -weston_seat_release_pointer(&context->item.seat);
>> -weston_seat_release(&context->item.seat);
>> +weston_seat_release_keyboard(context->item.seat);
>> +weston_seat_release_pointer(context->item.seat);
>> +/*weston_seat_release(context->item.seat);*/
>>  }
>>  
>>  Stream_Free(context->encode_stream, TRUE);
>> @@ -894,9 +894,15 @@ xf_peer_activate(freerdp_peer* client)
>>  else
>>  snprintf(seat_name, sizeof(seat_name), "RDP peer @%s", 
>> settings->ClientAddress);
>>  
>> -weston_seat_init(&peersItem->seat, b->compositor, seat_name);
>> -weston_seat_init_keyboard(&peersItem->seat, keymap);
>> -weston_seat_init_pointer(&peersItem->seat);
>> +peersItem->seat = zalloc(sizeof(*peersItem->seat));
>> +if (!peersItem->seat) {
>> +weston_log("unable to create a weston_seat\n");
>> +return FALSE;
> 
> Does the xkbContext need freed in this error condition?

Indeed, good catch I'm posting a fix for this.

> 
>> +}
>> +
>> +weston_seat_init(peersItem->seat, b->compositor, seat_name);
>> +weston_seat_init_keyboard(peersItem->seat, keymap);
>> +weston_seat_init_pointer(peersItem->seat);
>>  
>>  peersItem->flags |= RDP_PEER_ACTIVATED;
>>  
>> @@ -935,7 +941,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
>> UINT16 y)
>>  if (flags & PTR_FLAGS_MOVE) {
>>  output = peerContext->rdpBackend->output;
>>  if (x < output->base.width && y < output->base.height) {
>> -notify_motion_absolute(&peerContext->item.seat, 
>> weston_compositor_get_time(),
>> +notify_motion_absolute(peerContext->item.seat, 
>> weston_compositor_get_time(),
>>  x, y);
>>  need_frame = true;
>>  }
>> @@ -949,7 +955,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
>> UINT16 y)
>>  button = BTN_MIDDLE;
>>  
>>  if (button) {
>> -notify_button(&peerContext->item.seat, 
>> weston_compositor_get_time(), button,
>> +notify_button(peerContext->item.seat, 
>> weston_compositor_get_time(), button,
>>  (flags & PTR_FLAGS_DOWN) ? 
>> WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED
>>  );
>>  need_frame = true;
>> @@ -974,13 +980,13 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
>> UINT16 y)
>>  weston_event.discrete = (int)value;
>>  weston_event.has_discrete = true;
>>  
>> -notify_axis(&peerContext->item.seat, 
>> weston_compositor_get_time(),
>> +notify_axis(peerContext->item.seat, 
>> weston_compositor_get_time(),
>>  &weston_event);
>>  need_frame = true;
>>  }
>>  
>>  if (need_frame)
>> -notify_pointer_frame(&peerContext->item.seat);
>> +notify_pointer_frame(peerContext->item.seat);
>>  
>>  FREERDP_CB_RETURN(TRUE);
>>  }
>> @@ -993,7 +999,7 @@ xf_extendedMouseEvent(rdpInput *input, UINT16 flags, 
>> UINT16 x, UINT16 y)
>>  
>>  output

Re: [PATCH] rdp: don't release the seat until it is safe v2

2016-05-20 Thread Hardening
Le 20/05/2016 11:58, Sam Spilsbury a écrit :
> On Fri, May 20, 2016 at 5:33 PM, David Fort  wrote:
>> Releasing a seat is not safe, so let's just announce it without keyboard
>> and mouse until this is fixed. Without this patch we just can't reconnect on
>> the RDP compositor as it crashes.
>>
>> v2: fixed the leak of the xkb_keymap
>>
>> Signed-off-by: David Fort 
>> ---
>>  src/compositor-rdp.c | 33 -
>>  1 file changed, 20 insertions(+), 13 deletions(-)
>>
>> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
>> index 4fc7c74..52cf426 100644
>> --- a/src/compositor-rdp.c
>> +++ b/src/compositor-rdp.c
>> @@ -109,7 +109,7 @@ enum peer_item_flags {
>>  struct rdp_peers_item {
>> int flags;
>> freerdp_peer *peer;
>> -   struct weston_seat seat;
>> +   struct weston_seat *seat;
>>
>> struct wl_list link;
>>  };
>> @@ -640,9 +640,9 @@ rdp_peer_context_free(freerdp_peer* client, 
>> RdpPeerContext* context)
>> }
>>
>> if (context->item.flags & RDP_PEER_ACTIVATED) {
>> -   weston_seat_release_keyboard(&context->item.seat);
>> -   weston_seat_release_pointer(&context->item.seat);
>> -   weston_seat_release(&context->item.seat);
>> +   weston_seat_release_keyboard(context->item.seat);
>> +   weston_seat_release_pointer(context->item.seat);
>> +   /*weston_seat_release(context->item.seat);*/
>> }
> 
> I think instead of just having commented out code, put the reasons why
> the seat cannot be released safely at the moment. Just having it
> commented out will confuse future maintainers.
> 

Well, future maintainers actually means me. The explanation is quite
long, I don't think a comment in the code is the right place for this.
And BTW it's not something that is RDP compositor specific, all the
weston compositors have it.

>>
>> Stream_Free(context->encode_stream, TRUE);
>> @@ -911,9 +911,16 @@ xf_peer_activate(freerdp_peer* client)
>> else
>> snprintf(seat_name, sizeof(seat_name), "RDP peer @%s", 
>> settings->ClientAddress);
>>
>> -   weston_seat_init(&peersItem->seat, b->compositor, seat_name);
>> -   weston_seat_init_keyboard(&peersItem->seat, keymap);
>> -   weston_seat_init_pointer(&peersItem->seat);
>> +   peersItem->seat = zalloc(sizeof(*peersItem->seat));
>> +   if (!peersItem->seat) {
>> +   xkb_keymap_unref(keymap);
>> +   weston_log("unable to create a weston_seat\n");
>> +   return FALSE;
>> +   }
>> +
>> +   weston_seat_init(peersItem->seat, b->compositor, seat_name);
>> +   weston_seat_init_keyboard(peersItem->seat, keymap);
>> +   weston_seat_init_pointer(peersItem->seat);
> 
> Any reason to make this dynamically allocated memory? It seems to me
> like it is adding an additional point of failure for little added
> benefit. If it needs to be dynamically allocated, I think such a
> change should come in a separate patch, since it seems unrelated to
> this one.
> 

I have already answered this in a previous mail to Bryce. To do it
short, it's because the seat has to live longer than the RdpPeerContext.
So when the RDP peer disconnects, the RdpPeerContext will be destroyed
immediately, while the seat is supposed to live until all wayland client
have released it.


> Reviewed-by: Sam Spilsbury 
> 


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH 0/6] RDP compositor needs love v2

2016-05-26 Thread Hardening
Le 26/04/2016 23:34, David Fort a écrit :
> Compared to the first version:
> * compilation with FreeRDP 2.0 is now prefered;
> * trivial patch using constant instead of hard coded value has its own commit;
> * I have splitted the output resized patch so that the shell and the core 
> weston 
> part are separated. I have also reworked the shell part so that only the 
> right surface
> is reconfigured;
> * I've dropped the presentation fix hack.
> 
> David Fort (6):
>   rdp: allow to compile against FreeRDP 2.0
>   rdp: don't release the seat until it is safe
>   rdp: Fix the ContextNew callback with recent FreeRDP versions
>   compositor: use generated constant instead of hardcoded value
>   compositor: recompute output position on mode switch
>   desktop-shell: resize background, panel and lock surface on output
> resize
> 
>  configure.ac  |  8 +-
>  desktop-shell/shell.c | 60 +
>  desktop-shell/shell.h |  7 +
>  src/compositor-rdp.c  | 74 
> ---
>  src/compositor.c  | 36 +
>  src/compositor.h  |  1 +
>  6 files changed, 153 insertions(+), 33 deletions(-)
> 

Patch 1 and 3 have been integrated.

I really think patch 2 (don't release the seat until it is safe) should
be integrated.

And the 2 last ones have received no feedback even if they fix a bug
that is there from years.

Best regards.

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH wayland] shm: add getters for the fd and offset

2015-07-16 Thread Hardening
Le 01/07/2015 10:25, Giulio Camuffo a écrit :
> This allows to share the buffer data by mmapping the fd again.
> ---
>  src/wayland-server-core.h |  6 ++
>  src/wayland-shm.c | 16 +++-
>  2 files changed, 21 insertions(+), 1 deletion(-)
> 

Reviewed-by: David FORT 

> diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
> index 7d03789..938cdf7 100644
> --- a/src/wayland-server-core.h
> +++ b/src/wayland-server-core.h
> @@ -396,6 +396,12 @@ wl_shm_buffer_create(struct wl_client *client,
>uint32_t id, int32_t width, int32_t height,
>int32_t stride, uint32_t format);
>  
> +int
> +wl_shm_buffer_get_offset(struct wl_shm_buffer *buffer);
> +
> +int
> +wl_shm_buffer_get_fd(struct wl_shm_buffer *buffer);
> +
>  void wl_log_set_handler_server(wl_log_func_t handler);
>  
>  #ifdef  __cplusplus
> diff --git a/src/wayland-shm.c b/src/wayland-shm.c
> index b6b31d6..c85e839 100644
> --- a/src/wayland-shm.c
> +++ b/src/wayland-shm.c
> @@ -52,6 +52,7 @@ struct wl_shm_pool {
>   int refcount;
>   char *data;
>   int32_t size;
> + int fd;
>  };
>  
>  struct wl_shm_buffer {
> @@ -77,6 +78,7 @@ shm_pool_unref(struct wl_shm_pool *pool)
>   return;
>  
>   munmap(pool->data, pool->size);
> + close(pool->fd);
>   free(pool);
>  }
>  
> @@ -250,7 +252,7 @@ shm_create_pool(struct wl_client *client, struct 
> wl_resource *resource,
>  "failed mmap fd %d", fd);
>   goto err_close;
>   }
> - close(fd);
> + pool->fd = fd;
>  
>   pool->resource =
>   wl_resource_create(client, &wl_shm_pool_interface, 1, id);
> @@ -409,6 +411,18 @@ wl_shm_buffer_get_height(struct wl_shm_buffer *buffer)
>   return buffer->height;
>  }
>  
> +WL_EXPORT int
> +wl_shm_buffer_get_offset(struct wl_shm_buffer *buffer)
> +{
> + return buffer->offset;
> +}
> +
> +WL_EXPORT int
> +wl_shm_buffer_get_fd(struct wl_shm_buffer *buffer)
> +{
> + return buffer->pool->fd;
> +}
> +
>  static void
>  reraise_sigbus(void)
>  {
> 


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH wayland 3/3] shm: wl_shm_buffer_get_data() requires a valid pool.

2015-07-16 Thread Hardening
Le 01/07/2015 12:52, Marek Chalupa a écrit :
> 
> 
> On Wed, Jul 1, 2015 at 11:25 AM, Marek Chalupa  > wrote:
> 
> 
> 
> On Fri, Jun 26, 2015 at 6:35 PM, Derek Foreman
> mailto:der...@osg.samsung.com>> wrote:
> 
> There's no situation where a shm buffer without a pool makes sense,
> so we enforce the pool's existence a little more rigidly.
> 
> Signed-off-by: Derek Foreman  >
> ---
>  src/wayland-shm.c | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/src/wayland-shm.c b/src/wayland-shm.c
> index da11743..79b3886 100644
> --- a/src/wayland-shm.c
> +++ b/src/wayland-shm.c
> @@ -353,10 +353,12 @@ wl_shm_buffer_get_stride(struct
> wl_shm_buffer *buffer)
>  WL_EXPORT void *
>  wl_shm_buffer_get_data(struct wl_shm_buffer *buffer)
>  {
> -   if (buffer->pool)
> -   return buffer->pool->data + buffer->offset;
> -   else
> -   return buffer + 1;
> +   assert(buffer->pool);
> +
> +   if (!buffer->pool)
> +   return NULL;
> 
> 
> This condition is never true if the assert passed
> 
>  
> Yeah, but in non-debug build we do not have the assert, so it may make
> sense to have this doubled. Ok.
>  

I find it a little strange, that something that abort() in debug mode,
just "silently" return NULL in production mode...

Checking with the Eclipse "Call hierarchy" tool, none of the callers of
wl_shm_buffer_get_data() check the return value, so we may detect the
bug quite far from the real source.

So my suggestion is either wl_shm_buffer_get_data is a "succeed or kill
program" function (like xyzalloc functions), or the callers have to be
updated if we can live with buffer->pool == NULL.

Best regards.
-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH weston] compositor-rdp: free() can handle NULL pointers

2015-08-01 Thread Hardening
Le 01/08/2015 16:02, Dawid Gajownik a écrit :
> There's no need to check if a pointer exists before passing it to free().
> free() can handle NULL pointers.
> 
> Signed-off-by: Dawid Gajownik 

Reviewed-By: David FORT 

> ---
>  src/compositor-rdp.c | 9 +++--
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
> index a83948b..b5169a8 100644
> --- a/src/compositor-rdp.c
> +++ b/src/compositor-rdp.c
> @@ -1244,12 +1244,9 @@ err_output:
>  err_compositor:
>   weston_compositor_shutdown(compositor);
>  err_free_strings:
> - if (b->rdp_key)
> - free(b->rdp_key);
> - if (b->server_cert)
> - free(b->server_cert);
> - if (b->server_key)
> - free(b->server_key);
> + free(b->rdp_key);
> + free(b->server_cert);
> + free(b->server_key);
>   free(b);
>   return NULL;
>  }
> 


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH weston v3] compositor-rdp: rdp_destroy() double free error #91457

2015-08-06 Thread Hardening
Le 05/08/2015 22:20, Derek Foreman a écrit :
> On 05/08/15 03:21 PM, Dawid Gajownik wrote:
>> When something goes wrong during weston initialization,
>> weston_compositor_destroy() is executed. It destroys the backend and
>> then frees compositor memory. Unfortunately RDP backend is not correctly
>> destroyed. It frees compositor instead of a backend memory. This causes
>> later a double free error. The easiest way to reproduce a problem is to
>> run weston with an invalid option.
>>
>> Additionally some other objects of rdp_backend structure are not
>> destroyed/freed. The patch fixes both issues.
>>
>> Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=91457
>>
>> v3: comply with Weston coding style, this time for real
>> v2: comply with Weston coding style
>>
>> Signed-off-by: Dawid Gajownik 
> 
> Reviewed-by: Derek Foreman 

Looks good to me too

Reviewed-by: David FORT 

> 
>> ---
>>  src/compositor-rdp.c | 13 -
>>  1 file changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
>> index 6eac7f9..869c3f3 100644
>> --- a/src/compositor-rdp.c
>> +++ b/src/compositor-rdp.c
>> @@ -541,9 +541,20 @@ rdp_restore(struct weston_compositor *ec)
>>  static void
>>  rdp_destroy(struct weston_compositor *ec)
>>  {
>> +struct rdp_backend *b = (struct rdp_backend *) ec->backend;
>> +int i;
>> +
>>  weston_compositor_shutdown(ec);
>> +for (i = 0; i < MAX_FREERDP_FDS; i++)
>> +if (b->listener_events[i])
>> +wl_event_source_remove(b->listener_events[i]);
>> +
>> +freerdp_listener_free(b->listener);
>>  
>> -free(ec);
>> +free(b->server_cert);
>> +free(b->server_key);
>> +free(b->rdp_key);
>> +free(b);
>>  }
>>  
>>  static
>>
> 
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH weston] RDP compositor: make the seat dynamic and don't destroy it on removal

2015-09-25 Thread Hardening
Le 25/09/2015 11:31, Pekka Paalanen a écrit :
> On Thu, 24 Sep 2015 23:40:26 +0200
> David FORT  wrote:
> 
>> This patch makes the seat dynamic and leak it on purpose during seat removal 
>> to
>> prevent the ghost object case.
>> ---
>>  src/compositor-rdp.c | 39 +++
>>  1 file changed, 27 insertions(+), 12 deletions(-)
> 
> Hi David,
> 
> this patch is still missing the whole explanation of what is going on in
> here. My questions from
> http://lists.freedesktop.org/archives/wayland-devel/2015-May/022055.html
> are still unanswered, and today I understand even less than then. :-)
> 
> Or is there already a comment in the code explaining why rdp-backend
> does funny stuff with seats? I couldn't find it on a quick look.
> 
> Why leak it?
> What is the ghost object problem?
> Why you must use only part of weston_seat_release()?
> 
> I have some very vague memories of wl_seat missing destructor protocol
> or something, is this related?


Hello Pekka,
you're right I've not elaborated much.

So the general problem was that wl_seat doesn't have a release request,
so we can't track the usage of a wl_seat by wayland clients. And as we
can't track the usage, we can't release it safely or we take the risk
that clients could address a released object. In the current situation
we can't safely release a seat object.

So in my patch I'm mallocating a seat (not having it static with the RDP
context), an I took the parts of weston_seat_release() that only do
things internally to weston (so that I release as much as I can).


Perhaps I'm not cleaning up correctly because with my patch applied, if I:
* open a terminal;
* connect with 2 RDP clients (so 2 seats);
* take the focus in the terminal;
* stop weston with a Ctrl-C

I get the following valgrind traceback during weston's shutdown, related
to the input method:
^C[14:35:47.687] caught signal 2
==21909== Invalid read of size 8
==21909==at 0x4173B9: unbind_input_method (text-backend.c:834)
==21909==by 0x4E3D37B: destroy_resource (wayland-server.c:537)
==21909==by 0x4E42255: for_each_helper.isra.0 (wayland-util.c:359)
==21909==by 0x4E4279E: wl_map_for_each (wayland-util.c:365)
==21909==by 0x4E3DF57: wl_client_destroy (wayland-server.c:675)
==21909==by 0x418401: text_backend_destroy (text-backend.c:1046)
==21909==by 0x93542F2: shell_destroy (shell.c:6473)
==21909==by 0x4109C6: weston_compositor_destroy
(wayland-server-core.h:264)
==21909==by 0x40897D: main (main.c:829)
==21909==  Address 0x9b9e6f0 is 112 bytes inside a block of size 120 free'd
==21909==at 0x4C2BDEC: free (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21909==by 0x6A468AE: rdp_peer_context_free (wayland-server-core.h:264)
==21909==by 0x6D520DA: freerdp_peer_context_free (peer.c:738)
==21909==by 0x6A469B7: rdp_client_activity (compositor-rdp.c:674)
==21909==by 0x4E3FE51: wl_event_loop_dispatch (event-loop.c:422)
==21909==by 0x4E3E6B4: wl_display_run (wayland-server.c:1004)
==21909==by 0x408D35: main (main.c:818)
==21909==


Anyway without the patch, valgrind complains during seat releasing (for
example when a RDP peer disconnects).

Regards.
-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH weston] RDP compositor: make the seat dynamic and don't destroy it on removal

2015-09-25 Thread Hardening
Le 25/09/2015 19:15, Derek Foreman a écrit :
> On 25/09/15 08:19 AM, Hardening wrote:
>> Le 25/09/2015 11:31, Pekka Paalanen a écrit :
>>> On Thu, 24 Sep 2015 23:40:26 +0200
>>> David FORT  wrote:
>>>
>>>> This patch makes the seat dynamic and leak it on purpose during seat 
>>>> removal to
>>>> prevent the ghost object case.
>>>> ---

[...]

>>
>> Hello Pekka,
>> you're right I've not elaborated much.
>>
>> So the general problem was that wl_seat doesn't have a release request,
>> so we can't track the usage of a wl_seat by wayland clients. And as we
>> can't track the usage, we can't release it safely or we take the risk
>> that clients could address a released object. In the current situation
>> we can't safely release a seat object.
> 
> Should we move forward with your patch to add seat release protocol first?
> 
> Does that change this implementation at all?

Yeah this could be an idea. Once the "release seat patch" is passed, the
goal would be to not leak the seat at all, so the present patch would be
useless.

> 
>> So in my patch I'm mallocating a seat (not having it static with the RDP
>> context), an I took the parts of weston_seat_release() that only do
>> things internally to weston (so that I release as much as I can).
>>
>>

[...]
>>
>>
>> Anyway without the patch, valgrind complains during seat releasing (for
>> example when a RDP peer disconnects).
> 
> Sigh.  There's a lot of multi-seat related problems in the
> text-backend/input-method bits.  I've got a bunch of patches I need to
> sort through and post. :/
> 
> I don't think you've added this problem, I think it's already there (and
> I may have fixed it already...)
> 

I can test with these patches to see if things get better, any reference ?


Best regards.
-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH 3/3] Add a release request on wl_seat

2015-09-27 Thread Hardening
Le 24/09/2015 01:59, Jonas Ådahl a écrit :
> On Wed, Sep 23, 2015 at 11:17:33AM -0500, Derek Foreman wrote:
>> On 25/02/15 08:03 AM, David FORT wrote:
>>> This is required if we want to correctly remove a wl_seat server-side.
>>> ---
>>>  protocol/wayland.xml | 6 ++
>>>  1 file changed, 6 insertions(+)
>>>

Sorry very late reply.

[...]

>>> +
>>> +
>>> +
>>> +  
>>> +
>>> +
>>
>> wl_seat appears to currently be version="4", so I guess we'd have to
>> bump the since= and the version in the comment... (and probably the
>> version of wl_seat as well)
> 
> Yes. And we should bump the version of wl_pointer, wl_touch and
> wl_keyboard as part of it, just to make things clearer.
> 

Does it mean that that wl_pointer, wl_touch and wl_keyboard should all
have the same version as wl_seat ?

>>
>> Unfortunately, I don't think this is necessary or sufficient to solve
>> the problem at hand (RDP compositor connections are new seats, once apps
>> bind these seats they're essentially leaked forever even after RDP
>> client disconnect)
>>

[...]
>>
>> That is, there's a difference between a disconnected RDP client and a
>> libinput backed seat with no devices left in it.
>>
>> Would a new seat event (say, "removed") solve this sufficiently?
> 
> Wouldn't the global advertisement being removed be enough? Every seat is
> advertised individually in the registry, and removing it there should
> IMO be interpreted as there no longer any use for objects that was bound
> to the that global.
> 

Nope because the client can send a request on the seat while the
compositor is announcing the global removal. The release request is
there so that the client can say tto he compositor "understood I won't
use that object anymore". That allows the compositor to ref count users
and free it at the end.

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH] wayland: add release request on wl_seat

2015-09-29 Thread Hardening
Le 29/09/2015 09:58, Jonas Ådahl a écrit :
> On Tue, Sep 29, 2015 at 09:43:01AM +0200, David FORT wrote:
>> This is required if we want to correctly remove a wl_seat compositor-side. A
>> wl_seat is announced as a global object, then it is bound by the client. When
>> the compositor wants to remove the seat, it shall announce the global 
>> removal of
>> the object. The client can then call the release request on the wl_seat 
>> (which
>> means it won't use that object anymore). When all clients have released the
>> wl_seat, it can be destroyed by the compositor.
>> ---
>>  protocol/wayland.xml | 12 +++-
>>  1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/protocol/wayland.xml b/protocol/wayland.xml
>> index 42c9309..2c7a675 100644
>> --- a/protocol/wayland.xml
>> +++ b/protocol/wayland.xml
>> @@ -1329,7 +1329,7 @@
>>  
>> 
>>  
>> -  
>> +  
> 
> Could you bump the other interfaces that will get this version anyway
> as well? As mentioned, they will have this version anyway, when created.

Perhaps I missed something but I have just discussed this with Pekka,
and he told me not to bump the version from wl_pointer and al...

> 
>>  
>>A seat is a group of keyboards, pointer and touch devices. This
>>object is published as a global during start up, or when such a
>> @@ -1400,6 +1400,16 @@
>>
>>  
>>  
>> +
>> +
>> +
>> +  
>> +  This request is called by the client to inform that it will not 
>> address the seat
>> +  object. The compositor can destroy this seat when all clients have 
>> called
>> +  this request.
> 
> I don't think we should dictate how the implementation should look like.
> The compositor may have destroyed the seat already, leaving only defunct
> wl_seat objects around.
> 
I didn't mean to dictate the implementation, I'll try to find something
more neutral.


> Not sure what "address" means here. "Use" might be more clear, since we
> use that terminology elsewhere. Also using "this" instead of "the" to
> address the object might be more clear as well.

Ok I will change the description this way.

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH wayland v2] scanner: Close input resource when done to prevent leak

2015-10-02 Thread Hardening
Le 02/10/2015 03:13, Bryce Harrington a écrit :
> Addresses this error reported by Denis Denisov:
> 
>   [src/scanner.c:1415]: (error) Resource leak: input
> 
> Signed-off-by: Bryce Harrington 
> 
> v2: Also close input for other exit points in main.
> Signed-off-by: Bryce Harrington 

Reviewed-by: David FORT 

> ---
>  src/scanner.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/scanner.c b/src/scanner.c
> index 9b41ae4..5504fce 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -1531,6 +1531,7 @@ int main(int argc, char *argv[])
>   if (freopen(argv[2], "w", stdout) == NULL) {
>   fprintf(stderr, "Could not open output file: %s\n",
>   strerror(errno));
> + fclose(input);
>   exit(EXIT_FAILURE);
>   }
>   }
> @@ -1550,6 +1551,7 @@ int main(int argc, char *argv[])
>   XML_SetUserData(ctx.parser, &ctx);
>   if (ctx.parser == NULL) {
>   fprintf(stderr, "failed to create parser\n");
> + fclose(input);
>   exit(EXIT_FAILURE);
>   }
>  
> @@ -1561,6 +1563,7 @@ int main(int argc, char *argv[])
>   len = fread(buf, 1, XML_BUFFER_SIZE, input);
>   if (len < 0) {
>   fprintf(stderr, "fread: %m\n");
> + fclose(input);
>   exit(EXIT_FAILURE);
>   }
>   if (XML_ParseBuffer(ctx.parser, len, len == 0) == 0) {
> @@ -1569,6 +1572,7 @@ int main(int argc, char *argv[])
>   XML_GetCurrentLineNumber(ctx.parser),
>   XML_GetCurrentColumnNumber(ctx.parser),
>   XML_ErrorString(XML_GetErrorCode(ctx.parser)));
> + fclose(input);
>   exit(EXIT_FAILURE);
>   }
>   } while (len > 0);
> @@ -1588,6 +1592,7 @@ int main(int argc, char *argv[])
>   }
>  
>   free_protocol(&protocol);
> + fclose(input);
>  
>   return 0;
>  }
> 


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH 4/4] compositor-rdp: Add missing '\n' in weston_log usage

2015-10-07 Thread Hardening
Le 01/10/2015 16:51, Chris Michael a écrit :
> Signed-off-by: Chris Michael 
> ---
>  src/compositor-rdp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
> index c221eb9..7272f41 100644
> --- a/src/compositor-rdp.c
> +++ b/src/compositor-rdp.c
> @@ -1241,7 +1241,7 @@ rdp_backend_create(struct weston_compositor *compositor,
>   /* get the socket from RDP_FD var */
>   fd_str = getenv("RDP_FD");
>   if (!fd_str) {
> - weston_log("RDP_FD env variable not set");
> + weston_log("RDP_FD env variable not set\n");
>   goto err_output;
>   }
>  
> 
Reviewed-by: David FORT 

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH] weston-input: Reformat weston_log line to add missing space between words

2015-10-07 Thread Hardening
Le 07/10/2015 18:33, Derek Foreman a écrit :
> On 07/10/15 10:59 AM, Chris Michael wrote:
>> Signed-off-by: Chris Michael 
> 
> Reviewed-by: Derek Foreman 
> 
>> ---
>>  src/input.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/input.c b/src/input.c
>> index e230c83..2e5cd04 100644
>> --- a/src/input.c
>> +++ b/src/input.c
>> @@ -1571,7 +1571,7 @@ notify_touch(struct weston_seat *seat, uint32_t time, 
>> int touch_id,
>>  /* Unexpected condition: We have non-initial touch but
>>   * there is no focused surface.
>>   */
>> -weston_log("touch event received with %d points down"
>> +weston_log("touch event received with %d points down "
>> "but no surface focused\n", touch->num_tp);
>>  return;
>>  }
>>
> 
I hit the case today, so...

Reviewed-by: David FORT 

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH wayland] scanner: Generate 'since' macros for requests as well

2015-10-08 Thread Hardening
Le 08/10/2015 05:10, Jonas Ådahl a écrit :
> We already generate WL_[INTERFACE]_[REQUEST]_SINCE_VERSION macros for
> events in the server protocol headers. Lets do the same for requests in
> the client protocol headers as well.
> 
> Signed-off-by: Jonas Ådahl 
> ---
>  src/scanner.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/scanner.c b/src/scanner.c
> index 9b41ae4..2d5a0d8 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -1270,6 +1270,7 @@ emit_header(struct protocol *protocol, enum side side)
>   } else {
>   emit_structs(&i->event_list, i, side);
>   emit_opcodes(&i->request_list, i);
> + emit_opcode_versions(&i->request_list, i);
>   emit_stubs(&i->request_list, i);
>   }
>  
> 
I hit the case this week, this patch is definitely a must-have.

Reviewed-by: David FORT 

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH] weston: release keyboard/touch/pointer objects

2015-10-08 Thread Hardening
Le 08/10/2015 05:14, Jonas Ådahl a écrit :
> On Tue, Oct 06, 2015 at 10:59:32AM +0200, David FORT wrote:
>> This patch adds the missing calls to release when the seat has capabilities
>> changes. It also fixes a missing release of the touch object.
>> ---
>>  clients/window.c | 23 +++
>>  1 file changed, 19 insertions(+), 4 deletions(-)
>>
>> diff --git a/clients/window.c b/clients/window.c
>> index 47a79aa..7469259 100644
>> --- a/clients/window.c
>> +++ b/clients/window.c
>> @@ -79,6 +79,10 @@ typedef void *EGLContext;
>>  #include "ivi-application-client-protocol.h"
>>  #define IVI_SURFACE_ID 9000
>>  
>> +#define WL_KEYBOARD_RELEASE_SINCE_VERSION 3
>> +#define WL_POINTER_RELEASE_SINCE_VERSION 3
>> +#define WL_TOUCH_RELEASE_SINCE_VERSION 3
> 
> The code below looks good, but I don't think we should define macros
> prefixed with WL_ since that'd be something wayland might do.
> I just sent a patch (CC:ed you on it) that makes scanner.c generate
> these for us, just sa we do with events. If we don't go with generating
> the _SINCE_VERSION macros for requests, then you should probably prefix
> them in some way.
> 

Totally agree. Right now, there's several places where it's magic
numbers that are used.

So if people could review the straightforward patch here:
http://lists.freedesktop.org/archives/wayland-devel/2015-October/024742.html
so that it lands quickly.



-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH weston] clients: track seat_version per seat, not per display

2015-10-14 Thread Hardening
Le 14/10/2015 16:39, Derek Foreman a écrit :
> Apparently it's possible for a compositor to advertise seats with
> different versions on the same connection, so this makes us more robust
> against that dubious behaviour.
> 
> This also tracks the seat version we requested instead of the advertised
> maximum.
> 
> Signed-off-by: Derek Foreman 
> ---
> 
> As penance for my sass, I've gone ahead and "fixed" this - I think
> tracking the version we requested instead of the one advertised is
> more robust against catching a failure to increment the requested
> version though. However, it does seem like the correct thing to do.
> 
>  clients/window.c | 20 +++-
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/clients/window.c b/clients/window.c
> index 6d3e944..d8f2ee2 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -140,7 +140,6 @@ struct display {
>   void *dummy_surface_data;
>  
>   int has_rgb565;
> - int seat_version;
>   int data_device_manager_version;
>  };
>  
> @@ -362,6 +361,7 @@ struct input {
>   uint32_t repeat_sym;
>   uint32_t repeat_key;
>   uint32_t repeat_time;
> + int seat_version;
>  };
>  
>  struct output {
> @@ -3256,7 +3256,7 @@ seat_handle_capabilities(void *data, struct wl_seat 
> *seat,
>   wl_pointer_add_listener(input->pointer, &pointer_listener,
>   input);
>   } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
> - if (input->display->seat_version >= 
> WL_POINTER_RELEASE_SINCE_VERSION)
> + if (input->seat_version >= WL_POINTER_RELEASE_SINCE_VERSION)
>   wl_pointer_release(input->pointer);
>   else
>   wl_pointer_destroy(input->pointer);
> @@ -3269,7 +3269,7 @@ seat_handle_capabilities(void *data, struct wl_seat 
> *seat,
>   wl_keyboard_add_listener(input->keyboard, &keyboard_listener,
>input);
>   } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
> - if (input->display->seat_version >= 
> WL_KEYBOARD_RELEASE_SINCE_VERSION)
> + if (input->seat_version >= WL_KEYBOARD_RELEASE_SINCE_VERSION)
>   wl_keyboard_release(input->keyboard);
>   else
>   wl_keyboard_destroy(input->keyboard);
> @@ -3281,7 +3281,7 @@ seat_handle_capabilities(void *data, struct wl_seat 
> *seat,
>   wl_touch_set_user_data(input->touch, input);
>   wl_touch_add_listener(input->touch, &touch_listener, input);
>   } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) {
> - if (input->display->seat_version >= 
> WL_TOUCH_RELEASE_SINCE_VERSION)
> + if (input->seat_version >= WL_TOUCH_RELEASE_SINCE_VERSION)
>   wl_touch_release(input->touch);
>   else
>   wl_touch_destroy(input->touch);
> @@ -5218,17 +5218,20 @@ fini_xkb(struct input *input)
>  }
>  
>  static void
> -display_add_input(struct display *d, uint32_t id)
> +display_add_input(struct display *d, uint32_t id, int display_seat_version)
>  {
>   struct input *input;
> + int seat_version = MIN(display_seat_version, 4);
>  
>   input = xzalloc(sizeof *input);
>   input->display = d;
>   input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface,
> -MIN(d->seat_version, 4));
> +seat_version);
>   input->touch_focus = NULL;
>   input->pointer_focus = NULL;
>   input->keyboard_focus = NULL;
> + input->seat_version = seat_version;
> +
>   wl_list_init(&input->touch_point_list);
>   wl_list_insert(d->input_list.prev, &input->link);
>  
> @@ -5278,7 +5281,7 @@ input_destroy(struct input *input)
>   else
>   wl_data_device_destroy(input->data_device);
>   }
> - if (input->display->seat_version >= WL_POINTER_RELEASE_SINCE_VERSION) {
> + if (input->seat_version >= WL_POINTER_RELEASE_SINCE_VERSION) {
>   if (input->touch)
>   wl_touch_release(input->touch);
>   if (input->pointer)
> @@ -5365,8 +5368,7 @@ registry_handle_global(void *data, struct wl_registry 
> *registry, uint32_t id,
>   } else if (strcmp(interface, "wl_output") == 0) {
>   display_add_output(d, id);
>   } else if (strcmp(interface, "wl_seat") == 0) {
> - d->seat_version = version;
> - display_add_input(d, id);
> + display_add_input(d, id, version);
>   } else if (strcmp(interface, "wl_shm") == 0) {
>   d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
>   wl_shm_add_listener(d->shm, &shm_listener, d);
> 

I had noticed that too, I can't see in which situation this could
happen, perhaps a subcompositor advertising it

Re: [weston] xkbcommon library is not optional.

2015-10-16 Thread Hardening
Le 16/10/2015 03:28, Bryce Harrington a écrit :
> On Tue, Oct 13, 2015 at 01:59:13PM +0200, Joaquim Duran wrote:
>> Hello,
>>
>> When configuring the Weston project, it is possible to disable (don't
>> include) the library libxkbcommon. To compile Weston successfully,
>> even if the option --disable-xkbcommon is specified, the library must
>> be installed because the file src/compositor.h requires it.
> 
> Joaquim, good find.
> 
> From the comments in configure.ac:
> 
>   AS_HELP_STRING([--disable-xkbcommon], [Disable libxkbcommon
>   support: This is only useful in environments
>   where you do not have a hardware keyboard. If
>   libxkbcommon support is disabled clients will not
>   be sent a keymap and and must know how to
>   interpret the keycode sent for any key event.]),,
> 
> So it sounds like this is a special case that is intended to work.
> 
> The header include was from commit 855028fe three years ago, while the
> --disable-xkbcommon was added by 382ff46f just two years ago.  That
> makes me think that your situation was simply overlooked.
> 
> If that's true, then presumably the fix would involve peppering
> compositor.* and other files with tests like,
> 
> #ifdef ENABLE_XKBCOMMON
> ...
> #endif
> 
> For example it looks like the weston_xkb_info struct would need to
> either be removed or stubbed out, and users of it be disabled.  There
> are also some weston calls that use xkb_keymap, xkb_rule_names,
> etc. structures for params that'd need addressed.
> 
> On the face of it, seems like it could be a fair amount of work, and a
> bit invasive, but maybe there's some tricks to make it simpler
> (typedeffing the unsupported struct args and so on.)
> 
> Alternatively, --disable-xkbcommon could be dropped.  However I get the
> sense it actually solves a real world need, and functional regression is
> rarely a good idea.
> 

I'm to fix the bug. Anyway it's almost sure that there's no real usage
of this flag as otherwise weston does not compile...

Best regards


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [weston] xkbcommon library is not optional.

2015-10-16 Thread Hardening
Le 16/10/2015 10:34, Joaquim Duran a écrit :
> Disable xkbcommon library could be useful in devices based on
> touchscreen, like smartphones, but if you have USB connectors, you
> could connect an external keyboard. if xkbcommon is a small library,
> just change the documentation.
> 
> Joaquim Duran
> 


Don't get me wrong, I'm not saying it's not useful. I'm saying that
probably nobody's using it as otherwise it doesn't compile.


> 2015-10-16 10:27 GMT+02:00 Hardening :
>> Le 16/10/2015 03:28, Bryce Harrington a écrit :
>>> On Tue, Oct 13, 2015 at 01:59:13PM +0200, Joaquim Duran wrote:
>>>> Hello,
>>>>
>>>> When configuring the Weston project, it is possible to disable (don't
>>>> include) the library libxkbcommon. To compile Weston successfully,
>>>> even if the option --disable-xkbcommon is specified, the library must
>>>> be installed because the file src/compositor.h requires it.
>>>
>>> Joaquim, good find.
>>>
>>> From the comments in configure.ac:
>>>
>>>   AS_HELP_STRING([--disable-xkbcommon], [Disable libxkbcommon
>>>   support: This is only useful in environments
>>>   where you do not have a hardware keyboard. If
>>>   libxkbcommon support is disabled clients will not
>>>   be sent a keymap and and must know how to
>>>   interpret the keycode sent for any key event.]),,
>>>
>>> So it sounds like this is a special case that is intended to work.
>>>
>>> The header include was from commit 855028fe three years ago, while the
>>> --disable-xkbcommon was added by 382ff46f just two years ago.  That
>>> makes me think that your situation was simply overlooked.
>>>
>>> If that's true, then presumably the fix would involve peppering
>>> compositor.* and other files with tests like,
>>>
>>> #ifdef ENABLE_XKBCOMMON
>>> ...
>>> #endif
>>>
>>> For example it looks like the weston_xkb_info struct would need to
>>> either be removed or stubbed out, and users of it be disabled.  There
>>> are also some weston calls that use xkb_keymap, xkb_rule_names,
>>> etc. structures for params that'd need addressed.
>>>
>>> On the face of it, seems like it could be a fair amount of work, and a
>>> bit invasive, but maybe there's some tricks to make it simpler
>>> (typedeffing the unsupported struct args and so on.)
>>>
>>> Alternatively, --disable-xkbcommon could be dropped.  However I get the
>>> sense it actually solves a real world need, and functional regression is
>>> rarely a good idea.
>>>
>>
>> I'm to fix the bug. Anyway it's almost sure that there's no real usage
>> of this flag as otherwise weston does not compile...
>>
>> Best regards
>>
>>
>> --
>> David FORT
>> website: http://www.hardening-consulting.com/
>>
>> ___
>> wayland-devel mailing list
>> wayland-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [RFC] weston: implement inert objects for keyboard/pointer/touch

2015-10-16 Thread Hardening
Le 16/10/2015 11:53, David FORT a écrit :
> This patch implements inert objects for wl_keyboard, wl_pointer and wl_touch.
> The target case is when the server has just send a capability event about a
> disappearing object, and the client binds the corresponding object. We bind an
> inert object: an object does nothing when it is requested. If the client 
> behave
> correctly, this object should be released when the capability event is 
> received
> and treated (calling the corresponding release request).
> As a consequence, we can rely on seat->[keyboard|pointer|touch]_state to know
> if the seat has the corresponding object.
> Weston doesn't really handle multiple mice for one wl_pointer, so I have 
> removed
> the corresponding code and tests (it was quite a weston_test hack BTW).
> Finally I have fixed a wrong behaviour: the capabilities event's 
> documentation states
> that the capabilities should be sent when a new capability is set on the 
> seat. So
> attaching a second mouse to an existing wl_pointer should not broadcast seat
> capabilities (and the same for keyboard and touch).
> ---
>  desktop-shell/exposay.c  |  16 ++--
>  desktop-shell/shell.c|  21 +++--
>  src/compositor-wayland.c |  10 +-
>  src/compositor-x11.c |  12 ++-
>  src/compositor.h |   3 -
>  src/input.c  | 235 
> ++-
>  src/libinput-device.c|   2 +-
>  src/screen-share.c   |   2 +
>  src/text-backend.c   |  44 +
>  src/zoom.c   |   7 +-
>  tests/devices-test.c |  20 
>  tests/weston-test.c  |  18 ++--
>  xwayland/dnd.c   |   3 +-
>  13 files changed, 216 insertions(+), 177 deletions(-)
> 
> diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c
> index 08b86a3..d6919b3 100644
> --- a/desktop-shell/exposay.c
> +++ b/desktop-shell/exposay.c
> @@ -574,21 +574,23 @@ exposay_transition_active(struct desktop_shell *shell)
>   bool animate = false;
>  
>   shell->exposay.workspace = get_current_workspace(shell);
> - shell->exposay.focus_prev = get_default_view(keyboard->focus);
> - shell->exposay.focus_current = get_default_view(keyboard->focus);
> + if (keyboard) {
> + shell->exposay.focus_prev = get_default_view(keyboard->focus);
> + shell->exposay.focus_current = 
> get_default_view(keyboard->focus);
> + }
>   shell->exposay.clicked = NULL;
>   wl_list_init(&shell->exposay.surface_list);
>  
>   lower_fullscreen_layer(shell, NULL);
>   shell->exposay.grab_kbd.interface = &exposay_kbd_grab;
> - weston_keyboard_start_grab(keyboard,
> -&shell->exposay.grab_kbd);
> - weston_keyboard_set_focus(keyboard, NULL);
> + if (keyboard) {
> + weston_keyboard_start_grab(keyboard, &shell->exposay.grab_kbd);
> + weston_keyboard_set_focus(keyboard, NULL);
> + }
>  
>   shell->exposay.grab_ptr.interface = &exposay_ptr_grab;
>   if (pointer) {
> - weston_pointer_start_grab(pointer,
> -   &shell->exposay.grab_ptr);
> + weston_pointer_start_grab(pointer, &shell->exposay.grab_ptr);
>   weston_pointer_clear_focus(pointer);
>   }
>   wl_list_for_each(shell_output, &shell->output_list, link) {
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> index 3eb3f5c..cdddf09 100644
> --- a/desktop-shell/shell.c
> +++ b/desktop-shell/shell.c
> @@ -380,7 +380,8 @@ shell_grab_start(struct shell_grab *grab,
>   struct desktop_shell *shell = shsurf->shell;
>   struct weston_touch *touch = weston_seat_get_touch(pointer->seat);
>  
> - popup_grab_end(pointer);
> + if (pointer)
> + popup_grab_end(pointer);
>   if (touch)
>   touch_popup_grab_end(touch);
>  
> @@ -391,11 +392,13 @@ shell_grab_start(struct shell_grab *grab,
> &grab->shsurf_destroy_listener);
>  
>   shsurf->grabbed = 1;
> - weston_pointer_start_grab(pointer, &grab->grab);
> + if (pointer)
> + weston_pointer_start_grab(pointer, &grab->grab);
>   if (shell->child.desktop_shell) {
>   desktop_shell_send_grab_cursor(shell->child.desktop_shell,
>  cursor);
> - weston_pointer_set_focus(pointer,
> + if (pointer)
> + weston_pointer_set_focus(pointer,
>get_default_view(shell->grab_surface),
>wl_fixed_from_int(0),
>wl_fixed_from_int(0));
> @@ -925,12 +928,10 @@ restore_focus_state(struct desktop_shell *shell, struct 
> workspace *ws)
>   wl_list_insert(&shell->compositor->seat_list,
>  &state->seat->link);
>  
> - if (!keyboard)
> - continue;
> -
>   surface = state->keybo

Re: [RFC] weston: implement inert objects for keyboard/pointer/touch

2015-10-16 Thread Hardening
Le 16/10/2015 11:53, David FORT a écrit :
> This patch implements inert objects for wl_keyboard, wl_pointer and wl_touch.
> The target case is when the server has just send a capability event about a
> disappearing object, and the client binds the corresponding object. We bind an
> inert object: an object does nothing when it is requested. If the client 
> behave
> correctly, this object should be released when the capability event is 
> received
> and treated (calling the corresponding release request).
> As a consequence, we can rely on seat->[keyboard|pointer|touch]_state to know
> if the seat has the corresponding object.
> Weston doesn't really handle multiple mice for one wl_pointer, so I have 
> removed
> the corresponding code and tests (it was quite a weston_test hack BTW).
> Finally I have fixed a wrong behaviour: the capabilities event's 
> documentation states
> that the capabilities should be sent when a new capability is set on the 
> seat. So
> attaching a second mouse to an existing wl_pointer should not broadcast seat
> capabilities (and the same for keyboard and touch).
> ---
>  desktop-shell/exposay.c  |  16 ++--
>  desktop-shell/shell.c|  21 +++--
>  src/compositor-wayland.c |  10 +-
>  src/compositor-x11.c |  12 ++-
>  src/compositor.h |   3 -
>  src/input.c  | 235 
> ++-
>  src/libinput-device.c|   2 +-
>  src/screen-share.c   |   2 +
>  src/text-backend.c   |  44 +
>  src/zoom.c   |   7 +-
>  tests/devices-test.c |  20 
>  tests/weston-test.c  |  18 ++--
>  xwayland/dnd.c   |   3 +-
>  13 files changed, 216 insertions(+), 177 deletions(-)
> 
> diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c
> index 08b86a3..d6919b3 100644
> --- a/desktop-shell/exposay.c
> +++ b/desktop-shell/exposay.c
> @@ -574,21 +574,23 @@ exposay_transition_active(struct desktop_shell *shell)
>   bool animate = false;
>  
>   shell->exposay.workspace = get_current_workspace(shell);
> - shell->exposay.focus_prev = get_default_view(keyboard->focus);
> - shell->exposay.focus_current = get_default_view(keyboard->focus);
> + if (keyboard) {
> + shell->exposay.focus_prev = get_default_view(keyboard->focus);
> + shell->exposay.focus_current = 
> get_default_view(keyboard->focus);
> + }
>   shell->exposay.clicked = NULL;
>   wl_list_init(&shell->exposay.surface_list);
>  
>   lower_fullscreen_layer(shell, NULL);
>   shell->exposay.grab_kbd.interface = &exposay_kbd_grab;
> - weston_keyboard_start_grab(keyboard,
> -&shell->exposay.grab_kbd);
> - weston_keyboard_set_focus(keyboard, NULL);
> + if (keyboard) {
> + weston_keyboard_start_grab(keyboard, &shell->exposay.grab_kbd);
> + weston_keyboard_set_focus(keyboard, NULL);
> + }
>  
>   shell->exposay.grab_ptr.interface = &exposay_ptr_grab;
>   if (pointer) {
> - weston_pointer_start_grab(pointer,
> -   &shell->exposay.grab_ptr);
> + weston_pointer_start_grab(pointer, &shell->exposay.grab_ptr);
>   weston_pointer_clear_focus(pointer);
>   }
>   wl_list_for_each(shell_output, &shell->output_list, link) {
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> index 3eb3f5c..cdddf09 100644
> --- a/desktop-shell/shell.c
> +++ b/desktop-shell/shell.c
> @@ -380,7 +380,8 @@ shell_grab_start(struct shell_grab *grab,
>   struct desktop_shell *shell = shsurf->shell;
>   struct weston_touch *touch = weston_seat_get_touch(pointer->seat);
>  
> - popup_grab_end(pointer);
> + if (pointer)
> + popup_grab_end(pointer);
>   if (touch)
>   touch_popup_grab_end(touch);
>  
> @@ -391,11 +392,13 @@ shell_grab_start(struct shell_grab *grab,
> &grab->shsurf_destroy_listener);
>  
>   shsurf->grabbed = 1;
> - weston_pointer_start_grab(pointer, &grab->grab);
> + if (pointer)
> + weston_pointer_start_grab(pointer, &grab->grab);
>   if (shell->child.desktop_shell) {
>   desktop_shell_send_grab_cursor(shell->child.desktop_shell,
>  cursor);
> - weston_pointer_set_focus(pointer,
> + if (pointer)
> + weston_pointer_set_focus(pointer,
>get_default_view(shell->grab_surface),
>wl_fixed_from_int(0),
>wl_fixed_from_int(0));
> @@ -925,12 +928,10 @@ restore_focus_state(struct desktop_shell *shell, struct 
> workspace *ws)
>   wl_list_insert(&shell->compositor->seat_list,
>  &state->seat->link);
>  
> - if (!keyboard)
> - continue;
> -
>   surface = state->keybo

Re: [PATCH] weston: implement inert objects for keyboard/pointer/touch

2015-10-20 Thread Hardening
Le 20/10/2015 10:24, Bryce Harrington a écrit :
> On Mon, Oct 19, 2015 at 03:47:19PM +0200, David FORT wrote:
>> This patch implements inert objects for wl_keyboard, wl_pointer and wl_touch.
>> The target case is when the server has just send a capability event about a
>> disappearing object, and the client binds the corresponding object. We bind 
>> an
>> inert object: an object does nothing when it is requested. If the client 
>> behave
>> correctly, this object should be released when the capability event is 
>> received
>> and treated (calling the corresponding release request).
>> As a consequence, we can rely on seat->[keyboard|pointer|touch]_state to know
>> if the seat has the corresponding object.
> 
> This is a big patch but it looks like the vast bulk is merely adding in
> pointer checks for keyboard, pointer, etc. everywhere and subsequent
> retabbing.  If you broke that refactoring step out as a preliminary
> patch, it may make reviewing the pertinent changes (i.e. tracking and
> checking state for the input devices rather than just testing the
> reference count) a bit easier.

I'm not sure to understand, what should I do then ?

> 
> Thanks for tending to the test code too in the refactor; it would be
> grand to see a test case added to keyboard-test or devices-test to
> exercise the case of handling inert input objects.
> 

Such a test is already there in the existing tests. In
get_device_after_destroy of devices-test.c, we already exercise inert
objects.

Best regards

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH] weston: implement inert objects for keyboard/pointer/touch

2015-10-20 Thread Hardening
Le 20/10/2015 17:12, Bryce Harrington a écrit :
> On Tue, Oct 20, 2015 at 10:39:51AM +0200, Hardening wrote:
>> Le 20/10/2015 10:24, Bryce Harrington a écrit :
>>> On Mon, Oct 19, 2015 at 03:47:19PM +0200, David FORT wrote:
>>>> This patch implements inert objects for wl_keyboard, wl_pointer and 
>>>> wl_touch.
>>>> The target case is when the server has just send a capability event about a
>>>> disappearing object, and the client binds the corresponding object. We 
>>>> bind an
>>>> inert object: an object does nothing when it is requested. If the client 
>>>> behave
>>>> correctly, this object should be released when the capability event is 
>>>> received
>>>> and treated (calling the corresponding release request).
>>>> As a consequence, we can rely on seat->[keyboard|pointer|touch]_state to 
>>>> know
>>>> if the seat has the corresponding object.
>>>
>>> This is a big patch but it looks like the vast bulk is merely adding in
>>> pointer checks for keyboard, pointer, etc. everywhere and subsequent
>>> retabbing.  If you broke that refactoring step out as a preliminary
>>> patch, it may make reviewing the pertinent changes (i.e. tracking and
>>> checking state for the input devices rather than just testing the
>>> reference count) a bit easier.
>>
>> I'm not sure to understand, what should I do then ?
> 
> Create two patches, the first of which just adds all the "if
> (keyboard)..." checks, and the second (much smaller) patch which adds
> the inert_pointer_interface, inert_keyboard_interface, etc. parts which
> are what you actually need the review on.  The pointer checking is
> obviously a safe refactoring that can be landed with minimal review.
> 

Well I can do this way but the 2 patches are linked. In the current
code, once a keyboard has been created, you can't have a null
seat->keyboard_state. So in the current situation, I'm not sure the
checks are really needed .

>>> Thanks for tending to the test code too in the refactor; it would be
>>> grand to see a test case added to keyboard-test or devices-test to
>>> exercise the case of handling inert input objects.
>>>
>>
>> Such a test is already there in the existing tests. In
>> get_device_after_destroy of devices-test.c, we already exercise inert
>> objects.
> 
> Apparently it is not exercised sufficiently, because it passes already
> without your fix.
> 

Well you're right: in the current code input objects are never released,
so the calls are done on used objects without any visible side effect.
In fact, there's a side effect when calling wl_pointer.set_cursor on a
released pointer: the surface is given the mouse pointer role. Using
inert objects, you're just sure that there will be no side effect at
all. As I said It think it's also the first step to make it possible to
safely release the full seat.

> But you're right that this test case looks like a good place for you to
> add more coverage for this bug.  Does the current test pass without your
> fix because it is not making deep enough wayland calls?  I.e. does it
> need to do more than merely a wl_pointer_set_cursor call?
> 
> Also, it appears this test isn't doing the same checking for keyboard
> and touch as it does for pointer; even though internally all three are
> implemented the same way, there are three different protocol routines
> involved here (wl_seat_get_pointer, wl_seat_get_keyboard, and
> wl_seat_get_touch), any of which could present their own bugs, so proper
> test coverage should methodically check all three.
> 

+1 for testing all input objects.

Best regards.

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH weston 03/10] Use presentation timing protocol from wayland-protocols

2015-11-06 Thread Hardening
Le 04/11/2015 09:49, Jonas Ådahl a écrit :
> Signed-off-by: Jonas Ådahl 
> ---
>  Makefile.am  |  21 ++-
>  clients/presentation-shm.c   |  65 +-
>  clients/weston-info.c|  19 +--
>  protocol/presentation_timing.xml | 274 
> ---
>  src/compositor-drm.c |  14 +-
>  src/compositor-fbdev.c   |   2 +-
>  src/compositor-headless.c|   2 +-
>  src/compositor-rpi.c |   6 +-
>  src/compositor-wayland.c |   2 +-
>  src/compositor-x11.c |   2 +-
>  src/compositor.c |  29 +++--
>  tests/presentation-test.c|  34 ++---
>  12 files changed, 101 insertions(+), 369 deletions(-)
>  delete mode 100644 protocol/presentation_timing.xml
> 

The RDP compositor is not treated by this patch.


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH weston 03/10] Use presentation timing protocol from wayland-protocols

2015-11-06 Thread Hardening
Le 04/11/2015 09:49, Jonas Ådahl a écrit :
> Signed-off-by: Jonas Ådahl 
> ---
>  Makefile.am  |  21 ++-
>  clients/presentation-shm.c   |  65 +-
>  clients/weston-info.c|  19 +--
>  protocol/presentation_timing.xml | 274 
> ---
>  src/compositor-drm.c |  14 +-
>  src/compositor-fbdev.c   |   2 +-
>  src/compositor-headless.c|   2 +-
>  src/compositor-rpi.c |   6 +-
>  src/compositor-wayland.c |   2 +-
>  src/compositor-x11.c |   2 +-
>  src/compositor.c |  29 +++--
>  tests/presentation-test.c|  34 ++---
>  12 files changed, 101 insertions(+), 369 deletions(-)
>  delete mode 100644 protocol/presentation_timing.xml
> 

As stated on IRC, in fact no changes are needed for the RDP compositor.
Sorry for the noise.


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: Process for implementing a double buffer on Wayland

2015-11-25 Thread Hardening
Le 25/11/2015 17:18, Daniel Stone a écrit :
> Hi Mike,
> 
> On 25 November 2015 at 16:06, Mike Johnson  wrote:
>> I've created 2 buffers of the same size (800x600 pixels).  So I want the
>> input buffer to get filled off-screen, while the output buffer will show the
>> content on-screen.
>>
>> First of all what sort of content could be used to illustrate this
>> technique, and secondly, what mechanisms are available to:
>>
>> a) Notify that the input buffer is full
>> b) Copy the content to the output buffer so that it shows on-screen
> 
> It's quite simple. wl_surface_attach(surf, buf) +
> wl_surface_commit(surf) will display 'buf' for that surface. At that
> point, the compositor owns that buffer, so you should stop drawing on
> it. When the compositor has finished with a buffer, it will send you a
> wl_buffer.release event. You can sync your paint clock to the
> compositor's repaint loop with wl_surface_frame.
> 
> So, the normal workflow is:
>   - create surface S, buffer A, buffer B
>   - draw first frame into buffer A
>   - call wl_surface_frame(S) + wl_surface_attach(S, A) +
> wl_surface_commit(S) + wl_display_flush()
>   - go to sleep
>   - receive completion for wl_surface_frame callback
>   - draw second frame into buffer B
>   - call wl_surface_frame(S) + wl_surface_attach(S, B) +
> wl_surface_commit(S) + wl_display_flush()
>   - compositor now owns both buffers, so don't touch any
>   - receive wl_buffer.release event for buffer A - now unused
>   - receive completion for wl_surface_frame callback
>   - draw third frame into buffer A
>   - ...
> 

I may be wrong, but there's no guaranty that the compositor sends
wl_buffer.release event on buffer A. I think I have experimented this
when the renderer in weston is the pixman renderer.
IIRC I have been told on IRC that the compositor decides when the buffer
is not used, so you may not receive the release message immediately. I
have hit that kind of bug when coding libUWAC.

Best regards.

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH weston] compositor-fbdev: Drop intermediate shadow buffer

2015-12-08 Thread Hardening
Le 05/12/2015 02:20, Derek Foreman a écrit :
> From: Sjoerd Simons 
> 
> Currently the fbdev compositor has its own shadow buffer when rendering
> with pixman, causing the following copies to occur:
> 
> [pixman shadow buffer] -> [fbdev shadow buffer] -> [fbdev hardware]
> 
> As the pixman render already does all output translation when
> compositing the intermediate shadow buffer really isn't needed, so drop
> it.
> 
> As a side-effect this fixes updating the fbdev hardware for outputs not
> starting at 0x0.
> 
> Signed-off-by: Sjoerd Simons 
> ---
> 

Reviewed-by David FORT 

I haven't test it either.


-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH v4] xwm: let the shells decide the position of X windows

2015-12-15 Thread Hardening
Le 11/12/2015 19:57, Giulio Camuffo a écrit :
> The xwm used to automatically send to Xwayland the position of X windows
> when that changed, using the x,y of the primary view of the surface.
> This works fine for the desktop shell but less so for others.
> This patch adds a 'send_position' vfunc to the weston_shell_client that
> the shell will call when it wants to let Xwayland know what the position
> of a window is.
> The logic used by the desktop-shell for that is exactly the same the xwm
> used to have.
> Reviewed-by: Derek Foreman 
> ---
> v4: changed pos_dirty to bool instead of int
> 
>  desktop-shell/shell.c | 40 +++---
>  desktop-shell/shell.h |  1 +
>  src/compositor.h  |  4 +--
>  xwayland/window-manager.c | 72 
> +--
>  xwayland/xwayland.h   |  1 -
>  5 files changed, 64 insertions(+), 54 deletions(-)
> 
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> index 780902d..85664c6 100644
> --- a/desktop-shell/shell.c
> +++ b/desktop-shell/shell.c
> @@ -1813,7 +1813,8 @@ send_configure(struct weston_surface *surface, int32_t 
> width, int32_t height)
>  }
>  
>  static const struct weston_shell_client shell_client = {
> - send_configure
> + send_configure,
> + NULL
>  };
>  
>  static void
> @@ -3704,12 +3705,6 @@ create_shell_surface(void *shell, struct 
> weston_surface *surface,
>   return create_common_surface(NULL, shell, surface, client);
>  }
>  
> -static struct weston_view *
> -get_primary_view(void *shell, struct shell_surface *shsurf)
> -{
> - return shsurf->view;
> -}
> -
>  static void
>  shell_get_shell_surface(struct wl_client *client,
>   struct wl_resource *resource,
> @@ -3995,7 +3990,8 @@ xdg_send_configure(struct weston_surface *surface,
>  }
>  
>  static const struct weston_shell_client xdg_client = {
> - xdg_send_configure
> + xdg_send_configure,
> + NULL
>  };
>  
>  static void
> @@ -4119,7 +4115,8 @@ xdg_popup_send_configure(struct weston_surface *surface,
>  }
>  
>  static const struct weston_shell_client xdg_popup_client = {
> - xdg_popup_send_configure
> + xdg_popup_send_configure,
> + NULL
>  };
>  
>  static struct shell_surface *
> @@ -5412,6 +5409,27 @@ wake_handler(struct wl_listener *listener, void *data)
>  }
>  
>  static void
> +transform_handler(struct wl_listener *listener, void *data)
> +{
> + struct weston_surface *surface = data;
> + struct shell_surface *shsurf = get_shell_surface(surface);
> + struct weston_view *view;;
> + int x, y;
> +
> + if (!shsurf || !shsurf->client->send_position)
> + return;
> +
> + view = shsurf->view;
> + if (!view || !weston_view_is_mapped(view))
> + return;
> +
> + x = view->geometry.x;
> + y = view->geometry.y;
> +
> + shsurf->client->send_position(surface, x, y);
> +}
> +
> +static void
>  center_on_output(struct weston_view *view, struct weston_output *output)
>  {
>   int32_t surf_x, surf_y, width, height;
> @@ -6379,6 +6397,7 @@ shell_destroy(struct wl_listener *listener, void *data)
>  
>   wl_list_remove(&shell->idle_listener.link);
>   wl_list_remove(&shell->wake_listener.link);
> + wl_list_remove(&shell->transform_listener.link);
>  
>   text_backend_destroy(shell->text_backend);
>   input_panel_destroy(shell);
> @@ -6520,10 +6539,11 @@ module_init(struct weston_compositor *ec,
>   wl_signal_add(&ec->idle_signal, &shell->idle_listener);
>   shell->wake_listener.notify = wake_handler;
>   wl_signal_add(&ec->wake_signal, &shell->wake_listener);
> + shell->transform_listener.notify = transform_handler;
> + wl_signal_add(&ec->transform_signal, &shell->transform_listener);
>  
>   ec->shell_interface.shell = shell;
>   ec->shell_interface.create_shell_surface = create_shell_surface;
> - ec->shell_interface.get_primary_view = get_primary_view;
>   ec->shell_interface.set_toplevel = set_toplevel;
>   ec->shell_interface.set_transient = set_transient;
>   ec->shell_interface.set_fullscreen = shell_interface_set_fullscreen;
> diff --git a/desktop-shell/shell.h b/desktop-shell/shell.h
> index 2ef23f4..c55a225 100644
> --- a/desktop-shell/shell.h
> +++ b/desktop-shell/shell.h
> @@ -121,6 +121,7 @@ struct desktop_shell {
>  
>   struct wl_listener idle_listener;
>   struct wl_listener wake_listener;
> + struct wl_listener transform_listener;
>   struct wl_listener destroy_listener;
>   struct wl_listener show_input_panel_listener;
>   struct wl_listener hide_input_panel_listener;
> diff --git a/src/compositor.h b/src/compositor.h
> index 8a5aa91..a427088 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -86,6 +86,7 @@ struct weston_mode {
>  
>  struct weston_shell_client {
>   void (*send_configure)(struct weston_surface *surface, int32_t width, 
> int32_t height);
> + void (*send_position)(struct

Re: [PATCH] Fix compilation with FreeRdp 1.1 and master

2013-12-10 Thread Hardening

On 10/12/2013 00:42, Kristian Høgsberg wrote:

On Mon, Dec 09, 2013 at 10:16:39PM +0100, Hardening wrote:

The API to use remoteFx encoding has changed between master and stable 1.1
branch. This patch fixes compilation for both.
Please note that the freerdp/version.h file is generated in the very last 
versions
of FreeRdp so be sure to update/install the last versions.

Yeah, this doesn't compile for me with an older FreeRdp because of the
missing freerdp/version.h.  If we're going to require a newer FreeRdp
for this to compile, can we just drop the #if?  Or is version.h
included by freedrp.h or something so we can avoid the version.h
#include?


Until recent changes there were no safe way to know which version you 
were compiling against.
The FREERDP_VERSION_[MAJOR|MINOR|REVISION] macros have never been 
accurate to detect this (not updated when they should). These macros 
were included in the freerdp/freerdp.h and are now auto-generated in the 
freerdp/version.h file.


You're right i think i can have a better patch that will take care of 
the installation that are missing the freerdp/version.h file.


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


Re: [PATCH] Fix compilation with FreeRdp 1.1 and master

2013-12-10 Thread Hardening

On 10/12/2013 09:25, Hardening wrote:

On 10/12/2013 00:42, Kristian Høgsberg wrote:

On Mon, Dec 09, 2013 at 10:16:39PM +0100, Hardening wrote:
The API to use remoteFx encoding has changed between master and 
stable 1.1

branch. This patch fixes compilation for both.
Please note that the freerdp/version.h file is generated in the very 
last versions

of FreeRdp so be sure to update/install the last versions.

Yeah, this doesn't compile for me with an older FreeRdp because of the
missing freerdp/version.h.  If we're going to require a newer FreeRdp
for this to compile, can we just drop the #if?  Or is version.h
included by freedrp.h or something so we can avoid the version.h
#include?


Until recent changes there were no safe way to know which version you 
were compiling against.
The FREERDP_VERSION_[MAJOR|MINOR|REVISION] macros have never been 
accurate to detect this (not updated when they should). These macros 
were included in the freerdp/freerdp.h and are now auto-generated in 
the freerdp/version.h file.


You're right i think i can have a better patch that will take care of 
the installation that are missing the freerdp/version.h file.
Sorry to disappoint but my previous patch is the only way to deal 
between stable-1.1 (which is fact is a stabilization in progress branch) 
and master. The patch works only with last version of stable-1.1 or 
master (the config.h is here from a longer time in master). To mitigate 
things, nobody ships FreeRdp 1.1 for now.
Sorry about that, things have not been done cleanly in FreeRdp, but 
we'll take care of that in the future.


Regards

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


[PATCH 1/1] Add a FreeRds backend, take 3

2013-12-18 Thread Hardening
FreeRDS is a FreeRDP based RDP server, the server handles incoming connections 
and
talks RDP with the peers. FreeRds cooperates with an "out-service": the 
out-service creates
the content to display, and FreeRds will take care of encoding the content in 
the
appropriate format (bitmapUpdate, remoteFx or NsCodec).
To communicate, they use a unix socket for passing commands, and a shared 
buffer for
the screen content. A vblank signal sent by FreeRds via the command channel 
allows
to share the framebuffer nicely.
This patch adds a backend to create a FreeRDS compositor and have weston being 
an out-service
for FreeRds.

Compared to the previous version this one fixes a segfault at FreeRds 
disconnection. The mode
switch has been implemented too, so the desktop resizes if you connect once in 
800x600 and then
in 1024x768. And finally the refresh rates are now correctly send in mHz not Hz.
---
 configure.ac |   10 +
 src/compositor-freerds.c | 1057 ++
 2 files changed, 1067 insertions(+)
 create mode 100644 src/compositor-freerds.c

diff --git a/configure.ac b/configure.ac
index adf1bae..d9c1dfe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -206,6 +206,15 @@ if test x$enable_rdp_compositor = xyes; then
   PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0])
 fi
 
+AC_ARG_ENABLE([freerds-compositor], [  --enable-freerds-compositor],,
+  enable_freerds_compositor=no)
+AM_CONDITIONAL([ENABLE_FREERDS_COMPOSITOR],
+   [test x$enable_freerds_compositor = xyes])
+if test x$enable_freerds_compositor = xyes; then
+  AC_DEFINE([BUILD_FREERDS_COMPOSITOR], [1], [Build the FreeRDS compositor])
+  PKG_CHECK_MODULES(FREERDS_COMPOSITOR, [freerds-backend])
+fi
+
 AC_ARG_WITH(cairo,
AS_HELP_STRING([--with-cairo=@<:@image|gl|glesv2@:>@]
   [Which Cairo renderer to use for the clients]),
@@ -526,6 +535,7 @@ AC_MSG_RESULT([
RPI Compositor  ${enable_rpi_compositor}
FBDEV Compositor${enable_fbdev_compositor}
RDP Compositor  ${enable_rdp_compositor}
+   FreeRDS Compositor  ${enable_freerds_compositor}
 
Raspberry Pi BCM headers${have_bcm_host}
 
diff --git a/src/compositor-freerds.c b/src/compositor-freerds.c
new file mode 100644
index 000..19b68c3
--- /dev/null
+++ b/src/compositor-freerds.c
@@ -0,0 +1,1057 @@
+/**
+ * Copyright © 2013 Hardening 
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "config.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "compositor.h"
+#include "pixman-renderer.h"
+
+
+#define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int(10)
+#define FREERDS_COMMON_LENGTH 10
+#define FREERDS_MODE_FPS 60 * 1000
+
+
+struct freerds_compositor_config {
+   int width;
+   int height;
+   char *freerds_named_pipe;
+};
+
+struct freerds_compositor;
+struct freerds_output;
+
+/** @brief state of the module protocol automata */
+enum StreamState {
+   STREAM_WAITING_COMMON_HEADER,
+   STREAM_WAITING_DATA
+};
+
+struct freerds_compositor {
+   struct weston_compositor base;
+
+   struct freerds_output *output;
+   struct weston_seat seat;
+
+   bool have_seat;
+   int listening_fd;
+   struct wl_event_source *server_event_source;
+   int client_fd;
+   struct wl_event_source *client_event_source;
+   enum StreamState streamState;
+   wStream *in_stream;
+   wStream *out_stream;
+   int expected_bytes;
+   UINT32 keyboard_layout;
+   UINT32 keyboard_type;
+
+   RDS_MSG_COMMON

[PATCH] Release pointer and keyboard with the seat

2013-12-21 Thread Hardening
This patch fixes seat releasing during a RDP disconnection.
It does not fully fix https://bugs.freedesktop.org/show_bug.cgi?id=66830,
but makes things better.
---
 src/compositor-rdp.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 58342b9..446bf87 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -597,8 +597,11 @@ rdp_peer_context_free(freerdp_peer* client, 
RdpPeerContext* context)
wl_event_source_remove(context->events[i]);
}
 
-   if(context->item.flags & RDP_PEER_ACTIVATED)
+   if(context->item.flags & RDP_PEER_ACTIVATED) {
+   weston_seat_release_keyboard(&context->item.seat);
+   weston_seat_release_pointer(&context->item.seat);
weston_seat_release(&context->item.seat);
+   }
Stream_Free(context->encode_stream, TRUE);
nsc_context_free(context->nsc_context);
rfx_context_free(context->rfx_context);
-- 
1.8.1.2

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


Re: [PATCH] Release pointer and keyboard with the seat

2013-12-22 Thread Hardening

Le 22/12/2013 22:50, Kristian Høgsberg a écrit :

On Sat, Dec 21, 2013 at 11:19:11PM +0100, Hardening wrote:

This patch fixes seat releasing during a RDP disconnection.
It does not fully fix https://bugs.freedesktop.org/show_bug.cgi?id=66830,
but makes things better.


Thanks, applied.  What's left to fix 66830?



My impression for #68830 is that a weston client is trying to bind a 
released seat. The valgrind callstack I have experimented here suggest 
that, but for now I don't fully understand what's happening.


Regards.

PS: would you consider the patch to fix compilation of the RDP compositor.

--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH 1/1] Add a FreeRds backend, take 3

2013-12-23 Thread Hardening

Le 22/12/2013 23:52, Mariusz Ceier a écrit :

Hello,
I have installed freerdp with freerds and pysession-manager.
Applied this patch in weston, and configured weston as static content
provider for pysession-manager (both as greeter and desktop).
Here, I have some results after testing:

1) When using remmina as a client:
   a) With 1 connection - desktop shows up properly and it's possible
to interact with weston and wayland clients.
   b) With 2 or more connections simultaneously - only last connection
reacts to input - it seems, there's only 1 seat for all connections,
and only last connection owns it ?


This is the expected behaviour, there can be only one connection at once.



   c) After disconnecting, and during weston shutdown, text-backend.c
tries to use input_method structure in unbind_input_method function,
  after freeing it in input_method_notifier_destroy function,
here's backtrace:
==25237== Invalid read of size 8
==25237==at 0x41D49F: unbind_input_method (text-backend.c:750)
==25237==by 0x4E3B3F8: destroy_resource (wayland-server.c:533)
==25237==by 0x4E416D9: for_each_helper (wayland-util.c:353)
==25237==by 0x4E41715: wl_map_for_each (wayland-util.c:359)
==25237==by 0x4E3B718: wl_client_destroy (wayland-server.c:673)
==25237==by 0x41D9FE: text_backend_notifier_destroy (text-backend.c:938)
==25237==by 0x408248: wl_signal_emit (wayland-server.h:260)
==25237==by 0x411C60: main (compositor.c:4248)
==25237==  Address 0x68cf830 is 112 bytes inside a block of size 120 free'd
==25237==at 0x4C2B0CC: free (vg_replace_malloc.c:468)
==25237==by 0x41D627: input_method_notifier_destroy (text-backend.c:804)
==25237==by 0x411D78: wl_signal_emit (wayland-server.h:260)
==25237==by 0x416C1A: weston_seat_release (input.c:2199)
==25237==by 0x6A3DB89: freerds_kill_client (compositor-freerds.c:871)
==25237==by 0x6A3DF31: freerds_named_pipe_activity
(compositor-freerds.c:948)
==25237==by 0x4E3D7F7: wl_event_source_fd_dispatch (event-loop.c:86)
==25237==by 0x4E3E1A8: wl_event_loop_dispatch (event-loop.c:421)
==25237==by 0x4E3BFEC: wl_display_run (wayland-server.c:961)
==25237==by 0x411C3F: main (compositor.c:4242)

I don't know which backend - freerds or text - does here something wrong.


Perhaps it is a bug in the FreeRds backend, but i saw some similar 
backtrace with the RDP compositor. I'm not sure the seat releasing is 
really safe.




2) When using windows remote desktop client, weston exits after
accepting connection due to SIGPIPE signal. Here's backtrace:
==31717==
==31717== Process terminating with default action of signal 13 (SIGPIPE)
==31717==at 0x6080AD0: __write_nocancel (syscall-template.S:81)
==31717==by 0x6A3C156: freerds_send_stream (compositor-freerds.c:130)
==31717==by 0x6A3C4A4: freerds_refresh_region (compositor-freerds.c:186)
==31717==by 0x6A3DA19: freerds_treat_message (compositor-freerds.c:821)
==31717==by 0x6A3DF0A: freerds_client_activity (compositor-freerds.c:920)
==31717==by 0x4E3D7F7: wl_event_source_fd_dispatch (event-loop.c:86)
==31717==by 0x4E3E1A8: wl_event_loop_dispatch (event-loop.c:421)
==31717==by 0x4E3BFEC: wl_display_run (wayland-server.c:961)
==31717==by 0x411C3F: main (compositor.c:4242)

I can provide more detailed logs, if anyone is interested.



Yes please send them.

Regards, thanks for testing and the feedback.

--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH] Add a FreeRds backend, take 4

2014-01-08 Thread Hardening
FreeRDS is a FreeRDP based RDP server, the server handles incoming connections 
and
talks RDP with the peers. FreeRds cooperates with an "out-service": the 
out-service creates
the content to display, and FreeRds will take care of encoding the content in 
the
appropriate format (bitmapUpdate, remoteFx or NsCodec).
To communicate, they use a unix socket for passing commands, and a shared 
buffer for
the screen content. A vblank signal sent by FreeRds via the command channel 
allows
to share the framebuffer nicely.
This patch adds a backend to create a FreeRDS compositor and have weston being 
an out-service
for FreeRds.

Compared to the previous version, this one does some code cleanup. The keycodes 
are now computed using
FreeRdp buildin functions which simplifies the code much. The 
SynchronizeKeyboard packets are now
handled so if keyboard modifiers are changed when the RDP window is not 
focused, they will be resynced when
the RDP client is refocused. The VirtualKeyCode packets are handled too. The 
missing change on Makefile.am
is also included.
---
 configure.ac |   10 +
 src/Makefile.am  |   17 +-
 src/compositor-freerds.c | 1124 ++
 3 files changed, 1150 insertions(+), 1 deletion(-)
 create mode 100644 src/compositor-freerds.c

diff --git a/configure.ac b/configure.ac
index 571bf60..b28b528 100644
--- a/configure.ac
+++ b/configure.ac
@@ -206,6 +206,15 @@ if test x$enable_rdp_compositor = xyes; then
   PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0])
 fi
 
+AC_ARG_ENABLE([freerds-compositor], [  --enable-freerds-compositor],,
+  enable_freerds_compositor=no)
+AM_CONDITIONAL([ENABLE_FREERDS_COMPOSITOR],
+   [test x$enable_freerds_compositor = xyes])
+if test x$enable_freerds_compositor = xyes; then
+  AC_DEFINE([BUILD_FREERDS_COMPOSITOR], [1], [Build the FreeRDS compositor])
+  PKG_CHECK_MODULES(FREERDS_COMPOSITOR, [freerds-backend])
+fi
+
 AC_ARG_WITH(cairo,
AS_HELP_STRING([--with-cairo=@<:@image|gl|glesv2@:>@]
   [Which Cairo renderer to use for the clients]),
@@ -526,6 +535,7 @@ AC_MSG_RESULT([
RPI Compositor  ${enable_rpi_compositor}
FBDEV Compositor${enable_fbdev_compositor}
RDP Compositor  ${enable_rdp_compositor}
+   FreeRDS Compositor  ${enable_freerds_compositor}
 
Raspberry Pi BCM headers${have_bcm_host}
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 446639c..588625e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -117,7 +117,9 @@ module_LTLIBRARIES =\
$(wayland_backend)  \
$(headless_backend) \
$(fbdev_backend)\
-   $(rdp_backend)
+   $(rdp_backend)  \
+   $(freerds_backend)
+   
 
 if INSTALL_RPI_COMPOSITOR
 module_LTLIBRARIES += $(rpi_backend)
@@ -280,6 +282,19 @@ rdp_backend_la_CFLAGS =\
 rdp_backend_la_SOURCES = compositor-rdp.c
 endif
 
+if ENABLE_FREERDS_COMPOSITOR
+freerds_backend = freerds-backend.la
+freerds_backend_la_LDFLAGS = -module -avoid-version
+freerds_backend_la_LIBADD = $(COMPOSITOR_LIBS) \
+   $(FREERDS_COMPOSITOR_LIBS) \
+   ../shared/libshared.la -lwinpr-input -lfreerdp-core
+freerds_backend_la_CFLAGS =\
+   $(COMPOSITOR_CFLAGS)\
+   $(FREERDS_COMPOSITOR_CFLAGS) \
+   $(GCC_CFLAGS)
+freerds_backend_la_SOURCES = compositor-freerds.c
+endif
+
 if HAVE_LCMS
 cms_static = cms-static.la
 cms_static_la_LDFLAGS = -module -avoid-version
diff --git a/src/compositor-freerds.c b/src/compositor-freerds.c
new file mode 100644
index 000..cda1bff
--- /dev/null
+++ b/src/compositor-freerds.c
@@ -0,0 +1,1124 @@
+/**
+ * Copyright © 2013 Hardening 
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR O

[PATCH] Add a FreeRds backend, take 5

2014-01-09 Thread Hardening
FreeRDS is a FreeRDP based RDP server, the server handles incoming connections 
and
talks RDP with the peers. FreeRds cooperates with an "out-service": the 
out-service creates
the content to display, and FreeRds will take care of encoding the content in 
the
appropriate format (bitmapUpdate, remoteFx or NsCodec).
To communicate, they use a unix socket for passing commands, and a shared 
buffer for
the screen content. A vblank signal sent by FreeRds via the command channel 
allows
to share the framebuffer nicely.
This patch adds a backend to create a FreeRDS compositor and have weston being 
an out-service
for FreeRds.

Compared to the previous version, this one fixes a SIGPIPE bug when some 
refreshes occurs during
freerds disconnection or at the compositor shutdown. Socket functions from 
wayland-utils are used
to create CLOEXEC sockets. Misc leaks at shutdown have been fixed.
---
 configure.ac |   12 +-
 src/Makefile.am  |   17 +-
 src/compositor-freerds.c | 1206 ++
 3 files changed, 1233 insertions(+), 2 deletions(-)
 create mode 100644 src/compositor-freerds.c

diff --git a/configure.ac b/configure.ac
index 571bf60..51f3197 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,7 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[],
  [[#include ]])
 AC_CHECK_HEADERS([execinfo.h])
 
-AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
+AC_CHECK_FUNCS([accept4 mkostemp strchrnul initgroups posix_fallocate])
 
 COMPOSITOR_MODULES="wayland-server >= 1.3.90 pixman-1"
 
@@ -206,6 +206,15 @@ if test x$enable_rdp_compositor = xyes; then
   PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0])
 fi
 
+AC_ARG_ENABLE([freerds-compositor], [  --enable-freerds-compositor],,
+  enable_freerds_compositor=no)
+AM_CONDITIONAL([ENABLE_FREERDS_COMPOSITOR],
+   [test x$enable_freerds_compositor = xyes])
+if test x$enable_freerds_compositor = xyes; then
+  AC_DEFINE([BUILD_FREERDS_COMPOSITOR], [1], [Build the FreeRDS compositor])
+  PKG_CHECK_MODULES(FREERDS_COMPOSITOR, [freerds-backend])
+fi
+
 AC_ARG_WITH(cairo,
AS_HELP_STRING([--with-cairo=@<:@image|gl|glesv2@:>@]
   [Which Cairo renderer to use for the clients]),
@@ -526,6 +535,7 @@ AC_MSG_RESULT([
RPI Compositor  ${enable_rpi_compositor}
FBDEV Compositor${enable_fbdev_compositor}
RDP Compositor  ${enable_rdp_compositor}
+   FreeRDS Compositor  ${enable_freerds_compositor}
 
Raspberry Pi BCM headers${have_bcm_host}
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 446639c..588625e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -117,7 +117,9 @@ module_LTLIBRARIES =\
$(wayland_backend)  \
$(headless_backend) \
$(fbdev_backend)\
-   $(rdp_backend)
+   $(rdp_backend)  \
+   $(freerds_backend)
+   
 
 if INSTALL_RPI_COMPOSITOR
 module_LTLIBRARIES += $(rpi_backend)
@@ -280,6 +282,19 @@ rdp_backend_la_CFLAGS =\
 rdp_backend_la_SOURCES = compositor-rdp.c
 endif
 
+if ENABLE_FREERDS_COMPOSITOR
+freerds_backend = freerds-backend.la
+freerds_backend_la_LDFLAGS = -module -avoid-version
+freerds_backend_la_LIBADD = $(COMPOSITOR_LIBS) \
+   $(FREERDS_COMPOSITOR_LIBS) \
+   ../shared/libshared.la -lwinpr-input -lfreerdp-core
+freerds_backend_la_CFLAGS =\
+   $(COMPOSITOR_CFLAGS)\
+   $(FREERDS_COMPOSITOR_CFLAGS) \
+   $(GCC_CFLAGS)
+freerds_backend_la_SOURCES = compositor-freerds.c
+endif
+
 if HAVE_LCMS
 cms_static = cms-static.la
 cms_static_la_LDFLAGS = -module -avoid-version
diff --git a/src/compositor-freerds.c b/src/compositor-freerds.c
new file mode 100644
index 000..aa733f7
--- /dev/null
+++ b/src/compositor-freerds.c
@@ -0,0 +1,1206 @@
+/**
+ * Copyright © 2013 Hardening 
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRE

[PATCH] Fix compilation with FreeRdp 1.1 and master v2

2014-01-10 Thread Hardening
The API to use remoteFx encoding has changed between master and stable 1.1
branch. This patch should fix compilation for both.
This new version adds checks for the freerdp/version.h file
---
 configure.ac |  5 +
 src/compositor-rdp.c | 12 
 2 files changed, 17 insertions(+)

diff --git a/configure.ac b/configure.ac
index 571bf60..d66dbec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -204,6 +204,11 @@ AM_CONDITIONAL([ENABLE_RDP_COMPOSITOR],
 if test x$enable_rdp_compositor = xyes; then
   AC_DEFINE([BUILD_RDP_COMPOSITOR], [1], [Build the RDP compositor])
   PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0])
+
+  SAVED_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $RDP_COMPOSITOR_CFLAGS"
+  AC_CHECK_HEADERS([freerdp/version.h])
+  CPPFLAGS="$SAVED_CPPFLAGS"
 fi
 
 AC_ARG_WITH(cairo,
diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index b9c36cf..7f6ce28 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -27,6 +27,14 @@
 #include 
 #include 
 
+#if HAVE_FREERDP_VERSION_H
+#include 
+#else
+// assume it's a early 1.1 version
+#define FREERDP_MAJOR 1
+#define FREERDP_MINOR 1
+#endif
+
 #include 
 #include 
 #include 
@@ -571,7 +579,11 @@ rdp_peer_context_new(freerdp_peer* client, RdpPeerContext* 
context)
context->item.peer = client;
context->item.flags = RDP_PEER_OUTPUT_ENABLED;
 
+#if FREERDP_VERSION_MAJOR == 1 && FREERDP_VERSION_MINOR == 1
context->rfx_context = rfx_context_new();
+#else
+   context->rfx_context = rfx_context_new(TRUE);
+#endif
context->rfx_context->mode = RLGR3;
context->rfx_context->width = client->settings->DesktopWidth;
context->rfx_context->height = client->settings->DesktopHeight;
-- 
1.8.1.2

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


[PATCH] Add a FreeRds backend, take 6

2014-01-16 Thread Hardening
FreeRDS is a FreeRDP based RDP server, the server handles incoming connections 
and
talks RDP with the peers. FreeRds cooperates with an "out-service": the 
out-service creates
the content to display, and FreeRds will take care of encoding the content in 
the
appropriate format (bitmapUpdate, remoteFx or NsCodec).
To communicate, they use a unix socket for passing commands, and a shared 
buffer for
the screen content. A vblank signal sent by FreeRds via the command channel 
allows
to share the framebuffer nicely.
This patch adds a backend to create a FreeRDS compositor and have weston being 
an out-service
for FreeRds.

This new revision uses the refcounting of IPC shm to have the last process that 
shmdt() to
remove the segment. It also fixes a bug with the damaged region not resetted on 
mode_switch()
leading to invalid read accesses.
---
 configure.ac |   12 +-
 src/Makefile.am  |   17 +-
 src/compositor-freerds.c | 1206 ++
 3 files changed, 1233 insertions(+), 2 deletions(-)
 create mode 100644 src/compositor-freerds.c

diff --git a/configure.ac b/configure.ac
index 571bf60..51f3197 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,7 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[],
  [[#include ]])
 AC_CHECK_HEADERS([execinfo.h])
 
-AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
+AC_CHECK_FUNCS([accept4 mkostemp strchrnul initgroups posix_fallocate])
 
 COMPOSITOR_MODULES="wayland-server >= 1.3.90 pixman-1"
 
@@ -206,6 +206,15 @@ if test x$enable_rdp_compositor = xyes; then
   PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0])
 fi
 
+AC_ARG_ENABLE([freerds-compositor], [  --enable-freerds-compositor],,
+  enable_freerds_compositor=no)
+AM_CONDITIONAL([ENABLE_FREERDS_COMPOSITOR],
+   [test x$enable_freerds_compositor = xyes])
+if test x$enable_freerds_compositor = xyes; then
+  AC_DEFINE([BUILD_FREERDS_COMPOSITOR], [1], [Build the FreeRDS compositor])
+  PKG_CHECK_MODULES(FREERDS_COMPOSITOR, [freerds-backend])
+fi
+
 AC_ARG_WITH(cairo,
AS_HELP_STRING([--with-cairo=@<:@image|gl|glesv2@:>@]
   [Which Cairo renderer to use for the clients]),
@@ -526,6 +535,7 @@ AC_MSG_RESULT([
RPI Compositor  ${enable_rpi_compositor}
FBDEV Compositor${enable_fbdev_compositor}
RDP Compositor  ${enable_rdp_compositor}
+   FreeRDS Compositor  ${enable_freerds_compositor}
 
Raspberry Pi BCM headers${have_bcm_host}
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 446639c..588625e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -117,7 +117,9 @@ module_LTLIBRARIES =\
$(wayland_backend)  \
$(headless_backend) \
$(fbdev_backend)\
-   $(rdp_backend)
+   $(rdp_backend)  \
+   $(freerds_backend)
+   
 
 if INSTALL_RPI_COMPOSITOR
 module_LTLIBRARIES += $(rpi_backend)
@@ -280,6 +282,19 @@ rdp_backend_la_CFLAGS =\
 rdp_backend_la_SOURCES = compositor-rdp.c
 endif
 
+if ENABLE_FREERDS_COMPOSITOR
+freerds_backend = freerds-backend.la
+freerds_backend_la_LDFLAGS = -module -avoid-version
+freerds_backend_la_LIBADD = $(COMPOSITOR_LIBS) \
+   $(FREERDS_COMPOSITOR_LIBS) \
+   ../shared/libshared.la -lwinpr-input -lfreerdp-core
+freerds_backend_la_CFLAGS =\
+   $(COMPOSITOR_CFLAGS)\
+   $(FREERDS_COMPOSITOR_CFLAGS) \
+   $(GCC_CFLAGS)
+freerds_backend_la_SOURCES = compositor-freerds.c
+endif
+
 if HAVE_LCMS
 cms_static = cms-static.la
 cms_static_la_LDFLAGS = -module -avoid-version
diff --git a/src/compositor-freerds.c b/src/compositor-freerds.c
new file mode 100644
index 000..7e23f10
--- /dev/null
+++ b/src/compositor-freerds.c
@@ -0,0 +1,1206 @@
+/**
+ * Copyright © 2013 Hardening 
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES

[PATCH] FreeRds backend, weston 1.5 rebased

2014-01-27 Thread Hardening
FreeRDS is a FreeRDP based RDP server, the server handles incoming connections 
and
talks RDP with the peers. FreeRds cooperates with an "out-service": the 
out-service creates
the content to display, and FreeRds will take care of encoding the content in 
the
appropriate codec (raw, planar, remoteFx or NsCodec).
To communicate, they use a unix socket for passing commands, and a shared 
buffer for
the screen content. A vblank signal sent by FreeRds via the command channel 
allows
to share the framebuffer nicely.
This patch adds a backend to create a FreeRDS compositor and have weston being 
an out-service
for FreeRds.

This new revision is just a rebase for weston 1.5.
---
 configure.ac |   12 +-
 src/Makefile.am  |   17 +-
 src/compositor-freerds.c | 1206 ++
 3 files changed, 1233 insertions(+), 2 deletions(-)
 create mode 100644 src/compositor-freerds.c

diff --git a/configure.ac b/configure.ac
index cce1850..eeb94c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,7 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[],
  [[#include ]])
 AC_CHECK_HEADERS([execinfo.h])
 
-AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
+AC_CHECK_FUNCS([accept4 mkostemp strchrnul initgroups posix_fallocate])
 
 COMPOSITOR_MODULES="wayland-server >= 1.3.90 pixman-1"
 
@@ -211,6 +211,15 @@ if test x$enable_rdp_compositor = xyes; then
   CPPFLAGS="$SAVED_CPPFLAGS"
 fi
 
+AC_ARG_ENABLE([freerds-compositor], [  --enable-freerds-compositor],,
+  enable_freerds_compositor=no)
+AM_CONDITIONAL([ENABLE_FREERDS_COMPOSITOR],
+   [test x$enable_freerds_compositor = xyes])
+if test x$enable_freerds_compositor = xyes; then
+  AC_DEFINE([BUILD_FREERDS_COMPOSITOR], [1], [Build the FreeRDS compositor])
+  PKG_CHECK_MODULES(FREERDS_COMPOSITOR, [freerds-backend])
+fi
+
 AC_ARG_WITH(cairo,
AS_HELP_STRING([--with-cairo=@<:@image|gl|glesv2@:>@]
   [Which Cairo renderer to use for the clients]),
@@ -531,6 +540,7 @@ AC_MSG_RESULT([
RPI Compositor  ${enable_rpi_compositor}
FBDEV Compositor${enable_fbdev_compositor}
RDP Compositor  ${enable_rdp_compositor}
+   FreeRDS Compositor  ${enable_freerds_compositor}
 
Raspberry Pi BCM headers${have_bcm_host}
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 446639c..588625e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -117,7 +117,9 @@ module_LTLIBRARIES =\
$(wayland_backend)  \
$(headless_backend) \
$(fbdev_backend)\
-   $(rdp_backend)
+   $(rdp_backend)  \
+   $(freerds_backend)
+   
 
 if INSTALL_RPI_COMPOSITOR
 module_LTLIBRARIES += $(rpi_backend)
@@ -280,6 +282,19 @@ rdp_backend_la_CFLAGS =\
 rdp_backend_la_SOURCES = compositor-rdp.c
 endif
 
+if ENABLE_FREERDS_COMPOSITOR
+freerds_backend = freerds-backend.la
+freerds_backend_la_LDFLAGS = -module -avoid-version
+freerds_backend_la_LIBADD = $(COMPOSITOR_LIBS) \
+   $(FREERDS_COMPOSITOR_LIBS) \
+   ../shared/libshared.la -lwinpr-input -lfreerdp-core
+freerds_backend_la_CFLAGS =\
+   $(COMPOSITOR_CFLAGS)\
+   $(FREERDS_COMPOSITOR_CFLAGS) \
+   $(GCC_CFLAGS)
+freerds_backend_la_SOURCES = compositor-freerds.c
+endif
+
 if HAVE_LCMS
 cms_static = cms-static.la
 cms_static_la_LDFLAGS = -module -avoid-version
diff --git a/src/compositor-freerds.c b/src/compositor-freerds.c
new file mode 100644
index 000..7e23f10
--- /dev/null
+++ b/src/compositor-freerds.c
@@ -0,0 +1,1206 @@
+/**
+ * Copyright © 2013 Hardening 
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORM

[PATCH] FreeRds backend, simplifications and improvements

2014-02-26 Thread Hardening
FreeRDS is a FreeRDP based RDP server, the server handles incoming connections 
and
talks RDP with the peers. FreeRds cooperates with an "out-service": the 
out-service creates
the content to display, and FreeRds will take care of encoding the content in 
the
appropriate codec (raw, planar, remoteFx or NsCodec).
To communicate, they use a unix socket for passing commands, and a shared 
buffer for
the screen content. A vblank signal sent by FreeRds via the command channel 
allows
to share the framebuffer nicely.
This patch adds a backend to create a FreeRDS compositor and have weston being 
an out-service
for FreeRds.

This new revision simplifies packet extraction from the local socket. It also 
adds support for
xkb variants: RDP keyboards that requires a xkb variant should work correctly 
now. The keyboards
table has been filled with all know matches.
---
 configure.ac |   12 +-
 src/Makefile.am  |   17 +-
 src/compositor-freerds.c | 1237 ++
 3 files changed, 1264 insertions(+), 2 deletions(-)
 create mode 100644 src/compositor-freerds.c

diff --git a/configure.ac b/configure.ac
index cce1850..eeb94c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,7 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[],
  [[#include ]])
 AC_CHECK_HEADERS([execinfo.h])
 
-AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
+AC_CHECK_FUNCS([accept4 mkostemp strchrnul initgroups posix_fallocate])
 
 COMPOSITOR_MODULES="wayland-server >= 1.3.90 pixman-1"
 
@@ -211,6 +211,15 @@ if test x$enable_rdp_compositor = xyes; then
   CPPFLAGS="$SAVED_CPPFLAGS"
 fi
 
+AC_ARG_ENABLE([freerds-compositor], [  --enable-freerds-compositor],,
+  enable_freerds_compositor=no)
+AM_CONDITIONAL([ENABLE_FREERDS_COMPOSITOR],
+   [test x$enable_freerds_compositor = xyes])
+if test x$enable_freerds_compositor = xyes; then
+  AC_DEFINE([BUILD_FREERDS_COMPOSITOR], [1], [Build the FreeRDS compositor])
+  PKG_CHECK_MODULES(FREERDS_COMPOSITOR, [freerds-backend])
+fi
+
 AC_ARG_WITH(cairo,
AS_HELP_STRING([--with-cairo=@<:@image|gl|glesv2@:>@]
   [Which Cairo renderer to use for the clients]),
@@ -531,6 +540,7 @@ AC_MSG_RESULT([
RPI Compositor  ${enable_rpi_compositor}
FBDEV Compositor${enable_fbdev_compositor}
RDP Compositor  ${enable_rdp_compositor}
+   FreeRDS Compositor  ${enable_freerds_compositor}
 
Raspberry Pi BCM headers${have_bcm_host}
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 446639c..588625e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -117,7 +117,9 @@ module_LTLIBRARIES =\
$(wayland_backend)  \
$(headless_backend) \
$(fbdev_backend)\
-   $(rdp_backend)
+   $(rdp_backend)  \
+   $(freerds_backend)
+   
 
 if INSTALL_RPI_COMPOSITOR
 module_LTLIBRARIES += $(rpi_backend)
@@ -280,6 +282,19 @@ rdp_backend_la_CFLAGS =\
 rdp_backend_la_SOURCES = compositor-rdp.c
 endif
 
+if ENABLE_FREERDS_COMPOSITOR
+freerds_backend = freerds-backend.la
+freerds_backend_la_LDFLAGS = -module -avoid-version
+freerds_backend_la_LIBADD = $(COMPOSITOR_LIBS) \
+   $(FREERDS_COMPOSITOR_LIBS) \
+   ../shared/libshared.la -lwinpr-input -lfreerdp-core
+freerds_backend_la_CFLAGS =\
+   $(COMPOSITOR_CFLAGS)\
+   $(FREERDS_COMPOSITOR_CFLAGS) \
+   $(GCC_CFLAGS)
+freerds_backend_la_SOURCES = compositor-freerds.c
+endif
+
 if HAVE_LCMS
 cms_static = cms-static.la
 cms_static_la_LDFLAGS = -module -avoid-version
diff --git a/src/compositor-freerds.c b/src/compositor-freerds.c
new file mode 100644
index 000..d78b42c
--- /dev/null
+++ b/src/compositor-freerds.c
@@ -0,0 +1,1237 @@
+/**
+ * Copyright © 2013 Hardening 
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES W

[PATCH] FreeRds backend, simplifications and improvements take 2

2014-02-26 Thread Hardening
Sorry for the last mail that was badly rebased with an incorrect src/Makefile.am
file (thanks to Mariusz Ceier who told me about that).

FreeRDS is a FreeRDP based RDP server, the server handles incoming connections 
and
talks RDP with the peers. FreeRds cooperates with an "out-service": the 
out-service creates
the content to display, and FreeRds will take care of encoding the content in 
the
appropriate codec (raw, planar, remoteFx or NsCodec).
To communicate, they use a unix socket for passing commands, and a shared 
buffer for
the screen content. A vblank signal sent by FreeRds via the command channel 
allows
to share the framebuffer nicely.
This patch adds a backend to create a FreeRDS compositor and have weston being 
an out-service
for FreeRds.

This new revision simplifies packet extraction from the local socket. It also 
adds support for
xkb variants: RDP keyboards that requires a xkb variant should work correctly 
now. The keyboards
table has been filled with all know matches.
---
 Makefile.am  |   15 +
 configure.ac |   12 +-
 src/compositor-freerds.c | 1237 ++
 3 files changed, 1263 insertions(+), 1 deletion(-)
 create mode 100644 src/compositor-freerds.c

diff --git a/Makefile.am b/Makefile.am
index 64d0743..9d39d22 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -308,6 +308,21 @@ rdp_backend_la_CFLAGS =\
 rdp_backend_la_SOURCES = src/compositor-rdp.c
 endif
 
+if ENABLE_FREERDS_COMPOSITOR
+module_LTLIBRARIES += freerds-backend.la
+freerds_backend = freerds-backend.la
+freerds_backend_la_LDFLAGS = -module -avoid-version
+freerds_backend_la_LIBADD = $(COMPOSITOR_LIBS) \
+   $(FREERDS_COMPOSITOR_LIBS) \
+   libshared.la -lwinpr-input -lfreerdp-core
+freerds_backend_la_CFLAGS =\
+   $(COMPOSITOR_CFLAGS)\
+   $(FREERDS_COMPOSITOR_CFLAGS) \
+   $(GCC_CFLAGS)
+freerds_backend_la_SOURCES = src/compositor-freerds.c
+endif
+
+
 if HAVE_LCMS
 module_LTLIBRARIES += cms-static.la
 cms_static_la_LDFLAGS = -module -avoid-version
diff --git a/configure.ac b/configure.ac
index 00d7123..27d6d0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,7 +56,7 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[],
  [[#include ]])
 AC_CHECK_HEADERS([execinfo.h])
 
-AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
+AC_CHECK_FUNCS([accept4 mkostemp strchrnul initgroups posix_fallocate])
 
 COMPOSITOR_MODULES="wayland-server >= 1.3.90 pixman-1"
 
@@ -212,6 +212,15 @@ if test x$enable_rdp_compositor = xyes; then
   CPPFLAGS="$SAVED_CPPFLAGS"
 fi
 
+AC_ARG_ENABLE([freerds-compositor], [  --enable-freerds-compositor],,
+  enable_freerds_compositor=no)
+AM_CONDITIONAL([ENABLE_FREERDS_COMPOSITOR],
+   [test x$enable_freerds_compositor = xyes])
+if test x$enable_freerds_compositor = xyes; then
+  AC_DEFINE([BUILD_FREERDS_COMPOSITOR], [1], [Build the FreeRDS compositor])
+  PKG_CHECK_MODULES(FREERDS_COMPOSITOR, [freerds-backend])
+fi
+
 AC_ARG_WITH(cairo,
AS_HELP_STRING([--with-cairo=@<:@image|gl|glesv2@:>@]
   [Which Cairo renderer to use for the clients]),
@@ -505,6 +514,7 @@ AC_MSG_RESULT([
RPI Compositor  ${enable_rpi_compositor}
FBDEV Compositor${enable_fbdev_compositor}
RDP Compositor  ${enable_rdp_compositor}
+   FreeRDS Compositor  ${enable_freerds_compositor}
 
Raspberry Pi BCM headers${have_bcm_host}
 
diff --git a/src/compositor-freerds.c b/src/compositor-freerds.c
new file mode 100644
index 000..d78b42c
--- /dev/null
+++ b/src/compositor-freerds.c
@@ -0,0 +1,1237 @@
+/**
+ * Copyright © 2013 Hardening 
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+

Re: [PATCH 0/6] Add weston randr protocol

2014-02-27 Thread Hardening

Le 27/02/2014 04:27, Quanxian Wang a écrit :

These patches will provide weston randr protocol,
its implementation and randr application.

The idea is from xrandr provided by xserver. *Dynamic* mode
setting is the main objective of this protocol. Remember,
it is one shot operation. For example, if setting the mode,
just call one request wl_randr_set_mode without any other operation.

With this protocol, weston-wrandr application is developped to help
user implement randr protocol in command line just like xrandr command
in xserver.



Hi Quanxian,

I have submitted such functionality one year ago:
http://lists.freedesktop.org/archives/wayland-devel/2013-March/007872.html. 
The scope was smaller (targeting essentially mode resolution) but it was 
working.


At the time there were no real enthusiasm, some people were even 
against. Perhaps some have changed their mind since.


Regards.

--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] FreeRds backend, simplifications and improvements take 2

2014-02-27 Thread Hardening

Le 26/02/2014 19:14, Mariusz Ceier a écrit :

Hi,
   I did some basic testing of this version, and it seems to be as
stable as x11-backend :)
Issues that still aren't resolved:
  - when trying to enter polish letter they send either ^C or
characters from different keymap(?), depending on client used.
But this may not be issue in freerds backend of weston, but in
FreeRDS or FreeRDP.
  - focus never changes (at least it's not indicated visually which
window has focus), to reproduce:
run 2 instances of weston-terminal and see that cursor block isn't
filled in, and title bar doesn't change,
when switching between windows.

Other than that, it works great :)



Hi Mariusz,

for a fair comparison with the x11-backend, you have to run it with the 
pixman mode. We have discussed that on IRC: the pixman renderer is 
missing the opacity management so you're loosing some nice effects. 
Exposé effect is really ugly, and at connection you don't have the nice 
fade-in.


For keyboards this needs inquiry, I know that it works perfectly fine at 
least with French and German keyboards.


Regards.
--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH 1/6] Add weston randr protocol

2014-03-06 Thread Hardening

Le 05/03/2014 03:07, Wang, Quanxian a écrit :

Hi, All

With the first version of randr protol, I got many useful idea and comments. 
Thanks.

Before I send the email, I have make it happen in real world but need more deep 
testing.

Here are new changes and idea for that protocol based on the idea and comments, 
welcome your input.

1) Unique operation issue
Given that one client has two more threads to do mode setting on the same 
output at the same time, how to identify what response (done event) is belong 
to one or another request when they want to get response?

This is a design flaw in the first version of randr protocol.

The solution is to use the wayland/weston mechanism, every request will 
generate a resource which be used to send done event to the owner who start it. 
Owner could set the listener on that and keep tuning on the response event.

For example
In client:
randr_transform = 
wl_randr_set_transform(randr.randr,wayland_output,argument.transform);

/* Here will will add listen callback to get the response for this unique 
request */
wl_randr_add_listener(randr_transform, &randr_transform_listener, &randr);

In compositor:
randr_resource = wl_resource_create(client,&wl_randr_interface,1, action);
wl_randr_send_action_done(randr_resource, 1<

I don't think that allowing to set only announced modes is a good idea. 
The RDP compositor is a good example where you can't know the supported 
modes (as nearly all modes can be supported).


IIRC depending on the drivers, drm can also set arbitrary modes.

[...]

Apart from that I think we really have to find a way to offer randr like 
interface, this leads to the security requirements that have been talked 
extensively here.


Haven't you noticed that most recent talks on big subjects always end 
with "but what about security ?"


Regards

--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH 1/6] Add weston randr protocol

2014-03-06 Thread Hardening

Le 05/03/2014 11:04, Pekka Paalanen a écrit :

On Wed, 5 Mar 2014 09:40:32 +
"Wang, Quanxian"  wrote:


Just mention one thing

Pq:
But RandR is a disaster if random applications use it! Windows and
icons squashed into top-left corner, dialogs too large to fit on the
screen after the random application fails to restore the video mode,
or the picture just looking horrible and an average user not even
knowing why everything suddenly went ugly. [Wang, Quanxian] For this,
if you think it is disaster because of mode setting. It is a pity. If
the apps designer is careful, layout should be consistent with width
or height of output. In my testing for randr protocol, I found window
is designed to use width and height of output. Because it uses width
and height of output, but it doesn't care the change of
output(wl_output provides the mechanism to listen mode, scale
change). You can read my patch 6/6 for bug fix. It is just one fix.
It is the apps design flaw instead of wayland issue. Also you also
find 200 or 600 some hard code number is set.


Yeah, it looks like the patch 6/6 would be a nice fix, but I think you
should resend that alone, so it won't have to wait until the protocol
design is concluded. It's a stand-alone patch, right?



+1 for this one which is a very old bug.


--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH] Add error handling for wl_cursors

2014-03-18 Thread Hardening
This patch adds some error management in wayland cursors
---
 cursor/wayland-cursor.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/cursor/wayland-cursor.c b/cursor/wayland-cursor.c
index b16f530..dba3b51 100644
--- a/cursor/wayland-cursor.c
+++ b/cursor/wayland-cursor.c
@@ -94,6 +94,8 @@ shm_pool_resize(struct shm_pool *pool, int size)
 
pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
  pool->fd, 0);
+   if (pool->data == (void *)-1)
+   return 0;
pool->size = size;
 
return 1;
@@ -391,17 +393,15 @@ wl_cursor_theme_load(const char *name, int size, struct 
wl_shm *shm)
name = "default";
 
theme->name = strdup(name);
+   if (!theme->name)
+   goto out_error_name;
theme->size = size;
theme->cursor_count = 0;
theme->cursors = NULL;
 
-   theme->pool =
-   shm_pool_create(shm, size * size * 4);
-   if (!theme->pool) {
-   free(theme->name);
-   free(theme);
-   return NULL;
-   }
+   theme->pool = shm_pool_create(shm, size * size * 4);
+   if (!theme->pool)
+   goto out_error_pool;
 
xcursor_load_theme(name, size, load_callback, theme);
 
@@ -409,6 +409,12 @@ wl_cursor_theme_load(const char *name, int size, struct 
wl_shm *shm)
load_default_theme(theme);
 
return theme;
+
+out_error_pool:
+   free(theme->name);
+out_error_name:
+   free(theme);
+   return NULL;
 }
 
 /** Destroys a cursor theme object
-- 
1.8.1.2

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


[PATCH] Check return value of wl_cursor functions

2014-03-18 Thread Hardening
This patch adds checks for themes and cursors returned by wl_cursor functions.
---
 clients/simple-egl.c | 10 ++
 clients/window.c |  4 
 src/compositor-wayland.c |  7 ++-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index a6deff6..410e3ab 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -501,6 +501,8 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
else if (cursor) {
image = display->default_cursor->images[0];
buffer = wl_cursor_image_get_buffer(image);
+   if (!buffer)
+   return;
wl_pointer_set_cursor(pointer, serial,
  display->cursor_surface,
  image->hotspot_x,
@@ -715,8 +717,16 @@ registry_handle_global(void *data, struct wl_registry 
*registry,
d->shm = wl_registry_bind(registry, name,
  &wl_shm_interface, 1);
d->cursor_theme = wl_cursor_theme_load(NULL, 32, d->shm);
+   if (!d->cursor_theme) {
+   fprintf(stderr, "unable to load default theme\n");
+   return;
+   }
d->default_cursor =
wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
+   if (!d->default_cursor) {
+   fprintf(stderr, "unable to load default left 
pointer\n");
+   // TODO: abort ?
+   }
}
 }
 
diff --git a/clients/window.c b/clients/window.c
index 3136a7d..96b1731 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1280,6 +1280,10 @@ create_cursors(struct display *display)
weston_config_destroy(config);
 
display->cursor_theme = wl_cursor_theme_load(theme, size, display->shm);
+   if (!display->cursor_theme) {
+   fprintf(stderr, "could not load theme '%s'\n", theme);
+   return;
+   }
free(theme);
display->cursors =
xmalloc(ARRAY_LENGTH(cursors) * sizeof display->cursors[0]);
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 238946b..7d9e01b 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -968,7 +968,8 @@ input_set_cursor(struct wayland_input *input)
 
image = input->compositor->cursor->images[0];
buffer = wl_cursor_image_get_buffer(image);
-
+   if (!buffer)
+   return;
 
wl_pointer_set_cursor(input->parent.pointer, input->enter_serial,
  input->parent.cursor.surface,
@@ -1428,6 +1429,10 @@ create_cursor(struct wayland_compositor *c, struct 
weston_config *config)
weston_config_section_get_int(s, "cursor-size", &size, 32);
 
c->cursor_theme = wl_cursor_theme_load(theme, size, c->parent.shm);
+   if (!c->cursor_theme) {
+   fprintf(stderr, "could not load cursor theme\n");
+   return;
+   }
 
free(theme);
 
-- 
1.8.1.2

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


[PATCH] Make RDP backend supports arbitrary modes

2014-03-18 Thread Hardening
This patch removes the extra modes parameter for the RDP compositor. And
make it support any mode that is requested (be aware that RDP client may not
support all possible modes, especially odd resolution).
This is definitely useful for the fullscreen shell.
---
 src/compositor-rdp.c | 105 +++
 src/compositor.c |   1 -
 2 files changed, 38 insertions(+), 68 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index e8e4a8d..22380cb 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -49,6 +49,7 @@
 
 #define MAX_FREERDP_FDS 32
 #define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int(10)
+#define RDP_MODE_FREQ 60 * 1000
 
 struct rdp_compositor_config {
int width;
@@ -58,7 +59,6 @@ struct rdp_compositor_config {
char *rdp_key;
char *server_cert;
char *server_key;
-   char *extra_modes;
int env_socket;
 };
 
@@ -121,7 +121,6 @@ rdp_compositor_config_init(struct rdp_compositor_config 
*config) {
config->rdp_key = NULL;
config->server_cert = NULL;
config->server_key = NULL;
-   config->extra_modes = NULL;
config->env_socket = 0;
 }
 
@@ -320,11 +319,13 @@ rdp_output_repaint(struct weston_output *output_base, 
pixman_region32_t *damage)
pixman_renderer_output_set_buffer(output_base, output->shadow_surface);
ec->renderer->repaint_output(&output->base, damage);
 
-   wl_list_for_each(outputPeer, &output->peers, link) {
-   if ((outputPeer->flags & RDP_PEER_ACTIVATED) &&
-   (outputPeer->flags & RDP_PEER_OUTPUT_ENABLED))
-   {
-   rdp_peer_refresh_region(damage, outputPeer->peer);
+   if (pixman_region32_n_rects(damage)) {
+   wl_list_for_each(outputPeer, &output->peers, link) {
+   if ((outputPeer->flags & RDP_PEER_ACTIVATED) &&
+   (outputPeer->flags & 
RDP_PEER_OUTPUT_ENABLED))
+   {
+   rdp_peer_refresh_region(damage, 
outputPeer->peer);
+   }
}
}
 
@@ -352,16 +353,29 @@ finish_frame_handler(void *data)
return 1;
 }
 
+static struct weston_mode *
+rdp_insert_new_mode(struct weston_output *output, int width, int height, int 
rate) {
+   struct weston_mode *ret;
+   ret = zalloc(sizeof *ret);
+   if(!ret)
+   return ret;
+   ret->width = width;
+   ret->height = height;
+   ret->refresh = rate;
+   wl_list_insert(&output->mode_list, &ret->link);
+   return ret;
+}
 
 static struct weston_mode *
-find_matching_mode(struct weston_output *output, struct weston_mode *target) {
+ensure_matching_mode(struct weston_output *output, struct weston_mode *target) 
{
struct weston_mode *local;
 
wl_list_for_each(local, &output->mode_list, link) {
if((local->width == target->width) && (local->height == 
target->height))
return local;
}
-   return 0;
+
+   return rdp_insert_new_mode(output, target->width, target->height, 
RDP_MODE_FREQ);
 }
 
 static int
@@ -372,7 +386,7 @@ rdp_switch_mode(struct weston_output *output, struct 
weston_mode *target_mode) {
pixman_image_t *new_shadow_buffer;
struct weston_mode *local_mode;
 
-   local_mode = find_matching_mode(output, target_mode);
+   local_mode = ensure_matching_mode(output, target_mode);
if(!local_mode) {
weston_log("mode %dx%d not available\n", target_mode->width, 
target_mode->height);
return -ENOENT;
@@ -398,6 +412,9 @@ rdp_switch_mode(struct weston_output *output, struct 
weston_mode *target_mode) {
 
wl_list_for_each(rdpPeer, &rdpOutput->peers, link) {
settings = rdpPeer->peer->settings;
+   if (settings->DesktopWidth == target_mode->width && 
settings->DesktopHeight == target_mode->height)
+   continue;
+
if(!settings->DesktopResize) {
/* too bad this peer does not support desktop resize */
rdpPeer->peer->Close(rdpPeer->peer);
@@ -411,49 +428,12 @@ rdp_switch_mode(struct weston_output *output, struct 
weston_mode *target_mode) {
 }
 
 static int
-parse_extra_modes(const char *modes_str, struct rdp_output *output) {
-   const char *startAt = modes_str;
-   const char *nextPos;
-   int w, h;
-   struct weston_mode *mode;
-
-   while(startAt && *startAt) {
-   nextPos = strchr(startAt, 'x');
-   if(!nextPos)
-   return -1;
-
-   w = strtoul(startAt, NULL, 0);
-   startAt = nextPos + 1;
-   if(!*startAt)
-   return -1;
-
-   h = strtoul(startAt, NULL, 0);
-
-   if(!w || (w > 3000) || !h || (h > 3000))
-   

Re: [PATCH] compositor: Use weston_log rather than perror for error messages

2014-03-18 Thread Hardening

Le 18/03/2014 20:34, Bryce W. Harrington a écrit :

weston_log() seems to be the standard elsewhere in the codebase for
errors.  These are the only two instances where perror() is used
instead, and their error messages aren't that informative anyway.

Signed-off-by: Bryce Harrington 
---
  src/compositor-wayland.c |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 238946b..83eb59c 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -211,13 +211,13 @@ wayland_output_get_shm_buffer(struct wayland_output 
*output)

fd = os_create_anonymous_file(height * stride);
if (fd < 0) {
-   perror("os_create_anonymous_file");
+   weston_log("could not create an anonymous file buffer\n");


perror writes a human readable message, perhaps
weston_log("could not create an anonymous file buffer: %s\n", 
strerror(error));


would be better ?

[...]

Regards

--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH] Make RDP backend supports arbitrary modes v2

2014-03-20 Thread Hardening
This patch removes the extra modes parameter for the RDP compositor. And
make it support any mode that is requested (be aware that RDP client may not
support all possible modes, especially odd resolution).

This new version fixes remarks done by Jason Ekstrand. It also fixes
some missing spaces between if and (.
---
 src/compositor-rdp.c | 161 +--
 src/compositor.c |   1 -
 2 files changed, 66 insertions(+), 96 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index e8e4a8d..909e225 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -49,6 +49,7 @@
 
 #define MAX_FREERDP_FDS 32
 #define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int(10)
+#define RDP_MODE_FREQ 60 * 1000
 
 struct rdp_compositor_config {
int width;
@@ -58,7 +59,6 @@ struct rdp_compositor_config {
char *rdp_key;
char *server_cert;
char *server_key;
-   char *extra_modes;
int env_socket;
 };
 
@@ -121,7 +121,6 @@ rdp_compositor_config_init(struct rdp_compositor_config 
*config) {
config->rdp_key = NULL;
config->server_cert = NULL;
config->server_key = NULL;
-   config->extra_modes = NULL;
config->env_socket = 0;
 }
 
@@ -320,11 +319,13 @@ rdp_output_repaint(struct weston_output *output_base, 
pixman_region32_t *damage)
pixman_renderer_output_set_buffer(output_base, output->shadow_surface);
ec->renderer->repaint_output(&output->base, damage);
 
-   wl_list_for_each(outputPeer, &output->peers, link) {
-   if ((outputPeer->flags & RDP_PEER_ACTIVATED) &&
-   (outputPeer->flags & RDP_PEER_OUTPUT_ENABLED))
-   {
-   rdp_peer_refresh_region(damage, outputPeer->peer);
+   if (pixman_region32_not_empty(damage)) {
+   wl_list_for_each(outputPeer, &output->peers, link) {
+   if ((outputPeer->flags & RDP_PEER_ACTIVATED) &&
+   (outputPeer->flags & 
RDP_PEER_OUTPUT_ENABLED))
+   {
+   rdp_peer_refresh_region(damage, 
outputPeer->peer);
+   }
}
}
 
@@ -352,16 +353,29 @@ finish_frame_handler(void *data)
return 1;
 }
 
+static struct weston_mode *
+rdp_insert_new_mode(struct weston_output *output, int width, int height, int 
rate) {
+   struct weston_mode *ret;
+   ret = zalloc(sizeof *ret);
+   if (!ret)
+   return NULL;
+   ret->width = width;
+   ret->height = height;
+   ret->refresh = rate;
+   wl_list_insert(&output->mode_list, &ret->link);
+   return ret;
+}
 
 static struct weston_mode *
-find_matching_mode(struct weston_output *output, struct weston_mode *target) {
+ensure_matching_mode(struct weston_output *output, struct weston_mode *target) 
{
struct weston_mode *local;
 
wl_list_for_each(local, &output->mode_list, link) {
-   if((local->width == target->width) && (local->height == 
target->height))
+   if ((local->width == target->width) && (local->height == 
target->height))
return local;
}
-   return 0;
+
+   return rdp_insert_new_mode(output, target->width, target->height, 
RDP_MODE_FREQ);
 }
 
 static int
@@ -372,13 +386,13 @@ rdp_switch_mode(struct weston_output *output, struct 
weston_mode *target_mode) {
pixman_image_t *new_shadow_buffer;
struct weston_mode *local_mode;
 
-   local_mode = find_matching_mode(output, target_mode);
-   if(!local_mode) {
+   local_mode = ensure_matching_mode(output, target_mode);
+   if (!local_mode) {
weston_log("mode %dx%d not available\n", target_mode->width, 
target_mode->height);
return -ENOENT;
}
 
-   if(local_mode == output->current_mode)
+   if (local_mode == output->current_mode)
return 0;
 
output->current_mode->flags &= ~WL_OUTPUT_MODE_CURRENT;
@@ -398,7 +412,10 @@ rdp_switch_mode(struct weston_output *output, struct 
weston_mode *target_mode) {
 
wl_list_for_each(rdpPeer, &rdpOutput->peers, link) {
settings = rdpPeer->peer->settings;
-   if(!settings->DesktopResize) {
+   if (settings->DesktopWidth == target_mode->width && 
settings->DesktopHeight == target_mode->height)
+   continue;
+
+   if (!settings->DesktopResize) {
/* too bad this peer does not support desktop resize */
rdpPeer->peer->Close(rdpPeer->peer);
} else {
@@ -411,49 +428,12 @@ rdp_switch_mode(struct weston_output *output, struct 
weston_mode *target_mode) {
 }
 
 static int
-parse_extra_modes(const char *modes_str, struct rdp_output *output) {
-   const char *startAt = modes_str;
-   const char *nextPos;
-   int w, h;
-   struct we

Re: [PATCH] compositor: Use weston_log rather than perror for error messages

2014-03-22 Thread Hardening

Le 22/03/2014 12:21, Pekka Paalanen a écrit :

On Fri, 21 Mar 2014 05:54:02 +
"Bryce W. Harrington"  wrote:


weston_log() seems to be the standard elsewhere in the codebase for
errors.  These are the only two instances where perror() is used
instead, and their error messages aren't that informative anyway.

Signed-off-by: Bryce Harrington 
---
  src/compositor-wayland.c |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 238946b..0f67419 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -211,13 +211,13 @@ wayland_output_get_shm_buffer(struct wayland_output 
*output)

fd = os_create_anonymous_file(height * stride);
if (fd < 0) {
-   perror("os_create_anonymous_file");
+   weston_log("could not create an anonymous file buffer: %m\n");
return NULL;
}

data = mmap(NULL, height * stride, PROT_READ | PROT_WRITE, MAP_SHARED, 
fd, 0);
if (data == MAP_FAILED) {
-   perror("mmap");
+   weston_log("could not mmap %d memory for data: %m\n", height * 
stride);
close(fd);
return NULL;
}
--
1.7.9.5


Looks good!



Good for me too, thanks.


--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH] Add an option to disable client initiated resizes

2014-04-02 Thread Hardening
This patch adds an option to the RDP compositor to disable
desktop resizes initiated by RDP peer. The current behaviour
is that if an incoming RDP peer suggests a resolution that is
not the current one, a mode_switch() is done and the desktop is
resized to that new resolution. This new flag allows to disable
that behaviour. If the flag is set, the new behaviour is that the 
RDP peer will be instructed to resize to the size of the desktop.
---
 src/compositor-rdp.c | 44 
 src/compositor.c |  1 +
 2 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 909e225..edfab3d 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -60,6 +60,7 @@ struct rdp_compositor_config {
char *server_cert;
char *server_key;
int env_socket;
+   int no_clients_resize;
 };
 
 struct rdp_output;
@@ -75,6 +76,7 @@ struct rdp_compositor {
char *server_key;
char *rdp_key;
int tls_enabled;
+   int no_clients_resize;
 };
 
 enum peer_item_flags {
@@ -122,6 +124,7 @@ rdp_compositor_config_init(struct rdp_compositor_config 
*config) {
config->server_cert = NULL;
config->server_key = NULL;
config->env_socket = 0;
+   config->no_clients_resize = 0;
 }
 
 static void
@@ -412,7 +415,8 @@ rdp_switch_mode(struct weston_output *output, struct 
weston_mode *target_mode) {
 
wl_list_for_each(rdpPeer, &rdpOutput->peers, link) {
settings = rdpPeer->peer->settings;
-   if (settings->DesktopWidth == target_mode->width && 
settings->DesktopHeight == target_mode->height)
+   if (settings->DesktopWidth == (UINT32)target_mode->width &&
+   settings->DesktopHeight == 
(UINT32)target_mode->height)
continue;
 
if (!settings->DesktopResize) {
@@ -672,18 +676,32 @@ xf_peer_post_connect(freerdp_peer* client)
if (output->base.width != (int)settings->DesktopWidth ||
output->base.height != (int)settings->DesktopHeight)
{
-   struct weston_mode new_mode;
-   struct weston_mode *target_mode;
-   new_mode.width = (int)settings->DesktopWidth;
-   new_mode.height = (int)settings->DesktopHeight;
-   target_mode = ensure_matching_mode(&output->base, &new_mode);
-   if (!target_mode) {
-   weston_log("client mode not found\n");
-   return FALSE;
+   if (c->no_clients_resize) {
+   /* RDP peers don't dictate their resolution to weston */
+   if (!settings->DesktopResize) {
+   /* peer does not support desktop resize */
+   weston_log("%s: client doesn't support 
resizing, closing connection\n", __FUNCTION__);
+   client->Close(client);
+   } else {
+   settings->DesktopWidth = output->base.width;
+   settings->DesktopHeight = output->base.height;
+   client->update->DesktopResize(client->context);
+   }
+   } else {
+   /* ask weston to adjust size */
+   struct weston_mode new_mode;
+   struct weston_mode *target_mode;
+   new_mode.width = (int)settings->DesktopWidth;
+   new_mode.height = (int)settings->DesktopHeight;
+   target_mode = ensure_matching_mode(&output->base, 
&new_mode);
+   if (!target_mode) {
+   weston_log("client mode not found\n");
+   return FALSE;
+   }
+   weston_output_switch_mode(&output->base, target_mode, 
1, WESTON_MODE_SWITCH_SET_NATIVE);
+   output->base.width = new_mode.width;
+   output->base.height = new_mode.height;
}
-   weston_output_switch_mode(&output->base, target_mode, 1, 
WESTON_MODE_SWITCH_SET_NATIVE);
-   output->base.width = new_mode.width;
-   output->base.height = new_mode.height;
}
 
weston_log("kbd_layout:%x kbd_type:%x kbd_subType:%x 
kbd_functionKeys:%x\n",
@@ -988,6 +1006,7 @@ rdp_compositor_create(struct wl_display *display,
c->base.destroy = rdp_destroy;
c->base.restore = rdp_restore;
c->rdp_key = config->rdp_key ? strdup(config->rdp_key) : NULL;
+   c->no_clients_resize = config->no_clients_resize;
 
/* activate TLS only if certificate/key are available */
if (config->server_cert && config->server_key) {
@@ -1067,6 +1086,7 @@ backend_init(struct wl_display *display, int *argc, char 
*argv[],
{ WEST

Re: [PATCH] Add an option to disable client initiated resizes

2014-04-02 Thread Hardening

Le 03/04/2014 02:08, Bill Spitzak a écrit :

Hardening wrote:


+if (!settings->DesktopResize) {
+/* peer does not support desktop resize */
+weston_log("%s: client doesn't support resizing,
closing connection\n", __FUNCTION__);
+client->Close(client);



+target_mode = ensure_matching_mode(&output->base,
&new_mode);
+if (!target_mode) {
+weston_log("client mode not found\n");
+return FALSE;
+}


One failure mode is fatal, while the other one just returns FALSE? Both
just mean that weston's size is different than the RDP window size, so I
think the results should be the same.


Good catch,
at the end the behaviour is the same as returning FALSE for 
postConnect() closes the connection. But let's make it consistent and 
return FALSE in all error cases. I'm sending a v2.


Thanks for the review.

--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v2] Add an option to disable client initiated resizes

2014-04-02 Thread Hardening
This patch adds an option to the RDP compositor to disable
desktop resizes initiated by RDP peer. The current behaviour
is that if an incoming RDP peer suggests a resolution that is
not the current one, a mode_switch() is done and the desktop is
resized to that new resolution. This new flag allows to disable
that behaviour, and in that case the RDP peer will be instructed
to resize to the size of the desktop.
---
 src/compositor-rdp.c | 44 
 src/compositor.c |  1 +
 2 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 909e225..4c5ae36 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -60,6 +60,7 @@ struct rdp_compositor_config {
char *server_cert;
char *server_key;
int env_socket;
+   int no_clients_resize;
 };
 
 struct rdp_output;
@@ -75,6 +76,7 @@ struct rdp_compositor {
char *server_key;
char *rdp_key;
int tls_enabled;
+   int no_clients_resize;
 };
 
 enum peer_item_flags {
@@ -122,6 +124,7 @@ rdp_compositor_config_init(struct rdp_compositor_config 
*config) {
config->server_cert = NULL;
config->server_key = NULL;
config->env_socket = 0;
+   config->no_clients_resize = 0;
 }
 
 static void
@@ -412,7 +415,8 @@ rdp_switch_mode(struct weston_output *output, struct 
weston_mode *target_mode) {
 
wl_list_for_each(rdpPeer, &rdpOutput->peers, link) {
settings = rdpPeer->peer->settings;
-   if (settings->DesktopWidth == target_mode->width && 
settings->DesktopHeight == target_mode->height)
+   if (settings->DesktopWidth == (UINT32)target_mode->width &&
+   settings->DesktopHeight == 
(UINT32)target_mode->height)
continue;
 
if (!settings->DesktopResize) {
@@ -672,18 +676,32 @@ xf_peer_post_connect(freerdp_peer* client)
if (output->base.width != (int)settings->DesktopWidth ||
output->base.height != (int)settings->DesktopHeight)
{
-   struct weston_mode new_mode;
-   struct weston_mode *target_mode;
-   new_mode.width = (int)settings->DesktopWidth;
-   new_mode.height = (int)settings->DesktopHeight;
-   target_mode = ensure_matching_mode(&output->base, &new_mode);
-   if (!target_mode) {
-   weston_log("client mode not found\n");
-   return FALSE;
+   if (c->no_clients_resize) {
+   /* RDP peers don't dictate their resolution to weston */
+   if (!settings->DesktopResize) {
+   /* peer does not support desktop resize */
+   weston_log("%s: client doesn't support 
resizing, closing connection\n", __FUNCTION__);
+   return FALSE;
+   } else {
+   settings->DesktopWidth = output->base.width;
+   settings->DesktopHeight = output->base.height;
+   client->update->DesktopResize(client->context);
+   }
+   } else {
+   /* ask weston to adjust size */
+   struct weston_mode new_mode;
+   struct weston_mode *target_mode;
+   new_mode.width = (int)settings->DesktopWidth;
+   new_mode.height = (int)settings->DesktopHeight;
+   target_mode = ensure_matching_mode(&output->base, 
&new_mode);
+   if (!target_mode) {
+   weston_log("client mode not found\n");
+   return FALSE;
+   }
+   weston_output_switch_mode(&output->base, target_mode, 
1, WESTON_MODE_SWITCH_SET_NATIVE);
+   output->base.width = new_mode.width;
+   output->base.height = new_mode.height;
}
-   weston_output_switch_mode(&output->base, target_mode, 1, 
WESTON_MODE_SWITCH_SET_NATIVE);
-   output->base.width = new_mode.width;
-   output->base.height = new_mode.height;
}
 
weston_log("kbd_layout:%x kbd_type:%x kbd_subType:%x 
kbd_functionKeys:%x\n",
@@ -988,6 +1006,7 @@ rdp_compositor_create(struct wl_display *display,
c->base.destroy = rdp_destroy;
c->base.restore = rdp_restore;
c->rdp_key = config->rdp_key ? strdup(config->rdp_key) : NULL;
+   c->no_clients_resize = config->no_clients_resize;
 
/* activate TLS only if certificate/key are available */
if (config->server_cert && config->server_key) {
@@ -1067,6 +1086,7 @@ backend_init(struct wl_display *display, int *argc, char 
*argv[],
{ WESTON_OPTION_INTEGER, "height", 0, &config

Re: [PATCH V3 4/7] Add new mode function in drm backend

2014-04-08 Thread Hardening

Le 08/04/2014 07:03, Quanxian Wang a écrit :

provide drm_output_new_mode interface to create new mode
from outsite instead of only from edid or configure.

Signed-off-by: Quanxian Wang 
---
  src/compositor-drm.c | 76 
  1 file changed, 76 insertions(+)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 154e15e..57e0585 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1390,6 +1390,80 @@ drm_output_add_mode(struct drm_output *output, 
drmModeModeInfo *info)
  }



[...]


+
+static struct weston_mode *
+drm_output_new_timing(struct weston_output *output,
+ uint32_t clock,
+ int hdisplay,
+ int hsync_start,
+ int hsync_end,
+ int htotal,
+ int vdisplay,
+ int vsync_start,
+ int vsync_end,
+ int vtotal,
+ int vscan,
+ uint32_t flags)
+{
+   drmModeModeInfo *modeinfo;
+   struct drm_mode *mode = NULL;
+
+   modeinfo = malloc(sizeof(*modeinfo));
+   if (modeinfo == NULL)
+   return NULL;
+   memset(modeinfo, 0x0, sizeof(*modeinfo));


Hardening: you should use zmalloc here


+
+   modeinfo->type = DRM_MODE_TYPE_USERDEF;
+   modeinfo->hskew = 0;
+   modeinfo->vrefresh = 0;
+   modeinfo->hdisplay = hdisplay;


[...]

+

+static int
  drm_subpixel_to_wayland(int drm_value)
  {
switch (drm_value) {
@@ -2046,6 +2120,8 @@ create_output_for_connector(struct drm_compositor *ec,
output->base.assign_planes = drm_assign_planes;
output->base.set_dpms = drm_set_dpms;
output->base.switch_mode = drm_output_switch_mode;
+   output->base.new_timing = drm_output_new_timing;
+   output->base.compare_timing = drm_output_compare_timing;

output->base.gamma_size = output->original_crtc->gamma_size;
output->base.set_gamma = drm_output_set_gamma;



Regards.
--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH V3 0/7] Add weston randr protocol

2014-04-08 Thread Hardening

Le 08/04/2014 07:03, Quanxian Wang a écrit :

Important Changes compared with V2:

1) Provide 2 methods to mode match for mode setting and mode delete.
a) Exact mode number match
Client selects the mode number according to query information.



[...]



5) Add above and below move action of output.
Currently it is the empty because compositor's related functions are not 
ready.

6) Newmode request is provided for RDP backend, but it should be implemented in 
backend by RDP developer.
Provide newmode option in apps(widthxheight or widthxheight@refresh)
Provide newmode request in randr protocol to create a simple mode without 
detail timing information.



With RDP we know only width / height / bpp, so the timing callbacks will 
be very easy to implement...


--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH V3 5/7] weston:Add the weston randr protocol implementation

2014-04-09 Thread Hardening

Le 08/04/2014 07:03, Quanxian Wang a écrit :

Signed-off-by: Quanxian Wang 
---
  module/Makefile.am|3 +
  module/wrandr/Makefile.am |   32 ++
  module/wrandr/wrandr.c| 1262 +
  3 files changed, 1297 insertions(+)
  create mode 100644 module/Makefile.am
  create mode 100644 module/wrandr/Makefile.am
  create mode 100644 module/wrandr/wrandr.c

diff --git a/module/Makefile.am b/module/Makefile.am
new file mode 100644
index 000..1a10e65
--- /dev/null
+++ b/module/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS =
+
+SUBDIRS += wrandr
diff --git a/module/wrandr/Makefile.am b/module/wrandr/Makefile.am
new file mode 100644
index 000..b0f2e6b
--- /dev/null
+++ b/module/wrandr/Makefile.am
@@ -0,0 +1,32 @@
+moduledir = $(libdir)/weston
+module_LTLIBRARIES = $(wrandr)
+
+AM_CPPFLAGS =  \
+   -I$(top_srcdir)/shared  \
+   -I$(top_srcdir)/src \
+   -I$(top_builddir)/src   \
+   -DDATADIR='"$(datadir)"'  \
+   -DMODULEDIR='"$(moduledir)"'  \
+   -DLIBEXECDIR='"$(libexecdir)"'\
+   -DIN_WESTON
+


[...]


+static void
+update_region(struct weston_compositor *ec,
+ struct weston_output *target_output)
+{
+   pixman_region32_t old_output_region;
+
+   /* Update output region and transformation matrix. */
+   pixman_region32_init(&old_output_region);
+   pixman_region32_copy(&old_output_region, &target_output->region);
+   weston_output_transform_scale_init(target_output,
+  target_output->transform,
+  target_output->current_scale);
+
+   pixman_region32_init(&target_output->previous_damage);
+   pixman_region32_init_rect(&target_output->region,
+ target_output->x, target_output->y,
+ target_output->width, target_output->height);
+
+   weston_output_update_matrix(target_output);
+
+   adjust_pointer(target_output, &old_output_region);
+   pixman_region32_fini(&old_output_region);
+
+   /* Damage the output region in primary_plane */
+   pixman_region32_union(&ec->primary_plane.damage,
+ &ec->primary_plane.damage,
+ &target_output->region);
+
+   target_output->dirty = 1;
+}
+
+static void
+randr_switch_mode(struct randr_output_request *request,
+ uint32_t *results)
+{
+   time_t time = 0;
+   int i = 0, found = 0;
+   int result = WRANDR_TYPE_RET_NOACT;
+   int timing_mode = 0;
+   int move_bits = 0;
+   struct weston_mode *mode;
+   struct weston_output *output = request->output;
+
+   if (request->flags & 1<modenum.modi_time;
+   *results |= result<<
+  (WRANDR_TYPE_OOP_MODENUM * 2);
+   }
+
+   if (request->flags & 1<mode->modi_time > time) {
+   time = request->mode->modi_time;
+   timing_mode = 2;
+   }
+   }


[Hardening] Perhaps the case where request->flags has not bits set 
should be treated with an error returned ?



+
+   switch (timing_mode) {
+   case 1:
+   i = 0;
+   wl_list_for_each(mode, &output->mode_list, link) {
+   i++;
+   if (i == request->modenum.num) {
+   found = 1;
+   break;
+   }
+   }
+
+   if (found != 1)
+   mode = NULL;
+   break;
+   case 2:
+   mode = randr_find_mode(output,
+  request->mode->width,
+      request->mode->height,
+  request->mode->refresh);
+   break;
+   default:
+   return;
+   }


[Hardening] related to my remark above, *results should be set in the 
"default:" handling, as it catches the case where timing_mode == 0 which 
means no flags where set.



+
+
+   if (!mode) {
+   result = WRANDR_TYPE_RET_FAIL;
+   } else {
+   if (!(mode->flags & WL_OUTPUT_MODE_CURRENT) &&
+   output->switch_mode) {
+   result = output->switch_mode(output, mode);
+   if (result < 0)
+   result = WRANDR_TYPE_RET_FAIL;
+   else
+   result = WRANDR_TYPE_RET_SUCCESS;
+   } else
+   result = WR

Re: [PATCH libinput 1/9] evdev: Dynamically allocate slot array

2014-04-09 Thread Hardening

Le 09/04/2014 21:02, Jonas Ådahl a écrit :

Don't have a hard coded (previously 16) slot array size; instead
allocate dynamically depending what slots are assigned. There is still a
hard coded max though, to protect from invalid input, but its changed
to 60.

Signed-off-by: Jonas Ådahl 
---
  src/evdev.c | 82 +
  src/evdev.h | 13 ++
  2 files changed, 69 insertions(+), 26 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 72e4086..cc0c4bf 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -280,6 +280,36 @@ evdev_process_key(struct evdev_device *device, struct 
input_event *e, int time)
}
  }

+static int
+alloc_mt_slot_states(struct evdev_device *device, int len)
+{
+   struct mt_slot *slots = device->mt.slots;
+   int i;
+
+   slots = realloc(slots, sizeof(struct mt_slot) * len);
+   if (!slots)
+   return -1;


slots will be leaked in this case (realloc don't touch original block 
when it fails, check man realloc).



+
+   for (i = device->mt.slots_len; i < len; ++i) {
+   slots[i].seat_slot = -1;
+   slots[i].x = 0;
+   slots[i].y = 0;
+   }
+   device->mt.slots = slots;
+   device->mt.slots_len = len;
+
+   return 0;
+}
+
+static void
+set_active_slot(struct evdev_device *device, int32_t slot)
+{
+   slot = min(slot, MAX_SLOTS);
+   if (slot >= device->mt.slots_len)
+   alloc_mt_slot_states(device, device->mt.slots_len * 2);
+   device->mt.slot = min(slot, device->mt.slots_len - 1);
+}
+
  static void
  evdev_process_touch(struct evdev_device *device,
struct input_event *e,
@@ -288,7 +318,7 @@ evdev_process_touch(struct evdev_device *device,
switch (e->code) {
case ABS_MT_SLOT:
evdev_flush_pending_event(device, time);
-   device->mt.slot = e->value;
+   set_active_slot(device, e->value);
break;
case ABS_MT_TRACKING_ID:
if (device->pending_event != EVDEV_NONE &&
@@ -543,9 +573,11 @@ evdev_device_dispatch(void *data)
  static int
  evdev_configure_device(struct evdev_device *device)
  {
+   struct libevdev *evdev = device->evdev;
const struct input_absinfo *absinfo;
int has_abs, has_rel, has_mt;
int has_button, has_keyboard, has_touch;
+   int active_slot;
unsigned int i;

has_rel = 0;
@@ -555,14 +587,14 @@ evdev_configure_device(struct evdev_device *device)
has_keyboard = 0;
has_touch = 0;

-   if (libevdev_has_event_type(device->evdev, EV_ABS)) {
+   if (libevdev_has_event_type(evdev, EV_ABS)) {

-   if ((absinfo = libevdev_get_abs_info(device->evdev, ABS_X))) {
+   if ((absinfo = libevdev_get_abs_info(evdev, ABS_X))) {
device->abs.min_x = absinfo->minimum;
device->abs.max_x = absinfo->maximum;
has_abs = 1;
}
-   if ((absinfo = libevdev_get_abs_info(device->evdev, ABS_Y))) {
+   if ((absinfo = libevdev_get_abs_info(evdev, ABS_Y))) {
device->abs.min_y = absinfo->minimum;
device->abs.max_y = absinfo->maximum;
has_abs = 1;
@@ -570,56 +602,58 @@ evdev_configure_device(struct evdev_device *device)
  /* We only handle the slotted Protocol B in weston.
 Devices with ABS_MT_POSITION_* but not ABS_MT_SLOT
 require mtdev for conversion. */
-   if (libevdev_has_event_code(device->evdev, EV_ABS, ABS_MT_POSITION_X) 
&&
-   libevdev_has_event_code(device->evdev, EV_ABS, 
ABS_MT_POSITION_Y)) {
-   absinfo = libevdev_get_abs_info(device->evdev, 
ABS_MT_POSITION_X);
+   if (libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) &&
+   libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y)) {
+   absinfo = libevdev_get_abs_info(evdev, 
ABS_MT_POSITION_X);
device->abs.min_x = absinfo->minimum;
device->abs.max_x = absinfo->maximum;
-   absinfo = libevdev_get_abs_info(device->evdev, 
ABS_MT_POSITION_Y);
+   absinfo = libevdev_get_abs_info(evdev, 
ABS_MT_POSITION_Y);
device->abs.min_y = absinfo->minimum;
device->abs.max_y = absinfo->maximum;
device->is_mt = 1;
has_touch = 1;
has_mt = 1;

-   if (!libevdev_has_event_code(device->evdev, EV_ABS, 
ABS_MT_SLOT)) {
+   if (!libevdev_has_event_code(evdev,
+EV_ABS, ABS_MT_SLOT)) {
device->mtdev = mtdev_new_open(device->fd);
   

[PATCH] Check malloc result

2014-04-11 Thread Hardening
This patch checks malloc was successfull and release resources if it
wasn't.
---
 src/screen-share.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/screen-share.c b/src/screen-share.c
index 5de20be..d3e3f05 100644
--- a/src/screen-share.c
+++ b/src/screen-share.c
@@ -434,11 +434,12 @@ shared_output_get_shm_buffer(struct shared_output *so)
data = mmap(NULL, height * stride, PROT_READ | PROT_WRITE, MAP_SHARED, 
fd, 0);
if (data == MAP_FAILED) {
weston_log("mmap: %m");
-   close(fd);
-   return NULL;
+   goto out_close;
}
 
sb = zalloc(sizeof *sb);
+   if (!sb)
+   goto out_unmap;
 
sb->output = so;
wl_list_init(&sb->free_link);
@@ -457,14 +458,26 @@ shared_output_get_shm_buffer(struct shared_output *so)
wl_buffer_add_listener(sb->buffer, &buffer_listener, sb);
wl_shm_pool_destroy(pool);
close(fd);
+   fd = -1;
 
memset(data, 0, sb->size);
 
sb->pm_image =
pixman_image_create_bits(PIXMAN_a8r8g8b8, width, height,
 (uint32_t *)data, stride);
+   if (!sb->pm_image)
+   goto out_pixman_error;
 
return sb;
+
+out_pixman_error:
+   pixman_region32_fini(&sb->damage);
+out_unmap:
+   munmap(data, height * stride);
+out_close:
+   if (fd != -1)
+   close(fd);
+   return NULL;
 }
 
 static void
-- 
1.8.1.2

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


[PATCH 0/2] Keyboard oriented patch

2014-04-11 Thread Hardening
The RDP compositor could became more popular with the fullscreen shell, so
this serie brings enhancements for keyboard. 
The first patch adds the management of more RDP keyboard layouts.
The second one simplifies scan code computation by using existing FreeRDP 
functions.

Hardening (2):
  Add more keyboards for the RDP compositor
  Use FreeRDP buildin functions to get scancodes

 src/compositor-rdp.c | 156 +--
 1 file changed, 126 insertions(+), 30 deletions(-)

-- 
1.8.1.2

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


[PATCH 2/2] Use FreeRDP buildin functions to get scancodes

2014-04-11 Thread Hardening
This patch make use of the functions available in FreeRDP to retrieve
the scancode to inject.
---
 src/compositor-rdp.c | 24 ++--
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 437954f..b749129 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -822,6 +822,8 @@ xf_peer_post_connect(freerdp_peer* client)
if (rdp_keyboards[i].rdpLayoutCode == settings->KeyboardLayout) 
{
xkbRuleNames.layout = rdp_keyboards[i].xkbLayout;
xkbRuleNames.variant = rdp_keyboards[i].xkbVariant;
+   weston_log("%s: matching layout=%s variant=%s\n", 
__FUNCTION__,
+   xkbRuleNames.layout, 
xkbRuleNames.variant);
break;
}
}
@@ -952,17 +954,6 @@ xf_input_synchronize_event(rdpInput *input, UINT32 flags)
pixman_region32_fini(&damage);
 }
 
-extern DWORD KEYCODE_TO_VKCODE_EVDEV[];
-static uint32_t vk_to_keycode[256];
-static void
-init_vk_translator(void)
-{
-   int i;
-
-   memset(vk_to_keycode, 0, sizeof(vk_to_keycode));
-   for(i = 0; i < 256; i++)
-   vk_to_keycode[KEYCODE_TO_VKCODE_EVDEV[i] & 0xff] = i-8;
-}
 
 static void
 xf_input_keyboard_event(rdpInput *input, UINT16 flags, UINT16 code)
@@ -986,17 +977,15 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, 
UINT16 code)
full_code |= KBD_FLAGS_EXTENDED;
 
vk_code = GetVirtualKeyCodeFromVirtualScanCode(full_code, 4);
-   if (vk_code > 0xff) {
-   weston_log("invalid vk_code %x", vk_code);
-   return;
-   }
-   scan_code = vk_to_keycode[vk_code];
+   if(flags & KBD_FLAGS_EXTENDED)
+   vk_code |= KBDEXT;
 
+   scan_code = GetKeycodeFromVirtualKeyCode(vk_code, 
KEYCODE_TYPE_EVDEV);
 
/*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, 
(flags & KBD_FLAGS_EXTENDED) ? 1 : 0,
vk_code, scan_code);*/
notify_key(&peerContext->item.seat, 
weston_compositor_get_time(),
-   scan_code, keyState, 
STATE_UPDATE_AUTOMATIC);
+   scan_code - 8, keyState, 
STATE_UPDATE_AUTOMATIC);
}
 }
 
@@ -1188,7 +1177,6 @@ backend_init(struct wl_display *display, int *argc, char 
*argv[],
 
freerdp_get_version(&major, &minor, &revision);
weston_log("using FreeRDP version %d.%d.%d\n", major, minor, revision);
-   init_vk_translator();
 
const struct weston_option rdp_options[] = {
{ WESTON_OPTION_BOOLEAN, "env-socket", 0, &config.env_socket },
-- 
1.8.1.2

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


[PATCH 1/2] Add more keyboards for the RDP compositor

2014-04-11 Thread Hardening
This patch complements the table that contains matches between RDP
and xkb keyboard layouts. We now handle variants too.
---
 src/compositor-rdp.c | 132 ++-
 1 file changed, 120 insertions(+), 12 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index aecc0a8..437954f 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -42,6 +42,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "compositor.h"
@@ -618,21 +619,127 @@ xf_peer_capabilities(freerdp_peer* client)
return TRUE;
 }
 
-
 struct rdp_to_xkb_keyboard_layout {
UINT32 rdpLayoutCode;
-   char *xkbLayout;
+   const char *xkbLayout;
+   const char *xkbVariant;
 };
 
-/* picked from http://technet.microsoft.com/en-us/library/cc766503(WS.10).aspx 
*/
-static struct rdp_to_xkb_keyboard_layout rdp_keyboards[] = {
-   {0x0406, "dk"},
-   {0x0407, "de"},
-   {0x0409, "us"},
-   {0x040c, "fr"},
-   {0x0410, "it"},
-   {0x0813, "be"},
-   {0x, 0},
+/* table reversed from
+   
https://github.com/awakecoding/FreeRDP/blob/master/libfreerdp/locale/xkb_layout_ids.c#L811
 */
+static
+struct rdp_to_xkb_keyboard_layout rdp_keyboards[] = {
+   {KBD_ARABIC_101, "ara", 0},
+   {KBD_BULGARIAN, 0, 0},
+   {KBD_CHINESE_TRADITIONAL_US, 0},
+   {KBD_CZECH, "cz", 0},
+   {KBD_CZECH_PROGRAMMERS, "cz", "bksl"},
+   {KBD_CZECH_QWERTY, "cz", "qwerty"},
+   {KBD_DANISH, "dk", 0},
+   {KBD_GERMAN, "de", 0},
+   {KBD_GERMAN_NEO, "de", "neo"},
+   {KBD_GERMAN_IBM, "de", "qwerty"},
+   {KBD_GREEK, "gr", 0},
+   {KBD_GREEK_220, "gr", "simple"},
+   {KBD_GREEK_319, "gr", "extended"},
+   {KBD_GREEK_POLYTONIC, "gr", "polytonic"},
+   {KBD_US, "us", 0},
+   {KBD_US_ENGLISH_TABLE_FOR_IBM_ARABIC_238_L, "ara", "buckwalter"},
+   {KBD_SPANISH, "es", 0},
+   {KBD_SPANISH_VARIATION, "es", "nodeadkeys"},
+   {KBD_FINNISH, "fi", 0},
+   {KBD_FRENCH, "fr", 0},
+   {KBD_HEBREW, "il", 0},
+   {KBD_HUNGARIAN, "hu", 0},
+   {KBD_HUNGARIAN_101_KEY, "hu", "standard"},
+   {KBD_ICELANDIC, "is", 0},
+   {KBD_ITALIAN, "it", 0},
+   {KBD_ITALIAN_142, "it", "nodeadkeys"},
+   {KBD_JAPANESE, "jp", 0},
+   {KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002, "jp", "kana"},
+   {KBD_KOREAN, "kr", 0},
+   {KBD_KOREAN_INPUT_SYSTEM_IME_2000, "kr", "kr104"},
+   {KBD_DUTCH, "nl", 0},
+   {KBD_NORWEGIAN, "no", 0},
+   {KBD_POLISH_PROGRAMMERS, "pl", 0},
+   {KBD_POLISH_214, "pl", "qwertz"},
+   // {KBD_PORTUGUESE_BRAZILIAN_ABN0416, 0},
+   {KBD_ROMANIAN, "ro", 0},
+   {KBD_RUSSIAN, "ru", 0},
+   {KBD_RUSSIAN_TYPEWRITER, "ru", "typewriter"},
+   {KBD_CROATIAN, "hr", 0},
+   {KBD_SLOVAK, "sk", 0},
+   {KBD_SLOVAK_QWERTY, "sk", "qwerty"},
+   {KBD_ALBANIAN, 0, 0},
+   {KBD_SWEDISH, "se", 0},
+   {KBD_THAI_KEDMANEE, "th", 0},
+   {KBD_THAI_KEDMANEE_NON_SHIFTLOCK, "th", "tis"},
+   {KBD_TURKISH_Q, "tr", 0},
+   {KBD_TURKISH_F, "tr", "f"},
+   {KBD_URDU, "in", "urd-phonetic3"},
+   {KBD_UKRAINIAN, "ua", 0},
+   {KBD_BELARUSIAN, "by", 0},
+   {KBD_SLOVENIAN, "si", 0},
+   {KBD_ESTONIAN, "ee", 0},
+   {KBD_LATVIAN, "lv", 0},
+   {KBD_LITHUANIAN_IBM, "lt", "ibm"},
+   {KBD_FARSI, "af", 0},
+   {KBD_VIETNAMESE, "vn", 0},
+   {KBD_ARMENIAN_EASTERN, "am", 0},
+   {KBD_AZERI_LATIN, 0, 0},
+   {KBD_FYRO_MACEDONIAN, "mk", 0},
+   {KBD_GEORGIAN, "ge", 0},
+   {KBD_FAEROESE, 0, 0},
+   {KBD_DEVANAGARI_INSCRIPT, 0, 0},
+   {KBD_MALTESE_47_KEY, 0, 0},
+   {KBD_NORWEGIAN_WITH_SAMI, "no", "smi"},
+   {KBD_KAZAKH, "kz", 0},
+   {KBD_KYRGYZ_CYRILLIC, "kg", "phonetic"},
+   {KBD_TATAR, "ru", "tt"},
+   {KBD_BENGALI, "bd", 0},
+   {KBD_BENGALI_INSCRIPT, "bd", "probhat"},
+   {KBD_PUNJABI, 0, 0},
+   {KBD_GUJARATI, "in", "guj"},
+   {KBD_TAMIL, "in", "tam"},
+   {KBD_TELUGU, "in", "tel"},
+   {KBD_KANNADA, "in", "kan"},
+   {KBD_MALAYALAM, "in", "mal"},
+   {KBD_HINDI_TRADITIONAL, "in", 0},
+   {KBD_MARATHI, 0, 0},
+   {KBD_MONGOLIAN_CYRILLIC, "mn", 0},
+   {KBD_UNITED_KINGDOM_EXTENDED, "gb", "intl"},
+   {KBD_SYRIAC, "syc", 0},
+   {KBD_SYRIAC_PHONETIC, "syc", "syc_phonetic"},
+   {KBD_NEPALI, "np", 0},
+   {KBD_PASHTO, "af", "ps"},
+   {KBD_DIVEHI_PHONETIC, 0, 0},
+   {KBD_LUXEMBOURGISH, 0, 0},
+   {KBD_MAORI, "mao", 0},
+   {KBD_CHINESE_SIMPLIFIED_US, 0, 0},
+   {KBD_SWISS_GERMAN, "ch", "de_nodeadkeys"},
+   {KBD_UNITED_KINGDOM, "gb", 0},
+   {KBD_LATIN_AMERICAN, "latam", 0},
+   {KBD_BELGIAN_FRENCH, "be", 0},
+   {KBD_BELGIAN_PERIOD, "be", "oss_sundeadkeys"},
+   {KBD_PORTUGUESE, "pt", 0},
+   {KBD_SERBIAN_LATIN, "rs", 0},
+   {KBD_AZERI_CYRILLIC, "az", "cyrillic"},
+   {KBD_SWEDISH_WITH_SA

Re: [PATCH 1/2] Add more keyboards for the RDP compositor

2014-04-11 Thread Hardening

Le 11/04/2014 21:46, Bill Spitzak a écrit :

Rather than this ridiculousness, it would help a lot if there was a way
to send already-decoded keysyms to clients and the input method.

Keyboard mapping on remote X has always been a disaster because of this
strange requirement that you emulate a fake piece of hardware, and it
would be nice if Wayland got rid of it. I am sick and tired of having to
run xmodmap with a manually-configured "fix it up" whenever I use remote
X so that my arrow and function keys work. This is stupid and makes
things look absolutely terrible to end users.

On 04/11/2014 01:52 AM, Hardening wrote:

This patch complements the table that contains matches between RDP
and xkb keyboard layouts. We now handle variants too.
---
  src/compositor-rdp.c | 132
++-
  1 file changed, 120 insertions(+), 12 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index aecc0a8..437954f 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -42,6 +42,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include "compositor.h"
@@ -618,21 +619,127 @@ xf_peer_capabilities(freerdp_peer* client)
  return TRUE;
  }


With the RDP compositor, you have an out-of-the box experience. If your 
client announces the right keyboard layout, you will have your keyboard 
working correctly without any xmodmap (or equivalent) tricks. At least 
it's the way it is expected to work.


I have heard that in some cases windows layouts (which are also RDP 
ones) don't match exact the XKB ones :(. So the surprises can come when 
using mstsc against a linux host.


Regards.

--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland] connection: Don't write past the end of the connection buffer

2014-04-17 Thread Hardening

Le 17/04/2014 17:20, Ander Conselvan de Oliveira a écrit :

From: Ander Conselvan de Oliveira 

If a message was too big to fit in the connection buffer, the code
in wl_buffer_put would just write past the end of it.

I haven't seen any real world use case that would trigger this bug, but
it was possible to trigger it by sending a long enough string to the
wl_data_source.offer request.

https://bugs.freedesktop.org/show_bug.cgi?id=69267


Perhaps this should be marked as a security issue. If a wayland client 
can control an answer generated by the server, it would be able to 
overflow the buffer and corrupt the compositor's memory. I haven't check 
if it's not feasible.


Regards.

--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] event: Cheking for NULL before dereferencing the pointer.

2014-05-09 Thread Hardening

Le 09/05/2014 08:43, Srivardhan Hebbar a écrit :

Checking for NULL before dereferencing the wl_event_source
pointer so as to avoid crash.

Signed-off-by: Srivardhan Hebbar 
---
  src/event-loop.c |7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/event-loop.c b/src/event-loop.c
index 9790cde..b62d16e 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -312,7 +312,12 @@ wl_event_source_check(struct wl_event_source *source)
  WL_EXPORT int
  wl_event_source_remove(struct wl_event_source *source)
  {
-   struct wl_event_loop *loop = source->loop;
+   struct wl_event_loop *loop;
+
+   if (source == NULL)
+   return 0;
+
+   loop = source->loop;

/* We need to explicitly remove the fd, since closing the fd
 * isn't enough in case we've dup'ed the fd. */



Hello Srivardhan,

do you have a case where this check is hit ? I may be wrong but having 
no loop associated with a source event is not supposed to happen. So my 
guess is that a caller of wl_event_source_remove has forgotten to 
nullify the event source after the call.


Regards.

--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] event: Cheking for NULL before dereferencing the pointer.

2014-05-09 Thread Hardening

Le 09/05/2014 12:20, Pekka Paalanen a écrit :

On Fri, 09 May 2014 15:21:51 +0530
Srivardhan  wrote:





-Original Message-
From: Pekka Paalanen [mailto:ppaala...@gmail.com]
Sent: Friday, May 09, 2014 3:09 PM
To: Srivardhan
Cc: 'Hardening'; wayland-devel@lists.freedesktop.org
Subject: Re: [PATCH] event: Cheking for NULL before dereferencing the
pointer.

On Fri, 09 May 2014 14:56:14 +0530
Srivardhan  wrote:



[...]



Checking is one thing, silently hiding bugs is another thing.

If NULL is a legal input, then of course it needs to be checked.

If NULL can happen, but is a runtime error, the program needs to be
vocal about it, e.g. relay the error back to the caller.

If API specification says NULL is not a valid input, putting an
assert() would be fine, since violating that is a programmer error in
the caller.

I think wl_event_source_remove() falls into the last category. All
functions in wayland-util.h belong to this category, too.



IMHO wl_event_source_remove() should take a wl_event_source ** as 
parameter and set to NULL the event_source pointer (preventing anyone 
to use it). Using eclipse call hierarchy, I've seen many places where 
this extra precaution is not taken.
I don't know if wl_event_source_remove() can be considered as part of 
the libwayland API and so fixed in stone ?


Regards.

--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH 1/2] Set to NULL event source after a call to wl_event_source_remove

2014-05-09 Thread Hardening
This patch sets to NULL event sources after a call to wl_event_source_remove()
has been made.
---
 src/clipboard.c  | 3 ++-
 src/compositor-drm.c | 3 +++
 src/compositor-rpi.c | 1 +
 src/compositor-x11.c | 2 ++
 src/compositor.c | 6 +-
 src/evdev-touchpad.c | 1 +
 src/evdev.c  | 4 +++-
 src/libinput-seat.c  | 1 +
 src/logind-util.c| 2 ++
 xwayland/launcher.c  | 6 +-
 xwayland/selection.c | 9 +++--
 11 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/src/clipboard.c b/src/clipboard.c
index 5a3a02d..0e25dc1 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -61,6 +61,7 @@ clipboard_source_unref(struct clipboard_source *source)
 
if (source->event_source) {
wl_event_source_remove(source->event_source);
+   source->event_source = NULL;
close(source->fd);
}
wl_signal_emit(&source->base.destroy_signal,
@@ -90,8 +91,8 @@ clipboard_source_data(int fd, uint32_t mask, void *data)
len = read(fd, p, size);
if (len == 0) {
wl_event_source_remove(source->event_source);
-   close(fd);
source->event_source = NULL;
+   close(fd);
} else if (len < 0) {
clipboard_source_unref(source);
clipboard->source = NULL;
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 5f59789..0110f41 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2379,7 +2379,9 @@ drm_destroy(struct weston_compositor *ec)
udev_input_destroy(&d->input);
 
wl_event_source_remove(d->udev_drm_source);
+   d->udev_drm_source = NULL;
wl_event_source_remove(d->drm_source);
+   d->drm_source = NULL;
 
destroy_sprites(d);
 
@@ -2849,6 +2851,7 @@ drm_compositor_create(struct wl_display *display,
 
 err_udev_monitor:
wl_event_source_remove(ec->udev_drm_source);
+   ec->udev_drm_source = NULL;
udev_monitor_unref(ec->udev_monitor);
 err_drm_source:
wl_event_source_remove(ec->drm_source);
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index 287451d..cbfb770 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -213,6 +213,7 @@ static void
 rpi_flippipe_release(struct rpi_flippipe *flippipe)
 {
wl_event_source_remove(flippipe->source);
+   flippipe->source = NULL;
close(flippipe->readfd);
close(flippipe->writefd);
 }
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 56b3228..9f171e7 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -485,6 +485,7 @@ x11_output_destroy(struct weston_output *output_base)
(struct x11_compositor *)output->base.compositor;
 
wl_event_source_remove(output->finish_frame_timer);
+   output->finish_frame_timer = NULL;
 
if (compositor->use_pixman) {
pixman_renderer_output_destroy(output_base);
@@ -1424,6 +1425,7 @@ x11_destroy(struct weston_compositor *ec)
struct x11_compositor *compositor = (struct x11_compositor *)ec;
 
wl_event_source_remove(compositor->xcb_source);
+   compositor->xcb_source = NULL;
x11_input_destroy(compositor);
 
weston_compositor_shutdown(ec); /* destroys outputs, too */
diff --git a/src/compositor.c b/src/compositor.c
index cd1ca9a..6ad3387 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3736,8 +3736,12 @@ weston_compositor_shutdown(struct weston_compositor *ec)
struct weston_output *output, *next;
 
wl_event_source_remove(ec->idle_source);
-   if (ec->input_loop_source)
+   ec->idle_source = NULL;
+
+   if (ec->input_loop_source) {
wl_event_source_remove(ec->input_loop_source);
+   ec->input_loop_source = NULL;
+   }
 
/* Destroy all outputs associated with this compositor */
wl_list_for_each_safe(output, next, &ec->output_list, link)
diff --git a/src/evdev-touchpad.c b/src/evdev-touchpad.c
index 69f913a..360f87f 100644
--- a/src/evdev-touchpad.c
+++ b/src/evdev-touchpad.c
@@ -663,6 +663,7 @@ touchpad_destroy(struct evdev_dispatch *dispatch)
 
touchpad->filter->interface->destroy(touchpad->filter);
wl_event_source_remove(touchpad->fsm.timer_source);
+   touchpad->fsm.timer_source = NULL;
free(dispatch);
 }
 
diff --git a/src/evdev.c b/src/evdev.c
index 888dfbd..a1bce2c 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -697,8 +697,10 @@ evdev_device_destroy(struct evdev_device *device)
if (dispatch)
dispatch->interface->destroy(dispatch);
 
-   if (device->source)
+   if (device->source) {
wl_event_source_remove(device->source);
+   device->source = NULL;
+   }
if (device->output)
wl_list_remove(&device->output_destroy_listener.link);
wl_list_remove(&device->link);
diff --git a/src/libinput-seat.c b/src/libinput-seat.c
index a38d470..34f1aab 100644
--

[PATCH 2/2] Handle OOM with signal events

2014-05-09 Thread Hardening
This patch handles the case where a signal event source can not be created.
---
 src/compositor.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 6ad3387..047df8a 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4197,6 +4197,7 @@ int main(int argc, char *argv[])
display = wl_display_create();
 
loop = wl_display_get_event_loop(display);
+   memset(signals, 0, sizeof(signals));
signals[0] = wl_event_loop_add_signal(loop, SIGTERM, on_term_signal,
  display);
signals[1] = wl_event_loop_add_signal(loop, SIGINT, on_term_signal,
@@ -4208,6 +4209,9 @@ int main(int argc, char *argv[])
signals[3] = wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler,
  NULL);
 
+   if (!signals[0] || !signals[1] || !signals[2] || !signals[3])
+   goto out_signals;
+
config = weston_config_parse("weston.ini");
if (config != NULL) {
weston_log("Using config file '%s'\n",
@@ -4321,8 +4325,11 @@ int main(int argc, char *argv[])
 
wl_signal_emit(&ec->destroy_signal, ec);
 
-   for (i = ARRAY_LENGTH(signals); i;)
-   wl_event_source_remove(signals[--i]);
+ out_signals:
+   for (i = ARRAY_LENGTH(signals); i; i--) {
+   if (signals[i-1])
+   wl_event_source_remove(signals[i-1]);
+   }
 
weston_compositor_xkb_destroy(ec);
 
-- 
1.8.1.2

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


Re: [PATCH V2] event: assert wl_event_source pointer is NULL.

2014-05-12 Thread Hardening

Le 12/05/2014 07:56, Srivardhan Hebbar a écrit :

Signed-off-by: Srivardhan Hebbar 
---
  src/event-loop.c |6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/event-loop.c b/src/event-loop.c
index 9790cde..57e3fed 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -312,7 +312,11 @@ wl_event_source_check(struct wl_event_source *source)
  WL_EXPORT int
  wl_event_source_remove(struct wl_event_source *source)
  {
-   struct wl_event_loop *loop = source->loop;
+   struct wl_event_loop *loop;
+
+   assert(!source);


Isn't it the opposite ?


+
+   loop = source->loop;

/* We need to explicitly remove the fd, since closing the fd
 * isn't enough in case we've dup'ed the fd. */



Regards
--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Wayland and Weston 1.5.0 is released

2014-05-21 Thread Hardening

Le 20/05/2014 22:12, Kristian Høgsberg a écrit :

Hi,



[...]



Going forward, for master, I'd like to change the work flow a bit.
The biggest problem with how we work today is me being a bottleneck at
best or flat out dropping patches.  So I'd like to open up commit
access to some of the key contributors.  Either people that have their
corner of weston that they maintain (for example Pekka and the
Raspberry Pi backend or Hardening and the RDP backend) or contributors
who have been part of the project for a while and understands the code
base well - or both.



Hi,

congratulations for the release. Thank you for trusting me as a RDP 
compositor maintainer. Just like Pekka, I will be happy to handle RDP 
oriented patches after review on the list.


Best regards.
--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] protocol: remove redundant 'the' in description

2014-05-23 Thread Hardening

Le 23/05/2014 09:14, Pekka Paalanen a écrit :

On Fri, 23 May 2014 03:04:29 -0400
"Jasper St. Pierre"  wrote:


On Fri, May 23, 2014 at 2:49 AM, Pekka Paalanen  wrote:



[...]



This is obviously correct.

Can I push this, or shall we reserve the right to push to libwayland
for Kristian only, even for "obviously trivial" patches?



If you received permissions to push, I don't see why you shouldn't.
Kristian trusts you enough to add you to the list of committers, so I think
he can trust your judgement on stuff like this.


The talk was only about Weston AFAIU. I don't know if libwayland is
actually open for the group 'wayland' to push. Even if it was open
by access permissions on the server, I still want to be sure that I am
allowed (in the social sense) to push.

Like I have access to the Mesa repo from years ago, but I'm still not
allowed to push without proper review process which is defined by the
Mesa project.

The process for libwayland is still unclear to me, hence my question.



Hello Pekka,

quotes from the 1.5 release mail:
Being able to review *and* commit a patch will hopefully increase the
incentive to review and I won't need to be around all the time for
things to move forwards.  I think everybody has enough common sense to
decide when something is a quick fix that can be committed right away
and when something needs wider discussion and concensus.  For anything
that touches core weston and in particular, anything that adds
protocol, we still want to see patches, reviews and discussion the
list before committing.

So I think you can go with this trivial fix.

Regards.

PS: does someone know how to check if write access to a git repo is 
effective without doing some changes in it ?


--
David FORT
website: http://www.hardening-consulting.com/
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH 2/2] Use FreeRDP buildin functions to get scancodes

2014-05-26 Thread Hardening
This patch make use of the functions available in FreeRDP to retrieve
the scancode to inject.
---
 src/compositor-rdp.c | 24 ++--
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 437954f..b749129 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -822,6 +822,8 @@ xf_peer_post_connect(freerdp_peer* client)
if (rdp_keyboards[i].rdpLayoutCode == settings->KeyboardLayout) 
{
xkbRuleNames.layout = rdp_keyboards[i].xkbLayout;
xkbRuleNames.variant = rdp_keyboards[i].xkbVariant;
+   weston_log("%s: matching layout=%s variant=%s\n", 
__FUNCTION__,
+   xkbRuleNames.layout, 
xkbRuleNames.variant);
break;
}
}
@@ -952,17 +954,6 @@ xf_input_synchronize_event(rdpInput *input, UINT32 flags)
pixman_region32_fini(&damage);
 }
 
-extern DWORD KEYCODE_TO_VKCODE_EVDEV[];
-static uint32_t vk_to_keycode[256];
-static void
-init_vk_translator(void)
-{
-   int i;
-
-   memset(vk_to_keycode, 0, sizeof(vk_to_keycode));
-   for(i = 0; i < 256; i++)
-   vk_to_keycode[KEYCODE_TO_VKCODE_EVDEV[i] & 0xff] = i-8;
-}
 
 static void
 xf_input_keyboard_event(rdpInput *input, UINT16 flags, UINT16 code)
@@ -986,17 +977,15 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, 
UINT16 code)
full_code |= KBD_FLAGS_EXTENDED;
 
vk_code = GetVirtualKeyCodeFromVirtualScanCode(full_code, 4);
-   if (vk_code > 0xff) {
-   weston_log("invalid vk_code %x", vk_code);
-   return;
-   }
-   scan_code = vk_to_keycode[vk_code];
+   if(flags & KBD_FLAGS_EXTENDED)
+   vk_code |= KBDEXT;
 
+   scan_code = GetKeycodeFromVirtualKeyCode(vk_code, 
KEYCODE_TYPE_EVDEV);
 
/*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, 
(flags & KBD_FLAGS_EXTENDED) ? 1 : 0,
vk_code, scan_code);*/
notify_key(&peerContext->item.seat, 
weston_compositor_get_time(),
-   scan_code, keyState, 
STATE_UPDATE_AUTOMATIC);
+   scan_code - 8, keyState, 
STATE_UPDATE_AUTOMATIC);
}
 }
 
@@ -1188,7 +1177,6 @@ backend_init(struct wl_display *display, int *argc, char 
*argv[],
 
freerdp_get_version(&major, &minor, &revision);
weston_log("using FreeRDP version %d.%d.%d\n", major, minor, revision);
-   init_vk_translator();
 
const struct weston_option rdp_options[] = {
{ WESTON_OPTION_BOOLEAN, "env-socket", 0, &config.env_socket },
-- 
1.8.1.2

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


[PATCH 0/2] RDP Keyboard

2014-05-26 Thread Hardening
I'm resending this serie of patches that are related to keyboard with the RDP
compositor. The first one make weston support more RDP keyboard (RDP to Xkb
convertion). The second make use of buildin FreeRDP functions instead of 
reinventing
the wheel.

I didn't had many feedback for these at the last sending, so if nobody's 
against I 
will commit them.

Hardening (2):
  Add more keyboards for the RDP compositor
  Use FreeRDP buildin functions to get scancodes

 src/compositor-rdp.c | 156 +--
 1 file changed, 126 insertions(+), 30 deletions(-)

-- 
1.8.1.2

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


[PATCH 1/2] Add more keyboards for the RDP compositor

2014-05-26 Thread Hardening
This patch complements the table that contains matches between RDP
and xkb keyboard layouts. We now handle variants too.
---
 src/compositor-rdp.c | 132 ++-
 1 file changed, 120 insertions(+), 12 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index aecc0a8..437954f 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -42,6 +42,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "compositor.h"
@@ -618,21 +619,127 @@ xf_peer_capabilities(freerdp_peer* client)
return TRUE;
 }
 
-
 struct rdp_to_xkb_keyboard_layout {
UINT32 rdpLayoutCode;
-   char *xkbLayout;
+   const char *xkbLayout;
+   const char *xkbVariant;
 };
 
-/* picked from http://technet.microsoft.com/en-us/library/cc766503(WS.10).aspx 
*/
-static struct rdp_to_xkb_keyboard_layout rdp_keyboards[] = {
-   {0x0406, "dk"},
-   {0x0407, "de"},
-   {0x0409, "us"},
-   {0x040c, "fr"},
-   {0x0410, "it"},
-   {0x0813, "be"},
-   {0x, 0},
+/* table reversed from
+   
https://github.com/awakecoding/FreeRDP/blob/master/libfreerdp/locale/xkb_layout_ids.c#L811
 */
+static
+struct rdp_to_xkb_keyboard_layout rdp_keyboards[] = {
+   {KBD_ARABIC_101, "ara", 0},
+   {KBD_BULGARIAN, 0, 0},
+   {KBD_CHINESE_TRADITIONAL_US, 0},
+   {KBD_CZECH, "cz", 0},
+   {KBD_CZECH_PROGRAMMERS, "cz", "bksl"},
+   {KBD_CZECH_QWERTY, "cz", "qwerty"},
+   {KBD_DANISH, "dk", 0},
+   {KBD_GERMAN, "de", 0},
+   {KBD_GERMAN_NEO, "de", "neo"},
+   {KBD_GERMAN_IBM, "de", "qwerty"},
+   {KBD_GREEK, "gr", 0},
+   {KBD_GREEK_220, "gr", "simple"},
+   {KBD_GREEK_319, "gr", "extended"},
+   {KBD_GREEK_POLYTONIC, "gr", "polytonic"},
+   {KBD_US, "us", 0},
+   {KBD_US_ENGLISH_TABLE_FOR_IBM_ARABIC_238_L, "ara", "buckwalter"},
+   {KBD_SPANISH, "es", 0},
+   {KBD_SPANISH_VARIATION, "es", "nodeadkeys"},
+   {KBD_FINNISH, "fi", 0},
+   {KBD_FRENCH, "fr", 0},
+   {KBD_HEBREW, "il", 0},
+   {KBD_HUNGARIAN, "hu", 0},
+   {KBD_HUNGARIAN_101_KEY, "hu", "standard"},
+   {KBD_ICELANDIC, "is", 0},
+   {KBD_ITALIAN, "it", 0},
+   {KBD_ITALIAN_142, "it", "nodeadkeys"},
+   {KBD_JAPANESE, "jp", 0},
+   {KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002, "jp", "kana"},
+   {KBD_KOREAN, "kr", 0},
+   {KBD_KOREAN_INPUT_SYSTEM_IME_2000, "kr", "kr104"},
+   {KBD_DUTCH, "nl", 0},
+   {KBD_NORWEGIAN, "no", 0},
+   {KBD_POLISH_PROGRAMMERS, "pl", 0},
+   {KBD_POLISH_214, "pl", "qwertz"},
+   // {KBD_PORTUGUESE_BRAZILIAN_ABN0416, 0},
+   {KBD_ROMANIAN, "ro", 0},
+   {KBD_RUSSIAN, "ru", 0},
+   {KBD_RUSSIAN_TYPEWRITER, "ru", "typewriter"},
+   {KBD_CROATIAN, "hr", 0},
+   {KBD_SLOVAK, "sk", 0},
+   {KBD_SLOVAK_QWERTY, "sk", "qwerty"},
+   {KBD_ALBANIAN, 0, 0},
+   {KBD_SWEDISH, "se", 0},
+   {KBD_THAI_KEDMANEE, "th", 0},
+   {KBD_THAI_KEDMANEE_NON_SHIFTLOCK, "th", "tis"},
+   {KBD_TURKISH_Q, "tr", 0},
+   {KBD_TURKISH_F, "tr", "f"},
+   {KBD_URDU, "in", "urd-phonetic3"},
+   {KBD_UKRAINIAN, "ua", 0},
+   {KBD_BELARUSIAN, "by", 0},
+   {KBD_SLOVENIAN, "si", 0},
+   {KBD_ESTONIAN, "ee", 0},
+   {KBD_LATVIAN, "lv", 0},
+   {KBD_LITHUANIAN_IBM, "lt", "ibm"},
+   {KBD_FARSI, "af", 0},
+   {KBD_VIETNAMESE, "vn", 0},
+   {KBD_ARMENIAN_EASTERN, "am", 0},
+   {KBD_AZERI_LATIN, 0, 0},
+   {KBD_FYRO_MACEDONIAN, "mk", 0},
+   {KBD_GEORGIAN, "ge", 0},
+   {KBD_FAEROESE, 0, 0},
+   {KBD_DEVANAGARI_INSCRIPT, 0, 0},
+   {KBD_MALTESE_47_KEY, 0, 0},
+   {KBD_NORWEGIAN_WITH_SAMI, "no", "smi"},
+   {KBD_KAZAKH, "kz", 0},
+   {KBD_KYRGYZ_CYRILLIC, "kg", "phonetic"},
+   {KBD_TATAR, "ru", "tt"},
+   {KBD_BENGALI, "bd", 0},
+   {KBD_BENGALI_INSCRIPT, "bd", "probhat"},
+   {KBD_PUNJABI, 0, 0},
+   {KBD_GUJARATI, "in", "guj"},
+   {KBD_TAMIL, "in", "tam"},
+   {KBD_TELUGU, "in", "tel"},
+   {KBD_KANNADA, "in", "kan"},
+   {KBD_MALAYALAM, "in", "mal"},
+   {KBD_HINDI_TRADITIONAL, "in", 0},
+   {KBD_MARATHI, 0, 0},
+   {KBD_MONGOLIAN_CYRILLIC, "mn", 0},
+   {KBD_UNITED_KINGDOM_EXTENDED, "gb", "intl"},
+   {KBD_SYRIAC, "syc", 0},
+   {KBD_SYRIAC_PHONETIC, "syc", "syc_phonetic"},
+   {KBD_NEPALI, "np", 0},
+   {KBD_PASHTO, "af", "ps"},
+   {KBD_DIVEHI_PHONETIC, 0, 0},
+   {KBD_LUXEMBOURGISH, 0, 0},
+   {KBD_MAORI, "mao", 0},
+   {KBD_CHINESE_SIMPLIFIED_US, 0, 0},
+   {KBD_SWISS_GERMAN, "ch", "de_nodeadkeys"},
+   {KBD_UNITED_KINGDOM, "gb", 0},
+   {KBD_LATIN_AMERICAN, "latam", 0},
+   {KBD_BELGIAN_FRENCH, "be", 0},
+   {KBD_BELGIAN_PERIOD, "be", "oss_sundeadkeys"},
+   {KBD_PORTUGUESE, "pt", 0},
+   {KBD_SERBIAN_LATIN, "rs", 0},
+   {KBD_AZERI_CYRILLIC, "az", "cyrillic"},
+   {KBD_SWEDISH_WITH_SA

Re: [PATCH 0/2] RDP Keyboard

2014-06-02 Thread Hardening
Le 26/05/2014 17:22, Hardening a écrit :
> I'm resending this serie of patches that are related to keyboard with the RDP
> compositor. The first one make weston support more RDP keyboard (RDP to Xkb
> convertion). The second make use of buildin FreeRDP functions instead of 
> reinventing
> the wheel.
> 
> I didn't had many feedback for these at the last sending, so if nobody's 
> against I 
> will commit them.
> 
> Hardening (2):
>   Add more keyboards for the RDP compositor
>   Use FreeRDP buildin functions to get scancodes
> 
>  src/compositor-rdp.c | 156 
> +--
>  1 file changed, 126 insertions(+), 30 deletions(-)
> 

I have commited these two.

Regards.

-- 
David FORT
website: http://www.hardening-consulting.com/

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


Re: [PATCH] weston: Fix memleak issue in compositor.c

2014-06-03 Thread Hardening
Le 27/05/2014 11:00, Srivardhan Hebbar a écrit :
> This fix is upon "Hardening " patch. [PATCH 2/2] Handle 
> OOM with signal events.
> 
LGTM

Reviewed-by: Hardening 

> Signed-off-by: Srivardhan Hebbar 
> ---
>  src/compositor.c |   23 +--
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/src/compositor.c b/src/compositor.c
> index 574db2d..f233101 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -4207,6 +4207,11 @@ int main(int argc, char *argv[])
>   signals[3] = wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler,
> NULL);
>  
> + if (!signals[0] || !signals[1] || !signals[2] || !signals[3]) {
> + ret = EXIT_FAILURE;
> + goto out_signals;
> + }
> +
>   if (noconfig == 0)
>   config = weston_config_parse("weston.ini");
>   if (config != NULL) {
> @@ -4234,13 +4239,16 @@ int main(int argc, char *argv[])
>  
>   backend_init = weston_load_module(backend, "backend_init");
>   free(backend);
> - if (!backend_init)
> - exit(EXIT_FAILURE);
> + if (!backend_init) {
> + ret = EXIT_FAILURE;
> + goto out_signals;
> + }
>  
>   ec = backend_init(display, &argc, argv, config);
>   if (ec == NULL) {
>   weston_log("fatal: failed to create compositor\n");
> - exit(EXIT_FAILURE);
> + ret = EXIT_FAILURE;
> + goto out_signals;
>   }
>  
>   catch_signals();
> @@ -4321,12 +4329,15 @@ int main(int argc, char *argv[])
>  
>   wl_signal_emit(&ec->destroy_signal, ec);
>  
> - for (i = ARRAY_LENGTH(signals); i;)
> - wl_event_source_remove(signals[--i]);
> -
>   weston_compositor_xkb_destroy(ec);
>  
>   ec->destroy(ec);
> +
> +out_signals:
> + for (i = ARRAY_LENGTH(signals) - 1; i >= 0; i--)
> + if (signals[i])
> + wl_event_source_remove(signals[i]);
> +
>   wl_display_destroy(display);
>  
>   weston_log_file_close();
> 


-- 
David FORT
website: http://www.hardening-consulting.com/

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


  1   2   >