Re: [PATCH] Allow bare library names for non-superuser LOAD

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: solai v <solai(dot)cdac(at)gmail(dot)com>, Japin Li <japinli(at)hotmail(dot)com>
Cc: cca5507 <cca5507(at)qq(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Allow bare library names for non-superuser LOAD
Date: 2026-09-09 07:02:08
Message-ID: b08c5b95-f36d-412b-a936-7e710df6d24e@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
Thanks for the patch.

I have two quick observations:

== LOAD semantics ==

LOAD now means different things depending on which user runs it, which
can be quite problematic for scripting. For instance in the following
scenario, where we have two modules with the same name living in
different directories:

$ LIBDIR=$(pg_config --pkglibdir)
$ cp $LIBDIR/passwordcheck.so $LIBDIR/demo.so
$ cp $LIBDIR/auto_explain.so $LIBDIR/plugins/demo.so

-- a superuser loads the lib from the root directory:
postgres=# LOAD 'demo';
LOAD
postgres=# SELECT count(*) FROM pg_settings WHERE name LIKE 'auto_explain%';
count
-------
0
(1 row)

-- a normal user loads it from the plugins directory, although the
command is identical

postgres=# CREATE USER foo;
CREATE ROLE
postgres=# SET ROLE foo;
SET
postgres=> LOAD 'demo';
LOAD
postgres=> SELECT count(*) FROM pg_settings WHERE name LIKE 'auto_explain%';
count
-------
15
(1 row)

Without the patch we get an ERROR, which is arguably better than "the
wrong file":

postgres=> LOAD 'demo';
ERROR: access to library "demo" is not allowed

== error message ==

The error message now says something else (different sqlstates?):

postgres=> LOAD 'pg_stat_statements';
ERROR: could not access file "$libdir/plugins/pg_stat_statements": No
such file or directory

Without the patch:

postgres=> LOAD 'pg_stat_statements';
ERROR: access to library "pg_stat_statements" is not allowed

I believe that this kind of error reclassification might confuse
monitoring tools -- IMO not a blocker, but must be well justified.

Best, Jim

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Yuhang Qiu 2026-09-09 07:05:20 Re: [PATCH] Use maintenance_io_concurrency for parallel index builds
Previous Message Fujii Masao 2026-09-09 06:55:40 Re: pg_stat_progress_cluster: do not default to CLUSTER