New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update SCRAM using Postgres 15.1 #797
base: master
Are you sure you want to change the base?
Conversation
This commit copies the original files from PostgreSQL source code. It uses minor version 15.1 (latest stable minor version). As is, it overrides the changes made by previous commits. The required changes are reintroduced in the next commit. This SCRAM update requires additional files due to upstream changes. Although some header files were mixed *.c files (such as md5_int.h), all *.h files were added to include/common and the references were updated. The reason is that Makefile does not include the current directory for header files. No changes were made to these files yet. It is done in the next commit. THIS COMMIT DOES NOT COMPILE.
After copying (over) the required files, a few changes are required to compile the code. The challenge was to apply minimal changes to make it work. system.h and postgres_compat.h does the trick plus changing some references to header files that is now in the include/common directory. Makefile included the new required files.
scram_SaltedPassword(password, salt, saltlen, iterations, salted_password); | ||
scram_ServerKey(salted_password, computed_key); | ||
scram_SaltedPassword(password, salt, saltlen, iterations, salted_password, &errstr); | ||
scram_ServerKey(salted_password, computed_key, &errstr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we be doing something with errstr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I forgot to add a TODO. A few error/warning messages was added to these scram_XXX
functions in Postgres and we should do the same in PgBouncer as well.
@eulerto Do you still want to work on this? |
It is on my list for some time. I will post an updated PR soon. |
Since SCRAM support as copied from Postgres 11.5, SCRAM infrastructure changed quite a bit. This update uses Postgres 15.1 as base. New files need to be added due to code rearrangement.
I split this work in 3 steps:
etc/import-common.sh
. It adds additional files that needs to be copied for this update.Although Postgres mixes some header files (such as
sha2_int.h
) with *.c files, I moved all header files to include/common and updated the references to them. The reason is thatMakefile
does not include the current directory.After copying (over) the required files, a few changes are required to compile the code. The challenge was to apply minimal changes to make it work.
system.h
andpostgres_compat.h
does the trick plus changing some header file references that is now in theinclude/common
directory. Makefile was updated to include the new required files.TODO:
scram_XXX
functions should useerrstr
for error handling