vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Blob Blame History Raw
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/identity.h.psaa-agent openssh-7.1p2/pam_ssh_agent_auth-0.10.2/identity.h
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/identity.h.psaa-agent	2014-03-31 19:35:16.000000000 +0200
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/identity.h	2016-01-22 15:47:15.999919059 +0100
@@ -38,6 +38,12 @@
 typedef struct identity Identity;
 typedef struct idlist Idlist;
 
+typedef struct {
+       int     fd;
+       Buffer  identities;
+       int     howmany;
+}      AuthenticationConnection;
+
 struct identity {
     TAILQ_ENTRY(identity) next;
     AuthenticationConnection *ac;   /* set if agent supports key */
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c.psaa-agent openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c.psaa-agent	2016-01-22 15:47:15.998919060 +0100
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c	2016-01-22 15:53:38.427768239 +0100
@@ -39,6 +39,7 @@
 #include "buffer.h"
 #include "key.h"
 #include "authfd.h"
+#include "ssherr.h"
 #include <stdio.h>
 #include <openssl/evp.h>
 #include "ssh2.h"
@@ -285,36 +286,44 @@ pamsshagentauth_find_authorized_keys(con
 {
     Buffer session_id2 = { 0 };
     Identity *id;
-    Key *key;
     AuthenticationConnection *ac;
-    char *comment;
     uint8_t retval = 0;
     uid_t uid = getpwnam(ruser)->pw_uid;
+    struct ssh_identitylist *idlist;
+    int r;
+    unsigned int i;
 
     OpenSSL_add_all_digests();
     pamsshagentauth_session_id2_gen(&session_id2, user, ruser, servicename);
 
     if ((ac = ssh_get_authentication_connection_for_uid(uid))) {
         verbose("Contacted ssh-agent of user %s (%u)", ruser, uid);
-        for (key = ssh_get_first_identity(ac, &comment, 2); key != NULL; key = ssh_get_next_identity(ac, &comment, 2)) 
+		if ((r = ssh_fetch_identitylist(ac->fd, 2,
+		    &idlist)) != 0) {
+			if (r != SSH_ERR_AGENT_NO_IDENTITIES)
+				fprintf(stderr, "error fetching identities for "
+				    "protocol %d: %s\n", 2, ssh_err(r));
+		} else {
+		for (i = 0; i < idlist->nkeys; i++)
         {
-            if(key != NULL) {
+            if(idlist->keys[i] != NULL) {
                 id = xcalloc(1, sizeof(*id));
-                id->key = key;
-                id->filename = comment;
+                id->key = idlist->keys[i];
+                id->filename = idlist->comments[i];
                 id->ac = ac;
                 if(userauth_pubkey_from_id(ruser, id, &session_id2)) {
                     retval = 1;
                 }
-                free(id->filename);
-                key_free(id->key);
                 free(id);
                 if(retval == 1)
                     break;
             }
         }
         buffer_free(&session_id2);
-        ssh_close_authentication_connection(ac);
+        ssh_free_identitylist(idlist);
+        ssh_close_authentication_socket(ac->fd);
+        free(ac);
+        }
     }
     else {
         verbose("No ssh-agent could be contacted");
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c.psaa-agent openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c.psaa-agent	2016-01-22 15:47:15.995919061 +0100
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c	2016-01-22 16:06:20.611464261 +0100
@@ -55,10 +55,11 @@ extern uint8_t  session_id_len;
 int
 userauth_pubkey_from_id(const char *ruser, Identity * id, Buffer * session_id2)
 {
-    Buffer          b = { 0 };
+    Buffer          b;
     char           *pkalg = NULL;
     u_char         *pkblob = NULL, *sig = NULL;
-    u_int           blen = 0, slen = 0;
+    u_int           blen = 0;
+    size_t          slen = 0;
     int             authenticated = 0;
 
     pkalg = (char *) key_ssh_name(id->key);
@@ -82,7 +83,7 @@ userauth_pubkey_from_id(const char *ruse
     buffer_put_cstring(&b, pkalg);
     buffer_put_string(&b, pkblob, blen);
 
-    if(ssh_agent_sign(id->ac, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b)) != 0)
+    if(ssh_agent_sign(id->ac->fd, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b), 0) != 0)
         goto user_auth_clean_exit;
 
     /* test for correct signature */
diff --git a/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c b/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
--- a/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
+++ b/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
@@ -85,7 +85,7 @@ userauth_pubkey_from_id(const char *ruser, Identity * id, Buffer * session_id2)
     buffer_put_cstring(&b, pkalg);
     buffer_put_string(&b, pkblob, blen);
 
-    if(ssh_agent_sign(id->ac->fd, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b), 0) != 0)
+    if(ssh_agent_sign(id->ac->fd, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b), NULL, 0) != 0)
         goto user_auth_clean_exit;
 
     /* test for correct signature */