]> begriffs open source - ai-pg/blob - full-docs/man7/SECURITY_LABEL.7
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man7 / SECURITY_LABEL.7
1 '\" t
2 .\"     Title: SECURITY LABEL
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
10 .TH "SECURITY LABEL" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 SECURITY_LABEL \- define or change a security label applied to an object
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 SECURITY LABEL [ FOR \fIprovider\fR ] ON
36 {
37   TABLE \fIobject_name\fR |
38   COLUMN \fItable_name\fR\&.\fIcolumn_name\fR |
39   AGGREGATE \fIaggregate_name\fR ( \fIaggregate_signature\fR ) |
40   DATABASE \fIobject_name\fR |
41   DOMAIN \fIobject_name\fR |
42   EVENT TRIGGER \fIobject_name\fR |
43   FOREIGN TABLE \fIobject_name\fR |
44   FUNCTION \fIfunction_name\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ] |
45   LARGE OBJECT \fIlarge_object_oid\fR |
46   MATERIALIZED VIEW \fIobject_name\fR |
47   [ PROCEDURAL ] LANGUAGE \fIobject_name\fR |
48   PROCEDURE \fIprocedure_name\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ] |
49   PUBLICATION \fIobject_name\fR |
50   ROLE \fIobject_name\fR |
51   ROUTINE \fIroutine_name\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ] |
52   SCHEMA \fIobject_name\fR |
53   SEQUENCE \fIobject_name\fR |
54   SUBSCRIPTION \fIobject_name\fR |
55   TABLESPACE \fIobject_name\fR |
56   TYPE \fIobject_name\fR |
57   VIEW \fIobject_name\fR
58 } IS { \fIstring_literal\fR | NULL }
59
60 where \fIaggregate_signature\fR is:
61
62 * |
63 [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] |
64 [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] ] ORDER BY [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ]
65 .fi
66 .SH "DESCRIPTION"
67 .PP
68 \fBSECURITY LABEL\fR
69 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
70 \fBregister_label_provider\fR\&.
71 .if n \{\
72 .sp
73 .\}
74 .RS 4
75 .it 1 an-trap
76 .nr an-no-space-flag 1
77 .nr an-break-flag 1
78 .br
79 .ps +1
80 \fBNote\fR
81 .ps -1
82 .br
83 .PP
84 \fBregister_label_provider\fR
85 is not an SQL function; it can only be called from C code loaded into the backend\&.
86 .sp .5v
87 .RE
88 .PP
89 The label provider determines whether a given label is valid and whether 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\&.
90 PostgreSQL
91 places no restrictions on whether or how a 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
92 SELinux\&. Such systems make all access control decisions based on object labels, rather than traditional discretionary access control (DAC) concepts such as users and groups\&.
93 .PP
94 You must own the database object to use
95 \fBSECURITY LABEL\fR\&.
96 .SH "PARAMETERS"
97 .PP
98 \fIobject_name\fR
99 .br
100 \fItable_name\&.column_name\fR
101 .br
102 \fIaggregate_name\fR
103 .br
104 \fIfunction_name\fR
105 .br
106 \fIprocedure_name\fR
107 .br
108 \fIroutine_name\fR
109 .RS 4
110 The name of the object to be labeled\&. Names of objects that reside in schemas (tables, functions, etc\&.) can be schema\-qualified\&.
111 .RE
112 .PP
113 \fIprovider\fR
114 .RS 4
115 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\&.
116 .RE
117 .PP
118 \fIargmode\fR
119 .RS 4
120 The mode of a function, procedure, or aggregate argument:
121 IN,
122 OUT,
123 INOUT, or
124 VARIADIC\&. If omitted, the default is
125 IN\&. Note that
126 \fBSECURITY LABEL\fR
127 does not actually pay any attention to
128 OUT
129 arguments, since only the input arguments are needed to determine the function\*(Aqs identity\&. So it is sufficient to list the
130 IN,
131 INOUT, and
132 VARIADIC
133 arguments\&.
134 .RE
135 .PP
136 \fIargname\fR
137 .RS 4
138 The name of a function, procedure, or aggregate argument\&. Note that
139 \fBSECURITY LABEL\fR
140 does not actually pay any attention to argument names, since only the argument data types are needed to determine the function\*(Aqs identity\&.
141 .RE
142 .PP
143 \fIargtype\fR
144 .RS 4
145 The data type of a function, procedure, or aggregate argument\&.
146 .RE
147 .PP
148 \fIlarge_object_oid\fR
149 .RS 4
150 The OID of the large object\&.
151 .RE
152 .PP
153 PROCEDURAL
154 .RS 4
155 This is a noise word\&.
156 .RE
157 .PP
158 \fIstring_literal\fR
159 .RS 4
160 The new setting of the security label, written as a string literal\&.
161 .RE
162 .PP
163 NULL
164 .RS 4
165 Write
166 NULL
167 to drop the security label\&.
168 .RE
169 .SH "EXAMPLES"
170 .PP
171 The following example shows how the security label of a table could be set or changed:
172 .sp
173 .if n \{\
174 .RS 4
175 .\}
176 .nf
177 SECURITY LABEL FOR selinux ON TABLE mytable IS \*(Aqsystem_u:object_r:sepgsql_table_t:s0\*(Aq;
178 .fi
179 .if n \{\
180 .RE
181 .\}
182 .sp
183 To remove the label:
184 .sp
185 .if n \{\
186 .RS 4
187 .\}
188 .nf
189 SECURITY LABEL FOR selinux ON TABLE mytable IS NULL;
190 .fi
191 .if n \{\
192 .RE
193 .\}
194 .sp
195 .SH "COMPATIBILITY"
196 .PP
197 There is no
198 \fBSECURITY LABEL\fR
199 command in the SQL standard\&.
200 .SH "SEE ALSO"
201 sepgsql, src/test/modules/dummy_seclabel