pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix has_column_privilege function corner case
Date: Wed, 31 Mar 2021 17:55:53 +0000
Message-ID: <E1lRf4L-0002oT-7I@gemulon.postgresql.org> (raw)

Fix has_column_privilege function corner case

According to the comments, when an invalid or dropped column oid is passed
to has_column_privilege(), the intention has always been to return NULL.
However, when the caller had table level privilege the invalid/missing
column was never discovered, because table permissions were checked first.

Fix that by introducing extended versions of pg_attribute_acl(check|mask)
and pg_class_acl(check|mask) which take a new argument, is_missing. When
is_missing is NULL, the old behavior is preserved. But when is_missing is
passed by the caller, no ERROR is thrown for dropped or missing
columns/relations, and is_missing is flipped to true. This in turn allows
has_column_privilege to check for column privileges first, providing the
desired semantics.

Not backpatched since it is a user visible behavioral change with no previous
complaints, and the fix is a bit on the invasive side.

Author: Joe Conway
Reviewed-By: Tom Lane
Reported by: Ian Barwick
Discussion: https://postgr.es/m/flat/9b5f4311-157b-4164-7fe7-077b4fe8ed84%40joeconway.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b12bd4869b5e64b742a69ca07915e2f77f85a9ae

Modified Files
--------------
src/backend/catalog/aclchk.c             | 116 +++++++++++++++++++++++++++----
src/backend/utils/adt/acl.c              |  48 ++++---------
src/include/utils/acl.h                  |  11 +++
src/test/regress/expected/privileges.out |  14 +++-
src/test/regress/sql/privileges.sql      |   2 +
5 files changed, 142 insertions(+), 49 deletions(-)



Message-ID: <E1lRf4L-0002oT-7I@gemulon.postgresql.org>
Permalink:  ../E1lRf4L-0002oT-7I@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lRf4L-0002oT-7I@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: mail@joeconway.com
  Subject: Re: pgsql: Fix has_column_privilege function corner case
  In-Reply-To: <E1lRf4L-0002oT-7I@gemulon.postgresql.org>
  References: <E1lRf4L-0002oT-7I@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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