|
Jakub Jelen |
73d45f |
diff -up openssh-6.8p1/pam_ssh_agent_auth-0.9.3/iterate_ssh_agent_keys.c.psaa-agent openssh-6.8p1/pam_ssh_agent_auth-0.9.3/iterate_ssh_agent_keys.c
|
|
Jakub Jelen |
73d45f |
--- openssh-6.8p1/pam_ssh_agent_auth-0.9.3/iterate_ssh_agent_keys.c.psaa-agent 2015-06-02 16:43:09.231902255 +0200
|
|
Jakub Jelen |
73d45f |
+++ openssh-6.8p1/pam_ssh_agent_auth-0.9.3/iterate_ssh_agent_keys.c 2015-06-02 16:43:09.235902253 +0200
|
|
Jakub Jelen |
637556 |
@@ -37,6 +37,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 "ssh.h"
|
|
Jakub Jelen |
637556 |
#include <stdio.h>
|
|
Jakub Jelen |
637556 |
#include <sys/types.h>
|
|
Jakub Jelen |
405790 |
@@ -177,34 +178,41 @@ int
|
|
Jakub Jelen |
637556 |
find_authorized_keys(uid_t uid)
|
|
Jakub Jelen |
637556 |
{
|
|
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 |
73d45f |
+ struct ssh_identitylist *idlist;
|
|
Jakub Jelen |
73d45f |
+ int r, i;
|
|
Jakub Jelen |
637556 |
|
|
Jakub Jelen |
637556 |
OpenSSL_add_all_digests();
|
|
Jakub Jelen |
637556 |
session_id2 = session_id2_gen();
|
|
Jakub Jelen |
637556 |
|
|
Jakub Jelen |
637556 |
if ((ac = ssh_get_authentication_connection_for_uid(uid))) {
|
|
Jakub Jelen |
637556 |
verbose("Contacted ssh-agent of user %s (%u)", getpwuid(uid)->pw_name, 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 |
637556 |
if(userauth_pubkey_from_id(id)) {
|
|
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 |
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 |
73d45f |
diff -up openssh-6.8p1/pam_ssh_agent_auth-0.9.3/identity.h.psaa-agent openssh-6.8p1/pam_ssh_agent_auth-0.9.3/identity.h
|
|
Jakub Jelen |
73d45f |
--- openssh-6.8p1/pam_ssh_agent_auth-0.9.3/identity.h.psaa-agent 2009-08-09 02:54:21.000000000 +0200
|
|
Jakub Jelen |
73d45f |
+++ openssh-6.8p1/pam_ssh_agent_auth-0.9.3/identity.h 2015-06-02 16:43:09.235902253 +0200
|
|
Jakub Jelen |
637556 |
@@ -14,6 +14,12 @@
|
|
Jakub Jelen |
637556 |
typedef struct identity Identity;
|
|
Jakub Jelen |
637556 |
typedef struct idlist Idlist;
|
|
Jakub Jelen |
637556 |
|
|
Jakub Jelen |
637556 |
+typedef struct {
|
|
Jakub Jelen |
637556 |
+ int fd;
|
|
Jakub Jelen |
637556 |
+ Buffer identities;
|
|
Jakub Jelen |
637556 |
+ int howmany;
|
|
Jakub Jelen |
637556 |
+} AuthenticationConnection;
|
|
Jakub Jelen |
637556 |
+
|
|
Jakub Jelen |
637556 |
struct identity {
|
|
Jakub Jelen |
637556 |
TAILQ_ENTRY(identity) next;
|
|
Jakub Jelen |
637556 |
AuthenticationConnection *ac; /* set if agent supports key */
|
|
Jakub Jelen |
73d45f |
diff -up openssh-6.8p1/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c.psaa-agent openssh-6.8p1/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c
|
|
Jakub Jelen |
73d45f |
--- openssh-6.8p1/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c.psaa-agent 2015-06-02 16:43:09.232902254 +0200
|
|
Jakub Jelen |
73d45f |
+++ openssh-6.8p1/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c 2015-06-02 16:45:07.699822094 +0200
|
|
Jakub Jelen |
73d45f |
@@ -54,10 +54,11 @@ extern uint8_t session_id_len;
|
|
Jakub Jelen |
73d45f |
int
|
|
Jakub Jelen |
73d45f |
userauth_pubkey_from_id(Identity * id)
|
|
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 |
73d45f |
@@ -65,10 +65,10 @@ userauth_pubkey_from_id(Identity * id)
|
|
Jakub Jelen |
73d45f |
|
|
Jakub Jelen |
73d45f |
/* first test if this key is even allowed */
|
|
Jakub Jelen |
73d45f |
if(! pam_user_key_allowed(id->key))
|
|
Jakub Jelen |
73d45f |
- goto user_auth_clean_exit;
|
|
Jakub Jelen |
73d45f |
+ goto user_auth_clean_exit_without_buffer;
|
|
Jakub Jelen |
73d45f |
|
|
Jakub Jelen |
73d45f |
if(key_to_blob(id->key, &pkblob, &blen) == 0)
|
|
Jakub Jelen |
73d45f |
- goto user_auth_clean_exit;
|
|
Jakub Jelen |
73d45f |
+ goto user_auth_clean_exit_without_buffer;
|
|
Jakub Jelen |
73d45f |
|
|
Jakub Jelen |
73d45f |
/* construct packet to sign and test */
|
|
Jakub Jelen |
73d45f |
buffer_init(&b);
|
|
Jakub Jelen |
73d45f |
@@ -70,7 +70,7 @@ userauth_pubkey_from_id(Identity * id)
|
|
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 |
73d45f |
@@ -92,6 +92,7 @@ userauth_pubkey_from_id(Identity * id)
|
|
Jakub Jelen |
73d45f |
user_auth_clean_exit:
|
|
Jakub Jelen |
73d45f |
if(&b != NULL)
|
|
Jakub Jelen |
73d45f |
buffer_free(&b);
|
|
Jakub Jelen |
73d45f |
+ user_auth_clean_exit_without_buffer:
|
|
Jakub Jelen |
73d45f |
if(sig != NULL)
|
|
Jakub Jelen |
73d45f |
free(sig);
|
|
Jakub Jelen |
73d45f |
if(pkblob != NULL)
|