freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
[freetds] FreeTDS and FreeRadius - Problems Writing a Driver
- From: Chris Spears <Chris.Spears AT harrynorman.com>
- To: "'freetds AT lists.ibiblio.org'" <freetds AT lists.ibiblio.org>
- Subject: [freetds] FreeTDS and FreeRadius - Problems Writing a Driver
- Date: Mon, 28 Apr 2003 12:25:32 -0400
Hello, I am working with Freeradius [freeradius.org] and trying to
update/fix
the freetds driver that comes along with it.
The problem I am having write now is in the connection code to the server.
My connection code is basically a replication of the tsql.c connection
code.
tsql -S Test -U Administrator logs in fine on my box with this config file.
[Test]
host = sql-test
port = 1433
tds version = 8.0
try domain login = yes
try server login = no
nt domain = MYDOMAIN
-- My Driver Connection Code --
static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
const char *locale = NULL;
TDSSOCKET *tds;
TDSLOGIN *login;
TDSCONTEXT *context;
TDSCONNECTINFO *connect_info;
char *charset = "iso_1";
/* Setting connection parameters */
login = tds_alloc_login();
context = tds_alloc_context();
if(context->locale && !context->locale->date_fmt) {
context->locale->date_fmt = strdup("%b %e %Y %I:%M%p");
}
context->msg_handler = handle_message;
context->err_handler = handle_message;
/* populate_login(login, argc, argv); */
setlocale(LC_ALL, "");
locale = setlocale(LC_ALL, NULL);
tds_set_user (login, config->sql_login);
tds_set_app (login, "FREERADIUS");
tds_set_library (login, "TDS-Library");
tds_set_server (login, "Test");
tds_set_port (login, 1433);
tds_set_charset (login, charset);
tds_set_language(login, "us_english");
tds_set_packet (login, 512);
tds_set_passwd (login, config->sql_password);
tds = tds_alloc_socket(context, 512);
tds_set_parent(tds, NULL);
/* Do connection */
connect_info = tds_read_config_info(NULL, login, context->locale);
if (!connect_info || tds_connect(tds, connect_info) == TDS_FAIL)
{
tds_free_connect(connect_info);
radlog(L_ERR, "rlm_sql_freetds: Can't connect to the database
server");
return -1;
}
tds_free_connect(connect_info);
/* some other code that I have commented out atm */
}
The Config file refrenced (config->sql_login and config->sql_password) both
return fine.
When I run that code above I get a segfault or Illegal Instruction at the
tds_connect(*) line. The Interesting part
about the error is that I believe it is happening in tds7_send_login(). The
reason I
belief that is because if I go up to my config file and change "tds version"
from 8.0 to 4.2 or 5.0
then I get no error.
Where is the error? The above block of code is almost identical to the
tsql.c main/populate_login code.
Based on the fact that I am setting server to "Test" the attempted login
should function just like
a tsql -S Test. If anyone has any insight into the problem or see something
wrong with the code please
let me know.
thanks,
Chris Spears
-
[freetds] FreeTDS and FreeRadius - Problems Writing a Driver,
Chris Spears, 04/28/2003
- <Possible follow-up(s)>
- RE: [freetds] FreeTDS and FreeRadius - Problems Writing a Driver, Lowden, James K, 04/28/2003
- [freetds] FreeTDS and FreeRadius - Problems Writing a Driver, Chris Spears, 04/28/2003
- RE: [freetds] FreeTDS and FreeRadius - Problems Writing a Driver, Lowden, James K, 04/28/2003
- [freetds] FreeTDS and FreeRadius - Problems Writing a Driver, Chris Spears, 04/29/2003
Archive powered by MHonArc 2.6.24.