From cb1b654c7ccca5b21e3148c1d4f68f3d11901e99 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 6 Nov 2017 15:34:46 +0000 Subject: [PATCH] Change permissionf for pleroma user during database creation --- src/freedombone-app-pleroma | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/freedombone-app-pleroma b/src/freedombone-app-pleroma index 246eb40b..a72c3632 100755 --- a/src/freedombone-app-pleroma +++ b/src/freedombone-app-pleroma @@ -187,6 +187,10 @@ function pleroma_create_database { fi add_postgresql_user pleroma "$PLEROMA_ADMIN_PASSWORD" encrypted + run_system_query_postgresql "create database pleroma;" + # temporarily allow the user to create databases + run_system_query_postgresql "ALTER USER pleroma CREATEDB;" + run_system_query_postgresql "ALTER USER pleroma SUPERUSER;" run_system_query_postgresql "GRANT ALL ON ALL tables IN SCHEMA public TO pleroma;" run_system_query_postgresql "GRANT ALL ON ALL sequences IN SCHEMA public TO pleroma;" @@ -202,21 +206,28 @@ function pleroma_create_database { sed -i "s|email: .*|email: \"$MY_EMAIL_ADDRESS\",|g" $pleroma_config cd $PLEROMA_DIR - mix local.rebar --force + chown -R pleroma:pleroma * + sudo -u pleroma mix local.rebar --force if [ ! "$?" = "0" ]; then echo $'mix local.rebar failed' exit 73528562 fi - mix ecto.create --force + sudo -u pleroma mix local.hex --force + sudo -u pleroma mix deps.compile mimerl + sudo -u pleroma mix ecto.create --force if [ ! "$?" = "0" ]; then echo $'mix ecto.create failed' exit 83653582 fi - mix ecto.migrate --force + sudo -u pleroma mix ecto.migrate --force if [ ! "$?" = "0" ]; then echo $'mix ecto.migrate failed' exit 73752573 fi + + # revoke the ability to create databases for this user + run_system_query_postgresql "ALTER USER pleroma NOSUPERUSER;" + run_system_query_postgresql "ALTER USER pleroma NOCREATEDB;" } function reconfigure_pleroma { @@ -637,12 +648,13 @@ function install_pleroma { # back end cd $PLEROMA_DIR - mix local.hex --force + chown -R pleroma:pleroma * + sudo -u pleroma mix local.hex --force if [ ! "$?" = "0" ]; then echo $'mix local.hex failed' exit 1745673 fi - mix deps.get --force + sudo -u pleroma mix deps.get --force if [ ! "$?" = "0" ]; then echo $'mix deps.get failed' exit 7325733