diff --git a/cyberpanel_upgrade.sh b/cyberpanel_upgrade.sh index 9b9f7000a..e93ee77a6 100644 --- a/cyberpanel_upgrade.sh +++ b/cyberpanel_upgrade.sh @@ -573,6 +573,12 @@ for i in {1..50}; fi if grep -q "Django==" /usr/local/requirments.txt ; then echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Requirements file downloaded successfully" | tee -a /var/log/cyberpanel_upgrade_debug.log + + # Fix pysftp dependency issue by removing it from requirements + echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Fixing pysftp dependency issue..." | tee -a /var/log/cyberpanel_upgrade_debug.log + sed -i 's/^pysftp$/# pysftp - deprecated, using paramiko instead/' /usr/local/requirments.txt + sed -i 's/pysftp/# pysftp - deprecated, using paramiko instead/' /usr/local/requirments.txt + break else echo -e "\n Requirement list has failed to download for $i times..." @@ -1071,7 +1077,7 @@ else echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Django is properly installed" | tee -a /var/log/cyberpanel_upgrade_debug.log fi -echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Installing WSGI-LSAPI..." | tee -a /var/log/cyberpanel_upgrade_debug.log +echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Installing WSGI-LSAPI with optimized compilation..." | tee -a /var/log/cyberpanel_upgrade_debug.log # Save current directory UPGRADE_CWD=$(pwd) @@ -1085,11 +1091,27 @@ cd wsgi-lsapi-2.1 || exit echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Configuring WSGI..." | tee -a /var/log/cyberpanel_upgrade_debug.log /usr/local/CyberPanel/bin/python ./configure.py 2>&1 | tee -a /var/log/cyberpanel_upgrade_debug.log + +# Fix Makefile to use proper optimization flags to avoid _FORTIFY_SOURCE warnings +echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Optimizing Makefile for proper compilation..." | tee -a /var/log/cyberpanel_upgrade_debug.log +if [[ -f Makefile ]]; then + # Replace -O0 -g3 with -O2 -g to satisfy _FORTIFY_SOURCE + sed -i 's/-O0 -g3/-O2 -g/g' Makefile + # Ensure we have proper optimization flags + if grep -q "CFLAGS" Makefile && ! grep -q "-O2" Makefile; then + sed -i 's/CFLAGS =/CFLAGS = -O2/' Makefile + fi + echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Makefile optimized for proper compilation" | tee -a /var/log/cyberpanel_upgrade_debug.log +fi + +echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Compiling WSGI with optimized flags..." | tee -a /var/log/cyberpanel_upgrade_debug.log +make clean 2>&1 | tee -a /var/log/cyberpanel_upgrade_debug.log make 2>&1 | tee -a /var/log/cyberpanel_upgrade_debug.log echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Installing lswsgi binary..." | tee -a /var/log/cyberpanel_upgrade_debug.log rm -f /usr/local/CyberCP/bin/lswsgi cp lswsgi /usr/local/CyberCP/bin/ +chmod +x /usr/local/CyberCP/bin/lswsgi # Return to original directory cd "$UPGRADE_CWD" || cd /root diff --git a/install/install.py b/install/install.py index 2db012a60..0276c715d 100644 --- a/install/install.py +++ b/install/install.py @@ -2118,6 +2118,7 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; def setupPythonWSGI(self): try: + preFlightsChecks.stdOut("Setting up Python WSGI-LSAPI with optimized compilation...", 1) command = "wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-2.1.tgz" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) @@ -2130,7 +2131,13 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; command = "/usr/local/CyberPanel/bin/python ./configure.py" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + # Fix Makefile to use proper optimization flags to avoid _FORTIFY_SOURCE warnings + self._fixWSGIMakefile() + # Compile with proper optimization flags + command = "make clean" + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + command = "make" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) @@ -2140,11 +2147,47 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; command = "cp lswsgi /usr/local/CyberCP/bin/" preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - os.chdir(self.cwd) + # Set proper permissions + command = "chmod +x /usr/local/CyberCP/bin/lswsgi" + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - except: + os.chdir(self.cwd) + preFlightsChecks.stdOut("WSGI-LSAPI compiled successfully with optimized flags", 1) + + except Exception as e: + preFlightsChecks.stdOut(f"WSGI setup error: {str(e)}", 0) return 0 + def _fixWSGIMakefile(self): + """Fix the Makefile to use proper compiler optimization flags""" + try: + makefile_path = "Makefile" + + if not os.path.exists(makefile_path): + preFlightsChecks.stdOut("Makefile not found, skipping optimization fix", 1) + return + + # Read the Makefile + with open(makefile_path, 'r') as f: + content = f.read() + + # Fix compiler flags to avoid _FORTIFY_SOURCE warnings + # Replace -O0 -g3 with -O2 -g to satisfy _FORTIFY_SOURCE + content = content.replace('-O0 -g3', '-O2 -g') + + # Ensure we have proper optimization flags + if 'CFLAGS' in content and '-O2' not in content: + content = content.replace('CFLAGS =', 'CFLAGS = -O2') + + # Write the fixed Makefile + with open(makefile_path, 'w') as f: + f.write(content) + + preFlightsChecks.stdOut("Makefile optimized for proper compilation", 1) + + except Exception as e: + preFlightsChecks.stdOut(f"Warning: Could not optimize Makefile: {str(e)}", 1) + def setupLSCPDDaemon(self): try: diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 8ad910ba5..2c9982d26 100644 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -3733,7 +3733,7 @@ echo $oConfig->Save() ? 'Done' : 'Error'; # PHP 8.x versions if Upgrade.installedOutput.find(f'lsphp{version}') == -1: command = f"yum install lsphp{version}* -y" - subprocess.call(command, shell=True) + subprocess.call(command, shell=True) Upgrade.stdOut(f"Installed PHP {version}", 1) except Exception as e: @@ -3745,7 +3745,7 @@ echo $oConfig->Save() ? 'Done' : 'Error'; 'lsphp7? lsphp7?-common lsphp7?-curl lsphp7?-dev lsphp7?-imap lsphp7?-intl lsphp7?-json ' \ 'lsphp7?-ldap lsphp7?-mysql lsphp7?-opcache lsphp7?-pspell lsphp7?-recode ' \ 'lsphp7?-sqlite3 lsphp7?-tidy' - Upgrade.executioner(command, 'Install PHP 73, 0') + Upgrade.executioner(command, 'Install PHP 7.x', 0) command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp80*' os.system(command) diff --git a/requirments-old.txt b/requirments-old.txt index 89018350d..f8fd36088 100644 --- a/requirments-old.txt +++ b/requirments-old.txt @@ -21,7 +21,7 @@ pexpect==4.8.0 psutil==5.7.3 py3dns==4.0.2 pyOpenSSL==19.1.0 -pysftp +# pysftp - deprecated, using paramiko instead pyotp requests==2.26.0 s3transfer==0.5.0