rutwa189 / rpms / openssh

Forked from rpms/openssh a year ago
Clone

Blame SOURCES/pam_ssh_agent_auth-0.9.2-seteuid.patch

f09e2e
diff -up pam_ssh_agent_auth-0.9.2/iterate_ssh_agent_keys.c.seteuid pam_ssh_agent_auth-0.9.2/iterate_ssh_agent_keys.c
f09e2e
--- pam_ssh_agent_auth-0.9.2/iterate_ssh_agent_keys.c.seteuid	2010-09-08 08:54:29.000000000 +0200
f09e2e
+++ pam_ssh_agent_auth-0.9.2/iterate_ssh_agent_keys.c	2010-11-22 08:38:05.000000000 +0100
f09e2e
@@ -131,13 +131,18 @@ ssh_get_authentication_socket_for_uid(ui
f09e2e
 	}
f09e2e
 
f09e2e
 	errno = 0; 
f09e2e
-	seteuid(uid); /* To ensure a race condition is not used to circumvent the stat
f09e2e
-	             above, we will temporarily drop UID to the caller */
f09e2e
+	/* To ensure a race condition is not used to circumvent the stat
f09e2e
+	   above, we will temporarily drop UID to the caller */
f09e2e
+	if (seteuid(uid) == -1) {
f09e2e
+		close(sock);
f09e2e
+		error("seteuid(%lu) failed", (unsigned long) uid);
f09e2e
+		return -1;
f09e2e
+	}
f09e2e
 	if (connect(sock, (struct sockaddr *)&sunaddr, sizeof sunaddr) < 0) {
f09e2e
 		close(sock);
f09e2e
-        if(errno == EACCES)
f09e2e
-		fatal("MAJOR SECURITY WARNING: uid %lu made a deliberate and malicious attempt to open an agent socket owned by another user", (unsigned long) uid);
f09e2e
-		return -1;
f09e2e
+		sock = -1;
f09e2e
+		if(errno == EACCES)
f09e2e
+			fatal("MAJOR SECURITY WARNING: uid %lu made a deliberate and malicious attempt to open an agent socket owned by another user", (unsigned long) uid);
f09e2e
 	}
f09e2e
 
f09e2e
 	seteuid(0); /* we now continue the regularly scheduled programming */