From: Jouni Malinen Date: Tue, 1 Jan 2019 19:27:54 +0000 (+0200) Subject: Use internal EAP server identity as dot1xAuthSessionUserName X-Git-Tag: hostap_2_8~628 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28ab9344b50577d67a58e488a5b6f4785ad27439;p=thirdparty%2Fhostap.git Use internal EAP server identity as dot1xAuthSessionUserName If the internal EAP server is used instead of an external RADIUS server, sm->identity does not get set. Use the identity from the internal EAP server in such case to get the dot1xAuthSessionUserName value in STA MIB information. Signed-off-by: Jouni Malinen --- diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c index efcbe6f1a..68d3a81a1 100644 --- a/src/ap/ieee802_1x.c +++ b/src/ap/ieee802_1x.c @@ -1,6 +1,6 @@ /* * hostapd / IEEE 802.1X-2004 Authenticator - * Copyright (c) 2002-2012, Jouni Malinen + * Copyright (c) 2002-2019, Jouni Malinen * * This software may be distributed under the terms of the BSD license. * See README for more details. @@ -2596,6 +2596,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta, struct os_reltime diff; const char *name1; const char *name2; + char *identity_buf = NULL; if (sm == NULL) return 0; @@ -2711,6 +2712,14 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta, /* dot1xAuthSessionStatsTable */ os_reltime_age(&sta->acct_session_start, &diff); + if (sm->eap && !sm->identity) { + const u8 *id; + size_t id_len; + + id = eap_get_identity(sm->eap, &id_len); + if (id) + identity_buf = dup_binstr(id, id_len); + } ret = os_snprintf(buf + len, buflen - len, /* TODO: dot1xAuthSessionOctetsRx */ /* TODO: dot1xAuthSessionOctetsTx */ @@ -2726,7 +2735,8 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta, wpa_auth_sta_key_mgmt(sta->wpa_sm))) ? 1 : 2, (unsigned int) diff.sec, - sm->identity); + sm->identity ? (char *) sm->identity : identity_buf); + os_free(identity_buf); if (os_snprintf_error(buflen - len, ret)) return len; len += ret;