pg_guard
pg_guard · Delegate selected privileged operations through a configuration-only library
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102469 | pg_guard | pg_guard | 3.1.0 | SEC | Apache-2.0 | C |
PostgreSQL · 13, 14, 15, 16, 17, 18
Usage
Sources:
pg_guard 3.1.0 is a configuration-only loadable library derived from supautils, with a distinct library name and pg_guard.* settings. It delegates selected superuser operations to a privileged role. It adds no SQL extension objects and has no CREATE EXTENSION pg_guard step. The reviewed fork documents PostgreSQL 13 and later and contains version-specific paths through PostgreSQL 18; the Supatype distribution targets PostgreSQL 17.
Delegate Explicit Operations
An administrator installs the matching library and configures the delegation boundary. Preserve existing preload entries, then restart PostgreSQL for cluster-wide use:
Provision the role and grants separately. The library temporarily uses the configured superuser for allowed operations, assigns ownership as documented, then restores the caller. A privileged administrator can instead arrange session_preload_libraries for selected roles; it takes effect in new sessions, not existing connections.
Configuration Surface
The privileged role can manage publications, selected FDWs and event triggers under the extension’s checks. pg_guard.privileged_role_allowed_configs delegates listed superuser settings. pg_guard.reserved_roles and pg_guard.reserved_memberships restrict role changes. pg_guard.policy_grants and pg_guard.drop_trigger_grants delegate selected table-owner operations. Core policy settings in the bundled source use reload-only configuration.
pg_guard.extension_custom_scripts_path supplies trusted before/after-create scripts. pg_guard.extensions_parameter_overrides can replace an extension schema choice; pg_guard.constrained_extensions checks minimum CPU, memory or free disk requirements. These are privileged execution paths: restrict who can edit configuration, scripts and installed extension files.
Operational Boundaries
Privileged-role event triggers are skipped for superusers and reserved roles and do not fire for delegated publication, FDW or extension creation. Superuser event triggers have additional ownership rules. Do not assume every PostgreSQL superuser capability is delegated, or that reserved-role protection constrains actual superusers. Review the complete policy and hook interactions before using this cloud-administration library.