mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +03:00
1) Fix a bug *double error message*.
2) Fix a bug *passowrd prompt in case of md5 authentication*. 3) Improve the DSN setup dialog.
This commit is contained in:
parent
237fb9bbc6
commit
0484700cda
@ -129,7 +129,7 @@ PGAPI_Connect(
|
|||||||
|
|
||||||
qlog("conn = %u, %s(DSN='%s', UID='%s', PWD='%s')\n", conn, func, ci->dsn, ci->username, ci->password);
|
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 */
|
/* Error messages are filled in */
|
||||||
CC_log_error(func, "Error on CC_connect", conn);
|
CC_log_error(func, "Error on CC_connect", conn);
|
||||||
@ -608,7 +608,7 @@ md5_auth_send(ConnectionClass *self, const char *salt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char
|
char
|
||||||
CC_connect(ConnectionClass *self, char do_password)
|
CC_connect(ConnectionClass *self, char password_req, char *salt_para)
|
||||||
{
|
{
|
||||||
StartupPacket sp;
|
StartupPacket sp;
|
||||||
StartupPacket6_2 sp62;
|
StartupPacket6_2 sp62;
|
||||||
@ -627,7 +627,7 @@ CC_connect(ConnectionClass *self, char do_password)
|
|||||||
|
|
||||||
mylog("%s: entering...\n", func);
|
mylog("%s: entering...\n", func);
|
||||||
|
|
||||||
if (do_password)
|
if (password_req != AUTH_REQ_OK)
|
||||||
|
|
||||||
sock = self->sock; /* already connected, just authenticate */
|
sock = self->sock; /* already connected, just authenticate */
|
||||||
|
|
||||||
@ -780,7 +780,7 @@ another_version_retry:
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (do_password)
|
if (password_req != AUTH_REQ_OK)
|
||||||
beresp = 'R';
|
beresp = 'R';
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -811,11 +811,13 @@ another_version_retry:
|
|||||||
return 0;
|
return 0;
|
||||||
case 'R':
|
case 'R':
|
||||||
|
|
||||||
if (do_password)
|
if (password_req != AUTH_REQ_OK)
|
||||||
{
|
{
|
||||||
mylog("in 'R' do_password\n");
|
mylog("in 'R' password_req=%s\n", ci->password);
|
||||||
areq = AUTH_REQ_PASSWORD;
|
areq = password_req;
|
||||||
do_password = FALSE;
|
if (salt_para)
|
||||||
|
memcpy(salt, salt_para, sizeof(salt));
|
||||||
|
password_req = AUTH_REQ_OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -823,7 +825,7 @@ another_version_retry:
|
|||||||
areq = SOCK_get_int(sock, 4);
|
areq = SOCK_get_int(sock, 4);
|
||||||
if (areq == AUTH_REQ_MD5)
|
if (areq == AUTH_REQ_MD5)
|
||||||
SOCK_get_n_char(sock, salt, 4);
|
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);
|
SOCK_get_n_char(sock, salt, 2);
|
||||||
|
|
||||||
mylog("areq = %d\n", areq);
|
mylog("areq = %d\n", areq);
|
||||||
@ -850,7 +852,7 @@ another_version_retry:
|
|||||||
{
|
{
|
||||||
self->errornumber = CONNECTION_NEED_PASSWORD;
|
self->errornumber = CONNECTION_NEED_PASSWORD;
|
||||||
self->errormsg = "A password is required for this connection.";
|
self->errormsg = "A password is required for this connection.";
|
||||||
return -1; /* need password */
|
return -areq; /* need password */
|
||||||
}
|
}
|
||||||
|
|
||||||
mylog("past need password\n");
|
mylog("past need password\n");
|
||||||
@ -872,7 +874,9 @@ another_version_retry:
|
|||||||
{
|
{
|
||||||
self->errornumber = CONNECTION_NEED_PASSWORD;
|
self->errornumber = CONNECTION_NEED_PASSWORD;
|
||||||
self->errormsg = "A password is required for this connection.";
|
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))
|
if (md5_auth_send(self, salt))
|
||||||
{
|
{
|
||||||
@ -1478,7 +1482,10 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
|
|||||||
self->errornumber = CONNECTION_COULD_NOT_RECEIVE;
|
self->errornumber = CONNECTION_COULD_NOT_RECEIVE;
|
||||||
self->errormsg = QR_get_message(res);
|
self->errormsg = QR_get_message(res);
|
||||||
ReadyToReturn = TRUE;
|
ReadyToReturn = TRUE;
|
||||||
retres = NULL;
|
if (PGRES_FATAL_ERROR == QR_get_status(res))
|
||||||
|
retres = cmdres;
|
||||||
|
else
|
||||||
|
retres = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
query_completed = TRUE;
|
query_completed = TRUE;
|
||||||
|
@ -328,7 +328,7 @@ char CC_begin(ConnectionClass *self);
|
|||||||
char CC_commit(ConnectionClass *self);
|
char CC_commit(ConnectionClass *self);
|
||||||
char CC_abort(ConnectionClass *self);
|
char CC_abort(ConnectionClass *self);
|
||||||
int CC_set_translation(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_add_statement(ConnectionClass *self, StatementClass *stmt);
|
||||||
char CC_remove_statement(ConnectionClass *self, StatementClass *stmt);
|
char CC_remove_statement(ConnectionClass *self, StatementClass *stmt);
|
||||||
char CC_get_error(ConnectionClass *self, int *number, char **message);
|
char CC_get_error(ConnectionClass *self, int *number, char **message);
|
||||||
|
@ -174,6 +174,10 @@ int CALLBACK driver_optionsProc(HWND hdlg,
|
|||||||
UINT wMsg,
|
UINT wMsg,
|
||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam);
|
LPARAM lParam);
|
||||||
|
int CALLBACK global_optionsProc(HWND hdlg,
|
||||||
|
UINT wMsg,
|
||||||
|
WPARAM wParam,
|
||||||
|
LPARAM lParam);
|
||||||
int CALLBACK ds_options1Proc(HWND hdlg,
|
int CALLBACK ds_options1Proc(HWND hdlg,
|
||||||
UINT wMsg,
|
UINT wMsg,
|
||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
|
@ -266,6 +266,43 @@ driver_optionsProc(HWND hdlg,
|
|||||||
return FALSE;
|
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
|
int CALLBACK
|
||||||
ds_options1Proc(HWND hdlg,
|
ds_options1Proc(HWND hdlg,
|
||||||
UINT wMsg,
|
UINT wMsg,
|
||||||
|
@ -78,7 +78,8 @@ PGAPI_DriverConnect(
|
|||||||
char connStrIn[MAX_CONNECT_STRING];
|
char connStrIn[MAX_CONNECT_STRING];
|
||||||
char connStrOut[MAX_CONNECT_STRING];
|
char connStrOut[MAX_CONNECT_STRING];
|
||||||
int retval;
|
int retval;
|
||||||
char password_required = FALSE;
|
char salt[5];
|
||||||
|
char password_required = AUTH_REQ_OK;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
SWORD lenStrout;
|
SWORD lenStrout;
|
||||||
|
|
||||||
@ -114,6 +115,7 @@ PGAPI_DriverConnect(
|
|||||||
getDSNdefaults(ci);
|
getDSNdefaults(ci);
|
||||||
/* initialize pg_version */
|
/* initialize pg_version */
|
||||||
CC_initialize_pg_version(conn);
|
CC_initialize_pg_version(conn);
|
||||||
|
salt[0] = '\0';
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
dialog:
|
dialog:
|
||||||
@ -173,7 +175,7 @@ dialog:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* do the actual connect */
|
/* do the actual connect */
|
||||||
retval = CC_connect(conn, password_required);
|
retval = CC_connect(conn, password_required, salt);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
{ /* need a password */
|
{ /* need a password */
|
||||||
if (fDriverCompletion == SQL_DRIVER_NOPROMPT)
|
if (fDriverCompletion == SQL_DRIVER_NOPROMPT)
|
||||||
@ -185,7 +187,7 @@ dialog:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
password_required = TRUE;
|
password_required = -retval;
|
||||||
goto dialog;
|
goto dialog;
|
||||||
#else
|
#else
|
||||||
return SQL_ERROR; /* until a better solution is found. */
|
return SQL_ERROR; /* until a better solution is found. */
|
||||||
|
@ -79,7 +79,7 @@ BEGIN
|
|||||||
GROUPBOX "Options (Advanced):",IDC_OPTIONS,141,72,140,35,
|
GROUPBOX "Options (Advanced):",IDC_OPTIONS,141,72,140,35,
|
||||||
BS_CENTER
|
BS_CENTER
|
||||||
PUSHBUTTON "DataSource",IDC_DATASOURCE,149,89,50,14
|
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.",
|
CTEXT "Please supply any missing information needed to connect.",
|
||||||
DRV_MSG_LABEL,25,4,238,10
|
DRV_MSG_LABEL,25,4,238,10
|
||||||
END
|
END
|
||||||
@ -195,6 +195,21 @@ BEGIN
|
|||||||
PUSHBUTTON "Cancel",IDCANCEL,126,195,50,14
|
PUSHBUTTON "Cancel",IDCANCEL,126,195,50,14
|
||||||
PUSHBUTTON "Apply",IDAPPLY,201,195,50,14
|
PUSHBUTTON "Apply",IDAPPLY,201,195,50,14
|
||||||
END
|
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
|
#else
|
||||||
DLG_CONFIG DIALOG DISCARDABLE 65, 43, 292, 116
|
DLG_CONFIG DIALOG DISCARDABLE 65, 43, 292, 116
|
||||||
STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION |
|
STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION |
|
||||||
@ -221,7 +236,7 @@ BEGIN
|
|||||||
GROUPBOX "Options (Advanced):",IDC_OPTIONS,140,74,140,35,
|
GROUPBOX "Options (Advanced):",IDC_OPTIONS,140,74,140,35,
|
||||||
BS_CENTER
|
BS_CENTER
|
||||||
PUSHBUTTON "DataSource",IDC_DATASOURCE,160,90,50,14
|
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.",
|
CTEXT "Please supply any missing information needed to connect.",
|
||||||
DRV_MSG_LABEL,36,5,220,15
|
DRV_MSG_LABEL,36,5,220,15
|
||||||
END
|
END
|
||||||
@ -337,6 +352,21 @@ BEGIN
|
|||||||
PUSHBUTTON "Cancel",IDCANCEL,126,196,50,14
|
PUSHBUTTON "Cancel",IDCANCEL,126,196,50,14
|
||||||
PUSHBUTTON "Apply",IDAPPLY,201,196,50,14
|
PUSHBUTTON "Apply",IDAPPLY,201,196,50,14
|
||||||
END
|
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
|
#endif
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -456,6 +456,7 @@ QR_next_tuple(QResultClass *self)
|
|||||||
char fetch[128];
|
char fetch[128];
|
||||||
QueryInfo qi;
|
QueryInfo qi;
|
||||||
ConnInfo *ci = NULL;
|
ConnInfo *ci = NULL;
|
||||||
|
BOOL msg_truncated;
|
||||||
UDWORD abort_opt;
|
UDWORD abort_opt;
|
||||||
|
|
||||||
if (fetch_count < num_backend_rows)
|
if (fetch_count < num_backend_rows)
|
||||||
@ -665,9 +666,12 @@ QR_next_tuple(QResultClass *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'E': /* Error */
|
case 'E': /* Error */
|
||||||
SOCK_get_string(sock, msgbuffer, ERROR_MSG_LENGTH);
|
msg_truncated = SOCK_get_string(sock, msgbuffer,
|
||||||
QR_set_message(self, msgbuffer);
|
ERROR_MSG_LENGTH);
|
||||||
self->status = PGRES_FATAL_ERROR;
|
|
||||||
|
/* Remove a newline */
|
||||||
|
if (msgbuffer[0] != '\0' && msgbuffer[strlen(msgbuffer) - 1] == '\n')
|
||||||
|
msgbuffer[strlen(msgbuffer) - 1] = '\0';
|
||||||
|
|
||||||
abort_opt = 0;
|
abort_opt = 0;
|
||||||
if (!strncmp(msgbuffer, "FATAL", 5))
|
if (!strncmp(msgbuffer, "FATAL", 5))
|
||||||
@ -679,14 +683,19 @@ QR_next_tuple(QResultClass *self)
|
|||||||
|
|
||||||
mylog("ERROR from backend in next_tuple: '%s'\n", msgbuffer);
|
mylog("ERROR from backend in next_tuple: '%s'\n", msgbuffer);
|
||||||
qlog("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;
|
return FALSE;
|
||||||
|
|
||||||
case 'N': /* Notice */
|
case 'N': /* Notice */
|
||||||
SOCK_get_string(sock, msgbuffer, ERROR_MSG_LENGTH);
|
msg_truncated = SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
|
||||||
QR_set_message(self, msgbuffer);
|
QR_set_notice(self, cmdbuffer);
|
||||||
self->status = PGRES_NONFATAL_ERROR;
|
if (QR_command_successful(self))
|
||||||
|
QR_set_status(self, PGRES_NONFATAL_ERROR);
|
||||||
qlog("NOTICE from backend in next_tuple: '%s'\n", msgbuffer);
|
qlog("NOTICE from backend in next_tuple: '%s'\n", msgbuffer);
|
||||||
|
while (msg_truncated)
|
||||||
|
msg_truncated = SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
default: /* this should only happen if the backend
|
default: /* this should only happen if the backend
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define IDS_MSGTITLE 2
|
#define IDS_MSGTITLE 2
|
||||||
#define DLG_OPTIONS_DRV 102
|
#define DLG_OPTIONS_DRV 102
|
||||||
#define DLG_OPTIONS_DS 103
|
#define DLG_OPTIONS_DS 103
|
||||||
|
#define DLG_OPTIONS_GLOBAL 104
|
||||||
#define IDC_DSNAME 400
|
#define IDC_DSNAME 400
|
||||||
#define IDC_DSNAMETEXT 401
|
#define IDC_DSNAMETEXT 401
|
||||||
#define IDC_DESC 404
|
#define IDC_DESC 404
|
||||||
|
@ -290,9 +290,8 @@ ConfigDlgProc(HWND hdlg,
|
|||||||
|
|
||||||
case IDC_DRIVER:
|
case IDC_DRIVER:
|
||||||
lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER);
|
lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER);
|
||||||
|
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_GLOBAL),
|
||||||
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
|
hdlg, global_optionsProc, (LPARAM) &lpsetupdlg->ci);
|
||||||
hdlg, driver_optionsProc, (LPARAM) &lpsetupdlg->ci);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user