|
|
943807 |
diff -up openssh/pam_ssh_agent_auth-0.10.3/identity.h.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/identity.h
|
|
|
943807 |
--- openssh/pam_ssh_agent_auth-0.10.3/identity.h.psaa-agent 2016-11-13 04:24:32.000000000 +0100
|
|
|
943807 |
+++ openssh/pam_ssh_agent_auth-0.10.3/identity.h 2017-09-27 14:25:49.421739027 +0200
|
|
|
943807 |
@@ -38,6 +38,12 @@
|
|
|
943807 |
typedef struct identity Identity;
|
|
|
943807 |
typedef struct idlist Idlist;
|
|
|
943807 |
|
|
|
943807 |
+typedef struct {
|
|
|
943807 |
+ int fd;
|
|
|
943807 |
+ struct sshbuf *identities;
|
|
|
943807 |
+ int howmany;
|
|
|
943807 |
+} AuthenticationConnection;
|
|
|
943807 |
+
|
|
|
943807 |
struct identity {
|
|
|
943807 |
TAILQ_ENTRY(identity) next;
|
|
|
943807 |
AuthenticationConnection *ac; /* set if agent supports key */
|
|
|
943807 |
diff -up openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c
|
|
|
943807 |
--- openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c.psaa-agent 2017-09-27 14:25:49.420739021 +0200
|
|
|
943807 |
+++ openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c 2017-09-27 14:25:49.421739027 +0200
|
|
|
943807 |
@@ -39,6 +39,7 @@
|
|
|
943807 |
#include "sshbuf.h"
|
|
|
943807 |
#include "sshkey.h"
|
|
|
943807 |
#include "authfd.h"
|
|
|
943807 |
+#include "ssherr.h"
|
|
|
943807 |
#include <stdio.h>
|
|
|
943807 |
#include <openssl/evp.h>
|
|
|
943807 |
#include "ssh2.h"
|
|
|
943807 |
@@ -291,36 +292,43 @@ pamsshagentauth_find_authorized_keys(con
|
|
|
943807 |
{
|
|
|
943807 |
struct sshbuf *session_id2 = NULL;
|
|
|
943807 |
Identity *id;
|
|
|
943807 |
- struct sshkey *key;
|
|
|
943807 |
AuthenticationConnection *ac;
|
|
|
943807 |
- char *comment;
|
|
|
943807 |
uint8_t retval = 0;
|
|
|
943807 |
uid_t uid = getpwnam(ruser)->pw_uid;
|
|
|
943807 |
+ struct ssh_identitylist *idlist;
|
|
|
943807 |
+ int r;
|
|
|
943807 |
+ unsigned int i;
|
|
|
943807 |
|
|
|
943807 |
OpenSSL_add_all_digests();
|
|
|
943807 |
pamsshagentauth_session_id2_gen(&session_id2, user, ruser, servicename);
|
|
|
943807 |
|
|
|
943807 |
if ((ac = ssh_get_authentication_connection_for_uid(uid))) {
|
|
|
943807 |
verbose("Contacted ssh-agent of user %s (%u)", ruser, uid);
|
|
|
943807 |
- for (key = ssh_get_first_identity(ac, &comment, 2); key != NULL; key = ssh_get_next_identity(ac, &comment, 2))
|
|
|
943807 |
- {
|
|
|
943807 |
- if(key != NULL) {
|
|
|
943807 |
+ if ((r = ssh_fetch_identitylist(ac->fd, &idlist)) != 0) {
|
|
|
943807 |
+ if (r != SSH_ERR_AGENT_NO_IDENTITIES)
|
|
|
943807 |
+ fprintf(stderr, "error fetching identities for "
|
|
|
943807 |
+ "protocol %d: %s\n", 2, ssh_err(r));
|
|
|
943807 |
+ } else {
|
|
|
943807 |
+ for (i = 0; i < idlist->nkeys; i++)
|
|
|
943807 |
+ {
|
|
|
943807 |
+ if (idlist->keys[i] != NULL) {
|
|
|
943807 |
id = xcalloc(1, sizeof(*id));
|
|
|
943807 |
- id->key = key;
|
|
|
943807 |
- id->filename = comment;
|
|
|
943807 |
+ id->key = idlist->keys[i];
|
|
|
943807 |
+ id->filename = idlist->comments[i];
|
|
|
943807 |
id->ac = ac;
|
|
|
943807 |
if(userauth_pubkey_from_id(ruser, id, session_id2)) {
|
|
|
943807 |
retval = 1;
|
|
|
943807 |
}
|
|
|
943807 |
- free(id->filename);
|
|
|
943807 |
- key_free(id->key);
|
|
|
943807 |
free(id);
|
|
|
943807 |
if(retval == 1)
|
|
|
943807 |
break;
|
|
|
943807 |
- }
|
|
|
943807 |
- }
|
|
|
943807 |
+ }
|
|
|
943807 |
+ }
|
|
|
943807 |
- sshbuf_free(session_id2);
|
|
|
943807 |
- ssh_close_authentication_connection(ac);
|
|
|
943807 |
+ sshbuf_free(session_id2);
|
|
|
943807 |
+ ssh_free_identitylist(idlist);
|
|
|
943807 |
+ }
|
|
|
943807 |
+ ssh_close_authentication_socket(ac->fd);
|
|
|
943807 |
+ free(ac);
|
|
|
943807 |
}
|
|
|
943807 |
else {
|
|
|
943807 |
verbose("No ssh-agent could be contacted");
|
|
|
943807 |
diff -up openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c
|
|
|
943807 |
--- openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-agent 2017-09-27 14:25:49.420739021 +0200
|
|
|
943807 |
+++ openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c 2017-09-27 14:25:49.422739032 +0200
|
|
|
943807 |
@@ -84,7 +85,7 @@ userauth_pubkey_from_id(const char *ruse
|
|
|
943807 |
(r = sshbuf_put_string(b, pkblob, blen)) != 0)
|
|
|
943807 |
fatal("%s: buffer error: %s", __func__, ssh_err(r));
|
|
|
943807 |
|
|
|
943807 |
- if (ssh_agent_sign(id->ac, id->key, &sig, &slen, sshbuf_ptr(b), sshbuf_len(b)) != 0)
|
|
|
943807 |
+ if (ssh_agent_sign(id->ac->fd, id->key, &sig, &slen, sshbuf_ptr(b), sshbuf_len(b), NULL, 0) != 0)
|
|
|
943807 |
goto user_auth_clean_exit;
|
|
|
943807 |
|
|
|
943807 |
/* test for correct signature */
|