Skip to content

fix: handle errors if domain socket file is invalid - #164

Merged
olavloite merged 17 commits into
postgresql-dialectfrom
fix-default-domain-socket-file
Jun 1, 2022
Merged

olavloite merged 17 commits into
postgresql-dialectfrom
fix-default-domain-socket-file

Conversation

@olavloite

@olavloite olavloite commented May 25, 2022 •

Copy link
Copy Markdown
Collaborator

The default Unix domain socket file is in the directory /tmp/, but some PostgreSQL distributions use /var/run/postgresql/ as the default directory. If anyone tries to change the directory that should be used by PGAdapter to /var/run/postgresql/, the probability is very high that it will cause a permission denied error when PGAdapter tries to write to that directory. This PR adds error handling for the case that a user specifies an invalid or inaccessible file for Unix domain sockets.

Also adds additional tests for Unix domain sockets, and changes some of the psql tests to use domain sockets to connect instead of TCP, to verify that our domain sockets implementation also works with psql.

olavloite added 4 commits May 25, 2022 14:03
The default Unix domain socket file should be in /var/run/postgresql/
The official default directory for Unix domain sockets is /tmp. This is
changed by some distributions to /var/run/postgresql, but that is not
very convenient for PGAdapter, as it would require elevated permissions
to be able to write anything there.
@codecov

codecov Bot commented May 25, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #164 (ecacdae) into postgresql-dialect (52452d7) will increase coverage by 0.12%.
The diff coverage is 86.11%.

@@                   Coverage Diff                    @@
##             postgresql-dialect     #164      +/-   ##
========================================================
+ Coverage                 77.51%   77.64%   +0.12%     
- Complexity                  953      958       +5     
========================================================
  Files                        85       85              
  Lines                      3260     3283      +23     
  Branches                    380      384       +4     
========================================================
+ Hits                       2527     2549      +22     
+ Misses                      579      578       -1     
- Partials                    154      156       +2     
Flag Coverage Δ
all_tests 77.64% <86.11%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ud/spanner/pgadapter/wireprotocol/BindMessage.java 73.91% <ø> (ø)
...spanner/pgadapter/wireprotocol/ExecuteMessage.java 83.33% <ø> (ø)
...d/spanner/pgadapter/wireprotocol/ParseMessage.java 80.00% <ø> (-0.77%) ⬇️
...om/google/cloud/spanner/pgadapter/ProxyServer.java 73.33% <85.71%> (+1.99%) ⬆️
...ud/spanner/pgadapter/metadata/OptionsMetadata.java 79.67% <86.36%> (+0.75%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 52452d7...ecacdae. Read the comment docs.

@olavloite olavloite changed the title fix: default domain socket file fix: handle errors if domain socket file is invalid May 25, 2022
@olavloite
olavloite marked this pull request as ready for review May 25, 2022 15:41
@olavloite
olavloite merged commit 4a6d865 into postgresql-dialect Jun 1, 2022
@olavloite
olavloite deleted the fix-default-domain-socket-file branch June 1, 2022 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant