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

Sung-Jin Park input.hacker at gmail.com
Tue Jan 12 18:22:25 PST 2016


Derek, thanks for your review. :)

I'll correct the comment regarding fd and update this patch.
>Should probably just be
> * \return The fd to use for the connection

Thanks and regards,
Sung-Jin Park
2016. 1. 13. 오전 1:58에 "Derek Foreman" <derekf at osg.samsung.com>님이 작성:

> 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
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20160113/f6410bfa/attachment.html>


More information about the wayland-devel mailing list