Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb52950c

Browse files
author
Hiroshi Inoue
committed
Add md5 authentication support thanks to Bruce Momjian.
1 parentf14fdad commitb52950c

File tree

6 files changed

+468
-4
lines changed

6 files changed

+468
-4
lines changed

‎src/interfaces/odbc/GNUmakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# GNUMakefile for psqlodbc (Postgres ODBC driver)
44
#
5-
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.22 2001/10/09 22:32:33 petere Exp $
5+
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.23 2001/11/12 00:54:28 inoue Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -19,11 +19,11 @@ endif
1919
SO_MAJOR_VERSION = 0
2020
SO_MINOR_VERSION = 27
2121

22-
overrideCPPFLAGS := -I$(srcdir)$(CPPFLAGS)
22+
overrideCPPFLAGS := -I$(srcdir)$(CPPFLAGS) -DFRONTEND -DMD5_ODBC
2323

2424

2525
OBJS = info.o bind.o columninfo.o connection.o convert.o drvconn.o\
26-
environ.o execute.o lobj.o misc.o options.o\
26+
environ.o execute.o lobj.omd5.omisc.o options.o\
2727
pgtypes.o psqlodbc.o qresult.o results.o socket.o parse.o statement.o\
2828
tuple.o tuplelist.o dlg_specific.o odbcapi.o
2929

‎src/interfaces/odbc/connection.c

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#endif
3333

3434
#include"pgapifunc.h"
35+
#include"md5.h"
3536

3637
#defineSTMT_INCREMENT 16/* how many statement holders to allocate
3738
* at a time */
@@ -508,6 +509,39 @@ CC_set_translation(ConnectionClass *self)
508509
return TRUE;
509510
}
510511

512+
staticint
513+
md5_auth_send(ConnectionClass*self,constchar*salt)
514+
{
515+
char*pwd1=NULL,*pwd2=NULL;
516+
ConnInfo*ci=&(self->connInfo);
517+
SocketClass*sock=self->sock;
518+
519+
mylog("MD5 user=%s password=%s\n",ci->username,ci->password);
520+
if (!(pwd1=malloc(MD5_PASSWD_LEN+1)))
521+
return1;
522+
if (!EncryptMD5(ci->password,ci->username,strlen(ci->username),pwd1))
523+
{
524+
free(pwd1);
525+
return1;
526+
}
527+
if (!(pwd2=malloc(MD5_PASSWD_LEN+1)))
528+
{
529+
free(pwd1);
530+
return1;
531+
}
532+
if (!EncryptMD5(pwd1+strlen("md5"),salt,4,pwd2))
533+
{
534+
free(pwd2);
535+
free(pwd1);
536+
return1;
537+
}
538+
free(pwd1);
539+
SOCK_put_int(sock,4+strlen(pwd2)+1,4);
540+
SOCK_put_n_char(sock,pwd2,strlen(pwd2)+1);
541+
SOCK_flush_output(sock);
542+
free(pwd2);
543+
return0;
544+
}
511545

512546
char
513547
CC_connect(ConnectionClass*self,chardo_password)
@@ -763,10 +797,24 @@ CC_connect(ConnectionClass *self, char do_password)
763797
break;
764798

765799
caseAUTH_REQ_CRYPT:
766-
caseAUTH_REQ_MD5:
767800
self->errormsg="Password crypt authentication not supported";
768801
self->errornumber=CONN_AUTH_TYPE_UNSUPPORTED;
769802
return0;
803+
caseAUTH_REQ_MD5:
804+
mylog("in AUTH_REQ_MD5\n");
805+
if (ci->password[0]=='\0')
806+
{
807+
self->errornumber=CONNECTION_NEED_PASSWORD;
808+
self->errormsg="A password is required for this connection.";
809+
return-1;/* need password */
810+
}
811+
if (md5_auth_send(self,salt))
812+
{
813+
self->errormsg="md5 hashing failed";
814+
self->errornumber=CONN_INVALID_AUTHENTICATION;
815+
return0;
816+
}
817+
break;
770818

771819
caseAUTH_REQ_SCM_CREDS:
772820
self->errormsg="Unix socket credential authentication not supported";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp