Changeset: 8b47204a299b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8b47204a299b
Modified Files:
clients/odbc/winsetup/resource.h
clients/odbc/winsetup/setup.c
clients/odbc/winsetup/setup.rc
Branch: odbc-tls
Log Message:
Extend ODBC Data Source config dialog with new connection options.
diffs (truncated from 444 to 300 lines):
diff --git a/clients/odbc/winsetup/resource.h b/clients/odbc/winsetup/resource.h
--- a/clients/odbc/winsetup/resource.h
+++ b/clients/odbc/winsetup/resource.h
@@ -29,7 +29,7 @@
#define IDC_EDIT_SCHEMA 2013
#define IDC_EDIT_TIMEZONE 2014
// Secure connections using TLS
-#define IDC_EDIT_TLS 2021
+#define IDC_EDIT_USETLS 2021
#define IDC_EDIT_SERVERCERT 2022
#define IDC_EDIT_SERVERCERTHASH 2023
#define IDC_EDIT_CLIENTKEY 2024
diff --git a/clients/odbc/winsetup/setup.c b/clients/odbc/winsetup/setup.c
--- a/clients/odbc/winsetup/setup.c
+++ b/clients/odbc/winsetup/setup.c
@@ -77,13 +77,11 @@ ConfigDriver(HWND hwnd, WORD request, LP
case ODBC_CONFIG_DRIVER:
break;
default:
- SQLPostInstallerError(ODBC_ERROR_INVALID_REQUEST_TYPE,
- "Invalid request");
+ SQLPostInstallerError(ODBC_ERROR_INVALID_REQUEST_TYPE, "Invalid
request");
return FALSE;
}
if (strcmp(driver, DriverName) != 0) {
- SQLPostInstallerError(ODBC_ERROR_INVALID_NAME,
- "Invalid driver name");
+ SQLPostInstallerError(ODBC_ERROR_INVALID_NAME, "Invalid driver
name");
return FALSE;
}
return TRUE;
@@ -97,16 +95,17 @@ struct data {
char *port;
char *database;
char *schema;
- bool autocommit;
- long replysize;
- long timezone;
+ char *autocommit;
+ char *replysize;
+ char *timezone;
char *logfile;
// TLS settings
- bool use_tls;
+ char *use_tls;
char *servercert;
char *servercerthash;
char *clientkey;
char *clientcert;
+
HWND parent;
WORD request;
};
@@ -155,7 +154,16 @@ DialogProc(HWND hwndDlg, UINT uMsg, WPAR
SetDlgItemText(hwndDlg, IDC_EDIT_HOST, datap->host ?
datap->host : "");
SetDlgItemText(hwndDlg, IDC_EDIT_PORT, datap->port ?
datap->port : "");
SetDlgItemText(hwndDlg, IDC_EDIT_DATABASE, datap->database ?
datap->database : "");
+ SetDlgItemText(hwndDlg, IDC_EDIT_SCHEMA, datap->schema ?
datap->schema : "");
+ SetDlgItemText(hwndDlg, IDC_EDIT_AUTOCOMMIT, datap->autocommit
? datap->autocommit : "on");
+ SetDlgItemText(hwndDlg, IDC_EDIT_REPLYSIZE, datap->replysize ?
datap->replysize : "");
+ SetDlgItemText(hwndDlg, IDC_EDIT_TIMEZONE, datap->timezone ?
datap->timezone : "");
SetDlgItemText(hwndDlg, IDC_EDIT_LOGFILE, datap->logfile ?
datap->logfile : "");
+ SetDlgItemText(hwndDlg, IDC_EDIT_USETLS, datap->use_tls ?
datap->use_tls : "off");
+ SetDlgItemText(hwndDlg, IDC_EDIT_SERVERCERT, datap->servercert
? datap->servercert : "");
+ SetDlgItemText(hwndDlg, IDC_EDIT_SERVERCERTHASH,
datap->servercerthash ? datap->servercerthash : "");
+ SetDlgItemText(hwndDlg, IDC_EDIT_CLIENTKEY, datap->clientkey ?
datap->clientkey : "");
+ SetDlgItemText(hwndDlg, IDC_EDIT_CLIENTCERT, datap->clientcert
? datap->clientcert : "");
if (datap->request == ODBC_ADD_DSN && datap->dsn && *datap->dsn)
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_DSN), FALSE);
return TRUE;
@@ -167,10 +175,7 @@ DialogProc(HWND hwndDlg, UINT uMsg, WPAR
if (datap->request != ODBC_ADD_DSN || datap->dsn ==
NULL || *datap->dsn == 0) {
GetDlgItemText(hwndDlg, IDC_EDIT_DSN, buf,
sizeof(buf));
if (!SQLValidDSN(buf)) {
- MessageBox(hwndDlg,
- "Invalid Datasource Name",
- NULL,
- MB_ICONERROR);
+ MessageBox(hwndDlg, "Invalid Datasource
Name", NULL, MB_ICONERROR);
return TRUE;
}
if (datap->dsn)
@@ -197,10 +202,46 @@ DialogProc(HWND hwndDlg, UINT uMsg, WPAR
if (datap->database)
free(datap->database);
datap->database = strdup(buf);
+ GetDlgItemText(hwndDlg, IDC_EDIT_SCHEMA, buf,
sizeof(buf));
+ if (datap->schema)
+ free(datap->schema);
+ datap->schema = strdup(buf);
+ GetDlgItemText(hwndDlg, IDC_EDIT_AUTOCOMMIT, buf,
sizeof(buf));
+ if (datap->autocommit)
+ free(datap->autocommit);
+ datap->autocommit = strdup(buf);
+ GetDlgItemText(hwndDlg, IDC_EDIT_REPLYSIZE, buf,
sizeof(buf));
+ if (datap->replysize)
+ free(datap->replysize);
+ datap->replysize = strdup(buf);
+ GetDlgItemText(hwndDlg, IDC_EDIT_TIMEZONE, buf,
sizeof(buf));
+ if (datap->timezone)
+ free(datap->timezone);
+ datap->timezone = strdup(buf);
GetDlgItemText(hwndDlg, IDC_EDIT_LOGFILE, buf,
sizeof(buf));
if (datap->logfile)
free(datap->logfile);
datap->logfile = strdup(buf);
+ GetDlgItemText(hwndDlg, IDC_EDIT_USETLS, buf,
sizeof(buf));
+ if (datap->use_tls)
+ free(datap->use_tls);
+ datap->use_tls = strdup(buf);
+ GetDlgItemText(hwndDlg, IDC_EDIT_SERVERCERT, buf,
sizeof(buf));
+ if (datap->servercert)
+ free(datap->servercert);
+ datap->servercert = strdup(buf);
+ GetDlgItemText(hwndDlg, IDC_EDIT_SERVERCERTHASH, buf,
sizeof(buf));
+ if (datap->servercerthash)
+ free(datap->servercerthash);
+ datap->servercerthash = strdup(buf);
+ GetDlgItemText(hwndDlg, IDC_EDIT_CLIENTKEY, buf,
sizeof(buf));
+ if (datap->clientkey)
+ free(datap->clientkey);
+ datap->clientkey = strdup(buf);
+ GetDlgItemText(hwndDlg, IDC_EDIT_CLIENTCERT, buf,
sizeof(buf));
+ if (datap->clientcert)
+ free(datap->clientcert);
+ datap->clientcert = strdup(buf);
/* fall through */
case IDCANCEL:
EndDialog(hwndDlg, LOWORD(wParam));
@@ -223,8 +264,7 @@ ConfigDSN(HWND parent, WORD request, LPC
ODBCLOG("ConfigDSN %d %s %s 0x%" PRIxPTR "\n", request, driver ? driver
: "(null)", attributes ? attributes : "(null)", (uintptr_t) &data);
if (strcmp(driver, DriverName) != 0) {
- SQLPostInstallerError(ODBC_ERROR_INVALID_NAME,
- "Invalid driver name");
+ SQLPostInstallerError(ODBC_ERROR_INVALID_NAME, "Invalid driver
name");
return FALSE;
}
switch (request) {
@@ -233,8 +273,7 @@ ConfigDSN(HWND parent, WORD request, LPC
case ODBC_REMOVE_DSN:
break;
default:
- SQLPostInstallerError(ODBC_ERROR_INVALID_REQUEST_TYPE,
- "Invalid request");
+ SQLPostInstallerError(ODBC_ERROR_INVALID_REQUEST_TYPE, "Invalid
request");
return FALSE;
}
@@ -246,12 +285,12 @@ ConfigDSN(HWND parent, WORD request, LPC
data.database = NULL;
data.logfile = NULL;
data.schema = NULL;
- data.autocommit = true;
-// data.replysize = 1000;
-// data.timezone;
+ data.autocommit = NULL;
+ data.replysize = NULL;
+ data.timezone = NULL;
data.logfile = NULL;
// TLS settings
- data.use_tls = false;
+ data.use_tls = NULL;
data.servercert = NULL;
data.servercerthash = NULL;
data.clientkey = NULL;
@@ -264,8 +303,7 @@ ConfigDSN(HWND parent, WORD request, LPC
char *value = strchr(attributes, '=');
if (value == NULL) {
- SQLPostInstallerError(ODBC_ERROR_INVALID_KEYWORD_VALUE,
- "Invalid attributes string");
+ SQLPostInstallerError(ODBC_ERROR_INVALID_KEYWORD_VALUE,
"Invalid attributes string");
return FALSE;
}
value++;
@@ -282,15 +320,32 @@ ConfigDSN(HWND parent, WORD request, LPC
data.port = strdup(value);
else if (strncasecmp("database=", attributes, value -
attributes) == 0)
data.database = strdup(value);
+ else if (strncasecmp("schema=", attributes, value - attributes)
== 0)
+ data.schema = strdup(value);
+ else if (strncasecmp("autocommit=", attributes, value -
attributes) == 0)
+ data.autocommit = strdup(value);
+ else if (strncasecmp("replysize=", attributes, value -
attributes) == 0)
+ data.replysize = strdup(value);
+ else if (strncasecmp("timezone=", attributes, value -
attributes) == 0)
+ data.timezone = strdup(value);
else if (strncasecmp("logfile=", attributes, value -
attributes) == 0)
data.logfile = strdup(value);
+ else if (strncasecmp("tls=", attributes, value - attributes) ==
0)
+ data.use_tls = strdup(value);
+ else if (strncasecmp("cert=", attributes, value - attributes)
== 0)
+ data.servercert = strdup(value);
+ else if (strncasecmp("certhash=", attributes, value -
attributes) == 0)
+ data.servercerthash = strdup(value);
+ else if (strncasecmp("clientkey=", attributes, value -
attributes) == 0)
+ data.clientkey = strdup(value);
+ else if (strncasecmp("clientcert=", attributes, value -
attributes) == 0)
+ data.clientcert = strdup(value);
attributes = value + strlen(value) + 1;
}
if (request == ODBC_REMOVE_DSN) {
if (data.dsn == NULL) {
- SQLPostInstallerError(ODBC_ERROR_INVALID_KEYWORD_VALUE,
- "No DSN specified");
+ SQLPostInstallerError(ODBC_ERROR_INVALID_KEYWORD_VALUE,
"No DSN specified");
return FALSE;
}
rc = SQLRemoveDSNFromIni(data.dsn);
@@ -303,16 +358,34 @@ ConfigDSN(HWND parent, WORD request, LPC
MergeFromProfileString(data.dsn, &data.host, "host", "localhost");
MergeFromProfileString(data.dsn, &data.port, "port", MAPI_PORT_STR);
MergeFromProfileString(data.dsn, &data.database, "database", "");
+ MergeFromProfileString(data.dsn, &data.schema, "schema", "");
+ MergeFromProfileString(data.dsn, &data.autocommit, "autocommit", "on");
+ MergeFromProfileString(data.dsn, &data.replysize, "replysize", "");
+ MergeFromProfileString(data.dsn, &data.timezone, "timezone", "");
MergeFromProfileString(data.dsn, &data.logfile, "logfile", "");
+ MergeFromProfileString(data.dsn, &data.use_tls, "tls", "off");
+ MergeFromProfileString(data.dsn, &data.servercert, "cert", "");
+ MergeFromProfileString(data.dsn, &data.servercerthash, "certhash", "");
+ MergeFromProfileString(data.dsn, &data.clientkey, "clientkey", "");
+ MergeFromProfileString(data.dsn, &data.clientcert, "clientcert", "");
- ODBCLOG("ConfigDSN values: dsn=%s uid=%s pwd=%s host=%s port=%s
database=%s logfile=%s\n",
+ ODBCLOG("ConfigDSN values: dsn=%s uid=%s pwd=%s host=%s port=%s
database=%s schema=%s autocommit=%s replysize=%s timezone=%s logfile=%s tls=%s
cert=%s certhash=%s clientkey=%s clientcert=%s\n",
data.dsn ? data.dsn : "(null)",
data.uid ? data.uid : "(null)",
data.pwd ? data.pwd : "(null)",
data.host ? data.host : "(null)",
data.port ? data.port : "(null)",
data.database ? data.database : "(null)",
- data.logfile ? data.logfile : "(null)");
+ data.schema ? data.schema : "(null)",
+ data.autocommit ? data.autocommit : "(null)",
+ data.replysize ? data.replysize : "(null)",
+ data.timezone ? data.timezone : "(null)",
+ data.logfile ? data.logfile : "(null)",
+ data.use_tls ? data.use_tls : "(null)",
+ data.servercert ? data.servercert : "(null)",
+ data.servercerthash ? data.servercerthash : "(null)",
+ data.clientkey ? data.clientkey : "(null)",
+ data.clientcert ? data.clientcert : "(null)");
/* we're optimistic: default return value */
rc = TRUE;
@@ -327,8 +400,7 @@ ConfigDSN(HWND parent, WORD request, LPC
break;
default:
rc = FALSE;
- SQLPostInstallerError(ODBC_ERROR_REQUEST_FAILED,
- "Error creating configuration
dialog");
+ SQLPostInstallerError(ODBC_ERROR_REQUEST_FAILED, "Error
creating configuration dialog");
/* fall through */
case IDCANCEL:
goto finish;
@@ -339,12 +411,8 @@ ConfigDSN(HWND parent, WORD request, LPC
if (!SQLValidDSN(data.dsn)) {
rc = FALSE;
if (parent)
- MessageBox(parent,
- "Invalid Datasource Name",
- NULL,
- MB_ICONERROR);
- SQLPostInstallerError(ODBC_ERROR_INVALID_NAME,
- "Invalid driver name");
+ MessageBox(parent, "Invalid Datasource Name",
NULL, MB_ICONERROR);
+ SQLPostInstallerError(ODBC_ERROR_INVALID_NAME, "Invalid
driver name");
goto finish;
}
if (dsn == NULL || strcmp(dsn, data.dsn) != 0) {
@@ -355,21 +423,14 @@ ConfigDSN(HWND parent, WORD request, LPC
if (drv && *drv) {
free(drv);
if (parent &&
- MessageBox(parent,
- "Replace existing Datasource
Name?",
- NULL,
- MB_OKCANCEL | MB_ICONQUESTION)
!= IDOK) {
+ MessageBox(parent, "Replace existing
Datasource Name?", NULL, MB_OKCANCEL | MB_ICONQUESTION) != IDOK) {
goto finish;
}
ODBCLOG("ConfigDSN removing dsn %s\n",
data.dsn);
if (!SQLRemoveDSNFromIni(data.dsn)) {
rc = FALSE;
- MessageBox(parent,
- "Failed to remove old
Datasource Name",
- NULL,
- MB_ICONERROR);
-
SQLPostInstallerError(ODBC_ERROR_REQUEST_FAILED,
- "Failed to remove
old Datasource Name");
+ MessageBox(parent, "Failed to remove
old Datasource Name", NULL, MB_ICONERROR);
+
SQLPostInstallerError(ODBC_ERROR_REQUEST_FAILED, "Failed to remove old
Datasource Name");
goto finish;
}
} else if (drv)
@@ -378,57 +439,60 @@ ConfigDSN(HWND parent, WORD request, LPC
if (dsn && !SQLRemoveDSNFromIni(dsn)) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]