[PATCH] server: Add an API to get the socket fd for a client

박성진 sj76.park at samsung.com
Mon Jan 11 03:59:28 PST 2016

>From 3bdb494aa2be26ed2b8ba9115994fd5f4939d5fa Mon Sep 17 00:00:00 2001

From: Sung-Jin Park <input.hacker at gmail.com>

Date: Mon, 11 Jan 2016 18:51:21 +0900

Subject: [PATCH] server: Add an API to get the socket fd for a client


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

from a client.

For instance, this will be helpful in some linux distributions, in which

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

can validate a client request by getting socket fd of the client and by

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);


+wl_client_get_socket_fd(struct wl_client *client);



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

+ *

+ * This function returns the client socket fd for the given client.

+ *

+ * \memberof wl_client

+ */


+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



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20160111/0ea93118/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-server-Add-an-API-to-get-the-socket-fd-for-a-client.patch
Type: application/octet-stream
Size: 2067 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20160111/0ea93118/attachment-0001.obj>

More information about the wayland-devel mailing list