]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/sql-security-label.html
WIP: toc builder
[ai-pg] / full-docs / src / sgml / html / sql-security-label.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>SECURITY LABEL</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="sql-savepoint.html" title="SAVEPOINT" /><link rel="next" href="sql-select.html" title="SELECT" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">SECURITY LABEL</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-savepoint.html" title="SAVEPOINT">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-select.html" title="SELECT">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-SECURITY-LABEL"><div class="titlepage"></div><a id="id-1.9.3.171.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">SECURITY LABEL</span></h2><p>SECURITY LABEL — define or change a security label applied to an object</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
3 SECURITY LABEL [ FOR <em class="replaceable"><code>provider</code></em> ] ON
4 {
5   TABLE <em class="replaceable"><code>object_name</code></em> |
6   COLUMN <em class="replaceable"><code>table_name</code></em>.<em class="replaceable"><code>column_name</code></em> |
7   AGGREGATE <em class="replaceable"><code>aggregate_name</code></em> ( <em class="replaceable"><code>aggregate_signature</code></em> ) |
8   DATABASE <em class="replaceable"><code>object_name</code></em> |
9   DOMAIN <em class="replaceable"><code>object_name</code></em> |
10   EVENT TRIGGER <em class="replaceable"><code>object_name</code></em> |
11   FOREIGN TABLE <em class="replaceable"><code>object_name</code></em> |
12   FUNCTION <em class="replaceable"><code>function_name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ] |
13   LARGE OBJECT <em class="replaceable"><code>large_object_oid</code></em> |
14   MATERIALIZED VIEW <em class="replaceable"><code>object_name</code></em> |
15   [ PROCEDURAL ] LANGUAGE <em class="replaceable"><code>object_name</code></em> |
16   PROCEDURE <em class="replaceable"><code>procedure_name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ] |
17   PUBLICATION <em class="replaceable"><code>object_name</code></em> |
18   ROLE <em class="replaceable"><code>object_name</code></em> |
19   ROUTINE <em class="replaceable"><code>routine_name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ] |
20   SCHEMA <em class="replaceable"><code>object_name</code></em> |
21   SEQUENCE <em class="replaceable"><code>object_name</code></em> |
22   SUBSCRIPTION <em class="replaceable"><code>object_name</code></em> |
23   TABLESPACE <em class="replaceable"><code>object_name</code></em> |
24   TYPE <em class="replaceable"><code>object_name</code></em> |
25   VIEW <em class="replaceable"><code>object_name</code></em>
26 } IS { <em class="replaceable"><code>string_literal</code></em> | NULL }
27
28 <span class="phrase">where <em class="replaceable"><code>aggregate_signature</code></em> is:</span>
29
30 * |
31 [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [ , ... ] |
32 [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [ , ... ] ] ORDER BY [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [ , ... ]
33 </pre></div><div class="refsect1" id="id-1.9.3.171.5"><h2>Description</h2><p>
34    <code class="command">SECURITY LABEL</code> applies a security label to a database
35    object.  An arbitrary number of security labels, one per label provider, can
36    be associated with a given database object.  Label providers are loadable
37    modules which register themselves by using the function
38    <code class="function">register_label_provider</code>.
39   </p><div class="note"><h3 class="title">Note</h3><p>
40       <code class="function">register_label_provider</code> is not an SQL function; it can
41       only be called from C code loaded into the backend.
42     </p></div><p>
43    The label provider determines whether a given label is valid and whether
44    it is permissible to assign that label to a given object.  The meaning of a
45    given label is likewise at the discretion of the label provider.
46    <span class="productname">PostgreSQL</span> places no restrictions on whether or how a
47    label provider must interpret security labels; it merely provides a
48    mechanism for storing them.  In practice, this facility is intended to allow
49    integration with label-based mandatory access control (MAC) systems such as
50    <span class="productname">SELinux</span>.  Such systems make all access control decisions
51    based on object labels, rather than traditional discretionary access control
52    (DAC) concepts such as users and groups.
53   </p><p>
54    You must own the database object to use <code class="command">SECURITY LABEL</code>.
55   </p></div><div class="refsect1" id="id-1.9.3.171.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>object_name</code></em><br /></span><span class="term"><em class="replaceable"><code>table_name.column_name</code></em><br /></span><span class="term"><em class="replaceable"><code>aggregate_name</code></em><br /></span><span class="term"><em class="replaceable"><code>function_name</code></em><br /></span><span class="term"><em class="replaceable"><code>procedure_name</code></em><br /></span><span class="term"><em class="replaceable"><code>routine_name</code></em></span></dt><dd><p>
56       The name of the object to be labeled.  Names of objects that reside in
57       schemas (tables, functions, etc.) can be schema-qualified.
58      </p></dd><dt><span class="term"><em class="replaceable"><code>provider</code></em></span></dt><dd><p>
59       The name of the provider with which this label is to be associated.  The
60       named provider must be loaded and must consent to the proposed labeling
61       operation.  If exactly one provider is loaded, the provider name may be
62       omitted for brevity.
63      </p></dd><dt><span class="term"><em class="replaceable"><code>argmode</code></em></span></dt><dd><p>
64       The mode of a function, procedure, or aggregate
65       argument: <code class="literal">IN</code>, <code class="literal">OUT</code>,
66       <code class="literal">INOUT</code>, or <code class="literal">VARIADIC</code>.
67       If omitted, the default is <code class="literal">IN</code>.
68       Note that <code class="command">SECURITY LABEL</code> does not actually
69       pay any attention to <code class="literal">OUT</code> arguments, since only the input
70       arguments are needed to determine the function's identity.
71       So it is sufficient to list the <code class="literal">IN</code>, <code class="literal">INOUT</code>,
72       and <code class="literal">VARIADIC</code> arguments.
73      </p></dd><dt><span class="term"><em class="replaceable"><code>argname</code></em></span></dt><dd><p>
74       The name of a function, procedure, or aggregate argument.
75       Note that <code class="command">SECURITY LABEL</code> does not actually
76       pay any attention to argument names, since only the argument data
77       types are needed to determine the function's identity.
78      </p></dd><dt><span class="term"><em class="replaceable"><code>argtype</code></em></span></dt><dd><p>
79       The data type of a function, procedure, or aggregate argument.
80      </p></dd><dt><span class="term"><em class="replaceable"><code>large_object_oid</code></em></span></dt><dd><p>
81       The OID of the large object.
82      </p></dd><dt><span class="term"><code class="literal">PROCEDURAL</code></span></dt><dd><p>
83        This is a noise word.
84       </p></dd><dt><span class="term"><em class="replaceable"><code>string_literal</code></em></span></dt><dd><p>
85       The new setting of the security label, written as a string literal.
86      </p></dd><dt><span class="term"><code class="literal">NULL</code></span></dt><dd><p>
87       Write <code class="literal">NULL</code> to drop the security label.
88      </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.171.7"><h2>Examples</h2><p>
89    The following example shows how the security label of a table could
90    be set or changed:
91
92 </p><pre class="programlisting">
93 SECURITY LABEL FOR selinux ON TABLE mytable IS 'system_u:object_r:sepgsql_table_t:s0';
94 </pre><p>
95
96    To remove the label:
97
98 </p><pre class="programlisting">
99 SECURITY LABEL FOR selinux ON TABLE mytable IS NULL;
100 </pre><p>
101   </p></div><div class="refsect1" id="id-1.9.3.171.8"><h2>Compatibility</h2><p>
102    There is no <code class="command">SECURITY LABEL</code> command in the SQL standard.
103   </p></div><div class="refsect1" id="id-1.9.3.171.9"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sepgsql.html" title="F.40. sepgsql — SELinux-, label-based mandatory access control (MAC) security module">sepgsql</a>, <code class="filename">src/test/modules/dummy_seclabel</code></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-savepoint.html" title="SAVEPOINT">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-select.html" title="SELECT">Next</a></td></tr><tr><td width="40%" align="left" valign="top">SAVEPOINT </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> SELECT</td></tr></table></div></body></html>