firewall: add-rule -> split arguments instead of quoting the whole rule

This commit is contained in:
Crivion
2025-10-22 14:16:37 +03:00
parent f9596caf70
commit a8f163a8e5

View File

@@ -13,7 +13,11 @@ class AddUfwRuleAction
if ($ruleSpec === '') {
throw new RuntimeException('Empty rule spec');
}
$proc = Process::run(['bash', '-lc', 'sudo ufw allow ' . escapeshellarg($ruleSpec)]);
$parts = preg_split('/\s+/', trim($ruleSpec));
$parts = array_filter($parts, fn($v) => $v !== '');
$proc = Process::run(array_merge(['sudo', 'ufw', 'allow'], $parts));
if ($proc->failed()) {
throw new RuntimeException('UFW allow failed: ' . $proc->errorOutput());
}