From 1516746c01e903606a6389ba23be3513da6bdf48 Mon Sep 17 00:00:00 2001 From: boban Date: Mon, 20 Oct 2025 00:06:44 +0200 Subject: [PATCH] =?UTF-8?q?Rechtebechebung=20f=C3=BCr=20User=20mit=20Sudor?= =?UTF-8?q?echte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/DkimService.php | 64 ++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/app/Services/DkimService.php b/app/Services/DkimService.php index bbc8788..6b85ce6 100644 --- a/app/Services/DkimService.php +++ b/app/Services/DkimService.php @@ -109,31 +109,67 @@ class DkimService // OpenDKIM einhängen (wenn Helper existiert) $helper = '/usr/local/sbin/mailwolt-install-dkim'; - if (is_executable($helper)) { +// if (is_executable($helper)) { +// $cmd = [ +// 'sudo','-n', $helper, +// $domain->domain, +// $selKey, +// $privOKAbs, // …/storage/app/private/dkim//.private +// $dnsTxtAbs // …/storage/app/private/dkim//.txt +// ]; +// +// $res = Process::timeout(30)->run($cmd); +// +// if ($res->failed()) { +// Log::error('DKIM install failed', [ +// 'cmd' => implode(' ', $cmd), +// 'exit' => $res->exitCode(), +// 'out' => $res->output(), +// 'err' => $res->errorOutput(), +// ]); +// throw new RuntimeException( +// 'OpenDKIM-Install fehlgeschlagen: '.$res->errorOutput() +// ); +// } +// +// // OpenDKIM neu laden (falls der Helper das nicht selbst tut) +// Process::run(['sudo','-n','systemctl','reload','opendkim']); +// } + + $helper = '/usr/local/sbin/mailwolt-install-dkim'; + + Log::debug('DKIM helper call', [ + 'as' => trim(Process::run(['whoami'])->output()), + 'helper' => $helper, + 'exists' => is_file($helper), + // KEINE privaten Keys loggen! + ]); + + if (is_file($helper)) { $cmd = [ 'sudo','-n', $helper, $domain->domain, $selKey, - $privOKAbs, // …/storage/app/private/dkim//.private - $dnsTxtAbs // …/storage/app/private/dkim//.txt + $privOKAbs, + $dnsTxtAbs, ]; $res = Process::timeout(30)->run($cmd); + Log::info('DKIM install exit', [ + 'cmd' => implode(' ', $cmd), + 'exit' => $res->exitCode(), + 'out' => $res->output(), + 'err' => $res->errorOutput(), + ]); + if ($res->failed()) { - Log::error('DKIM install failed', [ - 'cmd' => implode(' ', $cmd), - 'exit' => $res->exitCode(), - 'out' => $res->output(), - 'err' => $res->errorOutput(), - ]); - throw new RuntimeException( - 'OpenDKIM-Install fehlgeschlagen: '.$res->errorOutput() - ); + throw new RuntimeException('OpenDKIM-Install fehlgeschlagen: '.$res->errorOutput()); } - // OpenDKIM neu laden (falls der Helper das nicht selbst tut) - Process::run(['sudo','-n','systemctl','reload','opendkim']); + Process::run(['sudo','-n','/usr/bin/systemctl','reload','opendkim']); + } else { + Log::warning('DKIM helper not found', ['path' => $helper]); } return [