2016-01-22 16:22:39 +00:00
|
|
|
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 @@
|
2015-05-27 13:08:37 +00:00
|
|
|
#include "buffer.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "authfd.h"
|
|
|
|
+#include "ssherr.h"
|
|
|
|
#include <stdio.h>
|
2016-01-22 16:22:39 +00:00
|
|
|
#include <openssl/evp.h>
|
|
|
|
#include "ssh2.h"
|
|
|
|
@@ -285,36 +286,43 @@ pamsshagentauth_find_authorized_keys(con
|
2015-05-27 13:08:37 +00:00
|
|
|
{
|
2016-01-22 16:22:39 +00:00
|
|
|
Buffer session_id2 = { 0 };
|
2015-05-27 13:08:37 +00:00
|
|
|
Identity *id;
|
|
|
|
- Key *key;
|
|
|
|
AuthenticationConnection *ac;
|
|
|
|
- char *comment;
|
|
|
|
uint8_t retval = 0;
|
2016-01-22 16:22:39 +00:00
|
|
|
uid_t uid = getpwnam(ruser)->pw_uid;
|
2015-06-02 11:28:54 +00:00
|
|
|
+ struct ssh_identitylist *idlist;
|
|
|
|
+ int r, i;
|
2015-05-27 13:08:37 +00:00
|
|
|
|
|
|
|
OpenSSL_add_all_digests();
|
2016-01-22 16:22:39 +00:00
|
|
|
pamsshagentauth_session_id2_gen(&session_id2, user, ruser, servicename);
|
2015-05-27 13:08:37 +00:00
|
|
|
|
|
|
|
if ((ac = ssh_get_authentication_connection_for_uid(uid))) {
|
2016-01-22 16:22:39 +00:00
|
|
|
verbose("Contacted ssh-agent of user %s (%u)", ruser, uid);
|
2015-05-27 13:08:37 +00:00
|
|
|
- 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));
|
2015-08-11 15:57:59 +00:00
|
|
|
+ } else {
|
2015-05-27 13:08:37 +00:00
|
|
|
+ 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;
|
2016-01-22 16:22:39 +00:00
|
|
|
if(userauth_pubkey_from_id(ruser, id, &session_id2)) {
|
2015-05-27 13:08:37 +00:00
|
|
|
retval = 1;
|
2015-06-02 11:28:54 +00:00
|
|
|
}
|
|
|
|
- free(id->filename);
|
|
|
|
- key_free(id->key);
|
|
|
|
free(id);
|
|
|
|
if(retval == 1)
|
2015-05-27 13:08:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-01-22 16:22:39 +00:00
|
|
|
buffer_free(&session_id2);
|
2015-05-27 13:08:37 +00:00
|
|
|
- ssh_close_authentication_connection(ac);
|
2015-06-02 11:28:54 +00:00
|
|
|
+ ssh_free_identitylist(idlist);
|
|
|
|
+ ssh_close_authentication_socket(ac->fd);
|
|
|
|
+ free(ac);
|
2015-08-11 15:57:59 +00:00
|
|
|
+ }
|
2015-05-27 13:08:37 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
verbose("No ssh-agent could be contacted");
|
2016-01-22 16:22:39 +00:00
|
|
|
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;
|
2015-06-02 11:28:54 +00:00
|
|
|
int
|
2016-01-22 16:22:39 +00:00
|
|
|
userauth_pubkey_from_id(const char *ruser, Identity * id, Buffer * session_id2)
|
2015-06-02 11:28:54 +00:00
|
|
|
{
|
|
|
|
- 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);
|
2016-01-22 16:22:39 +00:00
|
|
|
@@ -82,7 +83,7 @@ userauth_pubkey_from_id(const char *ruse
|
2015-05-27 13:08:37 +00:00
|
|
|
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)
|
2015-08-17 14:27:38 +00:00
|
|
|
+ if(ssh_agent_sign(id->ac->fd, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b), 0) != 0)
|
2015-05-27 13:08:37 +00:00
|
|
|
goto user_auth_clean_exit;
|
|
|
|
|
|
|
|
/* test for correct signature */
|