Skip to contentSkip to conversation

package/postgresql: enable data checksums by default for initdb

PATCH New Pascal de Bruijn 2 participants 2 messages Nov 21, 2019 – Nov 25, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 package/postgresql: enable data checksums by default for initdb

From: Pascal de Bruijn <[email protected]>

This makes PostgreSQL as robust as possible by default

---
 package/postgresql/S50postgresql      | 2 +-
 package/postgresql/postgresql.service | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
package/postgresql/S50postgresql +1 -1
index 3c0c520..ce72e12 100644
@@ -7,7 +7,7 @@ umask 077
 
 if [ ! -f /var/lib/pgsql/PG_VERSION ]; then
 	echo "Initializing postgresql data base..."
-	su - postgres -c '/usr/bin/pg_ctl initdb -D /var/lib/pgsql -o --locale=en_US.UTF-8'
+	su - postgres -c '/usr/bin/pg_ctl initdb -D /var/lib/pgsql -o --locale=en_US.UTF-8 -o --data-checksums'
 	echo "done"
 fi
 
package/postgresql/postgresql.service +1 -1
index 4bbe742..2f5d2a9 100644
@@ -17,7 +17,7 @@ StandardError=syslog
 SyslogIdentifier=postgres
 PIDFile=/var/lib/pgsql/postmaster.pid
 
-ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql -o --locale=en_US.UTF-8; fi"
+ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql -o --locale=en_US.UTF-8 -o --data-checksums; fi"
 ExecStart=/usr/bin/postgres -D /var/lib/pgsql
 ExecReload=/usr/bin/kill -HUP $MAINPID
 KillMode=mixed
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 package/postgresql: enable data checksums by default for initdb

Hello Pascal,

Quoted 15 lines · Pascal de Bruijn

From: Pascal de Bruijn <[email protected]>

This makes PostgreSQL as robust as possible by default

---
 package/postgresql/S50postgresql      | 2 +-
 package/postgresql/postgresql.service | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
package/postgresql/S50postgresql +0 -0
index 3c0c520..ce72e12 100644

package/postgresql/S50postgresql umask 077 · line 10

Quoted 5 lines
package/postgresql/S50postgresql +1 -1
@@ -7,7 +7,7 @@ umask 077
 
 if [ ! -f /var/lib/pgsql/PG_VERSION ]; then
 	echo "Initializing postgresql data base..."
-	su - postgres -c '/usr/bin/pg_ctl initdb -D /var/lib/pgsql -o --locale=en_US.UTF-8'
+	su - postgres -c '/usr/bin/pg_ctl initdb -D /var/lib/pgsql -o --locale=en_US.UTF-8 -o --data-checksums'

Thanks for the patch, but I believe buildroot is about providing a very basic/minimum setup as starting point customized projects and the postgresql documentation states ([1]):

Enabling checksums may incur a noticeable performance penalty.

And I think not everyone (specially for embedded projects) will accept this performance vs. data security tradeoff..., same applies to your locale/en_US.UTF-8 suggestion (not everyone will be happy/use en_US and I hope no one will run a non-customized production project)...

Regards,
Peter

[1] https://www.postgresql.org/docs/12/app-initdb.html

Quoted 16 lines
package/postgresql/S50postgresql +0 -0
 	echo "done"
 fi
 
package/postgresql/postgresql.service +1 -1
index 4bbe742..2f5d2a9 100644
@@ -17,7 +17,7 @@ StandardError=syslog
 SyslogIdentifier=postgres
 PIDFile=/var/lib/pgsql/postmaster.pid
 
-ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql -o --locale=en_US.UTF-8; fi"
+ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql -o --locale=en_US.UTF-8 -o --data-checksums; fi"
 ExecStart=/usr/bin/postgres -D /var/lib/pgsql
 ExecReload=/usr/bin/kill -HUP $MAINPID
 KillMode=mixed