Sorry, maybe i didn't explain correctly.<br><br>Im not updating the database. I am using auth-type perl and when the user authenticates my perl script looks in the db to see what nas is bieng used on that IP and then checks the value for "databank" for the user and then send the correct attribute with the correct value like so<br>
<br>                                        $RAD_REPLY{'Nomadix-MaxBytesDown'} = "$DATABANK";<br><br>(in this example its a nomadix gateway)<br><br>That part works perfectly. The issue im having is when the stop request comes in, it doesn't update the value in the radcheck table, well it does but only sometimes..<br>
<br><div class="gmail_quote">On Sun, Feb 6, 2011 at 8:32 PM, Brian Candler <span dir="ltr"><<a href="mailto:B.Candler@pobox.com">B.Candler@pobox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sun, Feb 06, 2011 at 04:55:34PM +0200, Tyller D wrote:<br>
>    freeradius is used to authenticate users at our hotspots, as we are<br>
>    using different nas devices and we must cater for them all i did this.<br>
>    in dictionary file I added an attribute called databank, then I created<br>
>    a perl script to check which type of nas the user is coming from and<br>
>    renaming databank to the correct attribute, now that works fine.<br>
<br>
</div>Not sure what you mean by "renaming databank to the correct attribute" - are<br>
you actually changing the authentication database? If so that's scary.<br>
<br>
If you simply want to send a different attribute based on what type of NAS<br>
they are connecting from, then you can change the response attribute sent,<br>
without modifying the underlying database.<br>
<br>
For identifying the NAS: the simplest way is to use the preprocess<br>
module.  It reads the "huntgroups" file which maps NAS-IP-Address to control<br>
attribute Huntgroup-Name, and then you can use a regular users file to add<br>
an appropriate attribute, or do it in unlang:<br>
<br>
    sql<br>
<br>
    if ( "%{control:Huntgroup-Name}" == "Foo" && "%{reply:Databank}" ) {<br>
        update reply {<br>
            OtherAttr = "%{reply:Databank}"<br>
            Databank !* ""<br>
        }<br>
    }<br>
<br>
<br>
Or you can do anything in perl of course.<br>
<br>
The point is, I don't think you should be updating the database simply to<br>
change which reply attribute is sent based on which NAS they're connecting<br>
from at this instant.<br>
<div class="im"><br>
>    Then<br>
>    on the stop request I need to update the value associated to databank<br>
>    to be (databank - (acctinputoctets+acctoutputoctets)). that way<br>
>    limiting users to only as much "data" as we stipulated in the begining.<br>
<br>
</div>I'm guessing your "databank" is some sort of data limit attribute, a bit<br>
like a Session-Timeout but for bytes transferred?<br>
<div><div></div><div class="h5"><br>
>    my problem is that it doesn't always update the databank value, I can<br>
>    see how much traffic a users used in his session (i.e. in the radacct<br>
>    table) so the  accounting_stop_query &  accounting_stop_query_alt are<br>
>    not failing, its just not updating the databank value in radcheck.<br>
...<br>
>    here are the two queries<br>
>            accounting_stop_query = " \<br>
>              UPDATE radacct,radcheck SET \<br>
>                 radacct.acctstoptime       = '%S', \<br>
>                 radacct.acctsessiontime    = '%{Acct-Session-Time}', \<br>
>                 radacct.acctinputoctets    =<br>
>    '%{%{Acct-Input-Gigawords}:-0}' << 32 | \<br>
>                                      '%{%{Acct-Input-Octets}:-0}', \<br>
>                 radacct.acctoutputoctets   =<br>
>    '%{%{Acct-Output-Gigawords}:-0}' << 32 | \<br>
>                                      '%{%{Acct-Output-Octets}:-0}', \<br>
>                 radacct.acctterminatecause = '%{Acct-Terminate-Cause}', \<br>
>                    radcheck.value = radcheck.value -<br>
>    '%{Acct-Output-Octets}' - '%{Acct-Input-Octets}', \<br>
>                 radacct.acctstopdelay      = '%{%{Acct-Delay-Time}:-0}', \<br>
>                 radacct.connectinfo_stop   = '%{Connect-Info}' \<br>
>              WHERE radacct.acctsessionid   = '%{Acct-Session-Id}' \<br>
>            AND radcheck.username = '%{SQL-User-Name}' \<br>
>            AND radcheck.attribute = 'databank' \<br>
>              AND radacct.username          = '%{SQL-User-Name}' \<br>
>              AND radacct.nasipaddress      = '%{NAS-IP-Address}'"<br>
<br>
</div></div>That's a scary update: updating two independent tables with the same query.<br>
<br>
What database are you using? Calling a stored procedure would be a much<br>
cleaner way of doing this, if your database supports it. (I use mysql which<br>
does)<br>
<br>
    accounting_stop_query = "CALL process_stop_packet(...)"<br>
<br>
Then you can do two separate updates, which I think is what you really want.<br>
<div class="im"><br>
>    does anyone know how this can happen?<br>
<br>
</div>Watch radiusd -X until you see it happen. Look at exactly what SQL updates<br>
are being done.<br>
<div class="im"><br>
>    could it be something to do with<br>
>    interim-updates (grasping at straws here).<br>
<br>
</div>Sounds highly unlikely to me.<br>
<div><div></div><div class="h5"><br>
-<br>
List info/subscribe/unsubscribe? See <a href="http://www.freeradius.org/list/users.html" target="_blank">http://www.freeradius.org/list/users.html</a><br>
</div></div></blockquote></div><br>