MCPcopy Create free account
hub / github.com/apache/cloudberry / sepgsql_attribute_relabel

Function sepgsql_attribute_relabel

contrib/sepgsql/relation.c:164–201  ·  view source on GitHub ↗

* sepgsql_attribute_relabel * * It checks privileges to relabel the supplied column * by the `seclabel'. */

Source from the content-addressed store, hash-verified

162 * by the `seclabel'.
163 */
164void
165sepgsql_attribute_relabel(Oid relOid, AttrNumber attnum,
166 const char *seclabel)
167{
168 ObjectAddress object;
169 char *audit_name;
170 char relkind = get_rel_relkind(relOid);
171
172 if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE)
173 ereport(ERROR,
174 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
175 errmsg("cannot set security label on non-regular columns")));
176
177 object.classId = RelationRelationId;
178 object.objectId = relOid;
179 object.objectSubId = attnum;
180 audit_name = getObjectIdentity(&object, false);
181
182 /*
183 * check db_column:{setattr relabelfrom} permission
184 */
185 sepgsql_avc_check_perms(&object,
186 SEPG_CLASS_DB_COLUMN,
187 SEPG_DB_COLUMN__SETATTR |
188 SEPG_DB_COLUMN__RELABELFROM,
189 audit_name,
190 true);
191
192 /*
193 * check db_column:{relabelto} permission
194 */
195 sepgsql_avc_check_perms_label(seclabel,
196 SEPG_CLASS_DB_COLUMN,
197 SEPG_DB_PROCEDURE__RELABELTO,
198 audit_name,
199 true);
200 pfree(audit_name);
201}
202
203/*
204 * sepgsql_attribute_setattr

Callers 1

sepgsql_object_relabelFunction · 0.85

Calls 7

get_rel_relkindFunction · 0.85
getObjectIdentityFunction · 0.85
sepgsql_avc_check_permsFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
pfreeFunction · 0.50

Tested by

no test coverage detected