From 82b9bab207ea3cc351581bab89abce48cff2ad12 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Tue, 10 Feb 2015 08:18:11 +0100 Subject: postgresql-setup: mention login shell explicitly The setup script was reported to not work if user 'postgres' has /sbin/nologin in /etc/passwd (explicitly set by administrator). This configuration does not seem to be terribly useful but there is no need to fail at all. Resolves: rhbz#1122143 * postgresql-setup.in ($SU_L_POSTGRES): New wrapping variable, using '-s /bin/sh' to bypass /sbin/nologin. This option should be supported both by 'su' and 'runuser'. * NEWS: Document. --- NEWS | 2 ++ postgresql-setup.in | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 277a7b2..dae256a 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ New in 3.0 version * Use 'pg_upgrade --username' instead of 'pg_upgrade --user' for PostgreSQL >= 9.4. +* postgresql-setup now works if postgres user is /bin/nologin + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New in 2.0 version diff --git a/postgresql-setup.in b/postgresql-setup.in index 17a14f0..959ee06 100644 --- a/postgresql-setup.in +++ b/postgresql-setup.in @@ -29,6 +29,8 @@ POSTGRES_HOMEDIR=@POSTGRES_HOMEDIR@ SU=@SU@ +SU_L_POSTGRES="$SU -s /bin/sh -l postgres" + # The where PostgreSQL server listens by default PGPORT_DEF=5432 @@ -124,7 +126,7 @@ perform_initdb() initdbcmd="$PGENGINE/initdb --pgdata='$pgdata' --auth='ident'" initdbcmd+=" $PGSETUP_INITDB_OPTIONS" - $SU -l postgres -c "$initdbcmd" >> "$initdb_log" 2>&1 < /dev/null + $SU_L_POSTGRES -c "$initdbcmd" >> "$initdb_log" 2>&1 < /dev/null # Create directory for postmaster log files mkdir "$pgdata/pg_log" @@ -221,7 +223,7 @@ upgrade() # Create empty new-format database if perform_initdb; then # Do the upgrade - $SU -l postgres -c "$PGENGINE/pg_upgrade \ + $SU_L_POSTGRES -c "$PGENGINE/pg_upgrade \ '--old-bindir=$PREVPGENGINE' \ '--new-bindir=$PGENGINE' \ '--old-datadir=$pgdataold' \ -- cgit