|
Jakub Jelen |
87ab5f |
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
|
|
Jakub Jelen |
87ab5f |
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/identity.h.psaa-agent 2014-03-31 19:35:16.000000000 +0200
|
|
Jakub Jelen |
87ab5f |
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/identity.h 2016-01-22 15:47:15.999919059 +0100
|
|
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 |
87ab5f |
+ Buffer 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 |
87ab5f |
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
|
|
Jakub Jelen |
87ab5f |
--- 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
|
|
Jakub Jelen |
87ab5f |
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c 2016-01-22 15:53:38.427768239 +0100
|
|
Jakub Jelen |
87ab5f |
@@ -39,6 +39,7 @@
|
|
Jakub Jelen |
637556 |
#include "buffer.h"
|
|
Jakub Jelen |
637556 |
#include "key.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 |
87ab5f |
@@ -285,36 +286,43 @@ pamsshagentauth_find_authorized_keys(con
|
|
Jakub Jelen |
637556 |
{
|
|
Jakub Jelen |
87ab5f |
Buffer session_id2 = { 0 };
|
|
Jakub Jelen |
637556 |
Identity *id;
|
|
Jakub Jelen |
637556 |
- Key *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 |
73d45f |
+ int r, 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 |
637556 |
+ if ((r = ssh_fetch_identitylist(ac->fd, 2,
|
|
Jakub Jelen |
637556 |
+ &idlist)) != 0) {
|
|
Jakub Jelen |
637556 |
+ if (r != SSH_ERR_AGENT_NO_IDENTITIES)
|
|
Jakub Jelen |
637556 |
+ fprintf(stderr, "error fetching identities for "
|
|
Jakub Jelen |
637556 |
+ "protocol %d: %s\n", 2, ssh_err(r));
|
|
Jakub Jelen |
405790 |
+ } else {
|
|
Jakub Jelen |
637556 |
+ for (i = 0; i < idlist->nkeys; i++)
|
|
Jakub Jelen |
637556 |
{
|
|
Jakub Jelen |
637556 |
- if(key != NULL) {
|
|
Jakub Jelen |
637556 |
+ 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 |
87ab5f |
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 |
637556 |
}
|
|
Jakub Jelen |
637556 |
}
|
|
Jakub Jelen |
87ab5f |
buffer_free(&session_id2);
|
|
Jakub Jelen |
637556 |
- ssh_close_authentication_connection(ac);
|
|
Jakub Jelen |
73d45f |
+ ssh_free_identitylist(idlist);
|
|
Jakub Jelen |
73d45f |
+ ssh_close_authentication_socket(ac->fd);
|
|
Jakub Jelen |
73d45f |
+ free(ac);
|
|
Jakub Jelen |
405790 |
+ }
|
|
Jakub Jelen |
637556 |
}
|
|
Jakub Jelen |
637556 |
else {
|
|
Jakub Jelen |
637556 |
verbose("No ssh-agent could be contacted");
|
|
Jakub Jelen |
87ab5f |
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
|
|
Jakub Jelen |
87ab5f |
--- 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
|
|
Jakub Jelen |
87ab5f |
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c 2016-01-22 16:06:20.611464261 +0100
|
|
Jakub Jelen |
87ab5f |
@@ -55,10 +55,11 @@ extern uint8_t session_id_len;
|
|
Jakub Jelen |
73d45f |
int
|
|
Jakub Jelen |
87ab5f |
userauth_pubkey_from_id(const char *ruser, Identity * id, Buffer * session_id2)
|
|
Jakub Jelen |
73d45f |
{
|
|
Jakub Jelen |
73d45f |
- Buffer b = { 0 };
|
|
Jakub Jelen |
73d45f |
+ Buffer b;
|
|
Jakub Jelen |
73d45f |
char *pkalg = NULL;
|
|
Jakub Jelen |
73d45f |
u_char *pkblob = NULL, *sig = NULL;
|
|
Jakub Jelen |
73d45f |
- u_int blen = 0, slen = 0;
|
|
Jakub Jelen |
73d45f |
+ u_int blen = 0;
|
|
Jakub Jelen |
73d45f |
+ size_t slen = 0;
|
|
Jakub Jelen |
73d45f |
int authenticated = 0;
|
|
Jakub Jelen |
73d45f |
|
|
Jakub Jelen |
73d45f |
pkalg = (char *) key_ssh_name(id->key);
|
|
Jakub Jelen |
87ab5f |
@@ -82,7 +83,7 @@ userauth_pubkey_from_id(const char *ruse
|
|
Jakub Jelen |
637556 |
buffer_put_cstring(&b, pkalg);
|
|
Jakub Jelen |
637556 |
buffer_put_string(&b, pkblob, blen);
|
|
Jakub Jelen |
637556 |
|
|
Jakub Jelen |
637556 |
- if(ssh_agent_sign(id->ac, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b)) != 0)
|
|
Jakub Jelen |
459bd2 |
+ if(ssh_agent_sign(id->ac->fd, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b), 0) != 0)
|
|
Jakub Jelen |
637556 |
goto user_auth_clean_exit;
|
|
Jakub Jelen |
637556 |
|
|
Jakub Jelen |
637556 |
/* test for correct signature */
|
|
Jakub Jelen |
13073f |
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
|
|
Jakub Jelen |
13073f |
--- a/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
|
|
Jakub Jelen |
13073f |
+++ b/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
|
|
Jakub Jelen |
13073f |
@@ -85,7 +85,7 @@ userauth_pubkey_from_id(const char *ruser, Identity * id, Buffer * session_id2)
|
|
Jakub Jelen |
13073f |
buffer_put_cstring(&b, pkalg);
|
|
Jakub Jelen |
13073f |
buffer_put_string(&b, pkblob, blen);
|
|
Jakub Jelen |
13073f |
|
|
Jakub Jelen |
13073f |
- if(ssh_agent_sign(id->ac->fd, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b), 0) != 0)
|
|
Jakub Jelen |
13073f |
+ if(ssh_agent_sign(id->ac->fd, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b), NULL, 0) != 0)
|
|
Jakub Jelen |
13073f |
goto user_auth_clean_exit;
|
|
Jakub Jelen |
13073f |
|
|
Jakub Jelen |
13073f |
/* test for correct signature */
|
|
Jakub Jelen |
13073f |
|