17
17
#include "catalog/indexing.h"
18
18
#include "catalog/pg_attribute.h"
19
19
#include "catalog/pg_class.h"
20
+ #include "catalog/pg_database.h"
20
21
#include "catalog/pg_namespace.h"
21
22
#include "catalog/pg_proc.h"
22
23
#include "commands/dbcommands.h"
@@ -121,9 +122,14 @@ sepgsql_object_relabel(const ObjectAddress *object, const char *seclabel)
121
122
*/
122
123
switch (object -> classId )
123
124
{
125
+ case DatabaseRelationId :
126
+ sepgsql_database_relabel (object -> objectId , seclabel );
127
+ break ;
128
+
124
129
case NamespaceRelationId :
125
130
sepgsql_schema_relabel (object -> objectId , seclabel );
126
131
break ;
132
+
127
133
case RelationRelationId :
128
134
if (object -> objectSubId == 0 )
129
135
sepgsql_relation_relabel (object -> objectId ,
@@ -133,6 +139,7 @@ sepgsql_object_relabel(const ObjectAddress *object, const char *seclabel)
133
139
object -> objectSubId ,
134
140
seclabel );
135
141
break ;
142
+
136
143
case ProcedureRelationId :
137
144
sepgsql_proc_relabel (object -> objectId , seclabel );
138
145
break ;
@@ -315,6 +322,7 @@ exec_object_restorecon(struct selabel_handle * sehnd, Oid catalogId)
315
322
SnapshotNow , 0 , NULL );
316
323
while (HeapTupleIsValid (tuple = systable_getnext (sscan )))
317
324
{
325
+ Form_pg_database datForm ;
318
326
Form_pg_namespace nspForm ;
319
327
Form_pg_class relForm ;
320
328
Form_pg_attribute attForm ;
@@ -330,6 +338,19 @@ exec_object_restorecon(struct selabel_handle * sehnd, Oid catalogId)
330
338
*/
331
339
switch (catalogId )
332
340
{
341
+ case DatabaseRelationId :
342
+ datForm = (Form_pg_database ) GETSTRUCT (tuple );
343
+
344
+ objtype = SELABEL_DB_DATABASE ;
345
+
346
+ objname = quote_object_name (NameStr (datForm -> datname ),
347
+ NULL , NULL , NULL );
348
+
349
+ object .classId = DatabaseRelationId ;
350
+ object .objectId = HeapTupleGetOid (tuple );
351
+ object .objectSubId = 0 ;
352
+ break ;
353
+
333
354
case NamespaceRelationId :
334
355
nspForm = (Form_pg_namespace ) GETSTRUCT (tuple );
335
356
@@ -506,10 +527,7 @@ sepgsql_restorecon(PG_FUNCTION_ARGS)
506
527
errmsg ("SELinux: failed to initialize labeling handle: %m" )));
507
528
PG_TRY ();
508
529
{
509
- /*
510
- * Right now, we have no support labeling on the shared database
511
- * objects, such as database, role, or tablespace.
512
- */
530
+ exec_object_restorecon (sehnd , DatabaseRelationId );
513
531
exec_object_restorecon (sehnd , NamespaceRelationId );
514
532
exec_object_restorecon (sehnd , RelationRelationId );
515
533
exec_object_restorecon (sehnd , AttributeRelationId );
0 commit comments