1-- 2-- contrib/sepgsql/sepgsql.sql 3-- 4-- [Step to install] 5-- 6-- 1. Run initdb 7-- to set up a new database cluster. 8-- 9-- 2. Edit $PGDATA/postgresql.conf 10-- to add 'MODULE_PATHNAME' to shared_preload_libraries. 11-- 12-- Example) 13-- shared_preload_libraries = 'MODULE_PATHNAME' 14-- 15-- 3. Run this script for each databases 16-- This script installs corresponding functions, and assigns initial 17-- security labels on target database objects. 18-- It can be run both single-user mode and multi-user mode, according 19-- to your preference. 20-- 21-- Example) 22-- $ for DBNAME in template0 template1 postgres; \ 23-- do \ 24-- postgres --single -F -c exit_on_error=true -D $PGDATA $DBNAME \ 25-- < /path/to/script/sepgsql.sql > /dev/null \ 26-- done 27-- 28-- 4. Start postmaster, 29-- if you initialized the database in single-user mode. 30-- 31LOAD 'MODULE_PATHNAME'; 32CREATE OR REPLACE FUNCTION pg_catalog.sepgsql_getcon() RETURNS text AS 'MODULE_PATHNAME', 'sepgsql_getcon' LANGUAGE C; 33CREATE OR REPLACE FUNCTION pg_catalog.sepgsql_setcon(text) RETURNS bool AS 'MODULE_PATHNAME', 'sepgsql_setcon' LANGUAGE C; 34CREATE OR REPLACE FUNCTION pg_catalog.sepgsql_mcstrans_in(text) RETURNS text AS 'MODULE_PATHNAME', 'sepgsql_mcstrans_in' LANGUAGE C STRICT; 35CREATE OR REPLACE FUNCTION pg_catalog.sepgsql_mcstrans_out(text) RETURNS text AS 'MODULE_PATHNAME', 'sepgsql_mcstrans_out' LANGUAGE C STRICT; 36CREATE OR REPLACE FUNCTION pg_catalog.sepgsql_restorecon(text) RETURNS bool AS 'MODULE_PATHNAME', 'sepgsql_restorecon' LANGUAGE C; 37SELECT sepgsql_restorecon(NULL); 38