From b0eaf3b05d01e25bf54973e9d38e3062d626c0e6 Mon Sep 17 00:00:00 2001 From: Kathia Barahona Date: Thu, 15 Aug 2024 14:29:08 +0200 Subject: [PATCH] Build PG17 --- .github/workflows/build.yml | 4 +-- .idea/workspace.xml | 68 +++++++++++++++++++++++++++++++++++++ src/aiven_gatekeeper.c | 12 ++++++- 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 .idea/workspace.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b8de7a..5dca70b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: strategy: max-parallel: 3 matrix: - pg-version: [11, 12, 13, 14, 15, 16] + pg-version: [11, 12, 13, 14, 15, 16, 17] steps: - id: install run: | @@ -25,7 +25,7 @@ jobs: # Get the postgresql gpg key sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7FCC7D46ACCC4CF8 # Setup the Postgres repositories - sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' + sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main ${{ matrix.pg-version }}" > /etc/apt/sources.list.d/pgdg.list' sudo apt-get update # Install build deps sudo apt-get install -y postgresql-server-dev-${{ matrix.pg-version }} diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..e907fca --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + { + "associatedIndex": 2 +} + + + + { + "keyToString": { + "RunOnceActivity.ShowReadmeOnStart": "true", + "git-widget-placeholder": "main", + "last_opened_file_path": "/Users/kathia.barahona/Desktop/aiven-dev/aiven-pg-security", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "vue.rearranger.settings.migration": "true" + } +} + + + + + + + + + + + 1723724750186 + + + + + + \ No newline at end of file diff --git a/src/aiven_gatekeeper.c b/src/aiven_gatekeeper.c index 4a4355d..eb2b7ee 100644 --- a/src/aiven_gatekeeper.c +++ b/src/aiven_gatekeeper.c @@ -36,6 +36,16 @@ PG_MODULE_MAGIC; +/* Check the PostgreSQL version */ +#if PG_VERSION_NUM >= 170000 +/* For PostgreSQL 17 and later, use current_role_is_superuser */ +#define SUPERUSER_CHECK current_role_is_superuser +#else +/* For earlier versions, use session_auth_is_superuser */ +#define SUPERUSER_CHECK session_auth_is_superuser +#endif + + void _PG_init(void); void _PG_fini(void); @@ -141,7 +151,7 @@ is_elevated(void) is_superuser = superuser_arg(currentUserId); /* elevated to supersuser when the session auth user does not have superuser privileges */ - return is_superuser && !session_auth_is_superuser; + return is_superuser && !SUPERUSER_CHECK(); } static bool