postgres-make-base-backups: resist running as root
authorPeter Palfrader <peter@palfrader.org>
Tue, 24 Sep 2019 09:10:39 +0000 (11:10 +0200)
committerPeter Palfrader <peter@palfrader.org>
Tue, 24 Sep 2019 09:10:39 +0000 (11:10 +0200)
modules/postgres/templates/backup_server/postgres-make-base-backups.erb

index ab6cac8..ca17f62 100755 (executable)
@@ -41,6 +41,11 @@ STATEDIR=/var/lib/dsa/postgres-make-base-backups
 ####
 set -u
 
+if [ "$(id -u)" = 0 ];
+    echo >&2 "Do not run me as root.  Probably you want sudo -u debbackup."
+    exit 1
+fi
+
 SELF="`basename "$0"`[$$]"
 DELTA_WAIT_SUCCESS=$(( MAX_WAIT_SUCCESS - MIN_WAIT_SUCCESS ))
 MYHOSTNAME=$(hostname -f)