Skip to content

Commit 1557f9b

Browse files
author
Serghey Rodin
committed
Security: separate passwords for databases
1 parent a7e115f commit 1557f9b

File tree

4 files changed

+30
-22
lines changed

4 files changed

+30
-22
lines changed

install/vst-install-amazon.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,9 @@ if [ "$mysql" = 'yes' ]; then
10081008
fi
10091009

10101010
# Securing MySQL installation
1011-
mysqladmin -u root password $vpass
1012-
echo -e "[client]\npassword='$vpass'\n" > /root/.my.cnf
1011+
mpass=$(gen_pass)
1012+
mysqladmin -u root password $mpass
1013+
echo -e "[client]\npassword='$mpass'\n" > /root/.my.cnf
10131014
chmod 600 /root/.my.cnf
10141015
mysql -e "DELETE FROM mysql.user WHERE User=''"
10151016
mysql -e "DROP DATABASE test" >/dev/null 2>&1
@@ -1031,17 +1032,18 @@ fi
10311032
#----------------------------------------------------------#
10321033

10331034
if [ "$postgresql" = 'yes' ]; then
1035+
ppass=$(gen_pass)
10341036
if [ $release -eq 5 ]; then
10351037
service postgresql start
1036-
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$vpass'"
1038+
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$ppass'"
10371039
service postgresql stop
10381040
cp -f $vestacp/postgresql/pg_hba.conf /var/lib/pgsql/data/
10391041
service postgresql start
10401042
else
10411043
service postgresql initdb
10421044
cp -f $vestacp/postgresql/pg_hba.conf /var/lib/pgsql/data/
10431045
service postgresql start
1044-
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$vpass'"
1046+
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$ppass'"
10451047
fi
10461048
# Configuring phpPgAdmin
10471049
if [ "$apache" = 'yes' ]; then
@@ -1272,13 +1274,13 @@ fi
12721274

12731275
# Configuring MySQL host
12741276
if [ "$mysql" = 'yes' ]; then
1275-
$VESTA/bin/v-add-database-host mysql localhost root $vpass
1277+
$VESTA/bin/v-add-database-host mysql localhost root $mpass
12761278
$VESTA/bin/v-add-database admin default default $(gen_pass) mysql
12771279
fi
12781280

12791281
# Configuring PostgreSQL host
12801282
if [ "$postgresql" = 'yes' ]; then
1281-
$VESTA/bin/v-add-database-host pgsql localhost postgres $vpass
1283+
$VESTA/bin/v-add-database-host pgsql localhost postgres $ppass
12821284
$VESTA/bin/v-add-database admin db db $(gen_pass) pgsql
12831285
fi
12841286

install/vst-install-debian.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -985,8 +985,9 @@ if [ "$mysql" = 'yes' ]; then
985985
check_result $? "mysql start failed"
986986

987987
# Securing MySQL installation
988-
mysqladmin -u root password $vpass
989-
echo -e "[client]\npassword='$vpass'\n" > /root/.my.cnf
988+
mpass=$(gen_pass)
989+
mysqladmin -u root password $mpass
990+
echo -e "[client]\npassword='$mpass'\n" > /root/.my.cnf
990991
chmod 600 /root/.my.cnf
991992
mysql -e "DELETE FROM mysql.user WHERE User=''"
992993
mysql -e "DROP DATABASE test" >/dev/null 2>&1
@@ -1008,9 +1009,10 @@ fi
10081009
#----------------------------------------------------------#
10091010

10101011
if [ "$postgresql" = 'yes' ]; then
1012+
ppass=$(gen_pass)
10111013
wget $vestacp/postgresql/pg_hba.conf -O /etc/postgresql/*/main/pg_hba.conf
10121014
service postgresql restart
1013-
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$vpass'"
1015+
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$ppass'"
10141016

10151017
# Configuring phpPgAdmin
10161018
if [ "$apache" = 'yes' ]; then
@@ -1298,13 +1300,13 @@ fi
12981300

12991301
# Configuring mysql host
13001302
if [ "$mysql" = 'yes' ]; then
1301-
$VESTA/bin/v-add-database-host mysql localhost root $vpass
1303+
$VESTA/bin/v-add-database-host mysql localhost root $mpass
13021304
$VESTA/bin/v-add-database admin default default $(gen_pass) mysql
13031305
fi
13041306

13051307
# Configuring pgsql host
13061308
if [ "$postgresql" = 'yes' ]; then
1307-
$VESTA/bin/v-add-database-host pgsql localhost postgres $vpass
1309+
$VESTA/bin/v-add-database-host pgsql localhost postgres $ppass
13081310
$VESTA/bin/v-add-database admin db db $(gen_pass) pgsql
13091311
fi
13101312

install/vst-install-rhel.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,8 +1024,9 @@ if [ "$mysql" = 'yes' ]; then
10241024
fi
10251025

10261026
# Securing MySQL installation
1027-
mysqladmin -u root password $vpass
1028-
echo -e "[client]\npassword='$vpass'\n" > /root/.my.cnf
1027+
mpass=$(gen_pass)
1028+
mysqladmin -u root password $mpass
1029+
echo -e "[client]\npassword='$mpass'\n" > /root/.my.cnf
10291030
chmod 600 /root/.my.cnf
10301031
mysql -e "DELETE FROM mysql.user WHERE User=''"
10311032
mysql -e "DROP DATABASE test" >/dev/null 2>&1
@@ -1047,17 +1048,18 @@ fi
10471048
#----------------------------------------------------------#
10481049

10491050
if [ "$postgresql" = 'yes' ]; then
1051+
ppass=$(gen_pass)
10501052
if [ $release -eq 5 ]; then
10511053
service postgresql start
1052-
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$vpass'"
1054+
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$ppass'"
10531055
service postgresql stop
10541056
cp -f $vestacp/postgresql/pg_hba.conf /var/lib/pgsql/data/
10551057
service postgresql start
10561058
else
10571059
service postgresql initdb
10581060
cp -f $vestacp/postgresql/pg_hba.conf /var/lib/pgsql/data/
10591061
service postgresql start
1060-
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$vpass'"
1062+
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$ppass'"
10611063
fi
10621064
# Configuring phpPgAdmin
10631065
if [ "$apache" = 'yes' ]; then
@@ -1289,13 +1291,13 @@ fi
12891291

12901292
# Configuring MySQL/MariaDB host
12911293
if [ "$mysql" = 'yes' ]; then
1292-
$VESTA/bin/v-add-database-host mysql localhost root $vpass
1294+
$VESTA/bin/v-add-database-host mysql localhost root $mpass
12931295
$VESTA/bin/v-add-database admin default default $(gen_pass) mysql
12941296
fi
12951297

12961298
# Configuring PostgreSQL host
12971299
if [ "$postgresql" = 'yes' ]; then
1298-
$VESTA/bin/v-add-database-host pgsql localhost postgres $vpass
1300+
$VESTA/bin/v-add-database-host pgsql localhost postgres $ppass
12991301
$VESTA/bin/v-add-database admin db db $(gen_pass) pgsql
13001302
fi
13011303

install/vst-install-ubuntu.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,9 @@ if [ "$mysql" = 'yes' ]; then
977977
check_result $? "mysql start failed"
978978

979979
# Securing MySQL/MariaDB installation
980-
mysqladmin -u root password $vpass
981-
echo -e "[client]\npassword='$vpass'\n" > /root/.my.cnf
980+
mpass=$(gen_pass)
981+
mysqladmin -u root password $mpass
982+
echo -e "[client]\npassword='$mpass'\n" > /root/.my.cnf
982983
chmod 600 /root/.my.cnf
983984
mysql -e "DELETE FROM mysql.user WHERE User=''"
984985
mysql -e "DROP DATABASE test" >/dev/null 2>&1
@@ -1000,9 +1001,10 @@ fi
10001001
#----------------------------------------------------------#
10011002

10021003
if [ "$postgresql" = 'yes' ]; then
1004+
ppass=$(gen_pass)
10031005
cp -f $vestacp/postgresql/pg_hba.conf /etc/postgresql/*/main/
10041006
service postgresql restart
1005-
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$vpass'"
1007+
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$ppass'"
10061008

10071009
# Configuring phpPgAdmin
10081010
if [ "$apache" = 'yes' ]; then
@@ -1235,13 +1237,13 @@ fi
12351237

12361238
# Configuring MySQL/MariaDB host
12371239
if [ "$mysql" = 'yes' ]; then
1238-
$VESTA/bin/v-add-database-host mysql localhost root $vpass
1240+
$VESTA/bin/v-add-database-host mysql localhost root $mpass
12391241
$VESTA/bin/v-add-database admin default default $(gen_pass) mysql
12401242
fi
12411243

12421244
# Configuring PostgreSQL host
12431245
if [ "$postgresql" = 'yes' ]; then
1244-
$VESTA/bin/v-add-database-host pgsql localhost postgres $vpass
1246+
$VESTA/bin/v-add-database-host pgsql localhost postgres $ppass
12451247
$VESTA/bin/v-add-database admin db db $(gen_pass) pgsql
12461248
fi
12471249

0 commit comments

Comments
 (0)