1.5 Ensure Data Cluster Initialized Successfully

Warning! Audit Deprecated

This audit has been deprecated and will be removed in a future update.

View Next Audit Version

Information

Create a new PostgreSQL database cluster. First time installs of PostgreSQL requires the instantiation of the database cluster. A database cluster is a collection of databases that are managed by a single server instance.
Rationale:
For the purposes of security, PostgreSQL enforces ownership and permissions of the data-cluster such that:
An initialized data-cluster is owned by the UNIX account that created it.
The data-cluster cannot be accessed by other UNIX user-accounts.
The data-cluster cannot be created or owned by root
The Postgres process cannot be invoked by root nor any UNIX user account other than the owner of the data cluster.
Incorrectly instantiating the data-cluster will result in a failed installation.
NOTE: Nessus has not performed this check. Please review the benchmark to ensure target compliance.

Solution

Attempting to instantiate a data cluster to an existing non-empty directory will fail:
$ service postgresql-9.5 initdb
Data directory is not empty!
[root@pg1_centos ~]# [FAILED]
In the case of a cluster instantiation failure, one must delete/remove the entire data cluster directory and repeat the initdb command:
$ rm -rf ~postgres/9.5
$ service postgresql-9.5 initdb
2 Directory and File Permissions
This section provides guidance on securing all operating system specific objects for PostgreSQL.

See Also

https://workbench.cisecurity.org/files/2063