mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-14 02:22:03 +08:00
Added the configure option server-name
If set it will be used to set the NAS_IDENTIFIER in radius.
This commit is contained in:
+23
-1
@@ -38,8 +38,9 @@
|
||||
#define RAD_IPV4_DNS2 ((311<<16)|(29))
|
||||
|
||||
static rc_handle *rh = NULL;
|
||||
static char nas_identifier[64];
|
||||
|
||||
static void radius_global_init(void *pool, void *additional)
|
||||
static void radius_global_init(void *pool, const char *server_name, void *additional)
|
||||
{
|
||||
rh = rc_read_config(additional);
|
||||
if (rh == NULL) {
|
||||
@@ -47,6 +48,11 @@ static void radius_global_init(void *pool, void *additional)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (server_name)
|
||||
strlcpy(nas_identifier, server_name, sizeof(nas_identifier));
|
||||
else
|
||||
nas_identifier[0] = 0;
|
||||
|
||||
if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary")) != 0) {
|
||||
fprintf(stderr, "error reading the radius dictionary\n");
|
||||
exit(1);
|
||||
@@ -182,6 +188,16 @@ static int radius_auth_pass(void *ctx, const char *pass, unsigned pass_len)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (nas_identifier[0] != 0) {
|
||||
if (rc_avpair_add(rh, &send, PW_NAS_IDENTIFIER, nas_identifier, -1, 0) == NULL) {
|
||||
syslog(LOG_ERR,
|
||||
"%s:%u: user '%s' auth error", __func__, __LINE__,
|
||||
pctx->username);
|
||||
ret = ERR_AUTH_FAIL;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
if (rc_avpair_add(rh, &send, PW_CALLING_STATION_ID, pctx->remote_ip, -1, 0) == NULL) {
|
||||
syslog(LOG_ERR,
|
||||
"%s:%u: user '%s' auth error", __func__, __LINE__,
|
||||
@@ -347,6 +363,12 @@ static void append_acct_standard(struct radius_ctx_st * pctx, rc_handle *rh,
|
||||
{
|
||||
int i;
|
||||
|
||||
if (nas_identifier[0] != 0) {
|
||||
if (rc_avpair_add(rh, send, PW_NAS_IDENTIFIER, nas_identifier, -1, 0) == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (rc_avpair_add(rh, send, PW_USER_NAME, pctx->username, -1, 0) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user