agent: Fix sending connecting process uid to pinentry.

* agent/command-ssh.c (get_client_info): Use LOCAL_PEERCRED.

--

LOCAL_PEERUID was wrong (while there is LOCAL_PEERUUID).
For FreeBSD and macOS, we can use LOCAL_PEERCRED to get uid.

GnuPG-bug-id: 3757
Fixes-commit: 28aa689058
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2018-01-26 10:52:56 +09:00
parent c2e69a7a8c
commit 660eafa3a9
1 changed files with 9 additions and 1 deletions

View File

@ -3622,7 +3622,15 @@ get_client_info (int fd, struct peer_info_s *out)
socklen_t len = sizeof (pid_t);
getsockopt (fd, SOL_LOCAL, LOCAL_PEERPID, &client_pid, &len);
getsockopt (fd, SOL_LOCAL, LOCAL_PEERUID, &client_uid, &len);
#if defined (LOCAL_PEERCRED)
{
struct xucred cr;
len = sizeof (struct xucred);
if (!getsockopt (fd, SOL_LOCAL, LOCAL_PEERCRED, &cr, &len))
client_uid = cr.cr_uid;
}
#endif
}
#elif defined (LOCAL_PEEREID)
{