Skip to content

Commit 9e33798

Browse files
jaapmarcuswojsmol
andauthored
Minor fixes (hestiacp#2199)
* Add rate limit to forget password Max 1 email / 15 min / user same time length as key remains valid * Optional download generated SSL certificates / keys Closes hestiacp#2181 * Block access to .xxxx files (Exception for .well-know Same rules as PHP-FPM templates! * Fix hestiacp#2177 List available php version detection wrong Closes hestiacp#2177 * Update permissions RC log hestiacp#2173 * Update web/js/pages/list_ssl.js Co-authored-by: Wojciech Smoliński <wojsmol@wp.pl> * Add support for B2 download Co-authored-by: Wojciech Smoliński <wojsmol@wp.pl>
1 parent df86662 commit 9e33798

File tree

15 files changed

+127
-70
lines changed

15 files changed

+127
-70
lines changed

bin/v-add-sys-roundcube

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ if [ "$UPDATE" == "no" ]; then
132132
if [ ! -d $RC_LOG ];then
133133
mkdir $RC_LOG
134134
fi
135-
chown www-data:root $RC_LOG
135+
chown www-data:www-data $RC_LOG
136136
chmod 751 $RC_LOG
137137

138138
if [ ! -z "$(echo "$DB_SYSTEM" | grep -w 'mysql')" ]; then

bin/v-get-user-value

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Argument definition
1616
user=$1
17-
key=$(echo "$2"| tr '[:lower:]' '[:upper:]' | sed "s/^/$/")
17+
key=$(echo "$2"| tr '[:lower:]' '[:upper:]')
1818

1919
# Includes
2020
# shellcheck source=/etc/hestiacp/hestia.conf

bin/v-restart-web-backend

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ if [ "$1" = 'scheduled' ] || [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; th
5050
fi
5151

5252
tmpfile=$(mktemp)
53-
php_versions=$(ls /usr/sbin/php*fpm* | cut -d'/' -f4 | sed 's|php-fpm||')
5453
# Substitute php-fpm service name formats
55-
for version in $php_versions; do
54+
for version in $($BIN/v-list-sys-php plain); do
5655
v_php="php$version-fpm"
5756
if [ ! -f "/etc/php/${version}/fpm/pool.d/dummy.conf" ]; then
5857
cp -f "$HESTIA_INSTALL_DIR/php-fpm/dummy.conf" "/etc/php/${version}/fpm/pool.d/"

bin/v-restore-user

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,19 @@ if [ ! -e "$BACKUP/$backup" ]; then
8585
ftp_download "$backup"
8686
downloaded='yes'
8787
fi
88+
if [[ "$BACKUP_SYSTEM" =~ "b2" ]] && [ -z "$downloaded" ]; then
89+
b2_download "$backup"
90+
downloaded='yes'
91+
fi
8892
if [ -z "$downloaded" ]; then
8993
check_result "$E_NOTEXIST" "backup file $backup doesn't exist in '${BACKUP}' folder"
9094
fi
9195
fi
9296

97+
if [ ! -e "$BACKUP/$backup" ]; then
98+
check_result "$E_NOTEXIST" "backup file $backup doesn't exist in '${BACKUP}' folder"
99+
fi
100+
93101
# Checking user existence on the server
94102
check_user=$(is_object_valid 'user' 'USER' "$user")
95103
if [ -z "$check_user" ]; then

func/backup.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,3 +459,17 @@ b2_backup() {
459459
done
460460
fi
461461
}
462+
463+
b2_download() {
464+
# Defining backblaze b2 settings
465+
source_conf "$HESTIA/conf/b2.backup.conf"
466+
467+
# Recreate backblaze auth file ~/.b2_account_info (for situation when key was changed in b2.backup.conf)
468+
b2 clear-account > /dev/null 2>&1
469+
b2 authorize-account $B2_KEYID $B2_KEY > /dev/null 2>&1
470+
cd $BACKUP
471+
b2 download-file-by-name $BUCKET $user/$1 $1 > /dev/null 2>&1
472+
if [ "$?" -ne 0 ]; then
473+
check_result "$E_CONNECT" "b2 failed to download $user.$1"
474+
fi
475+
}

install/deb/templates/web/nginx/caching.stpl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ server {
5353
proxy_pass https://%ip%:%web_ssl_port%;
5454
}
5555

56-
location ~ /\.ht {return 404;}
57-
location ~ /\.svn/ {return 404;}
58-
location ~ /\.git/ {return 404;}
59-
location ~ /\.hg/ {return 404;}
60-
location ~ /\.bzr/ {return 404;}
56+
location ~ /\.(?!well-known\/) {
57+
deny all;
58+
return 404;
59+
}
6160

6261
proxy_hide_header Upgrade;
6362

install/deb/templates/web/nginx/caching.tpl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ server {
4848
proxy_pass http://%ip%:%web_port%;
4949
}
5050

51-
location ~ /\.ht {return 404;}
52-
location ~ /\.svn/ {return 404;}
53-
location ~ /\.git/ {return 404;}
54-
location ~ /\.hg/ {return 404;}
55-
location ~ /\.bzr/ {return 404;}
51+
location ~ /\.(?!well-known\/) {
52+
deny all;
53+
return 404;
54+
}
5655

5756
include %home%/%user%/conf/web/%domain%/nginx.conf_*;
5857
}

install/deb/templates/web/nginx/default.stpl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ server {
3333
proxy_pass https://%ip%:%web_ssl_port%;
3434
}
3535

36-
location ~ /\.ht {return 404;}
37-
location ~ /\.svn/ {return 404;}
38-
location ~ /\.git/ {return 404;}
39-
location ~ /\.hg/ {return 404;}
40-
location ~ /\.bzr/ {return 404;}
36+
location ~ /\.(?!well-known\/) {
37+
deny all;
38+
return 404;
39+
}
4140

4241
proxy_hide_header Upgrade;
4342

install/deb/templates/web/nginx/default.tpl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ server {
2828
proxy_pass http://%ip%:%web_port%;
2929
}
3030

31-
location ~ /\.ht {return 404;}
32-
location ~ /\.svn/ {return 404;}
33-
location ~ /\.git/ {return 404;}
34-
location ~ /\.hg/ {return 404;}
35-
location ~ /\.bzr/ {return 404;}
31+
location ~ /\.(?!well-known\/) {
32+
deny all;
33+
return 404;
34+
}
3635

3736
include %home%/%user%/conf/web/%domain%/nginx.conf_*;
3837
}

install/deb/templates/web/nginx/hosting.stpl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ server {
3333
proxy_pass https://%ip%:%web_ssl_port%;
3434
}
3535

36-
location ~ /\.ht {return 404;}
37-
location ~ /\.svn/ {return 404;}
38-
location ~ /\.git/ {return 404;}
39-
location ~ /\.hg/ {return 404;}
40-
location ~ /\.bzr/ {return 404;}
36+
location ~ /\.(?!well-known\/) {
37+
deny all;
38+
return 404;
39+
}
4140

4241
disable_symlinks if_not_owner from=%docroot%;
4342

0 commit comments

Comments
 (0)