virtualmin / virtualmin-gpl

Virtualmin web hosting control panel for Webmin
https://www.virtualmin.com
GNU General Public License v3.0
331 stars 102 forks source link

cpanel migrate - CGI folder and some scripts have been setup #940

Open shoulders opened 1 month ago

shoulders commented 1 month ago
SYSTEM INFORMATION
OS type and version Ubuntu Linux 22.04.5
Usermin version 2.102
Virtualmin version 7.20.2 Pro
Theme version 21.20.7
Apache version 2.4.52
Package updates 8 package updates are available

the issue

I imported a cpanel account in to virtualmin and it has created the following folder and CGI scripts

image

image

image

proposed solution

Don't install CGI stuff when CGI is not selected.

jcameron commented 1 month ago

Hmm, that's odd that those CGI wrappers would be created when they aren't needed!

To help debug this, it would be useful to see the output from the migration process. Also, if you create a new domain on your system, does it get those php*.cgi files?

shoulders commented 1 month ago

it would be useful to see the output from the migration process.

Is this the text that appears on screen while migrating?

I will runs some tests, clarify and get you the information.

shoulders commented 1 month ago

What I have done

my thoughts

requested details

Create New site - no folders - (From my dev site) ![image](https://github.com/user-attachments/assets/49a04ee8-0cf5-4598-95a2-2ebee0995a8d) ``` Saving server details .. .. done Creating administration group toenail .. .. done Creating administration user toenail .. .. done Creating aliases for administration user .. .. done Adding administration user to groups .. .. done Creating home directory .. .. done Creating mailbox for administration user .. .. done Adding new DNS zone .. .. done Adding to email domains list .. .. done Adding default mail aliases .. .. done Adding new virtual website .. .. done Setting up CGI scripts support with suEXEC execution mode .. .. done Adding webserver user www-data to server's group .. .. done Performing other Apache configuration .. .. done Creating SSL certificate and private key .. .. done Adding new SSL virtual website .. .. done Setting up log file rotation .. .. done Creating MariaDB login .. .. done Setting up spam filtering .. .. done Setting up AWStats reporting .. .. done Setting up password protection for AWStats .. .. done Creating Webmin user .. .. done Saving server details .. .. done Applying DNS zone for toenailxxx.com .. .. done Applying webserver configuration .. .. done Restarting PHP-FPM 8.2 server .. .. done Re-loading Webmin .. .. done Re-starting Usermin .. .. done Restarting mail server .. .. done Updating Webmin user .. .. done Setting up initial SSL certificate .. .. keeping self-signed certificate Creating initial website index page .. .. done Re-loading Webmin .. .. done ```
Import site - no folders - (From my dev site) - this in my live site had the CGI files ![image](https://github.com/user-attachments/assets/49a04ee8-0cf5-4598-95a2-2ebee0995a8d) ``` Uploading migration file .. .. uploaded 670.27 MiB Validating migration file .. .. done Starting migration of thelambs.co.uk from uploaded file .. Checking for cPanel features .. .. found Home directory, Administration user, Apache website, Log file rotation, Webmin login, DNS domain, Mail for domain, AWStats reporting, MariaDB database . However, the follow features are not supported or enabled on your system : Webalizer reporting. Some functions of the migrated virtual server may not work. Checking for clashes and dependencies .. .. all OK Creating initial virtual server thelambs.co.uk .. Saving server details .. .. done Creating administration group chickenuser .. .. done Creating administration user chickenuser .. .. done Creating aliases for administration user .. .. done Adding administration user to groups .. .. done Creating home directory .. .. done Creating mailbox for administration user .. .. done Adding new DNS zone .. .. done Adding to email domains list .. .. done Adding new virtual website .. .. done Setting up CGI scripts support with suEXEC execution mode .. .. done Adding webserver user www-data to server's group .. .. done Performing other Apache configuration .. .. done Setting up log file rotation .. .. done Creating MariaDB login .. .. done Setting up AWStats reporting .. .. done Setting up password protection for AWStats .. .. done Creating Webmin user .. .. done Saving server details .. .. done Applying DNS zone for thelambs.co.uk .. .. done Applying webserver configuration .. .. done Restarting PHP-FPM 8.2 server .. .. done Re-loading Webmin .. .. done Updating Webmin user .. .. done Re-loading Webmin .. .. done .. done Copying home directory to /home/chickenuser .. .. done Fixing home directory permissions .. .. done Re-creating mail users for thelambs.co.uk .. .. done (migrated 1 mail users) Moving server owner's mailbox .. .. done Copying email aliases .. .. done (migrated 1 aliases) Copying Cron jobs .. .. done Re-creating and loading MySQL databases .. Creating MariaDB database chickenuser_presta .. .. done Creating MariaDB database chickenuser_joomla .. .. done Creating MariaDB database chickenuser_cms .. .. done .. done (created 3 databases) Re-creating MySQL users .. .. done (created 3 MySQL users) Re-creating FTP users .. .. done (created 0 FTP users) Copying AWstats data files .. .. done Applying webserver configuration .. .. done Restarting PHP-FPM 8.2 server .. .. done Successfully migrated thelambs.co.uk virtual server, click here to manage it. ```
jcameron commented 1 month ago

Hmmm ... I'm not sure what could be going on here then. Maybe the default PHP mode wasn't set to FPM when a domain was imported, and thus those .cgi files were created?

shoulders commented 1 month ago

I don't have the php CGI mode available as I removed it. I think I removed php-cgi module for each php version.

I did have them installed at one point, I think.

Only php-fpm is available.

It is almost like some of the behind the scenes handling of php-cgi is being triggered as if it were installed.

Parts of the template system might be being ignored for php when you import.

Are there hardcoded rules for handling CGI?

Is the import saying cpanel had CGI so I will now add CGI files?

Tricky one. I can't see anything obvious.

jcameron commented 1 month ago

No, we don't even get the PHP mode from the cPanel backup. Hard to say what's going on here unless it can be re-produced, as I don't see any obvious trigger for this in the code.

jcameron commented 1 month ago

Actually ... I did find one code path where the .cgi wrappers can be created unnecessarily. I'll fix this for the next release : https://github.com/virtualmin/virtualmin-gpl/commit/4e3efd2bfaff558d1d652b240f4a0e5dfd1fba93

iliajie commented 1 month ago

I did find one code path where the .cgi wrappers can be created unnecessarily. I'll fix this for the next release : 4e3efd2

Even with this patch, if this function is called, like in FPM mode, it will still default to &cgi_bin_dir($_[0]), and create ~/cgi-bin and stuff, right?

Why not just add after $mode:

return if ($mode !~ /cgi/);
jcameron commented 1 month ago

But cgi-bin directories are different from PHP .cgi wrappers.

I will clean up those if statements though.