mirror of
https://github.com/crivion/laranode.git
synced 2026-09-03 06:24:09 +08:00
firewall: add-rule -> split arguments instead of quoting the whole rule
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user