[PATCH wayland v2 1/2] Extend WAYLAND_DISPLAY and name parameter semantics to support absolute paths.

Marek Chalupa mchqwerty at gmail.com
Thu Aug 6 01:37:31 PDT 2015


Hi,

the patch does not apply in the first place:

Applying: Extend WAYLAND_DISPLAY and name parameter semantics to support 
absolute paths.
fatal: corrupt patch at line 15
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.

Most of my comment regarding this patch still holds 
(https://patchwork.freedesktop.org/patch/43801/)

The main comment is below, though:

On 07/29/2015 11:34 AM, Davide Bettio wrote:
> Extend WAYLAND_DISPLAY and name parameter semantics to
> support absolute paths. For example WAYLAND_DISPLAY="/my/path/wayland-2" or
> connect_to_socket("/my/path/wayland-2").
>
> Signed-off-by: Davide Bettio <davide.bettio at ispirata.com>
> ---
>   doc/man/wl_display_connect.xml |  8 ++++----
>   src/wayland-client.c           | 22 +++++++++++++++++-----
>   src/wayland-server.c           | 23 ++++++++++++++++++-----
>   3 files changed, 39 insertions(+), 14 deletions(-)
>
> diff --git a/doc/man/wl_display_connect.xml
> b/doc/man/wl_display_connect.xml
> index 7e6e05c..b78c53f 100644
> --- a/doc/man/wl_display_connect.xml
> +++ b/doc/man/wl_display_connect.xml
> @@ -59,10 +59,10 @@
>             find it. The <varname>name</varname> argument specifies the
> name of
>             the socket or <constant>NULL</constant> to use the default
> (which is
>             <constant>"wayland-0"</constant>). The environment variable
> -          <envar>WAYLAND_DISPLAY</envar> replaces the default value. If
> -          <envar>WAYLAND_SOCKET</envar> is set, this function behaves like
> -          <function>wl_display_connect_to_fd</function> with the
> file-descriptor
> -          number taken from the environment variable.</para>
> +          <envar>WAYLAND_DISPLAY</envar> replaces the default value,
> and eventually uses
> +          a different path too. If <envar>WAYLAND_SOCKET</envar> is
> set, this function
> +          behaves like <function>wl_display_connect_to_fd</function>
> with the
> +          file-descriptor number taken from the environment
> variable.</para>
>
>       <para><function>wl_display_connect_to_fd</function> connects to a
> Wayland
>             socket with an explicit file-descriptor. The file-descriptor
> is passed
> diff --git a/src/wayland-client.c b/src/wayland-client.c
> index 6450b67..d8dd1b1 100644
> --- a/src/wayland-client.c
> +++ b/src/wayland-client.c
> @@ -771,14 +771,26 @@ connect_to_socket(const char *name)

On line 756 before this new code we check if XDG_RUNTIME_DIR is set in 
the environment and if it is not we return an error. But when you use 
absolute path, you don't need XDG_RUNTIME_DIR to be set.

>       memset(&addr, 0, sizeof addr);
>       addr.sun_family = AF_LOCAL;
> -    name_size =
> -        snprintf(addr.sun_path, sizeof addr.sun_path,
> -             "%s/%s", runtime_dir, name) + 1;
> +    if (name[0] != '/') {
> +        name_size =
> +            snprintf(addr.sun_path, sizeof addr.sun_path,
> +                 "%s/%s", runtime_dir, name) + 1;
> +    } else {
> +        /* absolute path */
> +        name_size =
> +            snprintf(addr.sun_path, sizeof addr.sun_path,
> +                 "%s", name) + 1;
> +    }
>
>       assert(name_size > 0);
>       if (name_size > (int)sizeof addr.sun_path) {
> -        wl_log("error: socket path \"%s/%s\" plus null terminator"
> -               " exceeds 108 bytes\n", runtime_dir, name);
> +        if (name[0] != '/') {
> +            wl_log("error: socket path \"%s/%s\" plus null terminator"
> +                   " exceeds %i bytes\n", runtime_dir, name, (int)
> sizeof(addr.sun_path));
> +        } else {
> +            wl_log("error: socket path \"%s\" plus null terminator"
> +                   " exceeds %i bytes\n", name, (int)
> sizeof(addr.sun_path));
> +        }
>           close(fd);
>           /* to prevent programs reporting
>            * "failed to add socket: Success" */
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index 0f04f66..fa2ad85 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -1109,15 +1109,28 @@ wl_socket_init_for_display_name(struct wl_socket
> *s, const char *name)
>       }

The same XDG_RUNTIME_DIR thing in this function.

>
>       s->addr.sun_family = AF_LOCAL;
> -    name_size = snprintf(s->addr.sun_path, sizeof s->addr.sun_path,
> -                 "%s/%s", runtime_dir, name) + 1;
> +    if (name[0] != '/') {
> +        name_size = snprintf(s->addr.sun_path, sizeof s->addr.sun_path,
> +                     "%s/%s", runtime_dir, name) + 1;
>
> -    s->display_name = (s->addr.sun_path + name_size - 1) - strlen(name);
> +        s->display_name = (s->addr.sun_path + name_size - 1) -
> strlen(name);
> +    } else {
> +        /* absolute path */
> +        name_size = snprintf(s->addr.sun_path, sizeof s->addr.sun_path,
> +                     "%s", name) + 1;
> +
> +        s->display_name = strrchr(s->addr.sun_path, '/') + 1;
> +    }
>
>       assert(name_size > 0);
>       if (name_size > (int)sizeof s->addr.sun_path) {
> -        wl_log("error: socket path \"%s/%s\" plus null terminator"
> -               " exceeds 108 bytes\n", runtime_dir, name);
> +        if (name[0] != '/') {
> +            wl_log("error: socket path \"%s/%s\" plus null terminator"
> +                               " exceeds %i bytes\n", runtime_dir,
> name, (int) sizeof(s->addr.sun_path));
> +        } else {
> +            wl_log("error: socket path \"%s\" plus null terminator"
> +                   " exceeds %i bytes\n", name, (int)
> sizeof(s->addr.sun_path));
> +        }
>           *s->addr.sun_path = 0;
>           /* to prevent programs reporting
>            * "failed to add socket: Success" */

Regards,
Marek


More information about the wayland-devel mailing list