|
Jakub Jelen |
637556 |
diff --git a/pam_ssh_agent_auth-0.9.3/iterate_ssh_agent_keys.c b/pam_ssh_agent_auth-0.9.3/iterate_ssh_agent_keys.c
|
|
Jakub Jelen |
637556 |
index 9555e7e..c17aae6 100644
|
|
Jakub Jelen |
637556 |
--- a/iterate_ssh_agent_keys.c 2015-05-27 14:09:13.591407306 +0200
|
|
Jakub Jelen |
637556 |
+++ b/iterate_ssh_agent_keys.c 2015-05-27 14:10:33.216267826 +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 |
637556 |
@@ -177,22 +177,28 @@ 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 |
637556 |
+ struct ssh_identitylist *idlist;
|
|
Jakub Jelen |
637556 |
+ 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 |
637556 |
+ }
|
|
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 |
637556 |
@@ -204,7 +211,10 @@ find_authorized_keys(uid_t uid)
|
|
Jakub Jelen |
637556 |
break;
|
|
Jakub Jelen |
637556 |
}
|
|
Jakub Jelen |
637556 |
}
|
|
Jakub Jelen |
637556 |
+ ssh_free_identitylist(idlist);
|
|
Jakub Jelen |
637556 |
+ ssh_close_authentication_socket(ac->fd);
|
|
Jakub Jelen |
637556 |
+ buffer_free(&ac->identities);
|
|
Jakub Jelen |
637556 |
+ free(ac);
|
|
Jakub Jelen |
637556 |
- ssh_close_authentication_connection(ac);
|
|
Jakub Jelen |
637556 |
}
|
|
Jakub Jelen |
637556 |
else {
|
|
Jakub Jelen |
637556 |
verbose("No ssh-agent could be contacted");
|
|
Jakub Jelen |
637556 |
diff --git a/pam_ssh_agent_auth-0.9.3/identity.h b/pam_ssh_agent_auth-0.9.3/identity.h
|
|
Jakub Jelen |
637556 |
index eb21320..c00da34 100644
|
|
Jakub Jelen |
637556 |
--- a/pam_ssh_agent_auth-0.9.3/identity.h
|
|
Jakub Jelen |
637556 |
+++ b/pam_ssh_agent_auth-0.9.3/identity.h
|
|
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 |
637556 |
diff --git a/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c b/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c
|
|
Jakub Jelen |
637556 |
index 323817a..93b928f 100644
|
|
Jakub Jelen |
637556 |
--- a/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c
|
|
Jakub Jelen |
637556 |
+++ b/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c
|
|
Jakub Jelen |
637556 |
@@ -81,7 +81,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 |
637556 |
+ if(ssh_agent_sign(id->ac->fd, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b), 1) != 0)
|
|
Jakub Jelen |
637556 |
goto user_auth_clean_exit;
|
|
Jakub Jelen |
637556 |
|
|
Jakub Jelen |
637556 |
/* test for correct signature */
|
|
Jakub Jelen |
637556 |
|