vishalmishra434 / rpms / openssh

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