Skip to content
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

Properly set schema for osm2pgsql_find_changed_ways() #2261

Merged

Conversation

falko17
Copy link
Contributor

@falko17 falko17 commented Oct 2, 2024

A temporary function osm2pgsql_find_changed_ways may be created during the update process, which has been placed under the public schema, regardless of any chosen custom schema. This is a problem if one implements security based on schemas, e.g., by assigning a custom schema for osm2pgsql and restricting it from accessing public elements (as mentioned at the end of section 3.3 of the manual).

This PR fixes that by using the configured schema. Additionally, tests are added in which a situation like the above is simulated (e.g., a user that can only access a custom schema and not public). Please tell me if there's anything I should improve/change before this can be merged.

Copy link
Collaborator

@joto joto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the PR looks pretty good except for the small changes I mention.

tests/test-output-flex-update.cpp Outdated Show resolved Hide resolved
tests/test-output-flex-update.cpp Outdated Show resolved Hide resolved
@joto
Copy link
Collaborator

joto commented Oct 3, 2024

@falko17 Most CI runs failed with this:

Connecting to database failed (context=middle.main): connection to server at
  "localhost" (::1), port 5432 failed: FATAL:  password authentication failed
  for user "limited"

Please check that.

@falko17 falko17 force-pushed the properly-set-schema-for-find_changed_ways branch from 82460e9 to 4eb9097 Compare October 3, 2024 13:19
@falko17
Copy link
Contributor Author

falko17 commented Oct 3, 2024

Thank you for the quick review! I've addressed both comments now.

Most CI runs failed [...]

On most systems, password authentication seems to be enforced for PostgreSQL—this wasn't the case on my system, hence I didn't catch it. Should be fixed now.

@joto
Copy link
Collaborator

joto commented Oct 3, 2024

Looks much better. The failing builds are probably transitory, we'll try to run them again.

Can you please fix this report from clang-tidy:

/home/runner/work/osm2pgsql/osm2pgsql/tests/test-output-flex-update.cpp:79:16: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
   79 |         return std::string(name);
      |                ^

i.e. use return {name};

Thanks!

@falko17 falko17 force-pushed the properly-set-schema-for-find_changed_ways branch from 4eb9097 to cd17e6b Compare October 3, 2024 18:34
@falko17
Copy link
Contributor Author

falko17 commented Oct 3, 2024

Yes, I've changed it to the braced initializer list now.

@falko17
Copy link
Contributor Author

falko17 commented Oct 10, 2024

@joto The PR should be fully fixed now, but two of the CI runs are still failing—given the errors shown in the logs, I don't think this is the fault of the changes. Can we try simply re-running those?

@joto joto merged commit 973abc4 into osm2pgsql-dev:master Oct 13, 2024
25 of 26 checks passed
@joto
Copy link
Collaborator

joto commented Oct 13, 2024

Sorry for the delay. It is always annoying when the CI breaks for unknown reasons, it really has nothing to do witth your code, but it means we have to be extra careful. Thanks for the nice PR with tests and everything!

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.

2 participants