Skip to content

Commit 6f3fff7

Browse files
committed
close TLS sockets when they're being removed
which helps prevent OpenSSL confusion. It doesn't check if the underlying socket is closed, and instead just returns an error
1 parent ce1b7e5 commit 6f3fff7

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/include/radiusd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,9 @@ int fr_bool_auto_parse(CONF_PAIR *cp, fr_bool_auto_t *out, char const *str);
587587
void listen_free(rad_listen_t **head);
588588
int listen_init(CONF_SECTION *cs, rad_listen_t **head, bool spawn_flag);
589589
rad_listen_t *proxy_new_listener(TALLOC_CTX *ctx, home_server_t *home, uint16_t src_port);
590+
#ifdef WITH_TLS
591+
void proxy_tls_close(rad_listen_t *listener);
592+
#endif
590593
RADCLIENT *client_listener_find(rad_listen_t *listener, fr_ipaddr_t const *ipaddr, uint16_t src_port);
591594

592595
#ifdef WITH_STATS

src/main/process.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6297,6 +6297,21 @@ static void event_new_fd(void *ctx)
62976297
this->dead = true;
62986298

62996299
remove_now:
6300+
#ifdef WITH_TLS
6301+
/*
6302+
* Close it. Which sets the status to EOL, so we
6303+
* have to update that, too.
6304+
*
6305+
* proxy_tls_close also clears this->tls, so it's
6306+
* safe run this check multiple times, as the
6307+
* second time it won't close the same socket.
6308+
*/
6309+
if ((this->type == RAD_LISTEN_PROXY) && this->tls) {
6310+
proxy_tls_close(this);
6311+
this->status = RAD_LISTEN_STATUS_REMOVE_NOW;
6312+
}
6313+
#endif
6314+
63006315
/*
63016316
* Re-open the socket, pointing it to /dev/null.
63026317
* This means that all writes proceed without

src/main/tls_listen.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ static void tls_socket_close(rad_listen_t *listener)
102102
*/
103103
}
104104

105+
void proxy_tls_close(rad_listen_t *listener)
106+
{
107+
listen_socket_t *sock = listener->data;
108+
109+
PTHREAD_MUTEX_LOCK(&sock->mutex);
110+
tls_socket_close(listener);
111+
PTHREAD_MUTEX_UNLOCK(&sock->mutex);
112+
}
113+
105114
static void tls_write_available(fr_event_list_t *el, int sock, void *ctx);
106115

107116
/*

0 commit comments

Comments
 (0)