|
|
f5835d |
diff -up openssh-7.4p1/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c.psaa-seteuid openssh-7.4p1/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c
|
|
|
f5835d |
--- openssh-7.4p1/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c.psaa-seteuid 2017-02-07 15:41:53.172334151 +0100
|
|
|
f5835d |
+++ openssh-7.4p1/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c 2017-02-07 15:41:53.174334149 +0100
|
|
|
f5835d |
@@ -238,17 +238,26 @@ ssh_get_authentication_socket_for_uid(ui
|
|
|
f5835d |
}
|
|
|
f5835d |
|
|
|
f5835d |
errno = 0;
|
|
|
f5835d |
- seteuid(uid); /* To ensure a race condition is not used to circumvent the stat
|
|
|
f5835d |
- above, we will temporarily drop UID to the caller */
|
|
|
f5835d |
- if (connect(sock, (struct sockaddr *)&sunaddr, sizeof sunaddr) < 0) {
|
|
|
f5835d |
+ /* To ensure a race condition is not used to circumvent the stat
|
|
|
f5835d |
+ above, we will temporarily drop UID to the caller */
|
|
|
f5835d |
+ if (seteuid(uid) == -1) {
|
|
|
f5835d |
close(sock);
|
|
|
f5835d |
- if(errno == EACCES)
|
|
|
f5835d |
- fatal("MAJOR SECURITY WARNING: uid %lu made a deliberate and malicious attempt to open an agent socket owned by another user", (unsigned long) uid);
|
|
|
f5835d |
+ error("seteuid(%lu) failed with error: %s",
|
|
|
f5835d |
+ (unsigned long) uid, strerror(errno));
|
|
|
f5835d |
return -1;
|
|
|
f5835d |
}
|
|
|
f5835d |
+ if (connect(sock, (struct sockaddr *)&sunaddr, sizeof sunaddr) < 0) {
|
|
|
f5835d |
+ close(sock);
|
|
|
f5835d |
+ sock = -1;
|
|
|
f5835d |
+ if(errno == EACCES)
|
|
|
f5835d |
+ fatal("MAJOR SECURITY WARNING: uid %lu made a deliberate and malicious attempt to open an agent socket owned by another user", (unsigned long) uid);
|
|
|
f5835d |
+ }
|
|
|
f5835d |
|
|
|
f5835d |
- seteuid(0); /* we now continue the regularly scheduled programming */
|
|
|
f5835d |
-
|
|
|
f5835d |
+ /* we now continue the regularly scheduled programming */
|
|
|
f5835d |
+ if (0 != seteuid(0)) {
|
|
|
f5835d |
+ fatal("setuid(0) failed with error: %s", strerror(errno));
|
|
|
f5835d |
+ return -1;
|
|
|
f5835d |
+ }
|
|
|
f5835d |
return sock;
|
|
|
f5835d |
}
|
|
|
f5835d |
|