|
Jakub Jelen |
5b55d0 |
diff -up openssh/pam_ssh_agent_auth-0.10.3/identity.h.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/identity.h
|
|
Jakub Jelen |
5b55d0 |
--- openssh/pam_ssh_agent_auth-0.10.3/identity.h.psaa-agent 2016-11-13 04:24:32.000000000 +0100
|
|
Jakub Jelen |
5b55d0 |
+++ openssh/pam_ssh_agent_auth-0.10.3/identity.h 2017-09-27 14:25:49.421739027 +0200
|
|
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 |
5b55d0 |
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
|
|
Jakub Jelen |
5b55d0 |
--- openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c.psaa-agent 2017-09-27 14:25:49.420739021 +0200
|
|
Jakub Jelen |
5b55d0 |
+++ openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c 2017-09-27 14:25:49.421739027 +0200
|
|
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 |
5b55d0 |
@@ -291,36 +292,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 |
a9ad70 |
+ int r;
|
|
Jakub Jelen |
a9ad70 |
+ unsigned int 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 |
5b55d0 |
+ if ((r = ssh_fetch_identitylist(ac->fd, &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 |
5b55d0 |
diff -up openssh/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c
|
|
Jakub Jelen |
5b55d0 |
--- openssh/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c.psaa-agent 2017-09-27 14:26:04.277820716 +0200
|
|
Jakub Jelen |
5b55d0 |
+++ openssh/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c 2017-09-27 14:26:34.426986497 +0200
|
|
Jakub Jelen |
5b55d0 |
@@ -70,7 +70,7 @@ pamsshagentauth_check_authkeys_file(FILE
|
|
Jakub Jelen |
5b55d0 |
char *fp;
|
|
Jakub Jelen |
5b55d0 |
|
|
Jakub Jelen |
5b55d0 |
found_key = 0;
|
|
Jakub Jelen |
5b55d0 |
- found = key_new(key->type);
|
|
Jakub Jelen |
5b55d0 |
+ found = sshkey_new(key->type);
|
|
Jakub Jelen |
5b55d0 |
|
|
Jakub Jelen |
5b55d0 |
while(read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) {
|
|
Jakub Jelen |
5b55d0 |
char *cp = NULL; /* *key_options = NULL; */
|
|
Jakub Jelen |
5b55d0 |
@@ -80,7 +80,7 @@ pamsshagentauth_check_authkeys_file(FILE
|
|
Jakub Jelen |
5b55d0 |
if(!*cp || *cp == '\n' || *cp == '#')
|
|
Jakub Jelen |
5b55d0 |
continue;
|
|
Jakub Jelen |
5b55d0 |
|
|
Jakub Jelen |
5b55d0 |
- if(key_read(found, &cp) != 1) {
|
|
Jakub Jelen |
5b55d0 |
+ if(sshkey_read(found, &cp) != 0) {
|
|
Jakub Jelen |
5b55d0 |
/* no key? check if there are options for this key */
|
|
Jakub Jelen |
5b55d0 |
int quoted = 0;
|
|
Jakub Jelen |
5b55d0 |
|
|
Jakub Jelen |
5b55d0 |
@@ -94,24 +94,24 @@ pamsshagentauth_check_authkeys_file(FILE
|
|
Jakub Jelen |
5b55d0 |
}
|
|
Jakub Jelen |
5b55d0 |
/* Skip remaining whitespace. */
|
|
Jakub Jelen |
5b55d0 |
for(; *cp == ' ' || *cp == '\t'; cp++);
|
|
Jakub Jelen |
5b55d0 |
- if(key_read(found, &cp) != 1) {
|
|
Jakub Jelen |
5b55d0 |
+ if(sshkey_read(found, &cp) != 0) {
|
|
Jakub Jelen |
5b55d0 |
verbose("user_key_allowed: advance: '%s'", cp);
|
|
Jakub Jelen |
5b55d0 |
/* still no key? advance to next line */
|
|
Jakub Jelen |
5b55d0 |
continue;
|
|
Jakub Jelen |
5b55d0 |
}
|
|
Jakub Jelen |
5b55d0 |
}
|
|
Jakub Jelen |
5b55d0 |
- if(key_equal(found, key)) {
|
|
Jakub Jelen |
5b55d0 |
+ if(sshkey_equal(found, key)) {
|
|
Jakub Jelen |
5b55d0 |
found_key = 1;
|
|
Jakub Jelen |
5b55d0 |
logit("matching key found: file/command %s, line %lu", file,
|
|
Jakub Jelen |
5b55d0 |
linenum);
|
|
Jakub Jelen |
5b55d0 |
fp = sshkey_fingerprint(found, SSH_DIGEST_MD5, SSH_FP_HEX);
|
|
Jakub Jelen |
5b55d0 |
logit("Found matching %s key: %s",
|
|
Jakub Jelen |
5b55d0 |
- key_type(found), fp);
|
|
Jakub Jelen |
5b55d0 |
+ sshkey_type(found), fp);
|
|
Jakub Jelen |
5b55d0 |
free(fp);
|
|
Jakub Jelen |
5b55d0 |
break;
|
|
Jakub Jelen |
5b55d0 |
}
|
|
Jakub Jelen |
5b55d0 |
}
|
|
Jakub Jelen |
5b55d0 |
- key_free(found);
|
|
Jakub Jelen |
5b55d0 |
+ sshkey_free(found);
|
|
Jakub Jelen |
5b55d0 |
if(!found_key)
|
|
Jakub Jelen |
5b55d0 |
verbose("key not found");
|
|
Jakub Jelen |
5b55d0 |
return found_key;
|
|
Jakub Jelen |
5b55d0 |
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
|
|
Jakub Jelen |
5b55d0 |
--- openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-agent 2017-09-27 14:25:49.420739021 +0200
|
|
Jakub Jelen |
5b55d0 |
+++ openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c 2017-09-27 14:25:49.422739032 +0200
|
|
Jakub Jelen |
5b55d0 |
@@ -57,10 +57,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 |
5b55d0 |
@@ -84,7 +85,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 |
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 |
3cd489 |
diff -up openssh-7.7p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-sshkey openssh-7.7p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c
|
|
Jakub Jelen |
3cd489 |
--- openssh-7.7p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-sshkey 2018-04-04 13:55:02.383899631 +0200
|
|
Jakub Jelen |
3cd489 |
+++ openssh-7.7p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c 2018-04-04 13:58:36.759339845 +0200
|
|
Jakub Jelen |
3cd489 |
@@ -89,7 +89,7 @@ userauth_pubkey_from_id(const char *ruse
|
|
Jakub Jelen |
3cd489 |
goto user_auth_clean_exit;
|
|
Jakub Jelen |
3cd489 |
|
|
Jakub Jelen |
3cd489 |
/* test for correct signature */
|
|
Jakub Jelen |
3cd489 |
- if(key_verify(id->key, sig, slen, buffer_ptr(&b), buffer_len(&b)) == 1)
|
|
Jakub Jelen |
3cd489 |
+ if(sshkey_verify(id->key, sig, slen, buffer_ptr(&b), buffer_len(&b), NULL, 0) == 0)
|
|
Jakub Jelen |
3cd489 |
authenticated = 1;
|
|
Jakub Jelen |
3cd489 |
|
|
Jakub Jelen |
3cd489 |
user_auth_clean_exit:
|