jonathancammack / rpms / openssh

Forked from rpms/openssh 8 months ago
Clone

Blame SOURCES/pam_ssh_agent_auth-0.9.3-agent_structure.patch

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