[PATCH] server: Add an API to get the socket fd for a client
Derek Foreman
derekf at osg.samsung.com
Tue Jan 12 08:58:16 PST 2016
On 11/01/16 04:30 PM, Sung-Jin Park wrote:
> This adds an API to get the socket fd for a client.
> The client socket fd can be used for a wayland compositor to validate a request
> from a client.
> For instance, this will be helpful in some linux distributions, in which SELinux
> or SMACK is enabled. In those environments, each file (including socket) will have
> each security context in its inode as xattr member variable. A wayland compositor
> can validate a client request by getting socket fd of the client and by checking
> the security context associated with the socket fd.
>
> Signed-off-by: Sung-Jin Park <input.hacker at gmail.com>
> ---
> src/wayland-server-core.h | 3 +++
> src/wayland-server.c | 15 +++++++++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
> index 1700cd3..0d5fbc1 100644
> --- a/src/wayland-server-core.h
> +++ b/src/wayland-server-core.h
> @@ -182,6 +182,9 @@ void
> wl_client_get_credentials(struct wl_client *client,
> pid_t *pid, uid_t *uid, gid_t *gid);
>
> +int
> +wl_client_get_socket_fd(struct wl_client *client);
> +
> void
> wl_client_add_destroy_listener(struct wl_client *client,
> struct wl_listener *listener);
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index 55c0cf9..973a71c 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -491,6 +491,21 @@ wl_client_get_credentials(struct wl_client *client,
> *gid = client->ucred.gid;
> }
>
> +/** Get the socket fd for the client
> + *
> + * \param client The display object
> + * \return fd The fd to use for the connection
Should probably just be
* \return The fd to use for the connection
Otherwise this looks good to me,
Reviewed-by: Derek Foreman <derekf at osg.samsung.com>
> + *
> + * This function returns the client socket fd for the given client.
> + *
> + * \memberof wl_client
> + */
> +WL_EXPORT int
> +wl_client_get_socket_fd(struct wl_client *client)
> +{
> + return client->connection->fd;
> +}
> +
> /** Look up an object in the client name space
> *
> * \param client The client object
>
More information about the wayland-devel
mailing list