2 doc/src/sgml/ref/security_label.sgml
3 PostgreSQL documentation
6 <refentry id="SQL-SECURITY-LABEL">
8 <refentrytitle>SECURITY LABEL</refentrytitle>
9 <manvolnum>7</manvolnum>
10 <refmiscinfo>SQL - Language Statements</refmiscinfo>
14 <refname>SECURITY LABEL</refname>
15 <refpurpose>define or change a security label applied to an object</refpurpose>
18 <indexterm zone="sql-security-label">
19 <primary>SECURITY LABEL</primary>
24 SECURITY LABEL [ FOR <replaceable class="PARAMETER">provider</replaceable> ] ON
26 TABLE <replaceable class="PARAMETER">object_name</replaceable> |
27 COLUMN <replaceable class="PARAMETER">table_name</replaceable>.<replaceable class="PARAMETER">column_name</replaceable> |
28 AGGREGATE <replaceable class="PARAMETER">agg_name</replaceable> (<replaceable class="PARAMETER">agg_type</replaceable> [, ...] ) |
29 DATABASE <replaceable class="PARAMETER">object_name</replaceable> |
30 DOMAIN <replaceable class="PARAMETER">object_name</replaceable> |
31 FOREIGN TABLE <replaceable class="PARAMETER">object_name</replaceable>
32 FUNCTION <replaceable class="PARAMETER">function_name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) |
33 LARGE OBJECT <replaceable class="PARAMETER">large_object_oid</replaceable> |
34 [ PROCEDURAL ] LANGUAGE <replaceable class="PARAMETER">object_name</replaceable> |
35 ROLE <replaceable class="PARAMETER">object_name</replaceable> |
36 SCHEMA <replaceable class="PARAMETER">object_name</replaceable> |
37 SEQUENCE <replaceable class="PARAMETER">object_name</replaceable> |
38 TABLESPACE <replaceable class="PARAMETER">object_name</replaceable> |
39 TYPE <replaceable class="PARAMETER">object_name</replaceable> |
40 VIEW <replaceable class="PARAMETER">object_name</replaceable>
41 } IS '<replaceable class="PARAMETER">label</replaceable>'
46 <title>Description</title>
49 <command>SECURITY LABEL</command> applies a security label to a database
50 object. An arbitrary number of security labels, one per label provider, can
51 be associated with a given database object. Label providers are loadable
52 modules which register themselves by using the function
53 <function>register_label_provider</>.
58 <function>register_label_provider</> is not an SQL function; it can
59 only be called from C code loaded into the backend.
64 The label provider determines whether a given label is valid and whether
65 it is permissible to assign that label to a given object. The meaning of a
66 given label is likewise at the discretion of the label provider.
67 <productname>PostgreSQL</> places no restrictions on whether or how a
68 label provider must interpret security labels; it merely provides a
69 mechanism for storing them. In practice, this facility is intended to allow
70 integration with label-based mandatory access control (MAC) systems such as
71 <productname>SE-Linux</>. Such systems make all access control decisions
72 based on object labels, rather than traditional discretionary access control
73 (DAC) concepts such as users and groups.
78 <title>Parameters</title>
82 <term><replaceable class="parameter">object_name</replaceable></term>
83 <term><replaceable class="parameter">table_name.column_name</replaceable></term>
84 <term><replaceable class="parameter">agg_name</replaceable></term>
85 <term><replaceable class="parameter">function_name</replaceable></term>
88 The name of the object to be labeled. Names of tables,
89 aggregates, domains, foreign tables, functions, sequences, types, and
90 views can be schema-qualified.
96 <term><replaceable class="parameter">provider</replaceable></term>
99 The name of the provider with which this label is to be associated. The
100 named provider must be loaded and must consent to the proposed labeling
101 operation. If exactly one provider is loaded, the provider name may be
108 <term><replaceable class="parameter">arg_type</replaceable></term>
111 An input data type on which the aggregate function operates.
112 To reference a zero-argument aggregate function, write <literal>*</>
113 in place of the list of input data types.
119 <term><replaceable class="parameter">argmode</replaceable></term>
123 The mode of a function argument: <literal>IN</>, <literal>OUT</>,
124 <literal>INOUT</>, or <literal>VARIADIC</>.
125 If omitted, the default is <literal>IN</>.
126 Note that <command>SECURITY LABEL ON FUNCTION</command> does not actually
127 pay any attention to <literal>OUT</> arguments, since only the input
128 arguments are needed to determine the function's identity.
129 So it is sufficient to list the <literal>IN</>, <literal>INOUT</>,
130 and <literal>VARIADIC</> arguments.
136 <term><replaceable class="parameter">argname</replaceable></term>
140 The name of a function argument.
141 Note that <command>SECURITY LABEL ON FUNCTION</command> does not actually
142 pay any attention to argument names, since only the argument data
143 types are needed to determine the function's identity.
149 <term><replaceable class="parameter">argtype</replaceable></term>
153 The data type(s) of the function's arguments (optionally
154 schema-qualified), if any.
160 <term><replaceable class="parameter">large_object_oid</replaceable></term>
163 The OID of the large object.
169 <term><literal>PROCEDURAL</literal></term>
173 This is a noise word.
179 <term><replaceable class="parameter">label</replaceable></term>
182 The new security label, written as a string literal; or <literal>NULL</>
183 to drop the security label.
191 <title>Examples</title>
194 The following example shows how the security label of a table might
198 SECURITY LABEL FOR selinux ON TABLE mytable IS 'system_u:object_r:sepgsql_table_t:s0';
199 </programlisting></para>
203 <title>Compatibility</title>
205 There is no <command>SECURITY LABEL</command> command in the SQL standard.
210 <title>See Also</title>
211 <simplelist type="inline">
212 <member><xref linkend="sepgsql"></member>
213 <member><xref linkend="dummy-seclabel"></member>