Trusted extension cannot be dropped by the owner of the extension - Mailing list pgsql-bugs

From Harinath Kanchu
Subject Trusted extension cannot be dropped by the owner of the extension
Date
Msg-id B20F3B79-DE7C-4705-8412-4AE5B84B53A8@apple.com
Whole thread Raw
List pgsql-bugs
Hello Postgres community,

We recently encountered a bug regarding the install/uninstall of extensions. Here are the details.


Facts/Observations:

 Unable to drop TRUSTED extension.


Postgres version:

test_db=> SELECT version();
                                                      version                                                      
-------------------------------------------------------------------------------------------------------------------
 PostgreSQL 13.2 on x86_64-apple-darwin20.3.0, compiled by Apple clang version 11.0.0 (clang-1100.0.33.17), 64-bit
(1 row)



Steps to reproduce the bug:

  1. Compile and install postgres 13.2
    1. ./configure --prefix=${INSTALL_PATH} --with-openssl --with-uuid=e2fs --with-perl --with-python --with-tcl
    2. make install-world
  2. Mark “bloom” extension as trusted
    1. Add  “trusted = true”  to “bloom.control” file located in  ${INSTALL_PATH}/share/extension/ 
    2. Contents of bloom.control file after adding
      1. # bloom extension
      2. comment = 'bloom access method - signature file based index'
      3. default_version = '1.0'
      4. module_pathname = '$libdir/bloom'
      5. relocatable = true
      6. trusted = true
  3. Run the below commands in PSQL client (attaching the commands with output)

test_db=> create extension bloom;
CREATE EXTENSION
test_db=> drop extension bloom;
ERROR:  42501: must be superuser to drop access methods
LOCATION:  RemoveAccessMethodById, amcmds.c:130


Expected:

As the extension is marked as TRUSTED, if superuser privilege is not necessary during the “create extension” then superuser privilege should not be required when the owner of the extension drops it.

Why this expectation:

According to the documentation referred here
https://www.postgresql.org/docs/current/sql-createextension.html the following is observed.

“””
The user who runs CREATE EXTENSION becomes the owner of the extension for purposes of later privilege checks, and normally also becomes the owner of any objects created by the extension's script.
“””

if the user is the owner of the extension then it is expected that the access methods created during the extension installation should be under the same user’s ownership and there should not be an error when dropping the extension.




Thank you,


Best,
Harinath






pgsql-bugs by date:

Previous
From: David Rowley
Date:
Subject: Re: ResultCache cache error: "cache entry already complete" in 14beta1
Next
From: David Rowley
Date:
Subject: Re: ResultCache cache error: "cache entry already complete" in 14beta1