Skip to content

Commit 2bb0bd6

Browse files
author
Joseph Palermo
committed
Additional fixes for postgres 15 bump
- The changes from tust to peer and md5 are a better security posture, but they break a lot of existing use cases and should probably instead be gated behind some sort of configuration flag. Co-located bbr relies upon passwordless connection to the database as vcap user, but runs a root. Many of the acceptance tests also try using the vcap user but run as root via ssh and fail with the changes. - Postgres 15 no longer grants users access to the public schema. This prevents generated users from being able to create tables. Update the create_databases function to grant access to the public schema for each role on each database.
1 parent ae5bc41 commit 2bb0bd6

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

jobs/postgres/templates/pg_hba.conf.erb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
local all vcap peer
2-
host all vcap 127.0.0.1/32 md5
3-
host all vcap ::1/128 md5
1+
local all vcap trust
2+
host all vcap 127.0.0.1/32 trust
3+
host all vcap ::1/128 trust
44
<% if !p("databases.trust_local_connections").nil? && !p("databases.trust_local_connections") %>
55
local all all md5
66
<% else %>
7-
local all all peer
8-
host all all 127.0.0.1/32 md5
9-
host all all ::1/128 md5
7+
local all all trust
8+
host all all 127.0.0.1/32 trust
9+
host all all ::1/128 trust
1010
<% end %>
1111
<% p("databases.roles", []).each do |role| %>
1212
<%=
1313
line=nil
1414
unless role["password"]
15-
line = "hostssl all #{role["name"]} 0.0.0.0/0 cert clientcert=1 "
15+
line = "hostssl all #{role["name"]} 0.0.0.0/0 cert clientcert=verify-full "
1616
line << 'map=cnmap' if role["common_name"]
1717
end
1818
line

jobs/postgres/templates/utils.sh.erb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ function create_databases() {
5252
echo "Enabling pg_stat_statements extension..."
5353
pgexec "<%= database["name"] %>" "CREATE EXTENSION IF NOT EXISTS pg_stat_statements"
5454
<% end %>
55+
<% p("databases.roles", []).each do |role| %>
56+
echo "Granting public schema access to <%= role["name"] %> on <%= database["name"] %>"
57+
"${PACKAGE_DIR}/bin/psql" \
58+
-U "vcap" \
59+
-p "${PORT}" \
60+
-d "<%= database["name"] %>" \
61+
-c "GRANT ALL ON schema public TO \"<%= role["name"] %>\""
62+
<% end %>
5563

5664
<% end %>
5765
}

0 commit comments

Comments
 (0)