froxlor / Froxlor

The server administration software for your needs - The official Froxlor development Git repository
http://www.froxlor.org
GNU General Public License v2.0
1.63k stars 458 forks source link

Allow field "reload_cmd" to contain the @-symbol #1175

Closed mgeha closed 1 year ago

mgeha commented 1 year ago

I am using gentoo with different php-fpm versions and configs. I use systemd service templates to configure those php-fpm services. The command to restart would be /bin/systemctl restart php-fpm@8.1

Today I tired to edit php-fpm versions in froxlor 2.0.22 - but I cannot save them I the command contains the @-symbol. Please allow for this.

Thx in advance

d00p commented 1 year ago

As workaround, you can specify a custom shell script that runs the desired command

mgeha commented 1 year ago

Well, I just edited reload_cmd in the froxlor mysql database, but I think we can agree that both variants are not very elegant :-)

d00p commented 1 year ago

Try the followin patch, it should resolve the issue:

diff --git a/lib/Froxlor/Api/Commands/FpmDaemons.php b/lib/Froxlor/Api/Commands/FpmDaemons.php
index 26d4d493..d74daa6d 100644
--- a/lib/Froxlor/Api/Commands/FpmDaemons.php
+++ b/lib/Froxlor/Api/Commands/FpmDaemons.php
@@ -202,7 +202,7 @@ class FpmDaemons extends ApiCommand implements ResourceEntity

                        // validation
                        $description = Validate::validate($description, 'description', Validate::REGEX_DESC_TEXT, '', [], true);
-                       $reload_cmd = Validate::validate($reload_cmd, 'reload_cmd', '/^[a-z0-9\/\._\- ]+$/i', '', [], true);
+                       $reload_cmd = Validate::validate($reload_cmd, 'reload_cmd', '/^[a-z0-9\/\._\-@ ]+$/i', '', [], true);
                        $sel_stmt = Database::prepare("SELECT `id` FROM `".TABLE_PANEL_FPMDAEMONS."` WHERE `reload_cmd` = :rc");
                        $dupcheck = Database::pexecute_first($sel_stmt, ['rc' => $reload_cmd]);
                        if ($dupcheck && $dupcheck['id']) {
@@ -327,7 +327,7 @@ class FpmDaemons extends ApiCommand implements ResourceEntity

                        // validation
                        $description = Validate::validate($description, 'description', Validate::REGEX_DESC_TEXT, '', [], true);
-                       $reload_cmd = Validate::validate($reload_cmd, 'reload_cmd', '/^[a-z0-9\/\._\- ]+$/i', '', [], true);
+                       $reload_cmd = Validate::validate($reload_cmd, 'reload_cmd', '/^[a-z0-9\/\._\-@ ]+$/i', '', [], true);
                        $sel_stmt = Database::prepare("SELECT `id` FROM `".TABLE_PANEL_FPMDAEMONS."` WHERE `reload_cmd` = :rc");
                        $dupcheck = Database::pexecute_first($sel_stmt, ['rc' => $reload_cmd]);
                        if ($dupcheck && $dupcheck['id'] != $id) {
d00p commented 1 year ago

fixed in 9d2077ddee366ea301490d4d2d82892b22632aed