From 2e231be197fe3ee766687f8c97d3ce6dd43a8f72 Mon Sep 17 00:00:00 2001 From: Sacha J Bernstein Date: Fri, 25 Jul 2014 11:21:28 -0400 Subject: [PATCH] Add configuration option and code to implement using the Hub name as the Radius realm --- src/Cedar/Hub.h | 1 + src/Cedar/Sam.c | 13 ++++++++++++- src/Cedar/Server.c | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Cedar/Hub.h b/src/Cedar/Hub.h index d3ce0771..609b8e28 100644 --- a/src/Cedar/Hub.h +++ b/src/Cedar/Hub.h @@ -424,6 +424,7 @@ struct HUB UINT RadiusRetryInterval; // Radius retry interval BUF *RadiusSecret; // Radius shared key char RadiusSuffixFilter[MAX_SIZE]; // Radius suffix filter + bool RadiusIncludeRealm; // Radius - Should be use hub name as realm volatile bool Halt; // Halting flag bool Offline; // Offline bool BeingOffline; // Be Doing Offline diff --git a/src/Cedar/Sam.c b/src/Cedar/Sam.c index 1072376d..ded4660d 100644 --- a/src/Cedar/Sam.c +++ b/src/Cedar/Sam.c @@ -211,7 +211,18 @@ bool SamAuthUserByPlainPassword(CONNECTION *c, HUB *hub, char *username, char *p AUTHRADIUS *auth = (AUTHRADIUS *)u->AuthData; if (ast || auth->RadiusUsername == NULL || UniStrLen(auth->RadiusUsername) == 0) { - name = CopyStrToUni(username); + if( h->RadiusIncludeRealm ) + { + char name_and_realm[MAX_SIZE]; + name_and_realm = StrCpy(name_and_realm, MAX_SIZE, username); + name_and_realm = StrCpy(name_and_realm, (MAX_SIZE - StrLen(name_and_realm)), "@"); + name_and_realm = StrCpy(name_and_realm, (MAX_SIZE - StrLen(name_and_realm)), hub.name); + name = CopyStrToUni(name_and_realm); + } + else + { + name = CopyStrToUni(username); + } } else { diff --git a/src/Cedar/Server.c b/src/Cedar/Server.c index dcf80aea..ac13078e 100644 --- a/src/Cedar/Server.c +++ b/src/Cedar/Server.c @@ -4926,6 +4926,7 @@ void SiWriteHubCfg(FOLDER *f, HUB *h) CfgAddInt(f, "RadiusServerPort", h->RadiusServerPort); CfgAddInt(f, "RadiusRetryInterval", h->RadiusRetryInterval); CfgAddStr(f, "RadiusSuffixFilter", h->RadiusSuffixFilter); + CfgAddBool(f, "RadiusIncludeRealm", h->RadiusIncludeRealm); } Unlock(h->RadiusOptionLock); @@ -5091,6 +5092,7 @@ void SiLoadHubCfg(SERVER *s, FOLDER *f, char *name) interval = CfgGetInt(f, "RadiusRetryInterval"); CfgGetStr(f, "RadiusSuffixFilter", h->RadiusSuffixFilter, sizeof(h->RadiusSuffixFilter)); + h->RadiusIncludeRealm = CfgGetBool(f, "RadiusIncludeRealm"); if (interval == 0) {