Skip to content

Commit

Permalink
add environment variable attribute Framed-IPv6-Prefix when present
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Apr 6, 2024
1 parent 53c0cff commit 032bc1c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/pam_radius_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,23 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, UNUSED int flags, int arg
_pam_log(LOG_DEBUG, "Set PAM environment variable : %s", frameip);
}
}
if ((attr_fip = find_attribute(response, PW_FRAMED_IPV6_PREFIX))) {
const char name[] = "Framed-IPv6-Prefix";
char buffer[INET6_ADDRSTRLEN];
char frameip[sizeof(name) + NET6_ADDRSTRLEN];
struct in_addr ip_addr;

ip_addr.s_addr = *(int*) attr_fip->data;

snprintf(frameip, sizeof(frameip), "%s=%s", name, inet_ntop(AF_INET6, ip_addr, buffer, INET6_ADDRSTRLEN));
retval = pam_putenv(pamh, frameip);
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);
}
}

} else {
retval = PAM_AUTH_ERR; /* authentication failure */
Expand Down
1 change: 1 addition & 0 deletions src/radius.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ typedef struct pw_auth_hdr {
#define PW_MANAGEMENT_PRIVILEGE_LEVEL 136 /* integer */

#define PW_NAS_IPV6_ADDRESS 95 /* octets */
#define PW_FRAMED_IPV6_PREFIX 97 /* octets */

/*
* INTEGER TRANSLATIONS
Expand Down

0 comments on commit 032bc1c

Please sign in to comment.