pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedglob support in extension_control_path/dynamic_library_path?
12+ messages / 6 participants
[nested] [flat]
* glob support in extension_control_path/dynamic_library_path?
@ 2026-05-29 12:26 Jakob Egger <jakob@eggerapps.at>
2026-05-29 21:36 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
2026-06-01 09:38 ` Re: glob support in extension_control_path/dynamic_library_path? Matheus Alcantara <matheusssilv97@gmail.com>
0 siblings, 2 replies; 12+ messages in thread
From: Jakob Egger @ 2026-05-29 12:26 UTC (permalink / raw)
To: pgsql-hackers; +Cc: david@justatheory.com, Tobias Bussmann <t.bussmann@gmx.net>
Hello!
The extension_control_path setting allowed us to offer precompiled downloadable extensions for Postgres.app: https://postgresapp.com/extensions/
We install extensions each into their own path, for example:
/Users/USER/Library/Application Support/Postgres/Extensions/18/http
/Users/USER/Library/Application Support/Postgres/Extensions/18/pg_cron
....
This allows us to update extensions by just deleting the folder and installing the new version -- we don't need to track all the files belonging to an extension. If we put all separately downloaded extensions in a single directory we would be very likely to end up with orphaned files sooner or later.
However, this leads to a rather lengthy configuration that needs to be updated whenever an extension is installed:
extension_control_path="$system:/Users/jakob/Library/Application Support/Postgres/Extensions/18/pg_parquet/share/postgresql:/Users/jakob/Library/Application Support/Postgres/Extensions/18/pg_cron/share/postgresql:/Users/jakob/Library/Application Support/Postgres/Extensions/18/http/share/postgresql:/Users/jakob/Library/Application Support/Postgres/Extensions/18/timescaledb/share/postgresql:/Users/jakob/Library/Application Support/Postgres/Extensions/18/plv8/share/postgresql:/Users/jakob/Library/Application Support/Postgres/Extensions/18/pg_search/share/postgresql"
It would be really nice if we could just use glob patterns like this:
extension_control_path="$system:/Users/jakob/Library/Application Support/Postgres/Extensions/18/*/share/postgresql"
dynamic_library_path="$libdir:/Users/jakob/Library/Application Support/Postgres/Extensions/18/*/lib/postgresql"
This would also have the advantage of not requiring a server restart after installing an extension.
I believe this would also be useful for Docker use case mentioned in the original thread (https://www.postgresql.org/message-id/E7C7BFFB-8857-48D4-A71F-88B359FADCFD%40justatheory.com) when multiple extensions are used
I have tried implementing this patch myself, and it was pretty straightforward to implement a proof of concept.
I wonder if such an addition would be useful for other packagers?
Best regards,
Jakob=
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: glob support in extension_control_path/dynamic_library_path?
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
@ 2026-05-29 21:36 ` David E. Wheeler <david@justatheory.com>
1 sibling, 0 replies; 12+ messages in thread
From: David E. Wheeler @ 2026-05-29 21:36 UTC (permalink / raw)
To: Jakob Egger <jakob@eggerapps.at>; +Cc: pgsql-hackers@postgresql.org, Tobias Bussmann <t.bussmann@gmx.net>
On May 29, 2026, at 14:26, Jakob Egger <jakob@eggerapps.at> wrote:
> It would be really nice if we could just use glob patterns like this:
>
> extension_control_path="$system:/Users/jakob/Library/Application Support/Postgres/Extensions/18/*/share/postgresql"
> dynamic_library_path="$libdir:/Users/jakob/Library/Application Support/Postgres/Extensions/18/*/lib/postgresql"
>
> This would also have the advantage of not requiring a server restart after installing an extension.
Somehow a glob never occurred to me. 🤦🏻
> I believe this would also be useful for Docker use case mentioned in the original thread (https://www.postgresql.org/message-id/E7C7BFFB-8857-48D4-A71F-88B359FADCFD%40justatheory.com) when multiple extensions are used
Indeed.
> I have tried implementing this patch myself, and it was pretty straightforward to implement a proof of concept.
>
> I wonder if such an addition would be useful for other packagers?
Me too! I had been planning to propose a new directory layout, but a glob is a much simpler solution.
D
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: glob support in extension_control_path/dynamic_library_path?
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
@ 2026-06-01 09:38 ` Matheus Alcantara <matheusssilv97@gmail.com>
2026-06-01 13:21 ` Re: glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
1 sibling, 1 reply; 12+ messages in thread
From: Matheus Alcantara @ 2026-06-01 09:38 UTC (permalink / raw)
To: Jakob Egger <jakob@eggerapps.at>; pgsql-hackers; +Cc: david@justatheory.com, Tobias Bussmann <t.bussmann@gmx.net>
On 29/05/26 09:26, Jakob Egger wrote:
> Hello!
>
> The extension_control_path setting allowed us to offer precompiled downloadable extensions for Postgres.app: https://postgresapp.com/extensions/
>
> We install extensions each into their own path, for example:
>
> /Users/USER/Library/Application Support/Postgres/Extensions/18/http
> /Users/USER/Library/Application Support/Postgres/Extensions/18/pg_cron
> ....
>
> This allows us to update extensions by just deleting the folder and installing the new version -- we don't need to track all the files belonging to an extension. If we put all separately downloaded extensions in a single directory we would be very likely to end up with orphaned files sooner or later.
>
> However, this leads to a rather lengthy configuration that needs to be updated whenever an extension is installed:
>
> extension_control_path="$system:/Users/jakob/Library/Application Support/Postgres/Extensions/18/pg_parquet/share/postgresql:/Users/jakob/Library/Application Support/Postgres/Extensions/18/pg_cron/share/postgresql:/Users/jakob/Library/Application Support/Postgres/Extensions/18/http/share/postgresql:/Users/jakob/Library/Application Support/Postgres/Extensions/18/timescaledb/share/postgresql:/Users/jakob/Library/Application Support/Postgres/Extensions/18/plv8/share/postgresql:/Users/jakob/Library/Application Support/Postgres/Extensions/18/pg_search/share/postgresql"
>
Yeah, I've also faced some configurations like this when working with
extension_control_path.
> It would be really nice if we could just use glob patterns like this:
>
> extension_control_path="$system:/Users/jakob/Library/Application Support/Postgres/Extensions/18/*/share/postgresql"
> dynamic_library_path="$libdir:/Users/jakob/Library/Application Support/Postgres/Extensions/18/*/lib/postgresql"
>
> This would also have the advantage of not requiring a server restart after installing an extension.
>
> I believe this would also be useful for Docker use case mentioned in the original thread (https://www.postgresql.org/message-id/E7C7BFFB-8857-48D4-A71F-88B359FADCFD%40justatheory.com) when multiple extensions are used
>
> I have tried implementing this patch myself, and it was pretty straightforward to implement a proof of concept.
>
> I wonder if such an addition would be useful for other packagers?
>
Please, share the patch so we can better evaluate.
--
Matheus Alcantara
EDB: https://www.enterprisedb.com
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: glob support in extension_control_path/dynamic_library_path?
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-01 09:38 ` Re: glob support in extension_control_path/dynamic_library_path? Matheus Alcantara <matheusssilv97@gmail.com>
@ 2026-06-01 13:21 ` Jakob Egger <jakob@eggerapps.at>
2026-06-24 15:34 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
0 siblings, 1 reply; 12+ messages in thread
From: Jakob Egger @ 2026-06-01 13:21 UTC (permalink / raw)
To: Matheus Alcantara <matheusssilv97@gmail.com>; +Cc: pgsql-hackers@postgresql.org, david@justatheory.com, Tobias Bussmann <t.bussmann@gmx.net>
> Am 01.06.2026 um 11:38 schrieb Matheus Alcantara <matheusssilv97@gmail.com>:
>
> Please, share the patch so we can better evaluate.
This is my attempt at the patch. It falls back to the previous behavior on Windows (would need to use alternative to glob() syscall)
Attachments:
0001-glob-support-in-extension_search_path-and-dynamic_li.patch (application/octet-stream, 4.5K) download
From 4ecaa7c65dcd1f2f843158fa554e14944096ba81 Mon Sep 17 00:00:00 2001
From: Jakob Egger <jakob@eggerapps.at>
Date: Mon, 1 Jun 2026 15:00:34 +0200
Subject: [PATCH] glob support in extension_search_path and
dynamic_library_path
---
src/backend/commands/extension.c | 40 ++++++++++++++++++++++++++++----
src/backend/utils/fmgr/dfmgr.c | 37 +++++++++++++++++++++++++++++
2 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index d073585c421..24348e4dcdc 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -28,6 +28,9 @@
#include <sys/file.h>
#include <sys/stat.h>
#include <unistd.h>
+#ifndef WIN32
+#include <glob.h>
+#endif
#include "access/genam.h"
#include "access/htup_details.h"
@@ -541,7 +544,13 @@ get_extension_control_directories(void)
int len;
char *mangled;
char *piece = first_path_var_separator(ecp);
- ExtensionLocation *location = palloc_object(ExtensionLocation);
+ char *macro;
+#ifndef WIN32
+ glob_t globres;
+ int glob_status;
+ int i;
+#endif
+ ExtensionLocation *location;
/* Get the length of the next path on ecp */
if (piece == NULL)
@@ -559,20 +568,43 @@ get_extension_control_directories(void)
*/
if (strcmp(piece, EXTENSION_SYSTEM_MACRO) == 0)
{
- location->macro = pstrdup(piece);
+ macro = pstrdup(piece);
mangled = substitute_path_macro(piece, EXTENSION_SYSTEM_MACRO, system_dir);
}
else
{
- location->macro = NULL;
+ macro = NULL;
mangled = psprintf("%s/extension", piece);
}
pfree(piece);
- /* Canonicalize the path based on the OS and add to the list */
+ /* Canonicalize the path based on the OS */
canonicalize_path(mangled);
+
+#ifndef WIN32
+ glob_status = glob(mangled, GLOB_BRACE | GLOB_ERR, NULL, &globres);
+ if (glob_status != 0)
+ {
+ if (glob_status == GLOB_NOMATCH)
+ elog(DEBUG3, "extension_search_path: glob(%s) returned no match", mangled);
+ else
+ ereport(ERROR,
+ (errcode(ERRCODE_CONFIG_FILE_ERROR),
+ errmsg("extension_search_path: glob(%s) returned %d", mangled, glob_status)));
+ }
+ for (i=0;i < globres.gl_pathc; i++) {
+ location = palloc_object(ExtensionLocation);
+ location->macro = macro;
+ location->loc = pstrdup(globres.gl_pathv[i]);
+ paths = lappend(paths, location);
+ }
+ globfree(&globres);
+#else
+ location = palloc_object(ExtensionLocation);
+ location->macro = macro;
location->loc = mangled;
paths = lappend(paths, location);
+#endif
/* Break if ecp is empty or move to the next path on ecp */
if (ecp[len] == '\0')
diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c
index e636cc81cf8..6d5d072a8aa 100644
--- a/src/backend/utils/fmgr/dfmgr.c
+++ b/src/backend/utils/fmgr/dfmgr.c
@@ -18,6 +18,7 @@
#ifndef WIN32
#include <dlfcn.h>
+#include <glob.h>
#endif /* !WIN32 */
#include "fmgr.h"
@@ -598,6 +599,11 @@ find_in_path(const char *basename, const char *path, const char *path_param,
char *piece;
char *mangled;
char *full;
+#ifndef WIN32
+ glob_t globres;
+ int glob_status;
+ int i;
+#endif
piece = first_path_var_separator(p);
if (piece == p)
@@ -624,6 +630,36 @@ find_in_path(const char *basename, const char *path, const char *path_param,
(errcode(ERRCODE_INVALID_NAME),
errmsg("component in parameter \"%s\" is not an absolute path", path_param)));
+#ifndef WIN32
+ glob_status = glob(mangled, GLOB_BRACE | GLOB_ERR, NULL, &globres);
+ if (glob_status != 0)
+ {
+ if (glob_status == GLOB_NOMATCH)
+ elog(DEBUG3, "%s: glob(%s) returned no match", path_param, mangled);
+ else
+ ereport(ERROR,
+ (errcode(ERRCODE_CONFIG_FILE_ERROR),
+ errmsg("%s: glob(%s) returned %d", path_param, mangled, glob_status)));
+ }
+ pfree(mangled);
+ for (i=0;i < globres.gl_pathc; i++)
+ {
+ mangled = globres.gl_pathv[i];
+ full = palloc(strlen(mangled) + 1 + baselen + 1);
+ sprintf(full, "%s/%s", mangled, basename);
+
+ elog(DEBUG3, "%s: trying \"%s\"", __func__, full);
+
+ if (pg_file_exists(full))
+ {
+ globfree(&globres);
+ return full;
+ }
+
+ pfree(full);
+ }
+ globfree(&globres);
+#else
full = palloc(strlen(mangled) + 1 + baselen + 1);
sprintf(full, "%s/%s", mangled, basename);
pfree(mangled);
@@ -634,6 +670,7 @@ find_in_path(const char *basename, const char *path, const char *path_param,
return full;
pfree(full);
+#endif
if (p[len] == '\0')
break;
--
2.50.1 (Apple Git-155)
=
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: glob support in extension_control_path/dynamic_library_path?
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-01 09:38 ` Re: glob support in extension_control_path/dynamic_library_path? Matheus Alcantara <matheusssilv97@gmail.com>
2026-06-01 13:21 ` Re: glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
@ 2026-06-24 15:34 ` David E. Wheeler <david@justatheory.com>
2026-06-24 15:43 ` Re: glob support in extension_control_path/dynamic_library_path? Peter Eisentraut <peter@eisentraut.org>
0 siblings, 1 reply; 12+ messages in thread
From: David E. Wheeler @ 2026-06-24 15:34 UTC (permalink / raw)
To: Jakob Egger <jakob@eggerapps.at>; +Cc: Matheus Alcantara <matheusssilv97@gmail.com>; pgsql-hackers@postgresql.org, Tobias Bussmann <t.bussmann@gmx.net>; Peter Eisentraut <peter@eisentraut.org>
(Added Peter Eisentraut)
On Jun 1, 2026, at 09:21, Jakob Egger <jakob@eggerapps.at> wrote:
> This is my attempt at the patch. It falls back to the previous behavior on Windows (would need to use alternative to glob() syscall)
Seems simple enough. Certainly far simpler than my Packaging & Lookup RFC[0], and solves the same problems. This would, for example, allow CNPG extension images to work as soon as they’re mounted as a directory covered by the wildcard, without requiring a Postgres restart! (k8s mounts still require a new pod, but that’s obviously not something we can change.)
[0]: https://justatheory.com/2024/11/rfc-extension-packaging-lookup/#solution
Peter E: what do you think about this as an evolution of the extension_control_path/dynamic_library_path work? Any gotchas to be aware of, aside from the current lack of Windows support?
D
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: glob support in extension_control_path/dynamic_library_path?
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-01 09:38 ` Re: glob support in extension_control_path/dynamic_library_path? Matheus Alcantara <matheusssilv97@gmail.com>
2026-06-01 13:21 ` Re: glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-24 15:34 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
@ 2026-06-24 15:43 ` Peter Eisentraut <peter@eisentraut.org>
2026-06-24 21:19 ` Re: glob support in extension_control_path/dynamic_library_path? Zsolt Parragi <zsolt.parragi@percona.com>
0 siblings, 1 reply; 12+ messages in thread
From: Peter Eisentraut @ 2026-06-24 15:43 UTC (permalink / raw)
To: David E. Wheeler <david@justatheory.com>; Jakob Egger <jakob@eggerapps.at>; +Cc: Matheus Alcantara <matheusssilv97@gmail.com>; pgsql-hackers@postgresql.org, Tobias Bussmann <t.bussmann@gmx.net>
On 24.06.26 17:34, David E. Wheeler wrote:
> Peter E: what do you think about this as an evolution of the extension_control_path/dynamic_library_path work? Any gotchas to be aware of, aside from the current lack of Windows support?
Yes: Anything involving paths and wildcards is scary security-wise. I
would like to see some analysis about whether or how this is safe.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: glob support in extension_control_path/dynamic_library_path?
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-01 09:38 ` Re: glob support in extension_control_path/dynamic_library_path? Matheus Alcantara <matheusssilv97@gmail.com>
2026-06-01 13:21 ` Re: glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-24 15:34 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
2026-06-24 15:43 ` Re: glob support in extension_control_path/dynamic_library_path? Peter Eisentraut <peter@eisentraut.org>
@ 2026-06-24 21:19 ` Zsolt Parragi <zsolt.parragi@percona.com>
2026-06-25 05:15 ` Re: glob support in extension_control_path/dynamic_library_path? Kyotaro Horiguchi <horikyota.ntt@gmail.com>
2026-06-25 14:47 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
2026-09-02 11:27 ` Re: glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
0 siblings, 3 replies; 12+ messages in thread
From: Zsolt Parragi @ 2026-06-24 21:19 UTC (permalink / raw)
To: pgsql-hackers@lists.postgresql.org
Security seems to be an interesting question for this.
The current patch simply takes a wildcard, and evaluates it every time
it is needed. Is that the correct approach? The advantage is that when
a new directory matching the pattern appears, it is automatically
detected... but that's also the disadvantage.
Wouldn't it be better to freeze the current list of matching
directories on configuration load, and require pg_reload_conf to add
the newly matching patterns? With possibly additional helper functions
that show what the patterns currently match compared to what's loaded
by the active configuration? That's more complex, but could limit
surprises.
Should it require ownership/permission checks on the pattern parts
somehow, or some other limitation?
Also, while glob symbols are unlikely in filenames, they can be valid.
Can backward compatibility be a possible concern, or accidental glob
patterns from old configurations? For example a "/pg[18]/" directory
would have a different meaning before/after.
+ glob_status = glob(mangled, GLOB_BRACE | GLOB_ERR, NULL, &globres
I think GLOB_BRACE isn't POSIX? Based on a quick search it isn't
available on Solaris, for example.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: glob support in extension_control_path/dynamic_library_path?
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-01 09:38 ` Re: glob support in extension_control_path/dynamic_library_path? Matheus Alcantara <matheusssilv97@gmail.com>
2026-06-01 13:21 ` Re: glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-24 15:34 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
2026-06-24 15:43 ` Re: glob support in extension_control_path/dynamic_library_path? Peter Eisentraut <peter@eisentraut.org>
2026-06-24 21:19 ` Re: glob support in extension_control_path/dynamic_library_path? Zsolt Parragi <zsolt.parragi@percona.com>
@ 2026-06-25 05:15 ` Kyotaro Horiguchi <horikyota.ntt@gmail.com>
2026-06-25 14:49 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
2 siblings, 1 reply; 12+ messages in thread
From: Kyotaro Horiguchi @ 2026-06-25 05:15 UTC (permalink / raw)
To: zsolt.parragi@percona.com; +Cc: pgsql-hackers@lists.postgresql.org
Hello,
At Wed, 24 Jun 2026 14:19:33 -0700, Zsolt Parragi <zsolt.parragi@percona.com> wrote in
> Security seems to be an interesting question for this.
>
> The current patch simply takes a wildcard, and evaluates it every time
> it is needed. Is that the correct approach? The advantage is that when
> a new directory matching the pattern appears, it is automatically
> detected... but that's also the disadvantage.
I understand the motivation, but I'm also a bit worried about allowing
glob patterns in paths searched for extension files.
Just a thought, but another approach would be to allow symlinks to
extension installation directories either in the existing extension
file search directories or in a separate directory added to the search
path. That would likely require PostgreSQL to recognize a somewhat
different extension file layout than it currently assumes, though.
Regards,
--
Kyotaro Horiguchi
NTT Open Source Software Center
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: glob support in extension_control_path/dynamic_library_path?
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-01 09:38 ` Re: glob support in extension_control_path/dynamic_library_path? Matheus Alcantara <matheusssilv97@gmail.com>
2026-06-01 13:21 ` Re: glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-24 15:34 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
2026-06-24 15:43 ` Re: glob support in extension_control_path/dynamic_library_path? Peter Eisentraut <peter@eisentraut.org>
2026-06-24 21:19 ` Re: glob support in extension_control_path/dynamic_library_path? Zsolt Parragi <zsolt.parragi@percona.com>
2026-06-25 05:15 ` Re: glob support in extension_control_path/dynamic_library_path? Kyotaro Horiguchi <horikyota.ntt@gmail.com>
@ 2026-06-25 14:49 ` David E. Wheeler <david@justatheory.com>
0 siblings, 0 replies; 12+ messages in thread
From: David E. Wheeler @ 2026-06-25 14:49 UTC (permalink / raw)
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>; +Cc: zsolt.parragi@percona.com; pgsql-hackers@lists.postgresql.org
On Jun 25, 2026, at 01:15, Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:
> Just a thought, but another approach would be to allow symlinks to
> extension installation directories either in the existing extension
> file search directories or in a separate directory added to the search
> path. That would likely require PostgreSQL to recognize a somewhat
> different extension file layout than it currently assumes, though.
I don’t follow the argument about symlinks, but suspect they wouldn’t work in environments like CNPG with read-only file systems.
But reorganizing where files live was exactly what I proposed in the Packaging & Lookup RFC[0]. It’s a *lot* more involved of a change, though, and has all sorts of compatibility challenges to work out.
[0]: https://justatheory.com/2024/11/rfc-extension-packaging-lookup/#solution
Best,
David
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: glob support in extension_control_path/dynamic_library_path?
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-01 09:38 ` Re: glob support in extension_control_path/dynamic_library_path? Matheus Alcantara <matheusssilv97@gmail.com>
2026-06-01 13:21 ` Re: glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-24 15:34 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
2026-06-24 15:43 ` Re: glob support in extension_control_path/dynamic_library_path? Peter Eisentraut <peter@eisentraut.org>
2026-06-24 21:19 ` Re: glob support in extension_control_path/dynamic_library_path? Zsolt Parragi <zsolt.parragi@percona.com>
@ 2026-06-25 14:47 ` David E. Wheeler <david@justatheory.com>
2026-06-25 17:38 ` Re: glob support in extension_control_path/dynamic_library_path? Zsolt Parragi <zsolt.parragi@percona.com>
2 siblings, 1 reply; 12+ messages in thread
From: David E. Wheeler @ 2026-06-25 14:47 UTC (permalink / raw)
To: Zsolt Parragi <zsolt.parragi@percona.com>; +Cc: pgsql-hackers@lists.postgresql.org
On Jun 24, 2026, at 17:19, Zsolt Parragi <zsolt.parragi@percona.com> wrote:
> Security seems to be an interesting question for this.
>
> The current patch simply takes a wildcard, and evaluates it every time
> it is needed. Is that the correct approach? The advantage is that when
> a new directory matching the pattern appears, it is automatically
> detected... but that's also the disadvantage.
What’s the disadvantage, exactly? Sure, an attacker could stick a new directory in the wild-carded path and it will suddenly be available, but they can also just stick a dynamic library in any directory in a dynamic_library_path and it’ll be available. How is a wild carded directory worse than the current wildcarding, essentially, of DSOs and control files?
I suppose an attacker could add a directory that contains files with the same names as others, in the hopes they’d be found first in a search. We could potentially account for that by requiring that the directory have the same name as the control file being loaded, and for libraries perhaps allow “dir_name/filename” to ensure no other directory can replace it.
> Wouldn't it be better to freeze the current list of matching
> directories on configuration load, and require pg_reload_conf to add
> the newly matching patterns? With possibly additional helper functions
> that show what the patterns currently match compared to what's loaded
> by the active configuration? That's more complex, but could limit
> surprises.
I could see that. Limit it to the subdirectories found on startup or after the latest pg_reload_conf and report the delta (or just list what it found). Makes sense to me, assuming pg_reload_conf works as expected in environments like Postgres.app and CNPG (I don’t see why it wouldn’t).
> Should it require ownership/permission checks on the pattern parts
> somehow, or some other limitation?
>
> Also, while glob symbols are unlikely in filenames, they can be valid.
> Can backward compatibility be a possible concern, or accidental glob
> patterns from old configurations? For example a "/pg[18]/" directory
> would have a different meaning before/after.
Perhaps we could limit globbing to `*`?
> + glob_status = glob(mangled, GLOB_BRACE | GLOB_ERR, NULL, &globres
>
> I think GLOB_BRACE isn't POSIX? Based on a quick search it isn't
> available on Solaris, for example.
Best to use the standard, yeah.
Best,
David
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: glob support in extension_control_path/dynamic_library_path?
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-01 09:38 ` Re: glob support in extension_control_path/dynamic_library_path? Matheus Alcantara <matheusssilv97@gmail.com>
2026-06-01 13:21 ` Re: glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-24 15:34 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
2026-06-24 15:43 ` Re: glob support in extension_control_path/dynamic_library_path? Peter Eisentraut <peter@eisentraut.org>
2026-06-24 21:19 ` Re: glob support in extension_control_path/dynamic_library_path? Zsolt Parragi <zsolt.parragi@percona.com>
2026-06-25 14:47 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
@ 2026-06-25 17:38 ` Zsolt Parragi <zsolt.parragi@percona.com>
0 siblings, 0 replies; 12+ messages in thread
From: Zsolt Parragi @ 2026-06-25 17:38 UTC (permalink / raw)
To: pgsql-hackers@lists.postgresql.org
> What’s the disadvantage, exactly? Sure, an attacker could stick a new directory in the wild-carded path and it will suddenly be available, but they can also just stick a dynamic library in any directory in a dynamic_library_path and it’ll be available. How is a wild carded directory worse than the current wildcarding, essentially, of DSOs and control files?
My main concern is observability: if you have a single directory, or a
list of directories, it is clearly visible, it is relatively easy to
argue about who can create files where. When we start adding wildcards
anywhere on the path, and we can also have symlinks anywhere, it gets
more difficult.
Providing admins a way to see the currently active paths, and also
possibly making it fixed between config reloads could mitigate most of
that.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: glob support in extension_control_path/dynamic_library_path?
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-01 09:38 ` Re: glob support in extension_control_path/dynamic_library_path? Matheus Alcantara <matheusssilv97@gmail.com>
2026-06-01 13:21 ` Re: glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-06-24 15:34 ` Re: glob support in extension_control_path/dynamic_library_path? David E. Wheeler <david@justatheory.com>
2026-06-24 15:43 ` Re: glob support in extension_control_path/dynamic_library_path? Peter Eisentraut <peter@eisentraut.org>
2026-06-24 21:19 ` Re: glob support in extension_control_path/dynamic_library_path? Zsolt Parragi <zsolt.parragi@percona.com>
@ 2026-09-02 11:27 ` Jakob Egger <jakob@eggerapps.at>
2 siblings, 0 replies; 12+ messages in thread
From: Jakob Egger @ 2026-09-02 11:27 UTC (permalink / raw)
To: Zsolt Parragi <zsolt.parragi@percona.com>; +Cc: pgsql-hackers@lists.postgresql.org, "David E. Wheeler" <david@justatheory.com>
> Am 24.06.2026 um 23:19 schrieb Zsolt Parragi <zsolt.parragi@percona.com>:
>
> The current patch simply takes a wildcard, and evaluates it every time
> it is needed. Is that the correct approach?
> [...]
>
> Wouldn't it be better to freeze the current list of matching
> directories on configuration load, and require pg_reload_conf to add
> the newly matching patterns?
This would be very confusing for users and undermine the main use case of adding glob support. The point of glob support is to reduce the complexity of packaging. If we need to manually reload the configuration after adding a directory, we could also just add the new directory to the extension_control_path GUC. This is what we currently do for Postgres.app, and glob support should make this easier.
Currently, PostgreSQL scans the file system every time it looks for extensions. It makes sense to also resolve the glob at that time.
If we resolve the glob when the backend starts, and then later search the resolved paths for extension control files, we are scanning the file system at two different points in time. This has a high potential for confusing users. Some changes (eg. adding files to directories) would show up immediately, but others (eg. renaming a directory) would require reloading the configuration.
If you actually wanted predictable results, you would need to store a complete snapshot of all exiting extension control files and dynamic libraries at server start instead of resolving them on demand as PostgreSQL currently does. And at load time you would need to verify the control files haven't changed in the mean time. But this seems futile. If an attacker already has write access to extension control directories, it's hard to think of a scenario where these extra checks would be helpful.
Best regards,
Jakob
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2026-09-02 11:27 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-05-29 12:26 glob support in extension_control_path/dynamic_library_path? Jakob Egger <jakob@eggerapps.at>
2026-05-29 21:36 ` David E. Wheeler <david@justatheory.com>
2026-06-01 09:38 ` Matheus Alcantara <matheusssilv97@gmail.com>
2026-06-01 13:21 ` Jakob Egger <jakob@eggerapps.at>
2026-06-24 15:34 ` David E. Wheeler <david@justatheory.com>
2026-06-24 15:43 ` Peter Eisentraut <peter@eisentraut.org>
2026-06-24 21:19 ` Zsolt Parragi <zsolt.parragi@percona.com>
2026-06-25 05:15 ` Kyotaro Horiguchi <horikyota.ntt@gmail.com>
2026-06-25 14:49 ` David E. Wheeler <david@justatheory.com>
2026-06-25 14:47 ` David E. Wheeler <david@justatheory.com>
2026-06-25 17:38 ` Zsolt Parragi <zsolt.parragi@percona.com>
2026-09-02 11:27 ` Jakob Egger <jakob@eggerapps.at>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox