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