Commit a3fbb0b4 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Tell PostgreSQL to trust local connections.

parent a4c38f42
#!/bin/bash
echo "[-] Checking for a local PostgreSQL installation..."
CONF_FILE=$(/bin/ls /etc/postgresql/*/main/pg_hba.conf 2>/dev/null | head -1)
if [ -z "${CONF_FILE}" ] ; then
echo '[x] No pg_hba.conf file under /etc/postgresql/*/main/ ... Aborting.'
exit 1
else
echo '[-] Good, found config file under '"${CONF_FILE}"
fi
echo "[-] Checking whether local connections to PostgreSQL are trusted..."
if ! sudo grep '^local.*trust$' "${CONF_FILE}" >/dev/null 2>&1 ; then
echo "[-] Setting local connections to PostgreSQL as trusted..."
echo "local all all trust" | \
sudo tee -a "${CONF_FILE}"
else
echo '[-] All good, already set as such.'
fi
echo "[-] Checking whether a local postgres DB install has a 'taste' user..."
echo | psql -U taste postgres 2>/dev/null
if [ $? -ne 0 ] ; then
......@@ -10,7 +26,7 @@ if [ $? -ne 0 ] ; then
exit 1
fi
else
echo '[-] Already there.'
echo '[-] Already there.'
fi
PGPASS="$HOME/.pgpass"
LINE='127.0.0.1:5432:*:postgres:tastevm'
......@@ -21,5 +37,6 @@ if ! grep "${LINE/*/\\*}" "$PGPASS" >/dev/null 2>&1 ; then
LINE='localhost:5432:*:postgres:tastevm'
echo "$LINE" >> "$PGPASS"
else
echo '[-] Already there.'
echo '[-] Already stored.'
fi
chmod 600 "${PGPASS}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment