Skip to content

Conversation

@leborchuk
Copy link

@leborchuk leborchuk commented Dec 29, 2025

initdb have functionality for allow group access apache@c37b3d0

Lets start use it for PGDATA and logdir

create-demo-cluster after setting permissions:


xifos@xifos-dev-jammy:~/git/cloudberry-gpdb$ ls -l /home/xifos/git/cloudberry-gpdb/gpAux/gpdemo/datadirs/dbfast1/demoDataDir0/
total 136
drwxr-x--- 5 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515  4096 Dec 29 15:34 base
drwxr-x--- 2 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515  4096 Dec 29 15:34 global
-rw-r----- 1 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515    10 Dec 29 15:35 internal.auto.conf
drwxr-x--- 2 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515  4096 Dec 29 15:34 log

xifos@xifos-dev-jammy:~/git/cloudberry-gpdb$ ls -l /home/xifos/git/cloudberry-gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1/
total 152
drwxr-x--- 5 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515  4096 Dec 29 15:34 base
-rw-r----- 1 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515    38 Dec 29 15:34 current_logfiles
drwxr-x--- 2 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515  4096 Dec 29 15:34 global
-rw-rw-r-- 1 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515   860 Dec 29 15:34 gpssh.conf
-rw-r----- 1 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515    10 Dec 29 15:34 internal.auto.conf
drwxr-x--- 2 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515  4096 Dec 29 15:34 log

new mirrors
xifos@xifos-dev-jammy:~$ ls -l /home/xifos/git/cloudberry-gpdb/gpAux/gpdemo/datadirs/dbfast_mirror2/demoDataDir1
total 320
-rw-r----- 1 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515    225 Dec 30 08:06 backup_label.old
-rw-r----- 1 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515 171484 Dec 30 08:06 backup_manifest
drwxr-x--- 5 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515   4096 Dec 30 08:06 base
-rw-r----- 1 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515     38 Dec 30 08:07 current_logfiles
drwxr-x--- 2 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515   4096 Dec 30 08:06 global
-rw-r----- 1 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515     10 Dec 30 08:06 internal.auto.conf
drwxr-x--- 2 xifos dpt_yandex_exp_9053_9308_4536_dep36035_dep04515   4096 Dec 30 08:07 log

reshke and others added 7 commits December 24, 2025 14:49
…reception (apache#1498)

This pr fixes https://www.postgresql.org/support/security/CVE-2022-41862/ in cloudberry


https://git.postgresql.org/cgit/postgresql.git/commit/?id=71c37797d7bd78266146a5829ab62b3687c47295


Original commit message:

===

pqsecure_open_gss() includes a code path handling error messages with v2-style protocol messages coming from the server.  The client-side buffer holding the error message does not force a NULL-termination, with the data of the server getting copied to the errorMessage of the connection.  Hence, it would be possible for a server to send an unterminated string and copy arbitrary bytes in the buffer receiving the error message in the client, opening the door to a crash or even data exposure.

As at this stage of the authentication process the exchange has not been completed yet, this could be abused by an attacker without Kerberos credentials.  Clients that have a valid kerberos cache are vulnerable as libpq opportunistically requests for it except if gssencmode is disabled.

Author: Jacob Champion
Backpatch-through: 12
Security: CVE-2022-41862
We inherited this issue from PostgreSQL.

PostgreSQL uses glibc to sort strings. In version glibc=2.28, collations
broke down badly (in general, there are no guarantees when updating glibc).
Changing collations breaks indexes. Similarly, a cluster with different
collations also behaves unpredictably.

What and when something has changed in glibc can be found
on https://github.com/ardentperf/glibc-unicode-sorting
Also there is special postgresql-wiki https://wiki.postgresql.org/wiki/Locale_data_changes
And you tube video https://www.youtube.com/watch?v=0E6O-V8Jato

In short, the issue can be seen through the use of bash:

( echo "1-1"; echo "11" ) | LC_COLLATE=en_US.UTF-8 sort

gives the different results in ubunru 18.04 and 22.04.

There is no way to solve the problem other than by not changing the symbol order.
We freeze symbol order and use it instead of glibc.

Here the solution https://github.com/postgredients/mdb-locales.

In this PR I have added PostgreSQL patch that replaces all glibc
locale-related calls with a calls to an external libary. It activates
using new configure parameter --with-mdblocales, which is off by
default.

Using custom locales needs libmdblocales1 package and mdb-locales
package with symbol table.

Build needs libmdblocales-dev package with headers.
* MDB admin patch & tests

This patch introcudes new pseudo-pre-defined role "mdb_admin".

Introduces 2 new function:
extern bool mdb_admin_allow_bypass_owner_checks(Oid userId,  Oid ownerId);
extern void check_mdb_admin_is_member_of_role(Oid member, Oid role);

To check mdb admin belongship and role-to-role ownership transfer
correctness.

Our mdb_admin ACL model is the following:

* Any roles user or/and roles can be granted with mdb_admin
* mdb_admin memeber can tranfser ownershup of relations,
namespaces and functions to other roles, if target role in neither:
superuser, pg_read_server_files, pg_write_server_files nor
pg_execute_server_program.

This patch allows mdb admin to tranfers ownership on non-superuser objects

* f
This commit introduces new mdb internal role mdb_superuser.

Role is capaple of:

GRANT/REVOKE any set of priviledges to/from any object in database.
Has power of pg_database_owner in any database, including:
DROP any object in database (except system catalog and stuff)

Role is NOT capaple of:

Create database, role, extension or alter other roles with such
priviledges.

Transfer ownership to /pass has_priv of roles:

PG_READ_ALL_DATA
PG_WRITE_ALL_DATA
PG_EXECUTE_SERVER_PROGRAM
PG_READ_SERVER_FILES
PG_WRITE_SERVER_FILES
PG_DATABASE_OWNER

Fix configure.ac USE_MDBLOCALES option handling

Apply autoreconf stuff

Set missing ok parameter ito true while acquiring mdb_superuser oid

In regress tests, nobody creates mdb_superuser role, so missing ok is
fine

Allow mdb_superuser to have power of pg_database_owner

Allow mdb_superuser to alter objects and grant ACl to
objects, owner by pg_database_owner. Also, when acl check,
allow mdb_supersuer use pg_database_owner role power to pass check
@leborchuk
Copy link
Author

Test misc will fix in other PR

@leborchuk
Copy link
Author

The tests failed because of space exhaustion. We could ignore it till apache#1511 is merged

@reshke reshke force-pushed the main branch 2 times, most recently from 03c99a9 to a3e8a2e Compare January 17, 2026 19:32
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.

4 participants