Addition of authenticated ID to pg_stat_activity

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Addition of authenticated ID to pg_stat_activity
Date: 2021-04-26 02:34:16
Message-ID: YIYmqIERKlgqmkZ6@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

9afffcb has added the concept of authenticated identity to the
information provided in log_connections for audit purposes, with this
data stored in each backend's port. One extra thing that can be
really useful for monitoring is the capability to track this
information directly in pg_stat_activity.

Please find attached a patch to do that, with the following choices
made:
- Like query strings, authenticated IDs could be rather long, so we
need a GUC to control the maximum size allocated for these in shared
memory. The attached uses 128 bytes by default, that should be enough
in most cases even for DNs, LDAP or krb5.
- Multi-byte strings need to be truncated appropriately. As a matter
of consistency with the query string code, I have made things so as
the truncation is done each time a string is requested, with
PgBackendStatus storing the raw information truncated depending on the
maximum size allowed at the GUC level.
- Some tests are added within the SSL and LDAP code paths. We could
add more of that within the authentication and kerberos tests but that
did not strike me as mandatory either as the backend logs are checked
everywhere already.
- The new field has been added at the end of pg_stat_end_activity()
mainly as a matter of readability. I'd rather move that just after
the application_name, now only pg_stat_activity does that.

I am adding that to the next CF.

Thanks,
--
Michael

Attachment Content-Type Size
v1-0001-Add-authenticated-data-to-pg_stat_activity.patch text/x-diff 21.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-04-26 03:11:45 Re: PageGetItemIdCareful - should we MAXALIGN sizeof(BTPageOpaqueData)?
Previous Message Masahiko Sawada 2021-04-26 02:30:27 Re: Replication slot stats misgivings