[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unix sockets and client PID



Hi

I'm trying to get the PID from a connecting process using a Unix socket.
On FreeBSD, it is possible to send a message of type SCM_CREDS on
sendmsg, which leads me to a cmsgcred structure:

struct cmsgcred {
	pid_t	cmcred_pid;	/* PID of sending process */
	uid_t	cmcred_uid;	/* real UID of sending process */
	uid_t	cmcred_euid;	/* effective UID of sending process */
	gid_t	cmcred_gid;	/* real GID of sending process */
	short	cmcred_ngroups;	/* number or groups */
	gid_t	cmcred_groups[CMGROUP_MAX];	/* groups */
};

However, on OpenBSD, using SCM_CREDS leads me to a sockcred structure,
which doesn't have a field for the PID:

struct sockcred {
	uid_t	sc_uid;		/* real user id */
	uid_t	sc_euid;	/* effective user id */
	gid_t	sc_gid;		/* real group id */
	gid_t	sc_egid;	/* effective group id */
	int	sc_ngroups;	/* number of supplemental groups */
	gid_t	sc_groups[1];	/* variable length */
};

What is the standard way to do this on OpenBSD?

Best regards,
Andre