FreeTDS affected_rows_count Problem, Virtual Servers - nas_table Server Column Problem

Alan DeKok aland at deployingradius.com
Thu Aug 6 14:16:54 CEST 2020


On Aug 6, 2020, at 6:55 AM, Ali Arslan via Freeradius-Users <freeradius-users at lists.freeradius.org> wrote:
> 
> Today i will post 2 problems together that i have already sent by 2 different emails but still i cannot resolve without taking side ways.
> I will give earlier email links but both of the problems will be stated completely here again not to make reader to consult other sources of the problem statement:
...
> 1-  FreeTDS affected_rows_count Problem
>     Since rlm_sql_freetds does not get the true affected rows count it continues to insert new records in radacct table for the same session in interim updates.
> I attached debug output (debug_freetds.txt).
> Some lines from debug that will summarize the problem are as follows:

  The short summary is to file a bug upstream.  i.e. with the people who wrote the FreeTDS client library.

  There's not a lot we can do to work around bugs in libraries that we use.  And unless the library is OpenSSL, we generally *don't* work around bugs like this.  Doing that would turn FreeRADIUS into a horrible collection of patches and work-arounds.

> To check true affected rows count i added an unlang statement in accounting section, it does not do anything but just to check if sql server returns true count:
>     update control {
>         Tmp-Integer-0 = "%{WISPSQL:SELECT @@ROWCOUNT}"
>     }
> 
>     (3)       EXPAND %{WISPSQL:SELECT @@ROWCOUNT}
>     (3)          --> 1
>     (3)       Tmp-Integer-0 = 1
> as seen it returns count as 1.
> 
> I also checked affected rows count by freetds utility tsql and saw that it returns true values with select @@ROWCOUNT statement.
> 
> I downloaded freeradius source code from gitHub to see if i can find anything about the way it gets affected rows count:
> 
> the 2 methods in rlm_sql_freetds.c file related are:
> 
> static int sql_num_rows(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)

  You can modify this function in your source free to run the "SELECT @@ROWCOUNT" query, and return that value.

  I'm inclined to *not* make that change in FreeRADIUS.  Because it's a bug in someone else's library.

> 2- Virtual Servers - nas_table Server Column Problem
>     I want to use vertiaul servers and add specific clients to specific servers. And to do that i set Server columns of nas_table records with virtual server name for wich i want to attach.
> I encountered 2 problems with this method:
>     1 - Multiple clients cannot be added to the same virtual server, if tried get error like:
>         rlm_sql (sql): Processing generate_sql_clients
>         rlm_sql (sql): Executing select query: SELECT Id, IPAddress, ShortName, 'other', Secret, ISNULL(Server, '') FROM nas WHERE IsActive = 1
>         rlm_sql (sql): Adding client 10.5.50.1 (home) to default clients list
>         rlm_sql (10.5.50.1): Client "home" (sql) added
>         rlm_sql (sql): Adding client 192.168.1.210 (citylight) to default clients list
>         Failed to associate clients with virtual server default
>         Failed to add client, possible duplicate?
>     
>         Although there is no other client with same Name (IPAddress) it cannot add second client.

  Hmm... that should work.  I'll see if I can do some tests.

>     2- If it gets an Access-Request it errors with "from unknown client" even if the client is added and same client works if it is made global, some lines from debug:
>         rlm_sql (WISPSQL): Adding client 192.168.1.200 (orbitalanya) to WISPServer clients list
>         rlm_sql (192.168.1.200): Client "orbitalanya" (WISPSQL) added
> 
>         Error with Access-Request:
>         Ignoring request to auth address * port 2812 bound to server WISPServer from unknown client 192.168.1.200 port 49390 proto udp

  That should work, too.

> I attached debug output as file debug_VirtualServers.txt
> 
> I got an answer from Mr. Alan DeKok on Wed, Jul 29 at 2:59 PM for my previous email for the same problem.
>     >>  I've pushed a fix.  You can download the latest version of v3.0.x from gthub. Alan DeKok
> I have downloaded source https://github.com/FreeRADIUS/freeradius-server/archive/v3.0.x.zip and installed 3.0.22 but still get same error. Is it wrong version or do i do something wrong with configuration?

  I'll see if I can reproduce it here.

  Alan DeKok.




More information about the Freeradius-Users mailing list