kentpeacock / rpms / openssh

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