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

Sung-Jin Park input.hacker at gmail.com
Tue Jan 12 19:14:17 PST 2016


Jonas Ådahl, thanks for your review.

wl_client_get_fd() looks better to me as well.  Including API name, I'll
correct comments as well.

Thanks and regards,
Sung-Jin Park
2016. 1. 13. 오전 11:32에 "Jonas Ådahl" <jadahl at gmail.com>님이 작성:

> On Tue, Jan 12, 2016 at 10:58:16AM -0600, Derek Foreman wrote:
> > 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
>
> s/fd/file descriptor/
>
> > > + *
> > > + * \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
>
> Maybe "file descriptor" here as well?
>
> >
> > Otherwise this looks good to me,
> > Reviewed-by: Derek Foreman <derekf at osg.samsung.com>
>
> I would also prefer the API to be "wl_client_get_fd()" as that is that
> is what all the other similar API looks like (be it a socket fd or a
> non-socket fd).
>
> Other than those issues, this looks reasonable to me, so consider it
> Reviewed-by: Jonas Ådahl <jadahl at gmail.com>
>
>
> Jonas
>
> >
> > > + *
> > > + * 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
> > >
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20160113/f4cbb57c/attachment-0001.html>


More information about the wayland-devel mailing list