Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
b52950cc
Commit
b52950cc
authored
Nov 12, 2001
by
Hiroshi Inoue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add md5 authentication support thanks to Bruce Momjian.
parent
f14fdad8
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
468 additions
and
4 deletions
+468
-4
src/interfaces/odbc/GNUmakefile
src/interfaces/odbc/GNUmakefile
+3
-3
src/interfaces/odbc/connection.c
src/interfaces/odbc/connection.c
+49
-1
src/interfaces/odbc/md5.c
src/interfaces/odbc/md5.c
+339
-0
src/interfaces/odbc/md5.h
src/interfaces/odbc/md5.h
+52
-0
src/interfaces/odbc/win32.mak
src/interfaces/odbc/win32.mak
+10
-0
src/interfaces/odbc/win_md5.c
src/interfaces/odbc/win_md5.c
+15
-0
No files found.
src/interfaces/odbc/GNUmakefile
View file @
b52950cc
...
...
@@ -2,7 +2,7 @@
#
# GNUMakefile for psqlodbc (Postgres ODBC driver)
#
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.2
2 2001/10/09 22:32:33 peter
e Exp $
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.2
3 2001/11/12 00:54:28 inou
e Exp $
#
#-------------------------------------------------------------------------
...
...
@@ -19,11 +19,11 @@ endif
SO_MAJOR_VERSION
=
0
SO_MINOR_VERSION
=
27
override CPPFLAGS
:
= -I$(srcdir) $(CPPFLAGS)
override CPPFLAGS
:
= -I$(srcdir) $(CPPFLAGS)
-DFRONTEND -DMD5_ODBC
OBJS
=
info.o bind.o columninfo.o connection.o convert.o drvconn.o
\
environ.o execute.o lobj.o misc.o options.o
\
environ.o execute.o lobj.o m
d5.o m
isc.o options.o
\
pgtypes.o psqlodbc.o qresult.o results.o socket.o parse.o statement.o
\
tuple.o tuplelist.o dlg_specific.o odbcapi.o
...
...
src/interfaces/odbc/connection.c
View file @
b52950cc
...
...
@@ -32,6 +32,7 @@
#endif
#include "pgapifunc.h"
#include "md5.h"
#define STMT_INCREMENT 16
/* how many statement holders to allocate
* at a time */
...
...
@@ -508,6 +509,39 @@ CC_set_translation(ConnectionClass *self)
return
TRUE
;
}
static
int
md5_auth_send
(
ConnectionClass
*
self
,
const
char
*
salt
)
{
char
*
pwd1
=
NULL
,
*
pwd2
=
NULL
;
ConnInfo
*
ci
=
&
(
self
->
connInfo
);
SocketClass
*
sock
=
self
->
sock
;
mylog
(
"MD5 user=%s password=%s
\n
"
,
ci
->
username
,
ci
->
password
);
if
(
!
(
pwd1
=
malloc
(
MD5_PASSWD_LEN
+
1
)))
return
1
;
if
(
!
EncryptMD5
(
ci
->
password
,
ci
->
username
,
strlen
(
ci
->
username
),
pwd1
))
{
free
(
pwd1
);
return
1
;
}
if
(
!
(
pwd2
=
malloc
(
MD5_PASSWD_LEN
+
1
)))
{
free
(
pwd1
);
return
1
;
}
if
(
!
EncryptMD5
(
pwd1
+
strlen
(
"md5"
),
salt
,
4
,
pwd2
))
{
free
(
pwd2
);
free
(
pwd1
);
return
1
;
}
free
(
pwd1
);
SOCK_put_int
(
sock
,
4
+
strlen
(
pwd2
)
+
1
,
4
);
SOCK_put_n_char
(
sock
,
pwd2
,
strlen
(
pwd2
)
+
1
);
SOCK_flush_output
(
sock
);
free
(
pwd2
);
return
0
;
}
char
CC_connect
(
ConnectionClass
*
self
,
char
do_password
)
...
...
@@ -763,10 +797,24 @@ another_version_retry:
break
;
case
AUTH_REQ_CRYPT
:
case
AUTH_REQ_MD5
:
self
->
errormsg
=
"Password crypt authentication not supported"
;
self
->
errornumber
=
CONN_AUTH_TYPE_UNSUPPORTED
;
return
0
;
case
AUTH_REQ_MD5
:
mylog
(
"in AUTH_REQ_MD5
\n
"
);
if
(
ci
->
password
[
0
]
==
'\0'
)
{
self
->
errornumber
=
CONNECTION_NEED_PASSWORD
;
self
->
errormsg
=
"A password is required for this connection."
;
return
-
1
;
/* need password */
}
if
(
md5_auth_send
(
self
,
salt
))
{
self
->
errormsg
=
"md5 hashing failed"
;
self
->
errornumber
=
CONN_INVALID_AUTHENTICATION
;
return
0
;
}
break
;
case
AUTH_REQ_SCM_CREDS
:
self
->
errormsg
=
"Unix socket credential authentication not supported"
;
...
...
src/interfaces/odbc/md5.c
0 → 100644
View file @
b52950cc
This diff is collapsed.
Click to expand it.
src/interfaces/odbc/md5.h
0 → 100644
View file @
b52950cc
/* File: connection.h
*
* Description: See "connection.c"
*
* Comments: See "notice.txt" for copyright and license information.
*
*/
#ifndef __MD5_H__
#define __MD5_H__
#include "psqlodbc.h"
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#define MD5_ODBC
#define FRONTEND
#endif
#define MD5_PASSWD_LEN 35
/* From c.h */
#ifndef __BEOS__
#ifndef __cplusplus
#ifndef bool
typedef
char
bool
;
#endif
#ifndef true
#define true ((bool) 1)
#endif
#ifndef false
#define false ((bool) 0)
#endif
#endif
/* not C++ */
#endif
/* __BEOS__ */
#ifndef __BEOS__
/* this shouldn't be required, but is is! */
typedef
unsigned
char
uint8
;
/* == 8 bits */
typedef
unsigned
short
uint16
;
/* == 16 bits */
typedef
unsigned
int
uint32
;
/* == 32 bits */
#endif
/* __BEOS__ */
extern
bool
EncryptMD5
(
const
char
*
passwd
,
const
char
*
salt
,
size_t
salt_len
,
char
*
buf
);
#endif
src/interfaces/odbc/win32.mak
View file @
b52950cc
...
...
@@ -67,6 +67,7 @@ CLEAN :
-
@erase
"
$(INTDIR)
\g
pps.obj"
-
@erase
"
$(INTDIR)
\i
nfo.obj"
-
@erase
"
$(INTDIR)
\l
obj.obj"
-
@erase
"
$(INTDIR)
\w
in_md5.obj"
-
@erase
"
$(INTDIR)
\m
isc.obj"
!IF
"$(CFG)"
==
"MultibyteRelease"
-@erase
"$(INTDIR)\multibyte.obj"
...
...
@@ -152,6 +153,7 @@ LINK32_OBJS= \
"
$(INTDIR)
\g
pps.obj"
\
"
$(INTDIR)
\i
nfo.obj"
\
"
$(INTDIR)
\l
obj.obj"
\
"
$(INTDIR)
\w
in_md5.obj"
\
"
$(INTDIR)
\m
isc.obj"
\
!
IF
"
$(CFG)
"
==
"MultibyteRelease"
"$(INTDIR)\multibyte.obj"
\
...
...
@@ -200,6 +202,7 @@ CLEAN :
-
@erase
"
$(INTDIR)
\g
pps.obj"
-
@erase
"
$(INTDIR)
\i
nfo.obj"
-
@erase
"
$(INTDIR)
\l
obj.obj"
-
@erase
"
$(INTDIR)
\w
in_md5.obj"
-
@erase
"
$(INTDIR)
\m
isc.obj"
!IF
"$(CFG)"
==
"MultibyteDebug"
-@erase
"$(INTDIR)\multibyte.obj"
...
...
@@ -288,6 +291,7 @@ LINK32_OBJS= \
"
$(INTDIR)
\g
pps.obj"
\
"
$(INTDIR)
\i
nfo.obj"
\
"
$(INTDIR)
\l
obj.obj"
\
"
$(INTDIR)
\w
in_md5.obj"
"$(INTDIR)\misc.obj"
\
!IF
"$(CFG)"
==
"MultibyteDebug"
"$(INTDIR)\multibyte.obj"
\
...
...
@@ -486,6 +490,12 @@ SOURCE=tuplelist.c
$(CPP)
$(CPP_PROJ)
$(SOURCE)
SOURCE
=
win_md5.c
"$(INTDIR)\win_md5.obj"
:
$(SOURCE)
"$(INTDIR)"
$(CPP)
$(CPP_PROJ)
$(SOURCE)
SOURCE
=
odbcapi.c
"$(INTDIR)\odbcapi.obj"
:
$(SOURCE)
"$(INTDIR)"
...
...
src/interfaces/odbc/win_md5.c
0 → 100644
View file @
b52950cc
/*
* win_md5.c
* Under Windows I don't love the following /D in makefiles. - inoue
*/
#define MD5_ODBC
#define FRONTEND
/*
* md5.c is the exact copy of the src/backend/libpq/md5.c.
*
* psqlodbc driver stuff never refer(link) to other
* stuff directly.
*
*/
#include "md5.c"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment