(RADIATOR) Re: using Util::format_special() in setVariable

Mariano Absatz radiator at lists.com.ar
Tue Oct 9 07:21:08 CDT 2001


Alright... but I'm stubborn enough to keep messing around...

what about adding a keyword 'DefineFormattedGlobalVar' (or whatever is 
appropriate) that allows me to do this without breaking existing config files?

I think it should suffice this change in ServerConfig.pm (now I'm working 
over release 2.18.4):

# diff -C5 ServerConfig.pm.ORI ServerConfig.pm
*** ServerConfig.pm.ORI Tue Oct  9 09:09:35 2001
--- ServerConfig.pm     Tue Oct  9 09:12:25 2001
***************
*** 188,197 ****
--- 188,203 ----
      {
        my ($name, $v) = split(/\s+/, $value);
        &main::setVariable($name, $v);
        return 1;
      }
+     elsif ($keyword eq 'DefineFormattedGlobalVar')
+     {
+       my ($name, $v) = split(/\s+/, $value);
+       &main::setVariable($name, &Radius::Util::format_special($v));
+       return 1;
+     }
      elsif ($keyword eq 'LogFile')
      {
        $self->{LogFile} = $value;
        # Allow the default logger to be rejigged during startup
        &Radius::Log::setupDefaultLogger

El 6 Oct 2001, a las 15:18, Hugh Irvine escribió:

> 
> Hello Mariano -
> 
> Just one further point on this - Mike and I discussed it at some length, 
> however we were concerned that (1) it would only work for a single level of 
> nesting, and (2) that it would break any previously defined "%nnnnn" string 
> in a GlobalVar (such as SQL queries for example).
> 
> Note that in the current Radiator design philosophy you would probably be 
> much better off doing this sort of complex setup in a StartupHook.
> 
> As Mike says, we thank you for the suggestion and encourage you to keep 
> coming up with them.
> 
> regards
> 
> Hugh
> 
> 
> On Saturday 06 October 2001 13:16, Mike McCauley wrote:
> > Hello Mariano,
> >
> > Thank you for your contribution.
> > We have carefully considerd this, and we dont think its a good idea to add
> > this to the base code.We think that it is too likely to break other users
> > configurations.
> >
> > But thanks for your suggestion: keep them coming.
> >
> > Cheers.
> >
> > On Sat, 6 Oct 2001 09:05, you wrote:
> > > Hi people,
> > >
> > > I added one more level of indirection in my config files and everything
> > > went nuts... my  %{GlobalVar:xxx}'s went crazy.
> > >
> > > Then I noted that the problem was that I was setting %{GlobalVar:xxx}'s
> > > whose contents included other %{GlobalVar:xxx}'s and this ones weren't
> > > translated...
> > >
> > > I made a really small change to radiusd and it started working (I
> > > think)... Am I the first one to try to do this?
> > >
> > > The idea is that now setVariable (in radiusd) sets the global variable to
> > > the value of its argument, but first calls Util::format_special() so, for
> > > my particular case, it can interpolate previously defined global
> > > variables, but you might use it for any of the %XXX stuff that make sense
> > > while parsing the config files...
> > >
> > > Can this change have unwanted side-effects?
> > >
> > > I think it's a really small and useful patch (well, if I'm the first,
> > > maybe my concept of useful is completely insane)
> > >
> > > :-D
> > >
> > > So, FWIW, here's the patch (based on 2.18.2):
> > >
> > > # diff -C5 radiusd.ORI radiusd
> > > *** radiusd.ORI        Fri Oct  5 19:41:09 2001
> > > --- radiusd     Fri Oct  5 19:42:11 2001
> > > ***************
> > > *** 275,285 ****
> > >   # as %{GlobalVar:name}
> > >   sub setVariable
> > >   {
> > >       my ($name, $value) = @_;
> > >
> > > !     $main::globals{$name} = $value;
> > >   }
> > >
> > >   sub getVariable
> > >   {
> > >       return $main::globals{$_[0]};
> > > --- 275,285 ----
> > >   # as %{GlobalVar:name}
> > >   sub setVariable
> > >   {
> > >       my ($name, $value) = @_;
> > >
> > > !     $main::globals{$name} = &Radius::Util::format_special($value);
> > >   }
> > >
> > >   sub getVariable
> > >   {
> > >       return $main::globals{$_[0]};


--
Mariano Absatz
El Baby
----------------------------------------------------------
God is REAL, unless explicitly declared INTEGER. 

===
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.


More information about the radiator mailing list