2) Fix a bug *passowrd prompt in case of md5 authentication*.
3) Improve the DSN setup dialog.
qlog("conn = %u, %s(DSN='%s', UID='%s', PWD='%s')\n", conn, func, ci->dsn, ci->username, ci->password);
- if (CC_connect(conn, FALSE) <= 0)
+ if (CC_connect(conn, AUTH_REQ_OK, NULL) <= 0)
{
/* Error messages are filled in */
CC_log_error(func, "Error on CC_connect", conn);
}
char
-CC_connect(ConnectionClass *self, char do_password)
+CC_connect(ConnectionClass *self, char password_req, char *salt_para)
{
StartupPacket sp;
StartupPacket6_2 sp62;
mylog("%s: entering...\n", func);
- if (do_password)
+ if (password_req != AUTH_REQ_OK)
sock = self->sock; /* already connected, just authenticate */
do
{
- if (do_password)
+ if (password_req != AUTH_REQ_OK)
beresp = 'R';
else
{
return 0;
case 'R':
- if (do_password)
+ if (password_req != AUTH_REQ_OK)
{
- mylog("in 'R' do_password\n");
- areq = AUTH_REQ_PASSWORD;
- do_password = FALSE;
+ mylog("in 'R' password_req=%s\n", ci->password);
+ areq = password_req;
+ if (salt_para)
+ memcpy(salt, salt_para, sizeof(salt));
+ password_req = AUTH_REQ_OK;
}
else
{
areq = SOCK_get_int(sock, 4);
if (areq == AUTH_REQ_MD5)
SOCK_get_n_char(sock, salt, 4);
- if (areq == AUTH_REQ_CRYPT)
+ else if (areq == AUTH_REQ_CRYPT)
SOCK_get_n_char(sock, salt, 2);
mylog("areq = %d\n", areq);
{
self->errornumber = CONNECTION_NEED_PASSWORD;
self->errormsg = "A password is required for this connection.";
- return -1; /* need password */
+ return -areq; /* need password */
}
mylog("past need password\n");
{
self->errornumber = CONNECTION_NEED_PASSWORD;
self->errormsg = "A password is required for this connection.";
- return -1; /* need password */
+ if (salt_para)
+ memcpy(salt_para, salt, sizeof(salt));
+ return -areq; /* need password */
}
if (md5_auth_send(self, salt))
{
self->errornumber = CONNECTION_COULD_NOT_RECEIVE;
self->errormsg = QR_get_message(res);
ReadyToReturn = TRUE;
- retres = NULL;
+ if (PGRES_FATAL_ERROR == QR_get_status(res))
+ retres = cmdres;
+ else
+ retres = NULL;
break;
}
query_completed = TRUE;
char CC_commit(ConnectionClass *self);
char CC_abort(ConnectionClass *self);
int CC_set_translation(ConnectionClass *self);
-char CC_connect(ConnectionClass *self, char do_password);
+char CC_connect(ConnectionClass *self, char password_req, char *salt);
char CC_add_statement(ConnectionClass *self, StatementClass *stmt);
char CC_remove_statement(ConnectionClass *self, StatementClass *stmt);
char CC_get_error(ConnectionClass *self, int *number, char **message);
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
+int CALLBACK global_optionsProc(HWND hdlg,
+ UINT wMsg,
+ WPARAM wParam,
+ LPARAM lParam);
int CALLBACK ds_options1Proc(HWND hdlg,
UINT wMsg,
WPARAM wParam,
return FALSE;
}
+int CALLBACK
+global_optionsProc(HWND hdlg,
+ UINT wMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+
+ switch (wMsg)
+ {
+ case WM_INITDIALOG:
+ CheckDlgButton(hdlg, DRV_COMMLOG, globals.commlog);
+#ifndef Q_LOG
+ EnableWindow(GetDlgItem(hdlg, DRV_COMMLOG), FALSE);
+#endif /* Q_LOG */
+ CheckDlgButton(hdlg, DRV_DEBUG, globals.debug);
+#ifndef MY_LOG
+ EnableWindow(GetDlgItem(hdlg, DRV_DEBUG), FALSE);
+#endif /* MY_LOG */
+ break;
+
+ case WM_COMMAND:
+ switch (GET_WM_COMMAND_ID(wParam, lParam))
+ {
+ case IDOK:
+ globals.commlog = IsDlgButtonChecked(hdlg, DRV_COMMLOG);
+ globals.debug = IsDlgButtonChecked(hdlg, DRV_DEBUG);
+ driver_options_update(hdlg, NULL, TRUE);
+
+ case IDCANCEL:
+ EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
int CALLBACK
ds_options1Proc(HWND hdlg,
UINT wMsg,
char connStrIn[MAX_CONNECT_STRING];
char connStrOut[MAX_CONNECT_STRING];
int retval;
- char password_required = FALSE;
+ char salt[5];
+ char password_required = AUTH_REQ_OK;
int len = 0;
SWORD lenStrout;
getDSNdefaults(ci);
/* initialize pg_version */
CC_initialize_pg_version(conn);
+ salt[0] = '\0';
#ifdef WIN32
dialog:
}
/* do the actual connect */
- retval = CC_connect(conn, password_required);
+ retval = CC_connect(conn, password_required, salt);
if (retval < 0)
{ /* need a password */
if (fDriverCompletion == SQL_DRIVER_NOPROMPT)
else
{
#ifdef WIN32
- password_required = TRUE;
+ password_required = -retval;
goto dialog;
#else
return SQL_ERROR; /* until a better solution is found. */
GROUPBOX "Options (Advanced):",IDC_OPTIONS,141,72,140,35,
BS_CENTER
PUSHBUTTON "DataSource",IDC_DATASOURCE,149,89,50,14
- PUSHBUTTON "Default",IDC_DRIVER,221,88,50,14
+ PUSHBUTTON "Global",IDC_DRIVER,221,88,50,14
CTEXT "Please supply any missing information needed to connect.",
DRV_MSG_LABEL,25,4,238,10
END
PUSHBUTTON "Cancel",IDCANCEL,126,195,50,14
PUSHBUTTON "Apply",IDAPPLY,201,195,50,14
END
+
+DLG_OPTIONS_GLOBAL DIALOG DISCARDABLE 0, 0, 306, 90
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Global settings"
+FONT 10, "Terminal"
+BEGIN
+ CTEXT "Logging before establishing connections(the default for new DSNs also)",
+ DRV_MSG_LABEL,25,15,238,10
+ CONTROL "Comm&Log (C:\\psqlodbc.log)",DRV_COMMLOG,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,30,120,10
+ CONTROL "Mylog(C:\\mylog_xxxx.log Detailed debug output)",DRV_DEBUG,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,45,200,10
+ DEFPUSHBUTTON "Save",IDOK,39,70,50,14,WS_GROUP
+ PUSHBUTTON "Cancel",IDCANCEL,104,70,50,15
+END
#else
DLG_CONFIG DIALOG DISCARDABLE 65, 43, 292, 116
STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION |
GROUPBOX "Options (Advanced):",IDC_OPTIONS,140,74,140,35,
BS_CENTER
PUSHBUTTON "DataSource",IDC_DATASOURCE,160,90,50,14
- PUSHBUTTON "Default",IDC_DRIVER,220,90,50,14
+ PUSHBUTTON "Global",IDC_DRIVER,220,90,50,14
CTEXT "Please supply any missing information needed to connect.",
DRV_MSG_LABEL,36,5,220,15
END
PUSHBUTTON "Cancel",IDCANCEL,126,196,50,14
PUSHBUTTON "Apply",IDAPPLY,201,196,50,14
END
+
+DLG_OPTIONS_GLOBAL DIALOG DISCARDABLE 0, 0, 306, 90
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Global settings"
+FONT 8, "MS Sans Serif"
+BEGIN
+ CTEXT "Logging before establishing connections(the default for new DSNs also)",
+ DRV_MSG_LABEL,25,15,238,10
+ CONTROL "Comm&Log (C:\\psqlodbc.log)",DRV_COMMLOG,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,30,120,10
+ CONTROL "Mylog(C:\\mylog_xxxx.log Detailed debug output)",
+ DRV_DEBUG,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,13,45,200,10
+ DEFPUSHBUTTON "Save",IDOK,39,70,50,14,WS_GROUP
+ PUSHBUTTON "Cancel",IDCANCEL,104,70,50,15
+END
#endif
/////////////////////////////////////////////////////////////////////////////
char fetch[128];
QueryInfo qi;
ConnInfo *ci = NULL;
+ BOOL msg_truncated;
UDWORD abort_opt;
if (fetch_count < num_backend_rows)
}
case 'E': /* Error */
- SOCK_get_string(sock, msgbuffer, ERROR_MSG_LENGTH);
- QR_set_message(self, msgbuffer);
- self->status = PGRES_FATAL_ERROR;
+ msg_truncated = SOCK_get_string(sock, msgbuffer,
+ ERROR_MSG_LENGTH);
+
+ /* Remove a newline */
+ if (msgbuffer[0] != '\0' && msgbuffer[strlen(msgbuffer) - 1] == '\n')
+ msgbuffer[strlen(msgbuffer) - 1] = '\0';
abort_opt = 0;
if (!strncmp(msgbuffer, "FATAL", 5))
mylog("ERROR from backend in next_tuple: '%s'\n", msgbuffer);
qlog("ERROR from backend in next_tuple: '%s'\n", msgbuffer);
+ while (msg_truncated)
+ msg_truncated = SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
return FALSE;
case 'N': /* Notice */
- SOCK_get_string(sock, msgbuffer, ERROR_MSG_LENGTH);
- QR_set_message(self, msgbuffer);
- self->status = PGRES_NONFATAL_ERROR;
+ msg_truncated = SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
+ QR_set_notice(self, cmdbuffer);
+ if (QR_command_successful(self))
+ QR_set_status(self, PGRES_NONFATAL_ERROR);
qlog("NOTICE from backend in next_tuple: '%s'\n", msgbuffer);
+ while (msg_truncated)
+ msg_truncated = SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
continue;
default: /* this should only happen if the backend
#define IDS_MSGTITLE 2\r
#define DLG_OPTIONS_DRV 102\r
#define DLG_OPTIONS_DS 103\r
+#define DLG_OPTIONS_GLOBAL 104\r
#define IDC_DSNAME 400\r
#define IDC_DSNAMETEXT 401\r
#define IDC_DESC 404\r
case IDC_DRIVER:
lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER);
-
- DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
- hdlg, driver_optionsProc, (LPARAM) &lpsetupdlg->ci);
+ DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_GLOBAL),
+ hdlg, global_optionsProc, (LPARAM) &lpsetupdlg->ci);
return TRUE;
}