Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion authfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ int
ssh_get_authentication_socket(uid_t uid)
{
const char *authsocket;
uid_t prev_uid;
int sock;
struct sockaddr_un sunaddr;
struct stat sock_st;
Expand Down Expand Up @@ -144,6 +145,7 @@ ssh_get_authentication_socket(uid_t uid)
}

errno = 0;
prev_uid = geteuid();
/* To ensure a race condition is not used to circumvent the stat
above, we will temporarily drop UID to the caller */
if (seteuid(uid) < 0)
Expand All @@ -157,7 +159,7 @@ ssh_get_authentication_socket(uid_t uid)
}

/* we now continue the regularly scheduled programming */
if (seteuid(0) < 0)
if (seteuid(prev_uid) < 0)
return -1;

agent_present = 1;
Expand Down