5b55d09
diff -up openssh/pam_ssh_agent_auth-0.10.3/identity.h.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/identity.h
5b55d09
--- openssh/pam_ssh_agent_auth-0.10.3/identity.h.psaa-agent	2016-11-13 04:24:32.000000000 +0100
5b55d09
+++ openssh/pam_ssh_agent_auth-0.10.3/identity.h	2017-09-27 14:25:49.421739027 +0200
87ab5fc
@@ -38,6 +38,12 @@
87ab5fc
 typedef struct identity Identity;
87ab5fc
 typedef struct idlist Idlist;
87ab5fc
 
87ab5fc
+typedef struct {
87ab5fc
+       int     fd;
bbf61da
+       struct sshbuf *identities;
87ab5fc
+       int     howmany;
87ab5fc
+}      AuthenticationConnection;
87ab5fc
+
87ab5fc
 struct identity {
87ab5fc
     TAILQ_ENTRY(identity) next;
87ab5fc
     AuthenticationConnection *ac;   /* set if agent supports key */
5b55d09
diff -up openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c
5b55d09
--- openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c.psaa-agent	2017-09-27 14:25:49.420739021 +0200
5b55d09
+++ openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c	2017-09-27 14:25:49.421739027 +0200
87ab5fc
@@ -39,6 +39,7 @@
bbf61da
 #include "sshbuf.h"
bbf61da
 #include "sshkey.h"
637556d
 #include "authfd.h"
637556d
+#include "ssherr.h"
637556d
 #include <stdio.h>
87ab5fc
 #include <openssl/evp.h>
87ab5fc
 #include "ssh2.h"
5b55d09
@@ -291,36 +292,43 @@ pamsshagentauth_find_authorized_keys(con
637556d
 {
bbf61da
     struct sshbuf *session_id2 = NULL;
637556d
     Identity *id;
bbf61da
-    struct sshkey *key;
637556d
     AuthenticationConnection *ac;
637556d
-    char *comment;
637556d
     uint8_t retval = 0;
87ab5fc
     uid_t uid = getpwnam(ruser)->pw_uid;
73d45fa
+    struct ssh_identitylist *idlist;
a9ad706
+    int r;
a9ad706
+    unsigned int i;
637556d
 
637556d
     OpenSSL_add_all_digests();
87ab5fc
     pamsshagentauth_session_id2_gen(&session_id2, user, ruser, servicename);
637556d
 
637556d
     if ((ac = ssh_get_authentication_connection_for_uid(uid))) {
87ab5fc
         verbose("Contacted ssh-agent of user %s (%u)", ruser, uid);
637556d
-        for (key = ssh_get_first_identity(ac, &comment, 2); key != NULL; key = ssh_get_next_identity(ac, &comment, 2)) 
c60b555
-        {
637556d
-            if(key != NULL) {
c60b555
+        if ((r = ssh_fetch_identitylist(ac->fd, &idlist)) != 0) {
c60b555
+            if (r != SSH_ERR_AGENT_NO_IDENTITIES)
c60b555
+               fprintf(stderr, "error fetching identities for "
c60b555
+                               "protocol %d: %s\n", 2, ssh_err(r));
c60b555
+        } else {
c60b555
+            for (i = 0; i < idlist->nkeys; i++)
c60b555
+            {
c60b555
+              if (idlist->keys[i] != NULL) {
637556d
                 id = xcalloc(1, sizeof(*id));
637556d
-                id->key = key;
637556d
-                id->filename = comment;
637556d
+                id->key = idlist->keys[i];
637556d
+                id->filename = idlist->comments[i];
637556d
                 id->ac = ac;
bbf61da
                 if(userauth_pubkey_from_id(ruser, id, session_id2)) {
637556d
                     retval = 1;
73d45fa
                 }
73d45fa
-                free(id->filename);
73d45fa
-                key_free(id->key);
73d45fa
                 free(id);
73d45fa
                 if(retval == 1)
637556d
                     break;
c60b555
-            }
c60b555
-        }
c60b555
+              }
c60b555
+            }
c60b555
-        sshbuf_free(session_id2);
637556d
-        ssh_close_authentication_connection(ac);
c60b555
+            sshbuf_free(session_id2);
c60b555
+            ssh_free_identitylist(idlist);
c60b555
+        }
73d45fa
+        ssh_close_authentication_socket(ac->fd);
73d45fa
+        free(ac);
637556d
     }
637556d
     else {
637556d
         verbose("No ssh-agent could be contacted");
5b55d09
diff -up openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c
5b55d09
--- openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-agent	2017-09-27 14:25:49.420739021 +0200
5b55d09
+++ openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c	2017-09-27 14:25:49.422739032 +0200
5b55d09
@@ -84,7 +85,7 @@ userauth_pubkey_from_id(const char *ruse
bbf61da
         (r = sshbuf_put_string(b, pkblob, blen)) != 0)
bbf61da
         fatal("%s: buffer error: %s", __func__, ssh_err(r));
637556d
 
bbf61da
-    if (ssh_agent_sign(id->ac, id->key, &sig, &slen, sshbuf_ptr(b), sshbuf_len(b)) != 0)
bbf61da
+    if (ssh_agent_sign(id->ac->fd, id->key, &sig, &slen, sshbuf_ptr(b), sshbuf_len(b), NULL, 0) != 0)
13073f8
         goto user_auth_clean_exit;
13073f8
 
13073f8
     /* test for correct signature */