1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-09-21 15:01:41 +02:00

agent: Fix build regression for Windows.

* agent/command-ssh.c (get_client_info): Turn client_uid into an int.
Fix setting of it in case of a failed getsocketopt.
* agent/command.c (start_command_handler): Fix setting of the pid and
uid for Windows.
--

Fixes-commit: 28aa689058
which obviously was only added to master.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-10-22 17:24:58 +02:00
parent 0a7f446c18
commit 68b8096b66
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 15 additions and 8 deletions

View File

@ -3625,7 +3625,7 @@ static void
get_client_info (int fd, struct peer_info_s *out) get_client_info (int fd, struct peer_info_s *out)
{ {
pid_t client_pid = (pid_t)(-1); pid_t client_pid = (pid_t)(-1);
uid_t client_uid = (uid_t)-1; int client_uid = -1;
#ifdef SO_PEERCRED #ifdef SO_PEERCRED
{ {
@ -3640,10 +3640,10 @@ get_client_info (int fd, struct peer_info_s *out)
{ {
#if defined (HAVE_STRUCT_SOCKPEERCRED_PID) || defined (HAVE_STRUCT_UCRED_PID) #if defined (HAVE_STRUCT_SOCKPEERCRED_PID) || defined (HAVE_STRUCT_UCRED_PID)
client_pid = cr.pid; client_pid = cr.pid;
client_uid = cr.uid; client_uid = (int)cr.uid;
#elif defined (HAVE_STRUCT_UCRED_CR_PID) #elif defined (HAVE_STRUCT_UCRED_CR_PID)
client_pid = cr.cr_pid; client_pid = cr.cr_pid;
client_pid = cr.cr_uid; client_uid = (int)cr.cr_uid;
#else #else
#error "Unknown SO_PEERCRED struct" #error "Unknown SO_PEERCRED struct"
#endif #endif
@ -3660,7 +3660,7 @@ get_client_info (int fd, struct peer_info_s *out)
len = sizeof (struct xucred); len = sizeof (struct xucred);
if (!getsockopt (fd, SOL_LOCAL, LOCAL_PEERCRED, &cr, &len)) if (!getsockopt (fd, SOL_LOCAL, LOCAL_PEERCRED, &cr, &len))
client_uid = cr.cr_uid; client_uid = (int)cr.cr_uid;
} }
#endif #endif
} }
@ -3670,8 +3670,10 @@ get_client_info (int fd, struct peer_info_s *out)
socklen_t unpl = sizeof unp; socklen_t unpl = sizeof unp;
if (getsockopt (fd, 0, LOCAL_PEEREID, &unp, &unpl) != -1) if (getsockopt (fd, 0, LOCAL_PEEREID, &unp, &unpl) != -1)
{
client_pid = unp.unp_pid; client_pid = unp.unp_pid;
client_uid = unp.unp_euid; client_uid = (int)unp.unp_euid;
}
} }
#elif defined (HAVE_GETPEERUCRED) #elif defined (HAVE_GETPEERUCRED)
{ {
@ -3680,7 +3682,7 @@ get_client_info (int fd, struct peer_info_s *out)
if (getpeerucred (fd, &ucred) != -1) if (getpeerucred (fd, &ucred) != -1)
{ {
client_pid = ucred_getpid (ucred); client_pid = ucred_getpid (ucred);
client_uid = ucred_geteuid (ucred); client_uid = (int)ucred_geteuid (ucred);
ucred_free (ucred); ucred_free (ucred);
} }
} }
@ -3689,7 +3691,7 @@ get_client_info (int fd, struct peer_info_s *out)
#endif #endif
out->pid = (client_pid == (pid_t)(-1)? 0 : (unsigned long)client_pid); out->pid = (client_pid == (pid_t)(-1)? 0 : (unsigned long)client_pid);
out->uid = (int)client_uid; out->uid = client_uid;
} }

View File

@ -3588,8 +3588,13 @@ start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd)
} }
else else
{ {
#ifdef HAVE_W32_SYSTEM
pid = assuan_get_pid (ctx);
ctrl->client_uid = -1;
#else
pid = client_creds->pid; pid = client_creds->pid;
ctrl->client_uid = client_creds->uid; ctrl->client_uid = client_creds->uid;
#endif
} }
ctrl->client_pid = (pid == ASSUAN_INVALID_PID)? 0 : (unsigned long)pid; ctrl->client_pid = (pid == ASSUAN_INVALID_PID)? 0 : (unsigned long)pid;
ctrl->server_local->connect_from_self = (pid == getpid ()); ctrl->server_local->connect_from_self = (pid == getpid ());