-/* $OpenBSD: ssh-agent.c,v 1.302 2023/12/18 14:46:56 djm Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.303 2023/12/18 14:48:08 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
struct sshbuf *request;
size_t nsession_ids;
struct hostkey_sid *session_ids;
+ int session_bind_attempted;
} SocketEntry;
u_int sockets_alloc = 0;
e->nsession_ids, id->ndest_constraints);
if (id->ndest_constraints == 0)
return 0; /* unconstrained */
+ if (e->session_bind_attempted && e->nsession_ids == 0) {
+ error_f("previous session bind failed on socket");
+ return -1;
+ }
if (e->nsession_ids == 0)
return 0; /* local use */
/*
return 0;
}
+static int
+socket_is_remote(SocketEntry *e)
+{
+ return e->session_bind_attempted || (e->nsession_ids != 0);
+}
+
/* return matching private key for given public key */
static Identity *
lookup_identity(struct sshkey *key)
if (strcasecmp(sk_provider, "internal") == 0) {
debug_f("internal provider");
} else {
- if (e->nsession_ids != 0 && !remote_add_provider) {
+ if (socket_is_remote(e) && !remote_add_provider) {
verbose("failed add of SK provider \"%.100s\": "
"remote addition of providers is disabled",
sk_provider);
goto send;
}
dump_dest_constraints(__func__, dest_constraints, ndest_constraints);
- if (e->nsession_ids != 0 && !remote_add_provider) {
+ if (socket_is_remote(e) && !remote_add_provider) {
verbose("failed PKCS#11 add of \"%.100s\": remote addition of "
"providers is disabled", provider);
goto send;
u_char fwd = 0;
debug2_f("entering");
+ e->session_bind_attempted = 1;
if ((r = sshkey_froms(e->request, &key)) != 0 ||
(r = sshbuf_froms(e->request, &sid)) != 0 ||
(r = sshbuf_froms(e->request, &sig)) != 0 ||