kentpeacock / rpms / openssh

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