1: #!/bin/bash
2: DB_USER='icinga'
3: DB_PASSWORD='Jaht5aChkib2The5iA'
4: SALT=$DB_USER
5: MD5_PASSWORD=$(echo -n ${DB_PASSWORD}${SALT} | md5sum | cut -d" " -f1)
6: PASSWORD_HASH="md5${MD5_PASSWORD}"
7: CURRENT_PASS=$(psql -tA -c "SELECT passwd FROM pg_shadow WHERE usename = '${DB_USER}';")
8:
9: if ! [ $CURRENT_PASS == $PASSWORD_HASH ]; then
10: psql -tA -c "ALTER ROLE ${DB_USER} WITH PASSWORD '${DB_PASSWORD}';"
11: fi
Note: to be run locally as postgres user.
onsdag 6. juni 2012
Check for correct password in PostgreSQL
Check if a ROLE has the correct password, and change if it isn't:
Abonner på:
Innlegg (Atom)