From e9757801f5a443506ac2536123ad74d5e2c2f145 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 6 Apr 2024 18:29:56 +0200 Subject: [PATCH] consistency between IPv4 and IPv6 --- src/pam_radius_auth.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pam_radius_auth.c b/src/pam_radius_auth.c index 409ba2b..b55b703 100644 --- a/src/pam_radius_auth.c +++ b/src/pam_radius_auth.c @@ -1577,15 +1577,16 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, UNUSED int flags, int arg attribute_t *attr_fip; if ((attr_fip = find_attribute(response, PW_FRAMED_ADDRESS))) { - char frameip[100]; + const char name[] = "Framed-IP-Address"; + char frameip[sizeof(name) + INET_ADDRSTRLEN]; struct in_addr ip_addr; ip_addr.s_addr = *(int*) attr_fip->data; - snprintf(frameip, sizeof(frameip), "Framed-IP-Address=%s", inet_ntoa(ip_addr)); + snprintf(frameip, sizeof(frameip), "%s=%s", name, inet_ntoa(ip_addr)); retval = pam_putenv(pamh, frameip); - if(retval != PAM_SUCCESS) { - _pam_log(LOG_ERR, "unable to set PAM environment variable : Framed-IP-Address"); + if (retval != PAM_SUCCESS) { + _pam_log(LOG_ERR, "unable to set PAM environment variable : %s", name); } else { _pam_log(LOG_DEBUG, "Set PAM environment variable : %s", frameip);