2010-09-28 02:55:27 +02:00
|
|
|
<!--
|
2010-12-13 22:22:52 +01:00
|
|
|
doc/src/sgml/ref/security_label.sgml
|
2010-09-28 02:55:27 +02:00
|
|
|
PostgreSQL documentation
|
|
|
|
-->
|
|
|
|
|
2017-10-20 03:16:39 +02:00
|
|
|
<refentry id="sql-security-label">
|
2014-02-24 03:25:35 +01:00
|
|
|
<indexterm zone="sql-security-label">
|
|
|
|
<primary>SECURITY LABEL</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
2010-09-28 02:55:27 +02:00
|
|
|
<refmeta>
|
|
|
|
<refentrytitle>SECURITY LABEL</refentrytitle>
|
|
|
|
<manvolnum>7</manvolnum>
|
|
|
|
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
|
|
|
</refmeta>
|
|
|
|
|
|
|
|
<refnamediv>
|
|
|
|
<refname>SECURITY LABEL</refname>
|
|
|
|
<refpurpose>define or change a security label applied to an object</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
|
|
|
<synopsis>
|
2017-10-09 04:00:57 +02:00
|
|
|
SECURITY LABEL [ FOR <replaceable class="parameter">provider</replaceable> ] ON
|
2010-09-28 02:55:27 +02:00
|
|
|
{
|
2017-10-09 04:00:57 +02:00
|
|
|
TABLE <replaceable class="parameter">object_name</replaceable> |
|
|
|
|
COLUMN <replaceable class="parameter">table_name</replaceable>.<replaceable class="parameter">column_name</replaceable> |
|
|
|
|
AGGREGATE <replaceable class="parameter">aggregate_name</replaceable> ( <replaceable>aggregate_signature</replaceable> ) |
|
|
|
|
DATABASE <replaceable class="parameter">object_name</replaceable> |
|
|
|
|
DOMAIN <replaceable class="parameter">object_name</replaceable> |
|
|
|
|
EVENT TRIGGER <replaceable class="parameter">object_name</replaceable> |
|
|
|
|
FOREIGN TABLE <replaceable class="parameter">object_name</replaceable>
|
|
|
|
FUNCTION <replaceable class="parameter">function_name</replaceable> [ ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ] |
|
|
|
|
LARGE OBJECT <replaceable class="parameter">large_object_oid</replaceable> |
|
|
|
|
MATERIALIZED VIEW <replaceable class="parameter">object_name</replaceable> |
|
|
|
|
[ PROCEDURAL ] LANGUAGE <replaceable class="parameter">object_name</replaceable> |
|
2017-11-30 14:46:13 +01:00
|
|
|
PROCEDURE <replaceable class="parameter">procedure_name</replaceable> [ ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ] |
|
2017-10-09 04:00:57 +02:00
|
|
|
PUBLICATION <replaceable class="parameter">object_name</replaceable> |
|
|
|
|
ROLE <replaceable class="parameter">object_name</replaceable> |
|
2017-11-30 14:46:13 +01:00
|
|
|
ROUTINE <replaceable class="parameter">routine_name</replaceable> [ ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ] |
|
2017-10-09 04:00:57 +02:00
|
|
|
SCHEMA <replaceable class="parameter">object_name</replaceable> |
|
|
|
|
SEQUENCE <replaceable class="parameter">object_name</replaceable> |
|
|
|
|
SUBSCRIPTION <replaceable class="parameter">object_name</replaceable> |
|
|
|
|
TABLESPACE <replaceable class="parameter">object_name</replaceable> |
|
|
|
|
TYPE <replaceable class="parameter">object_name</replaceable> |
|
|
|
|
VIEW <replaceable class="parameter">object_name</replaceable>
|
2023-01-31 20:32:24 +01:00
|
|
|
} IS { <replaceable class="parameter">string_literal</replaceable> | NULL }
|
Support ordered-set (WITHIN GROUP) aggregates.
This patch introduces generic support for ordered-set and hypothetical-set
aggregate functions, as well as implementations of the instances defined in
SQL:2008 (percentile_cont(), percentile_disc(), rank(), dense_rank(),
percent_rank(), cume_dist()). We also added mode() though it is not in the
spec, as well as versions of percentile_cont() and percentile_disc() that
can compute multiple percentile values in one pass over the data.
Unlike the original submission, this patch puts full control of the sorting
process in the hands of the aggregate's support functions. To allow the
support functions to find out how they're supposed to sort, a new API
function AggGetAggref() is added to nodeAgg.c. This allows retrieval of
the aggregate call's Aggref node, which may have other uses beyond the
immediate need. There is also support for ordered-set aggregates to
install cleanup callback functions, so that they can be sure that
infrastructure such as tuplesort objects gets cleaned up.
In passing, make some fixes in the recently-added support for variadic
aggregates, and make some editorial adjustments in the recent FILTER
additions for aggregates. Also, simplify use of IsBinaryCoercible() by
allowing it to succeed whenever the target type is ANY or ANYELEMENT.
It was inconsistent that it dealt with other polymorphic target types
but not these.
Atri Sharma and Andrew Gierth; reviewed by Pavel Stehule and Vik Fearing,
and rather heavily editorialized upon by Tom Lane
2013-12-23 22:11:35 +01:00
|
|
|
|
|
|
|
<phrase>where <replaceable>aggregate_signature</replaceable> is:</phrase>
|
|
|
|
|
|
|
|
* |
|
|
|
|
[ <replaceable>argmode</replaceable> ] [ <replaceable>argname</replaceable> ] <replaceable>argtype</replaceable> [ , ... ] |
|
|
|
|
[ [ <replaceable>argmode</replaceable> ] [ <replaceable>argname</replaceable> ] <replaceable>argtype</replaceable> [ , ... ] ] ORDER BY [ <replaceable>argmode</replaceable> ] [ <replaceable>argname</replaceable> ] <replaceable>argtype</replaceable> [ , ... ]
|
2010-09-28 02:55:27 +02:00
|
|
|
</synopsis>
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
<command>SECURITY LABEL</command> applies a security label to a database
|
|
|
|
object. An arbitrary number of security labels, one per label provider, can
|
|
|
|
be associated with a given database object. Label providers are loadable
|
|
|
|
modules which register themselves by using the function
|
2017-10-09 03:44:17 +02:00
|
|
|
<function>register_label_provider</function>.
|
2010-09-28 02:55:27 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<note>
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
<function>register_label_provider</function> is not an SQL function; it can
|
2010-09-28 02:55:27 +02:00
|
|
|
only be called from C code loaded into the backend.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
|
|
|
|
<para>
|
2011-01-19 22:09:08 +01:00
|
|
|
The label provider determines whether a given label is valid and whether
|
2010-09-28 02:55:27 +02:00
|
|
|
it is permissible to assign that label to a given object. The meaning of a
|
|
|
|
given label is likewise at the discretion of the label provider.
|
2017-10-09 03:44:17 +02:00
|
|
|
<productname>PostgreSQL</productname> places no restrictions on whether or how a
|
2010-09-28 02:55:27 +02:00
|
|
|
label provider must interpret security labels; it merely provides a
|
|
|
|
mechanism for storing them. In practice, this facility is intended to allow
|
|
|
|
integration with label-based mandatory access control (MAC) systems such as
|
2020-01-10 01:36:55 +01:00
|
|
|
<productname>SELinux</productname>. Such systems make all access control decisions
|
2010-09-28 02:55:27 +02:00
|
|
|
based on object labels, rather than traditional discretionary access control
|
|
|
|
(DAC) concepts such as users and groups.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Parameters</title>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">object_name</replaceable></term>
|
|
|
|
<term><replaceable class="parameter">table_name.column_name</replaceable></term>
|
Support ordered-set (WITHIN GROUP) aggregates.
This patch introduces generic support for ordered-set and hypothetical-set
aggregate functions, as well as implementations of the instances defined in
SQL:2008 (percentile_cont(), percentile_disc(), rank(), dense_rank(),
percent_rank(), cume_dist()). We also added mode() though it is not in the
spec, as well as versions of percentile_cont() and percentile_disc() that
can compute multiple percentile values in one pass over the data.
Unlike the original submission, this patch puts full control of the sorting
process in the hands of the aggregate's support functions. To allow the
support functions to find out how they're supposed to sort, a new API
function AggGetAggref() is added to nodeAgg.c. This allows retrieval of
the aggregate call's Aggref node, which may have other uses beyond the
immediate need. There is also support for ordered-set aggregates to
install cleanup callback functions, so that they can be sure that
infrastructure such as tuplesort objects gets cleaned up.
In passing, make some fixes in the recently-added support for variadic
aggregates, and make some editorial adjustments in the recent FILTER
additions for aggregates. Also, simplify use of IsBinaryCoercible() by
allowing it to succeed whenever the target type is ANY or ANYELEMENT.
It was inconsistent that it dealt with other polymorphic target types
but not these.
Atri Sharma and Andrew Gierth; reviewed by Pavel Stehule and Vik Fearing,
and rather heavily editorialized upon by Tom Lane
2013-12-23 22:11:35 +01:00
|
|
|
<term><replaceable class="parameter">aggregate_name</replaceable></term>
|
2010-09-28 02:55:27 +02:00
|
|
|
<term><replaceable class="parameter">function_name</replaceable></term>
|
2017-11-30 14:46:13 +01:00
|
|
|
<term><replaceable class="parameter">procedure_name</replaceable></term>
|
|
|
|
<term><replaceable class="parameter">routine_name</replaceable></term>
|
2010-09-28 02:55:27 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2021-06-05 09:08:40 +02:00
|
|
|
The name of the object to be labeled. Names of objects that reside in
|
|
|
|
schemas (tables, functions, etc.) can be schema-qualified.
|
2010-09-28 02:55:27 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">provider</replaceable></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The name of the provider with which this label is to be associated. The
|
|
|
|
named provider must be loaded and must consent to the proposed labeling
|
|
|
|
operation. If exactly one provider is loaded, the provider name may be
|
|
|
|
omitted for brevity.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">argmode</replaceable></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-11-30 14:46:13 +01:00
|
|
|
The mode of a function, procedure, or aggregate
|
2017-10-09 03:44:17 +02:00
|
|
|
argument: <literal>IN</literal>, <literal>OUT</literal>,
|
|
|
|
<literal>INOUT</literal>, or <literal>VARIADIC</literal>.
|
|
|
|
If omitted, the default is <literal>IN</literal>.
|
Reconsider the handling of procedure OUT parameters.
Commit 2453ea142 redefined pg_proc.proargtypes to include the types of
OUT parameters, for procedures only. While that had some advantages
for implementing the SQL-spec behavior of DROP PROCEDURE, it was pretty
disastrous from a number of other perspectives. Notably, since the
primary key of pg_proc is name + proargtypes, this made it possible to
have multiple procedures with identical names + input arguments and
differing output argument types. That would make it impossible to call
any one of the procedures by writing just NULL (or "?", or any other
data-type-free notation) for the output argument(s). The change also
seems likely to cause grave confusion for client applications that
examine pg_proc and expect the traditional definition of proargtypes.
Hence, revert the definition of proargtypes to what it was, and
undo a number of complications that had been added to support that.
To support the SQL-spec behavior of DROP PROCEDURE, when there are
no argmode markers in the command's parameter list, we perform the
lookup both ways (that is, matching against both proargtypes and
proallargtypes), succeeding if we get just one unique match.
In principle this could result in ambiguous-function failures
that would not happen when using only one of the two rules.
However, overloading of procedure names is thought to be a pretty
rare usage, so this shouldn't cause many problems in practice.
Postgres-specific code such as pg_dump can defend against any
possibility of such failures by being careful to specify argmodes
for all procedure arguments.
This also fixes a few other bugs in the area of CALL statements
with named parameters, and improves the documentation a little.
catversion bump forced because the representation of procedures
with OUT arguments changes.
Discussion: https://postgr.es/m/3742981.1621533210@sss.pgh.pa.us
2021-06-10 23:11:36 +02:00
|
|
|
Note that <command>SECURITY LABEL</command> does not actually
|
|
|
|
pay any attention to <literal>OUT</literal> arguments, since only the input
|
|
|
|
arguments are needed to determine the function's identity.
|
|
|
|
So it is sufficient to list the <literal>IN</literal>, <literal>INOUT</literal>,
|
|
|
|
and <literal>VARIADIC</literal> arguments.
|
2010-09-28 02:55:27 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">argname</replaceable></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-11-30 14:46:13 +01:00
|
|
|
The name of a function, procedure, or aggregate argument.
|
Allow aggregate functions to be VARIADIC.
There's no inherent reason why an aggregate function can't be variadic
(even VARIADIC ANY) if its transition function can handle the case.
Indeed, this patch to add the feature touches none of the planner or
executor, and little of the parser; the main missing stuff was DDL and
pg_dump support.
It is true that variadic aggregates can create the same sort of ambiguity
about parameters versus ORDER BY keys that was complained of when we
(briefly) had both one- and two-argument forms of string_agg(). However,
the policy formed in response to that discussion only said that we'd not
create any built-in aggregates with varying numbers of arguments, not that
we shouldn't allow users to do it. So the logical extension of that is
we can allow users to make variadic aggregates as long as we're wary about
shipping any such in core.
In passing, this patch allows aggregate function arguments to be named, to
the extent of remembering the names in pg_proc and dumping them in pg_dump.
You can't yet call an aggregate using named-parameter notation. That seems
like a likely future extension, but it'll take some work, and it's not what
this patch is really about. Likewise, there's still some work needed to
make window functions handle VARIADIC fully, but I left that for another
day.
initdb forced because of new aggvariadic field in Aggref parse nodes.
2013-09-03 23:08:38 +02:00
|
|
|
Note that <command>SECURITY LABEL</command> does not actually
|
2011-05-07 03:18:18 +02:00
|
|
|
pay any attention to argument names, since only the argument data
|
2010-09-28 02:55:27 +02:00
|
|
|
types are needed to determine the function's identity.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">argtype</replaceable></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-11-30 14:46:13 +01:00
|
|
|
The data type of a function, procedure, or aggregate argument.
|
2010-09-28 02:55:27 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">large_object_oid</replaceable></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The OID of the large object.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><literal>PROCEDURAL</literal></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
This is a noise word.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2023-01-31 20:32:24 +01:00
|
|
|
<term><replaceable class="parameter">string_literal</replaceable></term>
|
2010-09-28 02:55:27 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2023-01-31 20:32:24 +01:00
|
|
|
The new setting of the security label, written as a string literal.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><literal>NULL</literal></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Write <literal>NULL</literal> to drop the security label.
|
2010-09-28 02:55:27 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Examples</title>
|
|
|
|
|
|
|
|
<para>
|
2023-01-31 20:32:24 +01:00
|
|
|
The following example shows how the security label of a table could
|
|
|
|
be set or changed:
|
2010-09-28 02:55:27 +02:00
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
SECURITY LABEL FOR selinux ON TABLE mytable IS 'system_u:object_r:sepgsql_table_t:s0';
|
2023-01-31 20:32:24 +01:00
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
To remove the label:
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
SECURITY LABEL FOR selinux ON TABLE mytable IS NULL;
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
2010-09-28 02:55:27 +02:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Compatibility</title>
|
|
|
|
<para>
|
|
|
|
There is no <command>SECURITY LABEL</command> command in the SQL standard.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2011-07-20 15:22:57 +02:00
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>See Also</title>
|
|
|
|
<simplelist type="inline">
|
2017-11-23 15:39:47 +01:00
|
|
|
<member><xref linkend="sepgsql"/></member>
|
2014-11-30 03:55:00 +01:00
|
|
|
<member><filename>src/test/modules/dummy_seclabel</filename></member>
|
2011-07-20 15:22:57 +02:00
|
|
|
</simplelist>
|
|
|
|
</refsect1>
|
2010-09-28 02:55:27 +02:00
|
|
|
</refentry>
|