[freetds] FreeTDS and FreeRadius - Problems Writing a Driver

Chris Spears Chris.Spears at harrynorman.com
Mon Apr 28 16:20:24 EDT 2003


I am currently running MS SQL 2k (8.0). 

I have been filling the freetds/src/*.c files with debug outputs 
to find the exact spot it is dumping out.  Right now if I block out 

tds_answer_challenge(connect_info->password, challenge, &answer);

inside of  login.c:tds7_send_auth(*) my driver does not seg fault.

If I uncomment this line and compile it in then tsql works fine
and my driver segfaults the first time it exits tds_convert_key(*)
inside of challenge.c

Any ideas?

thanks,
Chris


-- 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 */
}




More information about the FreeTDS mailing list