SQSH does not compile anymore against FreeTDS 1.3.x
boekhold opened this issue · 9 comments
Applies to original SQSH version from SourceForge as well as the version from "vonloxley":
https://sourceforge.net/projects/sqsh/files/
https://github.com/vonloxley/sqsh
Platform: RHEL8
- sudo dnf group install -y "Development Tools"
- sudo dnf install -y readline-devel freetds freetds-devel
- mkdir ~/src
- cd ~/src
- wget https://github.com/vonloxley/sqsh/archive/refs/tags/rel_3_0_b.tar.gz
- tar zxf rel_3_0_b.tar.gz
- cd sqsh-rel_3_0_b
- export SYBASE=/usr
- ./configure
- make clean
- make
$ make
make[1]: Entering directory '/home/user/src/sqsh-rel_3_0_b/src/sqsh_parser'
gcc -c -g -O2 -o sqsh_parser.o sqsh_parser.c
gcc -c -g -O2 -o tsql.o tsql.c
gcc -c -g -O2 -o tsql.yy.o tsql.yy.c
ar -rcsv sqsh_parser.a sqsh_parser.o tsql.o tsql.yy.o
a - sqsh_parser.o
a - tsql.o
a - tsql.yy.o
make[1]: Leaving directory '/home/user/src/sqsh-rel_3_0_b/src/sqsh_parser'
make[1]: Entering directory '/home/user/src/sqsh-rel_3_0_b/src'
gcc -g -O2 -DSQSH_RC='"/usr/local/etc/sqshrc:${HOME}/.sqshrc"' -DUSE_READLINE -I/usr/include -DSYB_LP64 -c -o cmd_alias.o cmd_alias.c
gcc -g -O2 -DSQSH_RC='"/usr/local/etc/sqshrc:${HOME}/.sqshrc"' -DUSE_READLINE -I/usr/include -DSYB_LP64 -c -o cmd_bcp.o cmd_bcp.c
gcc -g -O2 -DSQSH_RC='"/usr/local/etc/sqshrc:${HOME}/.sqshrc"' -DUSE_READLINE -I/usr/include -DSYB_LP64 -c -o cmd_buf.o cmd_buf.c
gcc -g -O2 -DSQSH_RC='"/usr/local/etc/sqshrc:${HOME}/.sqshrc"' -DUSE_READLINE -I/usr/include -DSYB_LP64 -c -o cmd_connect.o cmd_connect.c
cmd_connect.c:54: warning: "CS_TDS_71" redefined
#define CS_TDS_71 7366
In file included from /usr/include/ctpublic.h:23,
from cmd_connect.c:28:
/usr/include/cspublic.h:289: note: this is the location of the previous definition
#define CS_TDS_71 CS_TDS_71
cmd_connect.c:55: warning: "CS_TDS_72" redefined
#define CS_TDS_72 7367
In file included from /usr/include/ctpublic.h:23,
from cmd_connect.c:28:
/usr/include/cspublic.h:291: note: this is the location of the previous definition
#define CS_TDS_72 CS_TDS_72
cmd_connect.c:56: warning: "CS_TDS_73" redefined
#define CS_TDS_73 7368
In file included from /usr/include/ctpublic.h:23,
from cmd_connect.c:28:
/usr/include/cspublic.h:293: note: this is the location of the previous definition
#define CS_TDS_73 CS_TDS_73
cmd_connect.c:57: warning: "CS_TDS_74" redefined
#define CS_TDS_74 7369
In file included from /usr/include/ctpublic.h:23,
from cmd_connect.c:28:
/usr/include/cspublic.h:295: note: this is the location of the previous definition
#define CS_TDS_74 CS_TDS_74
cmd_connect.c: In function ‘SetNetAuth’:
cmd_connect.c:1906:17: error: ‘CS_MAX_CHAR’ undeclared (first use in this function); did you mean ‘CS_VARCHAR’?
CS_CHAR buf[CS_MAX_CHAR+1];
^~~~~~~~~~~
CS_VARCHAR
cmd_connect.c:1906:17: note: each undeclared identifier is reported only once for each function it appears in
cmd_connect.c:1916:7: error: ‘CS_SEC_CHANBIND’ undeclared (first use in this function); did you mean ‘CS_SEC_CHALLENGE’?
{ CS_SEC_CHANBIND, 'b', "Channel binding" },
^~~~~~~~~~~~~~~
CS_SEC_CHALLENGE
cmd_connect.c:1917:7: error: ‘CS_SEC_CONFIDENTIALITY’ undeclared (first use in this function); did you mean ‘CS_SEC_NEGOTIATE’?
{ CS_SEC_CONFIDENTIALITY,'c', "Data confidentiality" },
^~~~~~~~~~~~~~~~~~~~~~
CS_SEC_NEGOTIATE
cmd_connect.c:1919:7: error: ‘CS_SEC_INTEGRITY’ undeclared (first use in this function); did you mean ‘CS_SEC_NEGOTIATE’?
{ CS_SEC_INTEGRITY, 'i', "Data integrity" },
^~~~~~~~~~~~~~~~
CS_SEC_NEGOTIATE
cmd_connect.c:1921:7: error: ‘CS_SEC_DATAORIGIN’ undeclared (first use in this function); did you mean ‘CS_SEC_DELEGATION’?
{ CS_SEC_DATAORIGIN, 'o', "Data origin stamping" },
^~~~~~~~~~~~~~~~~
CS_SEC_DELEGATION
cmd_connect.c:1922:7: error: ‘CS_SEC_DETECTSEQ’ undeclared (first use in this function); did you mean ‘CS_SEC_DELEGATION’?
{ CS_SEC_DETECTSEQ, 'q', "Data out-of-sequence detection" },
^~~~~~~~~~~~~~~~
CS_SEC_DELEGATION
cmd_connect.c:1923:7: error: ‘CS_SEC_DETECTREPLAY’ undeclared (first use in this function); did you mean ‘CS_SEC_DELEGATION’?
{ CS_SEC_DETECTREPLAY, 'r', "Data replay detection" },
^~~~~~~~~~~~~~~~~~~
CS_SEC_DELEGATION
cmd_connect.c:1959:27: error: ‘CS_SEC_KEYTAB’ undeclared (first use in this function); did you mean ‘CS_SEC_NEGOTIATE’?
CS_SEC_KEYTAB, /* Property */
^~~~~~~~~~~~~
CS_SEC_NEGOTIATE
cmd_connect.c:1980:27: error: ‘CS_SEC_MECHANISM’ undeclared (first use in this function); did you mean ‘CS_SEC_DELEGATION’?
CS_SEC_MECHANISM, /* Property */
^~~~~~~~~~~~~~~~
CS_SEC_DELEGATION
cmd_connect.c: In function ‘ShowNetAuthCredExp’:
cmd_connect.c:2111:23: error: ‘CS_SEC_CREDTIMEOUT’ undeclared (first use in this function); did you mean ‘CS_SEC_ENCRYPTION’?
CS_SEC_CREDTIMEOUT, /* Property */
^~~~~~~~~~~~~~~~~~
CS_SEC_ENCRYPTION
cmd_connect.c:2127:18: error: ‘CS_UNEXPIRED’ undeclared (first use in this function); did you mean ‘EKEYEXPIRED’?
case CS_UNEXPIRED:
^~~~~~~~~~~~
EKEYEXPIRED
make[1]: *** [<builtin>: cmd_connect.o] Error 1
make[1]: Leaving directory '/home/user/src/sqsh-rel_3_0_b/src'
It seems your /usr/include/ctpublic.h
and /usr/include/cspublic.h
do not match, maybe installation issue or packaging issue?
It seems your
/usr/include/ctpublic.h
and/usr/include/cspublic.h
do not match, maybe installation issue or packaging issue?
I don't think this is the case (official freetds-devel package from RHEL8 repos).
The first set reported are actually WARNINGS, e.g.:
cmd_connect.c:54: warning: "CS_TDS_71" redefined
#define CS_TDS_71 7366
In file included from /usr/include/ctpublic.h:23,
from cmd_connect.c:28:
/usr/include/cspublic.h:289: note: this is the location of the previous definition
#define CS_TDS_71 CS_TDS_71
(and more) is actually deliberate in SQSH due to:
/*
* sqsh-3.0: Define FreeTDS enumerated values to prevent compile errors
* when using different versions of FreeTDS.
*/
#define CS_TDS_70 7365
#define CS_TDS_71 7366
#define CS_TDS_72 7367
#define CS_TDS_73 7368
#define CS_TDS_74 7369
#define CS_TDS_80 CS_TDS_71
It's the real errors that are more confusing. It's like there are differences in #defines between Sybase CS constants and their FreeTDS equivalents, so seem Sybase and FreeTDS have diverged over time?
The real errors mostly seem to come from this block of code in the SQSH source code:
#if defined(CS_SEC_NETWORKAUTH)
CS_CHAR buf[CS_MAX_CHAR+1];
CS_INT buflen;
CS_INT i;
CS_BOOL OptSupported;
NET_SEC_SERVICE nss[] = {
/*
* CS_SEC_NETWORKAUTH must be the first entry
*/
{ CS_SEC_NETWORKAUTH, 'u', "Network user authentication (unified login)" },
{ CS_SEC_CHANBIND, 'b', "Channel binding" },
{ CS_SEC_CONFIDENTIALITY,'c', "Data confidentiality" },
{ CS_SEC_DELEGATION, 'd', "Credentials delegation" },
{ CS_SEC_INTEGRITY, 'i', "Data integrity" },
{ CS_SEC_MUTUALAUTH, 'm', "Mutual client/server authentication" },
{ CS_SEC_DATAORIGIN, 'o', "Data origin stamping" },
{ CS_SEC_DETECTSEQ, 'q', "Data out-of-sequence detection" },
{ CS_SEC_DETECTREPLAY, 'r', "Data replay detection" },
{ CS_UNUSED, ' ', "" }
};
And most of these don't seem to be provided by FreeTDS:
$ grep -E "CS_MAX_CHAR|CS_SEC_NETWORKAUTH|CS_SEC_CHANBIND|CS_SEC_CONFIDENTIALITY|CS_SEC_DELEGATION|CS_SEC_INTEGRITY|CS_SEC_MUTUALAUTH|CS_SEC_DATAORIGIN|CS_SEC_DETECTSEQ|CS_SEC_DETECTREPLAY|CS_UNUSED" cs*
cspublic.h: CS_SEC_NETWORKAUTH = 9175,
cspublic.h:#define CS_SEC_NETWORKAUTH CS_SEC_NETWORKAUTH
cspublic.h: CS_SEC_DELEGATION = 9176,
cspublic.h:#define CS_SEC_DELEGATION CS_SEC_DELEGATION
cspublic.h: CS_SEC_MUTUALAUTH = 9177,
cspublic.h:#define CS_SEC_MUTUALAUTH CS_SEC_MUTUALAUTH
cspublic.h:#define CS_UNUSED -99999
I also just tried with the "official" (abandoned) sqsh-2.5.16.1
with pretty much the same results (there are slight differences, see end of this comment).
It's weird because I'm quite sure that I have compiled SQSH against FreeTDS in the past. In fact I'm looking at a server right now that has a version of sqsh on it that was compiled against FreeTDS (I know for sure because I just used it to connect to a SQL Server DB). But I can see from yum history pkg-list freetds
:
ID | Action(s) | Package
-------------------------------------------------------------------------------
181 | Updated | freetds-1.1.20-1.el7.x86_64 EE
181 | Update | 1.3.3-1.el7.x86_64 EE
68 | Updated | freetds-0.95.81-1.el7.x86_64 EE
68 | Update | 1.1.20-1.el7.x86_64 EE
27 | Install | freetds-0.95.81-1.el7.x86_64
history pkg-list
Unfortunately I cannot tell if I originally compiled against 0.95 or against 1.1.20. I can confirm that it is using the currently installed shared libraries from 1.3.3.
Compile results of "sourceforge" version of sqsh-2.5.16.1:
$ make clean && make
make[1]: Entering directory '/home/user/src/sqsh-2.5/src/sqsh_parser'
rm -f sqsh_parser.o tsql.o tsql.yy.o sqsh_parser.a
make[1]: Leaving directory '/home/user/src/sqsh-2.5/src/sqsh_parser'
make[1]: Entering directory '/home/user/src/sqsh-2.5/src'
rm -f *.o sqsh sqsh_test sig_test
make[1]: Leaving directory '/home/user/src/sqsh-2.5/src'
make[1]: Entering directory '/home/user/src/sqsh-2.5/src/sqsh_parser'
gcc -c -g -O2 -o sqsh_parser.o sqsh_parser.c
gcc -c -g -O2 -o tsql.o tsql.c
gcc -c -g -O2 -o tsql.yy.o tsql.yy.c
ar -rcsv sqsh_parser.a sqsh_parser.o tsql.o tsql.yy.o
a - sqsh_parser.o
a - tsql.o
a - tsql.yy.o
make[1]: Leaving directory '/home/user/src/sqsh-2.5/src/sqsh_parser'
make[1]: Entering directory '/home/user/src/sqsh-2.5/src'
gcc -g -O2 -DSQSH_RC='"/usr/local/etc/sqshrc:${HOME}/.sqshrc"' -DUSE_READLINE -I/usr/include -DSYB_LP64 -c -o cmd_alias.o cmd_alias.c
gcc -g -O2 -DSQSH_RC='"/usr/local/etc/sqshrc:${HOME}/.sqshrc"' -DUSE_READLINE -I/usr/include -DSYB_LP64 -c -o cmd_bcp.o cmd_bcp.c
gcc -g -O2 -DSQSH_RC='"/usr/local/etc/sqshrc:${HOME}/.sqshrc"' -DUSE_READLINE -I/usr/include -DSYB_LP64 -c -o cmd_buf.o cmd_buf.c
gcc -g -O2 -DSQSH_RC='"/usr/local/etc/sqshrc:${HOME}/.sqshrc"' -DUSE_READLINE -I/usr/include -DSYB_LP64 -c -o cmd_connect.o cmd_connect.c
cmd_connect.c: In function ‘cmd_connect’:
cmd_connect.c:864:23: error: ‘CS_TDS_80’ undeclared (first use in this function); did you mean ‘CS_TDS_70’?
version = CS_TDS_80;
^~~~~~~~~
CS_TDS_70
cmd_connect.c:864:23: note: each undeclared identifier is reported only once for each function it appears in
cmd_connect.c: In function ‘SetNetAuth’:
cmd_connect.c:1880:17: error: ‘CS_MAX_CHAR’ undeclared (first use in this function); did you mean ‘CS_VARCHAR’?
CS_CHAR buf[CS_MAX_CHAR+1];
^~~~~~~~~~~
CS_VARCHAR
cmd_connect.c:1890:7: error: ‘CS_SEC_CHANBIND’ undeclared (first use in this function); did you mean ‘CS_SEC_CHALLENGE’?
{ CS_SEC_CHANBIND, 'b', "Channel binding" },
^~~~~~~~~~~~~~~
CS_SEC_CHALLENGE
cmd_connect.c:1891:7: error: ‘CS_SEC_CONFIDENTIALITY’ undeclared (first use in this function); did you mean ‘CS_SEC_NEGOTIATE’?
{ CS_SEC_CONFIDENTIALITY,'c', "Data confidentiality" },
^~~~~~~~~~~~~~~~~~~~~~
CS_SEC_NEGOTIATE
cmd_connect.c:1893:7: error: ‘CS_SEC_INTEGRITY’ undeclared (first use in this function); did you mean ‘CS_SEC_NEGOTIATE’?
{ CS_SEC_INTEGRITY, 'i', "Data integrity" },
^~~~~~~~~~~~~~~~
CS_SEC_NEGOTIATE
cmd_connect.c:1895:7: error: ‘CS_SEC_DATAORIGIN’ undeclared (first use in this function); did you mean ‘CS_SEC_DELEGATION’?
{ CS_SEC_DATAORIGIN, 'o', "Data origin stamping" },
^~~~~~~~~~~~~~~~~
CS_SEC_DELEGATION
cmd_connect.c:1896:7: error: ‘CS_SEC_DETECTSEQ’ undeclared (first use in this function); did you mean ‘CS_SEC_DELEGATION’?
{ CS_SEC_DETECTSEQ, 'q', "Data out-of-sequence detection" },
^~~~~~~~~~~~~~~~
CS_SEC_DELEGATION
cmd_connect.c:1897:7: error: ‘CS_SEC_DETECTREPLAY’ undeclared (first use in this function); did you mean ‘CS_SEC_DELEGATION’?
{ CS_SEC_DETECTREPLAY, 'r', "Data replay detection" },
^~~~~~~~~~~~~~~~~~~
CS_SEC_DELEGATION
cmd_connect.c:1933:27: error: ‘CS_SEC_KEYTAB’ undeclared (first use in this function); did you mean ‘CS_SEC_NEGOTIATE’?
CS_SEC_KEYTAB, /* Property */
^~~~~~~~~~~~~
CS_SEC_NEGOTIATE
cmd_connect.c:1954:27: error: ‘CS_SEC_MECHANISM’ undeclared (first use in this function); did you mean ‘CS_SEC_DELEGATION’?
CS_SEC_MECHANISM, /* Property */
^~~~~~~~~~~~~~~~
CS_SEC_DELEGATION
cmd_connect.c: In function ‘ShowNetAuthCredExp’:
cmd_connect.c:2085:23: error: ‘CS_SEC_CREDTIMEOUT’ undeclared (first use in this function); did you mean ‘CS_SEC_ENCRYPTION’?
CS_SEC_CREDTIMEOUT, /* Property */
^~~~~~~~~~~~~~~~~~
CS_SEC_ENCRYPTION
cmd_connect.c:2101:18: error: ‘CS_UNEXPIRED’ undeclared (first use in this function); did you mean ‘EKEYEXPIRED’?
case CS_UNEXPIRED:
^~~~~~~~~~~~
EKEYEXPIRED
make[1]: *** [<builtin>: cmd_connect.o] Error 1
make[1]: Leaving directory '/home/user/src/sqsh-2.5/src'
make: *** [Makefile:34: build-subdirs] Error 2
It seems your
/usr/include/ctpublic.h
and/usr/include/cspublic.h
do not match, maybe installation issue or packaging issue?I don't think this is the case (official freetds-devel package from RHEL8 repos).
The first set reported are actually WARNINGS, e.g.:
cmd_connect.c:54: warning: "CS_TDS_71" redefined #define CS_TDS_71 7366 In file included from /usr/include/ctpublic.h:23, from cmd_connect.c:28: /usr/include/cspublic.h:289: note: this is the location of the previous definition #define CS_TDS_71 CS_TDS_71
(and more) is actually deliberate in SQSH due to:
/* * sqsh-3.0: Define FreeTDS enumerated values to prevent compile errors * when using different versions of FreeTDS. */ #define CS_TDS_70 7365 #define CS_TDS_71 7366 #define CS_TDS_72 7367 #define CS_TDS_73 7368 #define CS_TDS_74 7369 #define CS_TDS_80 CS_TDS_71
Tested. I think the code is doing some assumptions that changed in time. Specifically initially only an enumeration was used but now there are also some preprocessor macro definition for compatibility with Sybase includes. This cause the double definitions.
It's the real errors that are more confusing. It's like there are differences in #defines between Sybase CS constants and their FreeTDS equivalents, so seem Sybase and FreeTDS have diverged over time?
The real errors mostly seem to come from this block of code in the SQSH source code:
#if defined(CS_SEC_NETWORKAUTH)
The code assumes that if CS_SEC_NETWORKAUTH
is defined a lot of other options are defined too.
CS_CHAR buf[CS_MAX_CHAR+1]; CS_INT buflen; CS_INT i; CS_BOOL OptSupported; NET_SEC_SERVICE nss[] = { /* * CS_SEC_NETWORKAUTH must be the first entry */ { CS_SEC_NETWORKAUTH, 'u', "Network user authentication (unified login)" }, { CS_SEC_CHANBIND, 'b', "Channel binding" }, { CS_SEC_CONFIDENTIALITY,'c', "Data confidentiality" }, { CS_SEC_DELEGATION, 'd', "Credentials delegation" }, { CS_SEC_INTEGRITY, 'i', "Data integrity" }, { CS_SEC_MUTUALAUTH, 'm', "Mutual client/server authentication" }, { CS_SEC_DATAORIGIN, 'o', "Data origin stamping" }, { CS_SEC_DETECTSEQ, 'q', "Data out-of-sequence detection" }, { CS_SEC_DETECTREPLAY, 'r', "Data replay detection" }, { CS_UNUSED, ' ', "" } };
And most of these don't seem to be provided by FreeTDS:
$ grep -E "CS_MAX_CHAR|CS_SEC_NETWORKAUTH|CS_SEC_CHANBIND|CS_SEC_CONFIDENTIALITY|CS_SEC_DELEGATION|CS_SEC_INTEGRITY|CS_SEC_MUTUALAUTH|CS_SEC_DATAORIGIN|CS_SEC_DETECTSEQ|CS_SEC_DETECTREPLAY|CS_UNUSED" cs*
cspublic.h: CS_SEC_NETWORKAUTH = 9175,
cspublic.h:#define CS_SEC_NETWORKAUTH CS_SEC_NETWORKAUTH
cspublic.h: CS_SEC_DELEGATION = 9176,
cspublic.h:#define CS_SEC_DELEGATION CS_SEC_DELEGATION
cspublic.h: CS_SEC_MUTUALAUTH = 9177,
cspublic.h:#define CS_SEC_MUTUALAUTH CS_SEC_MUTUALAUTH
cspublic.h:#define CS_UNUSED -99999
Yes, this confirms that CS_SEC_NETWORKAUTH
is defined but a lot of other CS_SEC_xxx
options are not.
...
cmd_connect.c:864:23: note: each undeclared identifier is reported only once for each function it appears in
cmd_connect.c: In function ‘SetNetAuth’:
cmd_connect.c:1880:17: error: ‘CS_MAX_CHAR’ undeclared (first use in this function); did you mean ‘CS_VARCHAR’?
CS_CHAR buf[CS_MAX_CHAR+1];
^~~~~~~~~~~
CS_VARCHAR
The CS_MAX_CHAR
was just defined recently in FreeTDS.
Can you try https://github.com/freddy77/sqsh/tree/freetds_compatibility ?
Working on it. Due to the below:
The
CS_MAX_CHAR
was just defined recently in FreeTDS.
I'll need to compile a recent version of FreeTDS as well. Seems that the 1.3.3-1 package available in EPEL isn't recent enough...
Can you try https://github.com/freddy77/sqsh/tree/freetds_compatibility ?
Working on it. Due to the below:
The CS_MAX_CHAR was just defined recently in FreeTDS.
I'll need to compile a recent version of FreeTDS as well. Seems that the 1.3.3-1 package available in EPEL isn't recent enough...
Even the latest FreeTDS Stable package (1.3.20) doesn't seem to provide CS_MAX_CHAR
. Can you suggest which minimum FreeTDS version provides that #define CS_MAX_CHAR
?
Can you try https://github.com/freddy77/sqsh/tree/freetds_compatibility ?
Working on it. Due to the below:
The CS_MAX_CHAR was just defined recently in FreeTDS.
I'll need to compile a recent version of FreeTDS as well. Seems that the 1.3.3-1 package available in EPEL isn't recent enough...
Even the latest FreeTDS Stable package (1.3.20) doesn't seem to provide
CS_MAX_CHAR
. Can you suggest which minimum FreeTDS version provides that#define CS_MAX_CHAR
?
Yes you are right, it's only defined in master at the moment. Added a commit to my branch. Can you try it again?
Tested against the EPEL freetds-devel 1.3.3-1 package on RHEL8, and it works like a charm! Thanks @freddy77 !
SQSH patch merged, closing this issue