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.62k stars 455 forks source link

autogenerated config files are missing CRLF at the EOF #1213

Closed hknet closed 7 months ago

hknet commented 7 months ago

after setting up froxlor using the script "bin/froxlor-cli froxlor:config-services --create" config-files for postfix, dovecot and proftp especially are missing CRLF at their respective end of file - resulting merely in warnings from proftpd like this:

proftpd[19033]: warning: handling possibly truncated configuration data at line 95 of '/etc/proftpd/modules.conf'

but - if one for example tries to add a configuration line to postfix using the most abstract mode available:

postconf -e "smtpd_tls_CAfile = /etc/ssl/froxlor-custom/myhostname_CA.pem"

this results in a defunct main.cf file as this setting is not yet within the main.cf and simply added at the end of file - resulting in a config line like this:

smtpd_tls_session_cache_timeout = 3600ssmtpd_tls_CAfile = /etc/ssl/froxlor-custom/myhostname_CA.pem

therefore - please end all generated config files with a proper linefeed at the end to prevent a) warnings and b) defunct configurations.

thx.

d00p commented 7 months ago

Pull requests are always welcome

hknet commented 7 months ago

If I had an idea where to change this behaviour - I'd happily supply a request.

d00p commented 7 months ago

Can you verify that the following patch solves the issue?

diff --git a/lib/Froxlor/Cli/ConfigServices.php b/lib/Froxlor/Cli/ConfigServices.php
index ba6389ba..1833e0e2 100644
--- a/lib/Froxlor/Cli/ConfigServices.php
+++ b/lib/Froxlor/Cli/ConfigServices.php
@@ -402,7 +402,7 @@ final class ConfigServices extends CliCommand
                                                        case "file":
                                                                if (array_key_exists('content', $action)) {
                                                                        $output->writeln('<comment>Creating file "' . $action['name'] . '"</>');
-                                                                       file_put_contents($action['name'], trim(strtr($action['content'], $replace_arr)));
+                                                                       file_put_contents($action['name'], trim(strtr($action['content'], $replace_arr)) . PHP_EOL);
                                                                } elseif (array_key_exists('subcommands', $action)) {
                                                                        foreach ($action['subcommands'] as $fileaction) {
                                                                                if (array_key_exists('execute', $fileaction) && $fileaction['execute'] == "pre") {
@@ -411,7 +411,7 @@ final class ConfigServices extends CliCommand
                                                                                        exec(strtr($fileaction['content'], $replace_arr));
                                                                                } elseif ($fileaction['type'] == 'file') {
                                                                                        $output->writeln('<comment>Creating file "' . $fileaction['name'] . '"</>');
-                                                                                       file_put_contents($fileaction['name'], trim(strtr($fileaction['content'], $replace_arr)));
+                                                                                       file_put_contents($fileaction['name'], trim(strtr($fileaction['content'], $replace_arr)) . PHP_EOL);
                                                                                }
                                                                        }
                                                                }
d00p commented 7 months ago

fixed in 832ee07e0e98db9ad65837793026f0a3a7fd4d69