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 DC52E9C2-B349-4291-89D0-F015E289DEB8@apple.com
Whole thread Raw
Responses Re: Trusted extension cannot be dropped by the owner of the extension  (Bruce Momjian <bruce@momjian.us>)
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: "Daniel Verite"
Date:
Subject: Re: BUG #17434: CREATE/DROP DATABASE can be executed in the same transaction with other commands
Next
From: Bruce Momjian
Date:
Subject: Re: Trusted extension cannot be dropped by the owner of the extension