Skip to content

Commit d4ae2dc

Browse files
authored
Fix: hestiacp#728 Upgrade phppgadmin (hestiacp#3288)
* Update config.php.inc * Fix installers * Fix installers * Fix installers * Add update script * Lint format * config.inc.php for RPM based setups
1 parent 8f718c3 commit d4ae2dc

File tree

8 files changed

+81
-4
lines changed

8 files changed

+81
-4
lines changed

func/upgrade.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ upgrade_init_backup() {
325325
if [ -d "/etc/phpmyadmin/" ]; then
326326
mkdir -p $HESTIA_BACKUP/conf/phpmyadmin/
327327
fi
328+
if [ -d "/etc/phppgadmin/" ]; then
329+
mkdir -p $HESTIA_BACKUP/conf/phppgadmin/
330+
fi
328331
}
329332

330333
upgrade_init_logging() {
@@ -467,6 +470,12 @@ upgrade_start_backup() {
467470
fi
468471
cp -fr /etc/phpmyadmin/* $HESTIA_BACKUP/conf/phpmyadmin
469472
fi
473+
if [ -d "/etc/phppgadmin" ]; then
474+
if [ "$DEBUG_MODE" = "true" ]; then
475+
echo " ---- phppgadmin"
476+
fi
477+
cp -fr /etc/phppgadmin/* $HESTIA_BACKUP/conf/phppgadmin
478+
fi
470479
}
471480

472481
upgrade_refresh_config() {
@@ -541,6 +550,29 @@ upgrade_b2_tool() {
541550
fi
542551
}
543552

553+
upgrade_phppgadmin() {
554+
if [ -n "$(echo $DB_SYSTEM | grep -w 'pgsql')" ]; then
555+
pga_release=$(cat /usr/share/phppgadmin/libraries/lib.inc.php | grep appVersion | head -n1 | cut -f2 -d\' | cut -f1 -d-)
556+
if version_ge "$pga_release" "pga_v"; then
557+
echo "[ * ] phppgadmin is up to date ($pga_release)..."
558+
else
559+
# Display upgrade information
560+
echo "[ * ] Upgrading phppgadmin to version $pga_v..."
561+
[ -d /usr/share/phpmyadmin ] || mkdir -p /usr/share/phpmyadmin
562+
# Download latest phpMyAdmin release
563+
wget --retry-connrefused --quiet https://github.com/hestiacp/phppgadmin/releases/download/v$pga_v/phppgadmin-v$pga_v.tar.gz
564+
tar xzf phppgadmin-v$pga_v.tar.gz -C /usr/share/phppgadmin/
565+
566+
if ! version_ge "$pga_release" "7.14.0"; then
567+
cp -f $HESTIA_INSTALL_DIR/pga/config.inc.php /etc/phppgadmin/
568+
fi
569+
if [ ! -f /usr/share/phppgadmin/conf/config.inc.php ]; then
570+
ln -s /etc/phppgadmin/config.inc.php /usr/share/phppgadmin/conf
571+
fi
572+
fi
573+
fi
574+
}
575+
544576
upgrade_phpmyadmin() {
545577
# Check if MariaDB/MySQL is installed on the server before attempting to install or upgrade phpMyAdmin
546578
if [ -n "$(echo $DB_SYSTEM | grep -w 'mysql')" ]; then

install/deb/pga/config.inc.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@
7878
// 'disable' disables AutoComplete.
7979
$conf["autocomplete"] = "default on";
8080

81+
// If extra session security is true, then PHP's session cookies will have
82+
// SameSite cookie flags set to prevent CSRF attacks. If you're using
83+
// auto-start sessions, autostarted sessions will be destroyed and
84+
// restarted with SameSite on. If this this solution is not acceptable for
85+
// your situation, you will need to either turn off auot-start sessions, or
86+
// turn off secure sessions. Versions of PHP below 7.3 do not have access
87+
// to this feature and will be vulnerable to CSRF attacks.
88+
$conf["extra_session_security"] = true;
89+
8190
// If extra login security is true, then logins via phpPgAdmin with no
8291
// password or certain usernames (pgsql, postgres, root, administrator)
8392
// will be denied. Only set this false once you have read the FAQ and

install/hst-install-debian.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ software="nginx apache2 apache2-utils apache2-suexec-custom
4848
awstats vsftpd proftpd-basic bind9 exim4 exim4-daemon-heavy
4949
clamav-daemon spamassassin dovecot-imapd dovecot-pop3d dovecot-sieve dovecot-managesieved
5050
net-tools mariadb-client mariadb-common mariadb-server mysql-client mysql-common mysql-server postgresql
51-
postgresql-contrib phppgadmin mc flex whois git idn2 unzip zip sudo bc ftp lsof
51+
postgresql-contrib mc flex whois git idn2 unzip zip sudo bc ftp lsof
5252
rrdtool quota e2fslibs bsdutils e2fsprogs curl imagemagick fail2ban
5353
dnsutils bsdmainutils cron hestia=${HESTIA_INSTALL_VER} hestia-nginx
5454
hestia-php expect libmail-dkim-perl unrar-free vim-common acl sysstat
@@ -1626,11 +1626,20 @@ if [ "$postgresql" = 'yes' ]; then
16261626
systemctl restart postgresql
16271627
sudo -iu postgres psql -c "ALTER USER postgres WITH PASSWORD '$ppass'"
16281628

1629+
mkdir -p /etc/phppgadmin/
1630+
mkdir -p /usr/share/phppgadmin/
1631+
1632+
cp -f $HESTIA_INSTALL_DIR/pga/config.inc.php /etc/phppgadmin/
1633+
1634+
wget --retry-connrefused --quiet https://github.com/hestiacp/phppgadmin/releases/download/v$pga_v/phppgadmin-v$pga_v.tar.gz
1635+
tar xzf phppgadmin-v$pga_v.tar.gz -C /usr/share/phppgadmin/
1636+
1637+
ln -s /etc/phppgadmin/config.inc.php /usr/share/phppgadmin/conf/
1638+
16291639
# Configuring phpPgAdmin
16301640
if [ "$apache" = 'yes' ]; then
16311641
cp -f $HESTIA_INSTALL_DIR/pga/phppgadmin.conf /etc/apache2/conf.d/phppgadmin.inc
16321642
fi
1633-
cp -f $HESTIA_INSTALL_DIR/pga/config.inc.php /etc/phppgadmin/
16341643

16351644
write_config_value "DB_PGA_ALIAS" "phppgadmin"
16361645
$HESTIA/bin/v-change-sys-db-alias 'pga' "phppgadmin"

install/hst-install-ubuntu.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ software="apache2 apache2.2-common apache2-suexec-custom apache2-utils
4646
imagemagick libapache2-mod-fcgid libapache2-mod-php$fpm_v libapache2-mod-rpaf
4747
lsof mc mariadb-client mariadb-common mariadb-server mysql-client mysql-common mysql-server nginx
4848
php$fpm_v php$fpm_v-cgi php$fpm_v-common php$fpm_v-curl
49-
php$fpm_v-mysql php$fpm_v-imap php$fpm_v-ldap php$fpm_v-apcu phppgadmin
49+
php$fpm_v-mysql php$fpm_v-imap php$fpm_v-ldap php$fpm_v-apcu
5050
php$fpm_v-pgsql php$fpm_v-zip php$fpm_v-bz2 php$fpm_v-cli php$fpm_v-gd
5151
php$fpm_v-imagick php$fpm_v-intl php$fpm_v-mbstring
5252
php$fpm_v-opcache php$fpm_v-pspell php$fpm_v-readline php$fpm_v-xml
@@ -1672,11 +1672,20 @@ if [ "$postgresql" = 'yes' ]; then
16721672
systemctl restart postgresql
16731673
sudo -iu postgres psql -c "ALTER USER postgres WITH PASSWORD '$ppass'" > /dev/null 2>&1
16741674

1675+
mkdir -p /etc/phppgadmin/
1676+
mkdir -p /usr/share/phppgadmin/
1677+
1678+
wget --retry-connrefused --quiet https://github.com/hestiacp/phppgadmin/releases/download/v$pga_v/phppgadmin-v$pga_v.tar.gz
1679+
tar xzf phppgadmin-v$pga_v.tar.gz -C /usr/share/phppgadmin/
1680+
1681+
cp -f $HESTIA_INSTALL_DIR/pga/config.inc.php /etc/phppgadmin/
1682+
1683+
ln -s /etc/phppgadmin/config.inc.php /usr/share/phppgadmin/conf/
1684+
16751685
# Configuring phpPgAdmin
16761686
if [ "$apache" = 'yes' ]; then
16771687
cp -f $HESTIA_INSTALL_DIR/pga/phppgadmin.conf /etc/apache2/conf.d/phppgadmin.inc
16781688
fi
1679-
cp -f $HESTIA_INSTALL_DIR/pga/config.inc.php /etc/phppgadmin/
16801689

16811690
write_config_value "DB_PGA_ALIAS" "phppgadmin"
16821691
$HESTIA/bin/v-change-sys-db-alias 'pga' "phppgadmin"

install/rpm/pga/config.inc.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@
148148
// Time in seconds. If set to 0, refreshing data using ajax will be disabled (locks and activity pages)
149149
$conf["ajax_refresh"] = 3;
150150

151+
// If extra session security is true, then PHP's session cookies will have
152+
// SameSite cookie flags set to prevent CSRF attacks. If you're using
153+
// auto-start sessions, autostarted sessions will be destroyed and
154+
// restarted with SameSite on. If this this solution is not acceptable for
155+
// your situation, you will need to either turn off auot-start sessions, or
156+
// turn off secure sessions. Versions of PHP below 7.3 do not have access
157+
// to this feature and will be vulnerable to CSRF attacks.
158+
$conf["extra_session_security"] = true;
159+
151160
/*****************************************
152161
* Don't modify anything below this line *
153162
*****************************************/

install/upgrade/upgrade.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0" "8.1" "8.2")
4545
# Set version of phpMyAdmin to install during upgrade if not already installed
4646
pma_v='5.2.1'
4747

48+
# Set version of phppgadmin to install during upgrade if not already installed
49+
pga_v='7.14.4'
50+
4851
# Set version of RoundCube (Webmail) to update during upgrade if not already installed
4952
# Note: only applies to "non-apt installs >= 1.4.0 or manually phased out"
5053
rc_v='1.6.1'

src/deb/hestia/postinst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ upgrade_dependencies | tee -a $LOG
8989
# Upgrade phpMyAdmin if applicable
9090
upgrade_phpmyadmin | tee -a $LOG
9191

92+
# Upgrade phpMyAdmin if applicable
93+
upgrade_phppgadmin | tee -a $LOG
94+
9295
# Upgrade blackblaze-cli-took if applicable
9396
upgrade_b2_tool | tee -a $LOG
9497

src/rpm/hestia/hestia.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ if [ -e "/usr/local/hestia/data/users/admin" ]; then
111111
# Upgrade phpMyAdmin if applicable
112112
upgrade_phpmyadmin | tee -a $LOG
113113

114+
# Upgrade phpMyAdmin if applicable
115+
upgrade_phppgadmin | tee -a $LOG
116+
114117
# Upgrade blackblaze-cli-took if applicable
115118
upgrade_b2_tool | tee -a $LOG
116119

0 commit comments

Comments
 (0)