conflicts in msodbcsql
This commit is contained in:
parent
652087d06b
commit
58f2068479
|
@ -779,7 +779,7 @@ void determine_server_version( _Inout_ sqlsrv_conn* conn TSRMLS_DC )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Column Encryption feature: if a custom keystore provider is specified,
|
// Column Encryption feature: if a custom keystore provider is specified,
|
||||||
// load and configure it when column encryption is enabled, but this step have
|
// load and configure it when column encryption is enabled, but this step has
|
||||||
// to be executed after the connection has been established
|
// to be executed after the connection has been established
|
||||||
void load_configure_ksp( _Inout_ sqlsrv_conn* conn TSRMLS_DC )
|
void load_configure_ksp( _Inout_ sqlsrv_conn* conn TSRMLS_DC )
|
||||||
{
|
{
|
||||||
|
@ -839,7 +839,7 @@ void load_configure_ksp( _Inout_ sqlsrv_conn* conn TSRMLS_DC )
|
||||||
core::SQLSetConnectAttr( conn, SQL_COPT_SS_CEKEYSTOREDATA, reinterpret_cast<SQLPOINTER>( pKsd ), SQL_IS_POINTER );
|
core::SQLSetConnectAttr( conn, SQL_COPT_SS_CEKEYSTOREDATA, reinterpret_cast<SQLPOINTER>( pKsd ), SQL_IS_POINTER );
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_conn_str_append_func( const char* odbc_name, const char* val, size_t val_len, std::string& conn_str TSRMLS_DC )
|
void common_conn_str_append_func( _In_z_ const char* odbc_name, _In_reads_(val_len) const char* val, _Inout_ size_t val_len, _Inout_ std::string& conn_str TSRMLS_DC )
|
||||||
{
|
{
|
||||||
// wrap a connection option in a quote. It is presumed that any character that need to be escaped will
|
// wrap a connection option in a quote. It is presumed that any character that need to be escaped will
|
||||||
// be escaped, such as a closing }.
|
// be escaped, such as a closing }.
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# ksp_app.c (or any equivalent)
|
# ksp_app.c (or any equivalent)
|
||||||
# msodbcsql.h (odbc header file)
|
# msodbcsql.h (odbc header file)
|
||||||
#
|
#
|
||||||
# Execution: Run with command line with required options
|
# Execution: Run with command line with optional options
|
||||||
# py build_ksp.py --KSP myKSP --APP ksp_app
|
# py build_ksp.py --KSP myKSP --APP ksp_app
|
||||||
#
|
#
|
||||||
#############################################################################################
|
#############################################################################################
|
||||||
|
@ -46,14 +46,14 @@ def create_batch_file(arch, filename, command):
|
||||||
# This invokes the newly created batch file to compile the code,
|
# This invokes the newly created batch file to compile the code,
|
||||||
# according to *arch* (either x86 or x64). The batch file will be
|
# according to *arch* (either x86 or x64). The batch file will be
|
||||||
# removed afterwards
|
# removed afterwards
|
||||||
def compile_KSP_windows(arch, ksp_name):
|
def compile_KSP_windows(arch, ksp_src):
|
||||||
output = 'myKSP'
|
output = 'myKSP'
|
||||||
if arch == 'x64':
|
if arch == 'x64':
|
||||||
output = output + arch + '.dll'
|
output = output + arch + '.dll'
|
||||||
else:
|
else:
|
||||||
output = output + '.dll'
|
output = output + '.dll'
|
||||||
|
|
||||||
command = 'cl {0}.c /LD /MD /link /out:'.format(ksp_name) + output
|
command = 'cl {0} /LD /MD /link /out:'.format(ksp_src) + output
|
||||||
batchfile = 'build_KSP.bat'
|
batchfile = 'build_KSP.bat'
|
||||||
create_batch_file(arch, batchfile, command)
|
create_batch_file(arch, batchfile, command)
|
||||||
os.system(batchfile)
|
os.system(batchfile)
|
||||||
|
@ -65,37 +65,37 @@ def compile_KSP_windows(arch, ksp_name):
|
||||||
# Otherwise, this will compile the code and generate a .so file.
|
# Otherwise, this will compile the code and generate a .so file.
|
||||||
#
|
#
|
||||||
# Output: A custom keystore provider created
|
# Output: A custom keystore provider created
|
||||||
def compile_KSP(ksp_name):
|
def compile_KSP(ksp_src):
|
||||||
print('Compiling ', ksp_name)
|
print('Compiling ', ksp_src)
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
compile_KSP_windows('x64', ksp_name)
|
compile_KSP_windows('x64', ksp_src)
|
||||||
compile_KSP_windows('x86', ksp_name)
|
compile_KSP_windows('x86', ksp_src)
|
||||||
else:
|
else:
|
||||||
os.system('gcc -fshort-wchar -fPIC -o myKSP.so -shared {0}.c'.format(ksp_name))
|
os.system('gcc -fshort-wchar -fPIC -o myKSP.so -shared {0}'.format(ksp_src))
|
||||||
|
|
||||||
# This compiles ksp app, which assumes the existence of the .dll or the .so file.
|
# This compiles ksp app, which assumes the existence of the .dll or the .so file.
|
||||||
#
|
#
|
||||||
# In Windows, a batch file is created in order to compile the code.
|
# In Windows, a batch file is created in order to compile the code.
|
||||||
def configure_KSP(app_name):
|
def configure_KSP(app_src):
|
||||||
print('Compiling ', app_name)
|
print('Compiling ', app_src)
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
command = 'cl /MD {0}.c /link odbc32.lib /out:ksp_app.exe'.format(app_name)
|
command = 'cl /MD {0} /link odbc32.lib /out:ksp_app.exe'.format(app_src)
|
||||||
batchfile = 'build_app.bat'
|
batchfile = 'build_app.bat'
|
||||||
create_batch_file('x86', batchfile, command)
|
create_batch_file('x86', batchfile, command)
|
||||||
os.system(batchfile)
|
os.system(batchfile)
|
||||||
os.remove(batchfile)
|
os.remove(batchfile)
|
||||||
else:
|
else:
|
||||||
os.system('gcc -o ksp_app -fshort-wchar {0}.c -lodbc -ldl'.format(app_name))
|
os.system('gcc -o ksp_app -fshort-wchar {0} -lodbc -ldl'.format(app_src))
|
||||||
|
|
||||||
################################### Main Function ###################################
|
################################### Main Function ###################################
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-ksp', '--KSPNAME', default='myKSP', help='The KSP (keystore provider)')
|
parser.add_argument('-ksp', '--KSPSRC', default='myKSP.c', help='The source file of KSP (keystore provider)')
|
||||||
parser.add_argument('-app', '--APPNAME', default='ksp_app', help='The app that uses the KSP')
|
parser.add_argument('-app', '--APPSRC', default='ksp_app.c', help='The source file for the app that uses the KSP')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
ksp_name = args.KSPNAME
|
ksp_src = args.KSPSRC
|
||||||
app_name = args.APPNAME
|
app_src = args.APPSRC
|
||||||
header = 'msodbcsql.h'
|
header = 'msodbcsql.h'
|
||||||
|
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
|
@ -107,15 +107,15 @@ if __name__ == '__main__':
|
||||||
if not os.path.exists(os.path.join(work_dir, header)):
|
if not os.path.exists(os.path.join(work_dir, header)):
|
||||||
print('Error: {0} not found!'.format(header))
|
print('Error: {0} not found!'.format(header))
|
||||||
exit(1)
|
exit(1)
|
||||||
if not os.path.exists(os.path.join(work_dir, ksp_name + '.c')):
|
if not os.path.exists(os.path.join(work_dir, ksp_src)):
|
||||||
print('Error: {0}.c not found!'.format(ksp_name))
|
print('Error: {0}.c not found!'.format(ksp_src))
|
||||||
exit(1)
|
exit(1)
|
||||||
if not os.path.exists(os.path.join(work_dir, app_name + '.c')):
|
if not os.path.exists(os.path.join(work_dir, app_src)):
|
||||||
print('Error: {0}.c not found!'.format(app_name))
|
print('Error: {0}.c not found!'.format(app_src))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
compile_KSP(ksp_name)
|
compile_KSP(ksp_src)
|
||||||
configure_KSP(app_name)
|
configure_KSP(app_src)
|
||||||
|
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ int setKSPLibrary(SQLHSTMT stmt) {
|
||||||
unsigned char CEK[32];
|
unsigned char CEK[32];
|
||||||
unsigned char *ECEK;
|
unsigned char *ECEK;
|
||||||
unsigned short ECEKlen;
|
unsigned short ECEKlen;
|
||||||
|
unsigned char foundProv = 0;
|
||||||
int i;
|
int i;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HMODULE hProvLib;
|
HMODULE hProvLib;
|
||||||
|
@ -100,12 +101,16 @@ int setKSPLibrary(SQLHSTMT stmt) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
while (pKsp = *ppKsp++) {
|
while (pKsp = *ppKsp++) {
|
||||||
if (!memcmp(KSPNAME, pKsp->Name, sizeof(KSPNAME)))
|
if (!memcmp(KSPNAME, pKsp->Name, sizeof(KSPNAME))) {
|
||||||
goto FoundProv;
|
foundProv = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (! foundProv) {
|
||||||
fprintf(stderr, "Could not find provider in the library\n");
|
fprintf(stderr, "Could not find provider in the library\n");
|
||||||
return 4;
|
return 4;
|
||||||
FoundProv:
|
}
|
||||||
|
|
||||||
if (pKsp->Init && !pKsp->Init(&ctx, postKspError)) {
|
if (pKsp->Init && !pKsp->Init(&ctx, postKspError)) {
|
||||||
fprintf(stderr, "Could not initialize provider\n");
|
fprintf(stderr, "Could not initialize provider\n");
|
||||||
return 5;
|
return 5;
|
||||||
|
|
Loading…
Reference in a new issue