mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-04 01:42:03 -05:00
os: Add QNX support for wl_os_socket_peercred()
This change introduces a QNX-specific implementation of wl_os_socket_peercred(), allowing Wayland to retrieve peer credentials on the QNX platform using LOCAL_PEERCRED. Signed-off-by: felixlionardo <flionardo@blackberry.com>
This commit is contained in:
parent
1ab6b693b1
commit
a2f2424ee8
1 changed files with 30 additions and 1 deletions
|
|
@ -40,6 +40,11 @@
|
||||||
#include <sys/ucred.h>
|
#include <sys/ucred.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__QNXNTO__)
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/ucred.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wayland-os.h"
|
#include "wayland-os.h"
|
||||||
|
|
||||||
/* used by tests */
|
/* used by tests */
|
||||||
|
|
@ -85,7 +90,31 @@ wl_os_socket_cloexec(int domain, int type, int protocol)
|
||||||
return set_cloexec_or_close(fd);
|
return set_cloexec_or_close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__QNXNTO__)
|
||||||
|
int
|
||||||
|
wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid)
|
||||||
|
{
|
||||||
|
socklen_t len;
|
||||||
|
struct xucred ucred;
|
||||||
|
|
||||||
|
len = sizeof(ucred);
|
||||||
|
if (getsockopt(sockfd, SOL_LOCAL, LOCAL_PEERCRED, &ucred, &len) < 0) {
|
||||||
|
if (errno != ENOTCONN)
|
||||||
|
return -1;
|
||||||
|
/* LOCAL_PEERCRED will report ENOTCONN for socketpair sockets */
|
||||||
|
*pid = getpid();
|
||||||
|
*uid = getuid();
|
||||||
|
*gid = getgid();
|
||||||
|
} else if (ucred.cr_version != XUCRED_VERSION) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
*uid = ucred.cr_uid;
|
||||||
|
*gid = ucred.cr_gid;
|
||||||
|
*pid = ucred.cr_pid;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
int
|
int
|
||||||
wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid)
|
wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue