From 30c0952ce620d5c74e4cc0b0e00794fc1288342a Mon Sep 17 00:00:00 2001 From: yasuoka Date: Wed, 14 Aug 2024 07:04:54 +0000 Subject: [PATCH] Don't abort the query when it is requesting to the next module. --- usr.sbin/radiusd/radiusd.c | 13 ++++++++++--- usr.sbin/radiusd/radiusd_local.h | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/usr.sbin/radiusd/radiusd.c b/usr.sbin/radiusd/radiusd.c index a48e5f33ab4..93d7bee5407 100644 --- a/usr.sbin/radiusd/radiusd.c +++ b/usr.sbin/radiusd/radiusd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd.c,v 1.53 2024/08/14 04:44:07 yasuoka Exp $ */ +/* $OpenBSD: radiusd.c,v 1.54 2024/08/14 07:04:54 yasuoka Exp $ */ /* * Copyright (c) 2013, 2023 Internet Initiative Japan Inc. @@ -708,9 +708,11 @@ radius_query_access_response(struct radius_query *q) goto on_error; q0 = q; q = q->prev; + /* dissolve the relation */ + q0->prev = NULL; + q->hasnext = false; radiusd_module_next_response(q->authen->auth->module, q, q_last->res); - q0->prev = NULL; radiusd_access_request_aborted(q0); return; } @@ -864,6 +866,7 @@ radiusd_access_request_next(struct radius_query *q, RADIUS_PACKET *pkt) radius_get_authenticator(pkt, q_next->req_auth); q_next->authen = authen; q_next->prev = q; + q->hasnext = true; strlcpy(q_next->username, username, sizeof(q_next->username)); TAILQ_INSERT_TAIL(&q->radiusd->query, q_next, next); @@ -878,8 +881,12 @@ radiusd_access_request_next(struct radius_query *q, RADIUS_PACKET *pkt) void radiusd_access_request_aborted(struct radius_query *q) { - if (q->prev != NULL) + if (q->hasnext) /* don't abort if filtering */ + return; + if (q->prev != NULL) { + q->prev->hasnext = false; radiusd_access_request_aborted(q->prev); + } if (q->req != NULL) radius_delete_packet(q->req); if (q->res != NULL) diff --git a/usr.sbin/radiusd/radiusd_local.h b/usr.sbin/radiusd/radiusd_local.h index 35a1da9e403..d58c6c7c624 100644 --- a/usr.sbin/radiusd/radiusd_local.h +++ b/usr.sbin/radiusd/radiusd_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_local.h,v 1.16 2024/07/17 11:31:46 yasuoka Exp $ */ +/* $OpenBSD: radiusd_local.h,v 1.17 2024/08/14 07:04:54 yasuoka Exp $ */ /* * Copyright (c) 2013 Internet Initiative Japan Inc. @@ -131,6 +131,7 @@ struct radius_query { struct sockaddr_storage clientaddr; int clientaddrlen; int req_id; + bool hasnext; u_char req_auth[16]; struct radiusd_listen *listen; struct radiusd_client *client; -- 2.20.1