Hello Requiem -

On Thu, 02 Sep 1999, [EMAIL PROTECTED] wrote:
>  
> > Your previous email said that the PreClientHook was working 
> > (is this the PreClientHook?) and that you wanted to access the log 
> > filename. What is being printed by the "print $logfile;" line?
> 
> Yes it's the preclienthook !
> Actually i just want to print the filename to be sure i've got 
> the correct name. but after, i will add informations into this file
> 
> Here is my latest source code !
> 
> use Mozilla::LDAP::Conn;
> use Mozilla::LDAP::Utils;
> use FileHandle;
> use Radius::Radius;
> use strict;
> 
> sub
> {
>       print "\n";
>       my $p = ${$_[0]};
>       my $code = $p->code;
>       my $subcodetype =
> $p->getAttrByNum($Radius::Radius::ACCT_STATUS_TYPE);
>       my $username;
>       my $msisdn;
> 
>       if ( $code eq 'Access-Request')
>       {
>               print "\n!!!!!!!!\n";
>               my $username = $p->getAttrByNum($Radius::Radius::USER_NAME);
>               my $msisdn =
> $p->getAttrByNum($Radius::Radius::CALLING_STATION_ID);
>               if (!$msisdn)
>               {
>                       $msisdn="000000000";
>               }
>               $p->{CachedAttrs}{$Radius::Radius::USER_NAME} = $msisdn;
>               $p->changeAttrByNum($Radius::Radius::USER_NAME, $msisdn);
> 
>               $p->{CachedAttrs}{$Radius::Radius::CALLING_STATION_ID} =
> $username;
>               $p->changeAttrByNum($Radius::Radius::CALLING_STATION_ID,
> $username);
>               my $logfile;
>               foreach $logfile ($p->{Handler}->{AcctLogFileName})
>               {
>                       print $logfile;
>                       print "\n-----------\n";
>               }
>       }
> }
> 

Thank you for all the information - it is much easier to understand what is
going on, and much easier to help you.

There are a couple of things that you need to be aware of:

1. A PreClientHook will be executed *before* any packet processing is done,
therefore the packet will not have any information about which Client it came
from, nor which Handler (or Realm) will be called for it. Therefore you will
not be able to do any logging to an AcctLogFileName, because we have not yet
passed the packet to its Handler (or Realm). You can however get at the global
LogFile like this:
      
# Print the filename of the global LogFile definition
# Call &main::format_special() to process any "%" strings

PreClientHook sub { print &main::format_special(Radius::Log::filename()); } 


2. You can get the AcctLogFileName(s) only inside the corresponding Handler (or
Realm) with a PreAuthHook or a PostAuthHook. Notice that AcctLogFileName is an
array:

# Use a PostAuthHook to print the AcctLogFileName(s)
# Call &main::format_special() to process any "%" strings

<Handler DEFAULT>
        <AuthBy FILE>
                Filename ./users
        </AuthBy>
        AcctLogFileName /tmp/accounting.1
        AcctLogFileName %L/accounting.2
        PostAuthHook sub \
        { \
                my $acctfile; \
                foreach $acctfile (@{${$_[0]}->{Handler}->{AcctLogFileName}}) \
                { \
                        print "acctfile is ",&main::format_special($acctfile),"\n";\
                  } \
        }
</Handler>                                    


So, after all of this I think you will have to split up your processing between
a PreClientHook and a PreAuthHook or PostAuthHook.

hth

Hugh

--
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, TACACS+, PAM, external, etc etc on Unix, Win95/8,
NT, Rhapsody

===
Archive at http://www.thesite.com.au/~radiator/
To unsubscribe, email '[EMAIL PROTECTED]' with
'unsubscribe radiator' in the body of the message.

Reply via email to