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

Commit828b64f

Browse files
committed
Merge branch 'PGPROEE9_6_sha2_scram_port' of gitlab.postgrespro.ru:pgpro-dev/postgrespro into PGPROEE9_6_sha2_scram_port
2 parents8cddd83 +833b894 commit828b64f

File tree

90 files changed

+4686
-1882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+4686
-1882
lines changed

‎contrib/file_fdw/file_fdw.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ file_fdw_validator(PG_FUNCTION_ARGS)
293293
/*
294294
* Now apply the core COPY code's validation logic for more checks.
295295
*/
296-
ProcessCopyOptions(NULL, true,other_options);
296+
ProcessCopyOptions(NULL,NULL,true,other_options);
297297

298298
/*
299299
* Filename option is required for file_fdw foreign tables.
@@ -455,10 +455,10 @@ get_file_fdw_attribute_options(Oid relid)
455455
* force_null options set
456456
*/
457457
if (fnncolumns!=NIL)
458-
options=lappend(options,makeDefElem("force_not_null", (Node*)fnncolumns));
458+
options=lappend(options,makeDefElem("force_not_null", (Node*)fnncolumns,-1));
459459

460460
if (fncolumns!=NIL)
461-
options=lappend(options,makeDefElem("force_null", (Node*)fncolumns));
461+
options=lappend(options,makeDefElem("force_null", (Node*)fncolumns,-1));
462462

463463
returnoptions;
464464
}
@@ -511,7 +511,7 @@ fileGetForeignPaths(PlannerInfo *root,
511511
foreigntableid,
512512
&columns))
513513
coptions=list_make1(makeDefElem("convert_selectively",
514-
(Node*)columns));
514+
(Node*)columns,-1));
515515

516516
/* Estimate costs */
517517
estimate_costs(root,baserel,fdw_private,
@@ -632,7 +632,8 @@ fileBeginForeignScan(ForeignScanState *node, int eflags)
632632
* Create CopyState from FDW options. We always acquire all columns, so
633633
* as to match the expected ScanTupleSlot signature.
634634
*/
635-
cstate=BeginCopyFrom(node->ss.ss_currentRelation,
635+
cstate=BeginCopyFrom(NULL,
636+
node->ss.ss_currentRelation,
636637
filename,
637638
false,
638639
NIL,
@@ -705,7 +706,8 @@ fileReScanForeignScan(ForeignScanState *node)
705706

706707
EndCopyFrom(festate->cstate);
707708

708-
festate->cstate=BeginCopyFrom(node->ss.ss_currentRelation,
709+
festate->cstate=BeginCopyFrom(NULL,
710+
node->ss.ss_currentRelation,
709711
festate->filename,
710712
false,
711713
NIL,
@@ -1053,7 +1055,7 @@ file_acquire_sample_rows(Relation onerel, int elevel,
10531055
/*
10541056
* Create CopyState from FDW options.
10551057
*/
1056-
cstate=BeginCopyFrom(onerel,filename, false,NIL,options);
1058+
cstate=BeginCopyFrom(NULL,onerel,filename, false,NIL,options);
10571059

10581060
/*
10591061
* Use per-tuple memory context to prevent leak of memory used to read

‎contrib/passwordcheck/passwordcheck.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#endif
2222

2323
#include"commands/user.h"
24+
#include"libpq/scram.h"
2425
#include"fmgr.h"
2526
#include"libpq/md5.h"
2627

@@ -57,14 +58,15 @@ check_password(const char *username,
5758
{
5859
intnamelen=strlen(username);
5960
intpwdlen=strlen(password);
60-
charencrypted[MD5_PASSWD_LEN+1];
61+
char*encrypted;
6162
inti;
6263
boolpwd_has_letter,
6364
pwd_has_nonletter;
6465

6566
switch (password_type)
6667
{
6768
casePASSWORD_TYPE_MD5:
69+
casePASSWORD_TYPE_SCRAM:
6870

6971
/*
7072
* Unfortunately we cannot perform exhaustive checks on encrypted
@@ -74,12 +76,23 @@ check_password(const char *username,
7476
*
7577
* We only check for username = password.
7678
*/
77-
if (!pg_md5_encrypt(username,username,namelen,encrypted))
78-
elog(ERROR,"password encryption failed");
79+
if (password_type==PASSWORD_TYPE_MD5)
80+
{
81+
encrypted=palloc(MD5_PASSWD_LEN+1);
82+
if (pg_md5_encrypt(username,username,namelen,encrypted))
83+
elog(ERROR,"password encryption failed");
84+
}
85+
elseif (password_type==PASSWORD_TYPE_SCRAM)
86+
{
87+
encrypted=scram_build_verifier(username,password,0);
88+
}
89+
else
90+
Assert(0);/* should not happen */
7991
if (strcmp(password,encrypted)==0)
8092
ereport(ERROR,
8193
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8294
errmsg("password must not contain user name")));
95+
pfree(encrypted);
8396
break;
8497

8598
casePASSWORD_TYPE_PLAINTEXT:

‎contrib/pgcrypto/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Source file copied from src/common
2+
/sha.c
3+
/sha_openssl.c
4+
15
# Generated subdirectories
26
/log/
37
/results/

‎contrib/pgcrypto/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# contrib/pgcrypto/Makefile
22

3-
INT_SRCS = md5.c sha1.c sha2.c internal.c internal-sha2.c blf.c rijndael.c\
4-
fortuna.c random.c pgp-mpi-internal.c imath.c
3+
INT_SRCS = md5.c internal.c internal-sha2.c blf.c rijndael.c\
4+
fortuna.c random.c pgp-mpi-internal.c imath.c\
5+
sha.c
56
INT_TESTS = sha2
67

7-
OSSL_SRCS = openssl.c pgp-mpi-openssl.c
8+
OSSL_SRCS = openssl.c pgp-mpi-openssl.c sha_openssl.c
89
OSSL_TESTS = sha2 des 3des cast5
910

1011
ZLIB_TST = pgp-compression
@@ -59,6 +60,9 @@ SHLIB_LINK += $(filter -leay32, $(LIBS))
5960
SHLIB_LINK += -lws2_32
6061
endif
6162

63+
sha.csha_openssl.c:% :$(top_srcdir)/src/common/%
64+
rm -f$@&&$(LN_S)$<.
65+
6266
rijndael.o: rijndael.tbl
6367

6468
rijndael.tbl:

‎contrib/pgcrypto/fortuna.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
#include<sys/time.h>
3535
#include<time.h>
3636

37+
#include"common/sha.h"
3738
#include"px.h"
3839
#include"rijndael.h"
39-
#include"sha2.h"
4040
#include"fortuna.h"
4141

4242

@@ -112,7 +112,7 @@
112112
#defineCIPH_BLOCK16
113113

114114
/* for internal wrappers */
115-
#defineMD_CTXSHA256_CTX
115+
#defineMD_CTXpg_sha256_ctx
116116
#defineCIPH_CTXrijndael_ctx
117117

118118
structfortuna_state
@@ -154,22 +154,22 @@ ciph_encrypt(CIPH_CTX * ctx, const uint8 *in, uint8 *out)
154154
staticvoid
155155
md_init(MD_CTX*ctx)
156156
{
157-
SHA256_Init(ctx);
157+
pg_sha256_init(ctx);
158158
}
159159

160160
staticvoid
161161
md_update(MD_CTX*ctx,constuint8*data,intlen)
162162
{
163-
SHA256_Update(ctx,data,len);
163+
pg_sha256_update(ctx,data,len);
164164
}
165165

166166
staticvoid
167167
md_result(MD_CTX*ctx,uint8*dst)
168168
{
169-
SHA256_CTXtmp;
169+
pg_sha256_ctxtmp;
170170

171171
memcpy(&tmp,ctx,sizeof(*ctx));
172-
SHA256_Final(dst,&tmp);
172+
pg_sha256_final(&tmp,dst);
173173
px_memset(&tmp,0,sizeof(tmp));
174174
}
175175

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp