aboutsummaryrefslogtreecommitdiffstats
path: root/src/wayland-server.c
diff options
context:
space:
mode:
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2021-03-15 22:21:12 +0000
committerAlexander Richardson <alexander.richardson@cl.cam.ac.uk>2021-09-10 11:35:54 +0000
commit54b237a61257a41d35d018c5871331bdf1df77a6 (patch)
tree97febf193bf1ea57e8eb5b6b5c5530bd71a5001d /src/wayland-server.c
parentgitlab-ci: add junit reports to the debian builder (diff)
downloadwayland-54b237a61257a41d35d018c5871331bdf1df77a6.tar
wayland-54b237a61257a41d35d018c5871331bdf1df77a6.tar.gz
wayland-54b237a61257a41d35d018c5871331bdf1df77a6.tar.bz2
wayland-54b237a61257a41d35d018c5871331bdf1df77a6.tar.lz
wayland-54b237a61257a41d35d018c5871331bdf1df77a6.tar.xz
wayland-54b237a61257a41d35d018c5871331bdf1df77a6.tar.zst
wayland-54b237a61257a41d35d018c5871331bdf1df77a6.zip
Support reading ucred from the socket on FreeBSD
On FreeBSD we have to use getsockopt(fd, SOL_LOCAL, LOCAL_PEERCRED) instead. This change is based on a downstream patch in FreeBSD ports. Co-authored-by: Greg V <greg@unrelenting.technology> Co-authored-by: Koop Mast <kwm@rainbow-runner.nl> Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Diffstat (limited to 'src/wayland-server.c')
-rw-r--r--src/wayland-server.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 4783ab3..4778d85 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -78,7 +78,9 @@ struct wl_client {
struct wl_list link;
struct wl_map objects;
struct wl_priv_signal destroy_signal;
- struct ucred ucred;
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
int error;
struct wl_priv_signal resource_created_signal;
};
@@ -314,7 +316,7 @@ wl_resource_post_error(struct wl_resource *resource,
static void
destroy_client_with_error(struct wl_client *client, const char *reason)
{
- wl_log("%s (pid %u)\n", reason, client->ucred.pid);
+ wl_log("%s (pid %u)\n", reason, client->pid);
wl_client_destroy(client);
}
@@ -513,7 +515,6 @@ WL_EXPORT struct wl_client *
wl_client_create(struct wl_display *display, int fd)
{
struct wl_client *client;
- socklen_t len;
client = zalloc(sizeof *client);
if (client == NULL)
@@ -528,9 +529,8 @@ wl_client_create(struct wl_display *display, int fd)
if (!client->source)
goto err_client;
- len = sizeof client->ucred;
- if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED,
- &client->ucred, &len) < 0)
+ if (wl_os_socket_peercred(fd, &client->uid, &client->gid,
+ &client->pid) != 0)
goto err_source;
client->connection = wl_connection_create(fd);
@@ -586,11 +586,11 @@ wl_client_get_credentials(struct wl_client *client,
pid_t *pid, uid_t *uid, gid_t *gid)
{
if (pid)
- *pid = client->ucred.pid;
+ *pid = client->pid;
if (uid)
- *uid = client->ucred.uid;
+ *uid = client->uid;
if (gid)
- *gid = client->ucred.gid;
+ *gid = client->gid;
}
/** Get the file descriptor for the client