Просмотр исходного кода

Fix: #3004 Invalidate session after session timeout (#3007)

* Fix: #3004 Invalidate session after session timeout 

Also use precomplied version

* Update versions openssl and php
Jaap Marcus 3 лет назад
Родитель
Сommit
017588901b

+ 7 - 7
bin/v-add-sys-filemanager

@@ -23,8 +23,8 @@ MODE=$1
 user="admin"
 
 FM_INSTALL_DIR="$HESTIA/web/fm"
-FM_FILE="v${fm_v}.zip"
-FM_URL="https://github.com/filegator/filegator/archive/refs/tags/${FM_FILE}"
+FM_FILE="filegator_latest"
+FM_URL="https://github.com/filegator/static/raw/master/builds/filegator_latest.zip"
 COMPOSER_BIN="$HOMEDIR/$user/.composer/composer"
 
 #----------------------------------------------------------#
@@ -69,18 +69,18 @@ rm --recursive --force "$FM_INSTALL_DIR"
 mkdir -p "$FM_INSTALL_DIR"
 cd "$FM_INSTALL_DIR"
 
-[ ! -f "${FM_INSTALL_DIR}/${FM_FILE}" ] && wget "$FM_URL" --quiet -O "${FM_INSTALL_DIR}/${FM_FILE}"
+[ ! -f "${FM_INSTALL_DIR}/${FM_FILE}" ] && wget "$FM_URL" --quiet -O "${FM_INSTALL_DIR}/${FM_FILE}.zip"
 
-unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}"
-mv --force ${FM_INSTALL_DIR}/filegator-${fm_v}/* "${FM_INSTALL_DIR}"
-rm --recursive --force ${FM_INSTALL_DIR}/filegator-${fm_v}
+unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}.zip"
+mv --force ${FM_INSTALL_DIR}/filegator/* "${FM_INSTALL_DIR}"
+rm --recursive --force ${FM_INSTALL_DIR}/${FM_FILE}
 [[ -f "${FM_INSTALL_DIR}/${FM_FILE}" ]] && rm "${FM_INSTALL_DIR}/${FM_FILE}"
 
 cp --recursive --force ${HESTIA_INSTALL_DIR}/filemanager/filegator/* "${FM_INSTALL_DIR}"
 
 chown $user: -R "${FM_INSTALL_DIR}"
 
-if [ -z "$openssl_installed"  ]; then 
+if [ -z "$openssl_installed"  ]; then
     COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/bin/php $COMPOSER_BIN --quiet --no-dev install
 else
     COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/local/hestia/php/bin/php $COMPOSER_BIN --quiet --no-dev install

+ 18 - 1
install/deb/filemanager/filegator/configuration.php

@@ -12,6 +12,23 @@ $dist_config['frontend_config']['guest_redirection'] = '/login/' ;
 $dist_config['frontend_config']['upload_max_size'] = 1024 * 1024 * 1024;
 
 $dist_config['services']['Filegator\Services\Storage\Filesystem']['config']['adapter'] = function () {
+    if (!empty($_SESSION['INACTIVE_SESSION_TIMEOUT'])){
+    if ($_SESSION['INACTIVE_SESSION_TIMEOUT'] * 60 + $_SESSION['LAST_ACTIVITY'] < time()) {
+        $v_user = quoteshellarg($_SESSION['user']);
+        $v_session_id = quoteshellarg($_SESSION['token']);
+        exec('/usr/local/hestia/bin/v-log-user-logout ' . $v_user . ' ' . $v_session_id, $output, $return_var);
+        unset($_SESSION);
+        session_unset();
+        session_destroy();
+        session_start();
+        echo '<meta http-equiv="refresh" content="0; url=/">';
+        exit;
+    } else {
+        $_SESSION['LAST_ACTIVITY'] = time();
+    }
+    }else{
+        echo '<meta http-equiv="refresh" content="0; url=/">';
+    }
     if (isset($_SESSION['user'])) {
         $v_user = $_SESSION['user'];
     }
@@ -105,7 +122,7 @@ $dist_config['services']['Filegator\Services\View\ViewInterface']['config'] = [
             }
             observer = new MutationObserver(callback);
             observer.observe(div,config);
-        }    
+        }
     }, 200);
 </script>',
 ];

+ 6 - 7
install/deb/filemanager/install-fm.sh

@@ -22,8 +22,8 @@ fi
 
 FM_INSTALL_DIR="$HESTIA/web/fm"
 
-FM_FILE="v${fm_v}.zip"
-FM_URL="https://github.com/filegator/filegator/archive/refs/tags/${FM_FILE}"
+FM_FILE="filegator_latest"
+FM_URL="https://github.com/filegator/static/raw/master/builds/filegator_latest.zip"
 
 
 COMPOSER_BIN="$HOMEDIR/$user/.composer/composer"
@@ -40,12 +40,11 @@ if [ "$fm_error" != "yes" ]; then
     mkdir -p "$FM_INSTALL_DIR"
     cd "$FM_INSTALL_DIR"
 
-    [ ! -f "${FM_INSTALL_DIR}/${FM_FILE}" ] && 
-        wget "$FM_URL" --quiet -O "${FM_INSTALL_DIR}/${FM_FILE}"
+    [ ! -f "${FM_INSTALL_DIR}/${FM_FILE}" ] && wget "$FM_URL" --quiet -O "${FM_INSTALL_DIR}/${FM_FILE}.zip"
 
-    unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}"
-    mv --force ${FM_INSTALL_DIR}/filegator-${fm_v}/* "${FM_INSTALL_DIR}"
-    rm --recursive --force ${FM_INSTALL_DIR}/filegator-${fm_v}
+    unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}.zip"
+    mv --force ${FM_INSTALL_DIR}/filegator/* "${FM_INSTALL_DIR}"
+    rm --recursive --force ${FM_INSTALL_DIR}/${FM_FILE}
     [[ -f "${FM_INSTALL_DIR}/${FM_FILE}" ]] && rm "${FM_INSTALL_DIR}/${FM_FILE}"
 
     cp --recursive --force ${HESTIA_INSTALL_DIR}/filemanager/filegator/* "${FM_INSTALL_DIR}"

+ 1 - 1
src/deb/php/control

@@ -1,7 +1,7 @@
 Source: hestia-php
 Package: hestia-php
 Priority: optional
-Version: 8.1.11
+Version: 8.1.12
 Section: admin
 Maintainer: HestaCP <info@hestiacp.com>
 Homepage: https://www.hestiacp.com

+ 30 - 30
src/hst_autocompile.sh

@@ -3,10 +3,10 @@
 # set -e
 # Autocompile Script for HestiaCP package Files.
 # For building from local source folder use "~localsrc" keyword as hesia branch name,
-#   and the script will not try to download the arhive from github, since '~' char is 
+#   and the script will not try to download the arhive from github, since '~' char is
 #   not accepted in branch name.
 # Compile but dont install -> ./hst_autocompile.sh --hestia --noinstall --keepbuild '~localsrc'
-# Compile and install -> ./hst_autocompile.sh --hestia --install '~localsrc' 
+# Compile and install -> ./hst_autocompile.sh --hestia --install '~localsrc'
 
 # Clear previous screen output
 clear
@@ -131,7 +131,7 @@ else
 fi
 
 # Set packages to compile
-for i in $*; do 
+for i in $*; do
     case "$i" in
         --all)
           NGINX_B='true'
@@ -190,7 +190,7 @@ if [ -z $branch ]; then
 fi
 
 if [ $(echo "$branch" | grep '^~localsrc')  ]; then
-    branch=$(echo "$branch" | sed 's/^~//'); 
+    branch=$(echo "$branch" | sed 's/^~//');
     use_src_folder='true'
 else
     use_src_folder='false'
@@ -224,7 +224,7 @@ if [ -e "/etc/redhat-release" ]; then
 else
     HESTIA_V="${BUILD_VER}_${BUILD_ARCH}"
 fi
-OPENSSL_V='3.0.5'
+OPENSSL_V='3.0.7'
 PCRE_V='10.40'
 ZLIB_V='1.2.13'
 
@@ -324,7 +324,7 @@ branch_dash=$(echo "$branch" |sed 's/\//-/g');
 
 if [ "$NGINX_B" = true ] ; then
     echo "Building hestia-nginx package..."
-    if [ "$CROSS" = "true" ]; then 
+    if [ "$CROSS" = "true" ]; then
       echo "Cross compile not supported for hestia-nginx or hestia-php"
       exit 1;
     fi
@@ -334,10 +334,10 @@ if [ "$NGINX_B" = true ] ; then
     BUILD_DIR_HESTIANGINX=$BUILD_DIR/hestia-nginx_$NGINX_V
     if [[ $NGINX_V =~ - ]]; then
       BUILD_DIR_NGINX=$BUILD_DIR/nginx-$(echo $NGINX_V |cut -d"-" -f1)
-    else 
+    else
       BUILD_DIR_NGINX=$BUILD_DIR/nginx-$(echo $NGINX_V |cut -d"~" -f1)
     fi
-    
+
     if [ "$KEEPBUILD" != 'true' ] || [ ! -d "$BUILD_DIR_HESTIANGINX" ]; then
         # Check if target directory exist
         if [ -d "$BUILD_DIR_HESTIANGINX" ]; then
@@ -471,23 +471,23 @@ fi
 #################################################################################
 
 if [ "$PHP_B" = true ] ; then
-    if [ "$CROSS" = "true" ]; then 
+    if [ "$CROSS" = "true" ]; then
       echo "Cross compile not supported for hestia-nginx or hestia-php"
       exit 1;
     fi
-    
+
     echo "Building hestia-php package..."
 
     BUILD_DIR_HESTIAPHP=$BUILD_DIR/hestia-php_$PHP_V
-    
+
     BUILD_DIR_PHP=$BUILD_DIR/php-$(echo $PHP_V |cut -d"~" -f1)
-    
+
     if [[ $PHP_V =~ - ]]; then
       BUILD_DIR_PHP=$BUILD_DIR/php-$(echo $PHP_V |cut -d"-" -f1)
     else
       BUILD_DIR_PHP=$BUILD_DIR/php-$(echo $PHP_V |cut -d"~" -f1)
     fi
-    
+
     if [ "$KEEPBUILD" != 'true' ] || [ ! -d "$BUILD_DIR_HESTIAPHP" ]; then
         # Check if target directory exist
         if [ -d $BUILD_DIR_HESTIAPHP ]; then
@@ -532,7 +532,7 @@ if [ "$PHP_B" = true ] ; then
     # Move php directory
     [ "$HESTIA_DEBUG" ] && echo DEBUG: mkdir -p $BUILD_DIR_HESTIAPHP/usr/local/hestia
     mkdir -p $BUILD_DIR_HESTIAPHP/usr/local/hestia
-    
+
     [ "$HESTIA_DEBUG" ] && echo DEBUG: rm -r $BUILD_DIR_HESTIAPHP/usr/local/hestia/php
     if [ -d $BUILD_DIR_HESTIAPHP/usr/local/hestia/php ]; then
         rm -r $BUILD_DIR_HESTIAPHP/usr/local/hestia/php
@@ -610,27 +610,27 @@ fi
 arch="$BUILD_ARCH"
 
 if [ "$HESTIA_B" = true ]; then
-  if [ "$CROSS" = "true" ]; then 
+  if [ "$CROSS" = "true" ]; then
     arch="amd64 arm64"
   fi
-  for BUILD_ARCH in $arch; do 
+  for BUILD_ARCH in $arch; do
       echo "Building Hestia Control Panel package..."
-      
+
       BUILD_DIR_HESTIA=$BUILD_DIR/hestia_$HESTIA_V
-  
+
       # Change to build directory
       cd $BUILD_DIR
-  
+
       if [ "$KEEPBUILD" != 'true' ] || [ ! -d "$BUILD_DIR_HESTIA" ]; then
           # Check if target directory exist
           if [ -d $BUILD_DIR_HESTIA ]; then
               rm -r $BUILD_DIR_HESTIA
           fi
-  
+
           # Create directory
           mkdir -p $BUILD_DIR_HESTIA
       fi
-  
+
       cd $BUILD_DIR
       rm -rf $BUILD_DIR/hestiacp-$branch_dash
       # Download and unpack source files
@@ -640,16 +640,16 @@ if [ "$HESTIA_B" = true ]; then
       elif [ -d $SRC_DIR ]; then
           download_file $HESTIA_ARCHIVE_LINK '-' 'fresh' | tar xz
       fi
-  
+
       mkdir -p $BUILD_DIR_HESTIA/usr/local/hestia
-  
+
       # Move needed directories
       cd $BUILD_DIR/hestiacp-$branch_dash
       cp -rf bin func install web $BUILD_DIR_HESTIA/usr/local/hestia/
-  
+
       # Set permissions
       find $BUILD_DIR_HESTIA/usr/local/hestia/ -type f -exec chmod -x {} \;
-      
+
       # Allow send email via /usr/local/hestia/web/inc/mail-wrapper.php via cli
       chmod +x $BUILD_DIR_HESTIA/usr/local/hestia/web/inc/mail-wrapper.php
       # Allow the executable to be executed
@@ -657,7 +657,7 @@ if [ "$HESTIA_B" = true ]; then
       find $BUILD_DIR_HESTIA/usr/local/hestia/install/ \( -name '*.sh' \) -exec chmod +x {} \;
       chmod -x $BUILD_DIR_HESTIA/usr/local/hestia/install/*.sh
       chown -R root:root $BUILD_DIR_HESTIA
-  
+
       if [ "$BUILD_DEB" = true ]; then
           # Get Debian package files
           mkdir -p $BUILD_DIR_HESTIA/DEBIAN
@@ -670,17 +670,17 @@ if [ "$HESTIA_B" = true ]; then
           get_branch_file 'src/deb/hestia/postinst' "$BUILD_DIR_HESTIA/DEBIAN/postinst"
           chmod +x $BUILD_DIR_HESTIA/DEBIAN/postinst
           chmod +x $BUILD_DIR_HESTIA/DEBIAN/preinst
-  
+
           echo Building Hestia DEB
           dpkg-deb -Zxz --build $BUILD_DIR_HESTIA $DEB_DIR
       fi
-  
+
       if [ "$BUILD_RPM" = true ]; then
           # Get RHEL package files
           get_branch_file 'src/rpm/hestia/hestia.spec' "${BUILD_DIR_HESTIA}/hestia.spec"
           sed -i "s/%HESTIA-VERSION%/${HESTIA_V}/g" "${BUILD_DIR_HESTIA}/hestia.spec"
           get_branch_file 'src/rpm/hestia/hestia.service' "${BUILD_DIR_HESTIA}/hestia.service"
-  
+
           # Build RPM package
           mkdir -p $BUILD_DIR/rpmbuild
           echo Building Hestia RPM
@@ -689,7 +689,7 @@ if [ "$HESTIA_B" = true ]; then
           rm ~/rpmbuild/RPMS/$(arch)/hestia-*.rpm
           rm -rf $BUILD_DIR/rpmbuild
       fi
-  
+
       # clear up the source folder
       if [ "$KEEPBUILD" != 'true' ]; then
           rm -r $BUILD_DIR_HESTIA