Host process hard coded to 37876 for Sybase

"Wood, David" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
Hello,

 

It seems host process is currently hard coded to 37876 if using TDS <= 5
(eg Sybase):

% grep 37876 src/tds/login.c

        tds_put_login_string(tds, "37876", TDS_MAX_LOGIN_STR_SZ);
/* host process */

 

% tsql -Ufoo -SSYB1 -Pbar

...

1> select hostprocess from sysprocesses where spid = @@spid

2> go

hostprocess

37876

^Z

 

% ps -ef | grep tsql | grep -v grep

   woodd  2990  2832   0 00:38:09 pts/140     0:00 tsql -Ufoo -SSYB1
-Pbar

 

After applying the patch below:

 

% tsql -Ufoo -SSYB1 -Pbar

...

1> select hostprocess from sysprocesses where spid = @@spid

2> go

hostprocess

23294 

^Z

 

% ps -ef | grep tsql | grep -v grep

   woodd 23294 23233   0 00:41:47 pts/17      0:00 tsql -Ufoo -SSYB1
-Pbar

 

Context diff against CVS:

 

*** login.c     Wed Aug  5 00:45:23 2009

--- login_patched.c     Wed Aug  5 00:44:22 2009

***************

*** 29,34 ****

--- 29,38 ----

  #include <stdlib.h>

  #endif /* HAVE_STDLIB_H */

 

+ #ifdef HAVE_LIMITS_H

+ #include <limits.h>

+ #endif /* HAVE_LIMITS_H */

+

  #include <assert.h>

 

  #if HAVE_STRING_H

***************

*** 593,599 ****

        tds_put_login_string(tds,
tds_dstr_cstr(&connection->client_host_name), TDS_MAX_LOGIN_STR_SZ);  /*
client host name */

        tds_put_login_string(tds, tds_dstr_cstr(&connection->user_name),
TDS_MAX_LOGIN_STR_SZ); /* account name */

        tds_put_login_string(tds, tds_dstr_cstr(&connection->password),
TDS_MAX_LOGIN_STR_SZ);  /* account password */

!       tds_put_login_string(tds, "37876", TDS_MAX_LOGIN_STR_SZ);
/* host process */

  #ifdef WORDS_BIGENDIAN

        if (tds->emul_little_endian) {

                tds_put_n(tds, le1, 6);

--- 597,605 ----

        tds_put_login_string(tds,
tds_dstr_cstr(&connection->client_host_name), TDS_MAX_LOGIN_STR_SZ);  /*
client host name */

        tds_put_login_string(tds, tds_dstr_cstr(&connection->user_name),
TDS_MAX_LOGIN_STR_SZ); /* account name */

        tds_put_login_string(tds, tds_dstr_cstr(&connection->password),
TDS_MAX_LOGIN_STR_SZ);  /* account password */

!       char pbuf[PID_MAX+1];

!       sprintf(pbuf, "%d", (int) getpid());

!       tds_put_login_string(tds, pbuf, TDS_MAX_LOGIN_STR_SZ);  /* host
process */

  #ifdef WORDS_BIGENDIAN

        if (tds->emul_little_endian) {

                tds_put_n(tds, le1, 6);

 

David
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.