Add a `pid` to the lttng_sock_cred structure definition used on
non-Linux platforms and receive the peer's PID when receiving
credentials.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9c92f6dda6441deca58f9cc85f846f5031cceb6e
struct lttng_sock_cred {
uid_t uid;
gid_t gid;
+ pid_t pid;
};
typedef struct lttng_sock_cred lttng_sock_cred;
#include <ucred.h>
static inline
-int getpeereid(int s, uid_t *euid, gid_t *gid)
+int getpeereid(int s, uid_t *euid, gid_t *gid, pid_t *pid)
{
int ret = 0;
ucred_t *ucred = NULL;
goto free;
}
*gid = ret;
+
+ ret = ucred_getpid(ucred);
+ if (ret == -1) {
+ goto free;
+ }
+ *pid = ret;
+
ret = 0;
free:
ucred_free(ucred);
{
int peer_ret;
- peer_ret = getpeereid(sock, &creds->uid, &creds->gid);
+ peer_ret = getpeereid(sock, &creds->uid, &creds->gid, &creds->pid);
if (peer_ret != 0) {
return peer_ret;
}