Microsoft ODBC bug

Dom Latter freeradius-users at latter.org
Fri Jun 21 14:30:37 CEST 2019


Hi all,

I have been experimenting with Microsoft SQL Server as a replacement for
our current mysql servers [1].

I installed Microsoft's own "ODBC Driver 17 for SQL Server" and have
tested against both SQL Server running on the same Linux machine as
Freeradius itself, and SQL Server running on a Windows machine.

In both cases I found the same (what appears to be a) bug, which
I will describe below for the benefit of the archives, even though it is
(probably) not a problem with freeradius.  Because people hitting this
are very likely to be searching with terms including "freeradius".

Also there is a chance that it is somehow specific to the interaction
with freeradius.  Because it is hard to imagine even Microsoft releasing
something with such a glaring fault.

I'll also give a work-around.

I think I will now try iodbc instead - anybody here used it?

Right, the bug.  Here's my custom attribute:

ATTRIBUTE       My-Int                  3004    integer

Here's part of the post-auth section in the "outer" site:

update control {
	My-Int := "%{sql:SELECT 9999 }"
	My-Int := "%{sql:SELECT 10000 }"
	My-Int := "%{sql:SELECT '10000' }"

Here's debug output:

EXPAND %{sql:SELECT 9999 }
    --> 9999
My-Int := 9999

Executing select query: SELECT 10000
rlm_sql_unixodbc: 22003 [Microsoft][ODBC Driver 17 for SQL 
Server]Numeric value out of range
ERROR: Error fetching row
ERROR: Unknown error
ERROR: SQL query failed: <INVALID>
EXPAND %{sql:SELECT 10000 }
    -->
My-Int := 0


Executing select query: SELECT '10000'
EXPAND %{sql:SELECT '10000' }
    --> 10000
My-Int := 10000


As you can see, if an integer is more than four digits long, the
driver throws an error.  But if you return the number as a string,
it works fine.   I'd love to see the source code for this...


[1] Everything else is SQL Server and our current integration between
the two databases is rather clunky; a homogeneous environment makes
sense, whatever I personally think of Microsoft <grin>.

















More information about the Freeradius-Users mailing list