diff --git a/app/Console/Commands/MigrateConfigNames.php b/app/Console/Commands/MigrateConfigNames.php new file mode 100644 index 0000000..59af70a --- /dev/null +++ b/app/Console/Commands/MigrateConfigNames.php @@ -0,0 +1,64 @@ + '/etc/rspamd/local.d/actions.conf', + '/etc/dovecot/conf.d/99-mailwolt-tls.conf' => '/etc/dovecot/conf.d/99-tls.conf', + '/etc/postfix/mailwolt-tls.cf' => '/etc/postfix/tls.cf', + '/etc/fail2ban/jail.d/mailwolt-whitelist.local' => '/etc/fail2ban/jail.d/whitelist.local', + '/etc/fail2ban/jail.d/00-mailwolt-defaults.local'=> '/etc/fail2ban/jail.d/00-defaults.local', + ]; + + public function handle(): int + { + $dry = $this->option('dry-run'); + + foreach ($this->renames as $old => $new) { + if (!file_exists($old)) { + $this->line(" übersprungen {$old} (nicht vorhanden)"); + continue; + } + + if (file_exists($new) && !is_link($new)) { + $this->line(" bereits vorhanden {$new}"); + continue; + } + + if ($dry) { + $this->line(" [dry-run] mv {$old} → {$new}"); + continue; + } + + // Als root direkt umbenennen; als www-data via sudo (sudo mv muss in sudoers sein) + if (posix_getuid() === 0) { + $ok = @rename($old, $new); + $errMsg = error_get_last()['message'] ?? ''; + } else { + @exec('sudo -n mv ' . escapeshellarg($old) . ' ' . escapeshellarg($new) . ' 2>&1', $out, $rc); + $ok = ($rc === 0); + $errMsg = implode(' ', $out); + } + + if ($ok) { + $this->info(" umbenannt: {$old} → {$new}"); + } else { + $this->error(" FEHLER bei {$old}: {$errMsg}"); + $this->line(" → manuell: mv {$old} {$new}"); + } + } + + if (!$dry) { + $this->info('Fertig. Dienste ggf. neu starten: rspamd, dovecot, postfix, fail2ban'); + } + + return self::SUCCESS; + } +} diff --git a/app/Livewire/Ui/Security/Fail2banSettings.php b/app/Livewire/Ui/Security/Fail2banSettings.php index 57aff59..c77c5f5 100644 --- a/app/Livewire/Ui/Security/Fail2banSettings.php +++ b/app/Livewire/Ui/Security/Fail2banSettings.php @@ -135,7 +135,7 @@ bantime.factor = {$s->bantime_factor} bantime.maxtime = {$s->max_bantime} CONF; - $this->writeRootFileViaTee('/etc/fail2ban/jail.d/00-mailwolt-defaults.local', $content); + $this->writeRootFileViaTee('/etc/fail2ban/jail.d/00-defaults.local', $content); } protected function writeWhitelistConfig(): void @@ -146,7 +146,7 @@ CONF; $content = "[DEFAULT]\nignoreip = {$ignore}\n"; - $this->writeRootFileViaTee('/etc/fail2ban/jail.d/mailwolt-whitelist.local', $content); + $this->writeRootFileViaTee('/etc/fail2ban/jail.d/whitelist.local', $content); } /* ---------------- Helper ---------------- */ @@ -320,7 +320,7 @@ CONF; //bantime.maxtime = {$s->max_bantime} //CONF; // -// $this->writeRootFileViaTee('/etc/fail2ban/jail.d/00-mailwolt-defaults.local', $content); +// $this->writeRootFileViaTee('/etc/fail2ban/jail.d/00-defaults.local', $content); // } // // protected function writeWhitelistConfig(): void @@ -330,7 +330,7 @@ CONF; // // $content = "[DEFAULT]\nignoreip = {$ignore}\n"; // -// $this->writeRootFileViaTee('/etc/fail2ban/jail.d/mailwolt-whitelist.local', $content); +// $this->writeRootFileViaTee('/etc/fail2ban/jail.d/whitelist.local', $content); // } // // /** @@ -493,7 +493,7 @@ CONF; //bantime.factor = {$s->bantime_factor} //bantime.maxtime = {$s->max_bantime} //CONF; -// file_put_contents('/etc/fail2ban/jail.d/00-mailwolt-defaults.local', $content); +// file_put_contents('/etc/fail2ban/jail.d/00-defaults.local', $content); // } // // protected function writeWhitelistConfig(): void @@ -501,7 +501,7 @@ CONF; // $ips = Fail2banIpList::where('type','whitelist')->pluck('ip')->toArray(); // $ignore = implode(' ', array_unique(array_filter($ips))); // $content = "[DEFAULT]\nignoreip = {$ignore}\n"; -// file_put_contents('/etc/fail2ban/jail.d/mailwolt-whitelist.local', $content); +// file_put_contents('/etc/fail2ban/jail.d/whitelist.local', $content); // } // // private function writeRootFileViaTee(string $target, string $content): void diff --git a/app/Livewire/Ui/Security/Modal/Fail2banIpModal.php b/app/Livewire/Ui/Security/Modal/Fail2banIpModal.php index 66cf691..0a65df5 100644 --- a/app/Livewire/Ui/Security/Modal/Fail2banIpModal.php +++ b/app/Livewire/Ui/Security/Modal/Fail2banIpModal.php @@ -168,7 +168,7 @@ class Fail2banIpModal extends ModalComponent $ignore = implode(' ', array_unique(array_filter($ips))); $content = "[DEFAULT]\nignoreip = {$ignore}\n"; - $this->writeRootFileViaTee('/etc/fail2ban/jail.d/mailwolt-whitelist.local', $content); + $this->writeRootFileViaTee('/etc/fail2ban/jail.d/whitelist.local', $content); } private function writeRootFileViaTee(string $target, string $content): void @@ -293,7 +293,7 @@ class Fail2banIpModal extends ModalComponent // Fail2banIpList::create(['ip' => $ip, 'type' => $this->type]); // // if ($this->type === 'whitelist') { -// $this->writeWhitelistConfig(); // schreibt /etc/fail2ban/jail.d/mailwolt-whitelist.local +// $this->writeWhitelistConfig(); // schreibt /etc/fail2ban/jail.d/whitelist.local // $this->reloadFail2ban(); // f2b neu laden // } else { // // Blacklist = sofort bannen im dedizierten Jail @@ -356,7 +356,7 @@ class Fail2banIpModal extends ModalComponent // $content = "[DEFAULT]\nignoreip = {$ignore}\n"; // // // sicher in Root-Pfad schreiben (sudo tee) -// $this->writeRootFileViaTee('/etc/fail2ban/jail.d/mailwolt-whitelist.local', $content); +// $this->writeRootFileViaTee('/etc/fail2ban/jail.d/whitelist.local', $content); // } // // private function writeRootFileViaTee(string $target, string $content): void @@ -540,7 +540,7 @@ class Fail2banIpModal extends ModalComponent // $ignore = implode(' ', array_unique(array_filter($ips))); // $content = "[DEFAULT]\nignoreip = {$ignore}\n"; // -// $file = '/etc/fail2ban/jail.d/mailwolt-whitelist.local'; +// $file = '/etc/fail2ban/jail.d/whitelist.local'; // $tmp = $file.'.tmp'; // @file_put_contents($tmp, $content, LOCK_EX); // @chmod($tmp, 0644); diff --git a/app/Livewire/Ui/Security/RspamdForm.php b/app/Livewire/Ui/Security/RspamdForm.php index 3e9d527..da10c7d 100644 --- a/app/Livewire/Ui/Security/RspamdForm.php +++ b/app/Livewire/Ui/Security/RspamdForm.php @@ -55,7 +55,7 @@ class RspamdForm extends Component private function writeRspamdConfig(): void { - $target = '/etc/rspamd/local.d/mailwolt-actions.conf'; + $target = '/etc/rspamd/local.d/actions.conf'; $content = <<reject_score}; diff --git a/app/Livewire/Ui/Security/TlsCiphersForm.php b/app/Livewire/Ui/Security/TlsCiphersForm.php index 888977c..b6be15d 100644 --- a/app/Livewire/Ui/Security/TlsCiphersForm.php +++ b/app/Livewire/Ui/Security/TlsCiphersForm.php @@ -96,7 +96,7 @@ class TlsCiphersForm extends Component private function writePostfixConfig(): void { - $target = '/etc/postfix/mailwolt-tls.cf'; + $target = '/etc/postfix/tls.cf'; $content = "smtpd_tls_protocols = {$this->postfix_protocols}\n" . "smtp_tls_protocols = {$this->postfix_protocols}\n" . "smtpd_tls_ciphers = {$this->postfix_ciphers}\n" @@ -106,7 +106,7 @@ class TlsCiphersForm extends Component private function writeDovecotConfig(): void { - $target = '/etc/dovecot/conf.d/99-mailwolt-tls.conf'; + $target = '/etc/dovecot/conf.d/99-tls.conf'; $content = "ssl_min_protocol = {$this->dovecot_min_proto}\n" . "ssl_cipher_list = {$this->dovecot_ciphers}\n"; $this->tee($target, $content);