[RADIATOR] Define a global array
Hugh Irvine
hugh at open.com.au
Tue Apr 1 19:24:30 CDT 2014
Hello Steve -
What you describe makes perfect sense - and this is exactly what globals are for.
See the hooks in “goodies/hooks.txt” for lots of examples.
regards
Hugh
On 2 Apr 2014, at 10:59, Steve Phillips <steve at focb.co.nz> wrote:
> Hi there,
>
> I am trying to setup a system that, on startup reads a DB table into a
> hashed array and then makes this available to the rest of the hooks. A
> later hook then takes this hashed array and parses it to add a value to
> a custom attribute which is then used for later processing within a handler.
>
> While I understand that globals are bad and should never be used, I
> believe that making a DB request on every radius packet would have more
> of an impact on performance for something that rarely changes (maybe
> once a week or so) and so the positives outweigh the negatives.
>
> What I had which doesn't seem to work was something along these lines.
>
> <from radius.cfg>
>
> # Hooks
> StartupHook file:"%D/hooks/StartupHook-SetupGlobals.pl"
>
> .
> .
> <Client>
> Secret blah
> PreHandlerHook file:"$D/hooks/AddAttribute.pl"
> </Client>
>
> <Handler MyAtttribute = /something/>
> .
> Do Stuff
> </Handler>
>
> in the SetupGlobals file I have something like;
>
> # Define a global (obviously, there is where I'd read in the DB table)
> our %global_steve = (
> 'message1' => 'Steve was here',
> 'message2' => 'woot'
> );
>
> and then, when trying to reference it I have in the PreHandler hook
>
> sub {
> &main::log($main::LOG_INFO, "Test: $main::global_steve{'messsage1'}");
> }
>
> Which ends up printing out a blank.
>
> Does anyone know of either, a way to get this going, or a way to read in
> a db table of data and cache it for use in later hooks without having
> each radius request generate another database call?
>
> Thanks in advance,
>
> --
> Steve.
>
>
> _______________________________________________
> radiator mailing list
> radiator at open.com.au
> http://www.open.com.au/mailman/listinfo/radiator
--
Hugh Irvine
hugh at open.com.au
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS,
TTLS, PEAP, TNC, WiMAX, RSA, Vasco, Yubikey, MOTP, HOTP, TOTP,
DIAMETER etc.
Full source on Unix, Windows, MacOSX, Solaris, VMS, NetWare etc.
More information about the radiator
mailing list