fix: add bash control structure keywords to sudo command processing

Fixes issue #7346 where proxy startup failed on non-root servers due to
bash syntax errors when control structure keywords like 'for', 'do', 'done',
'break', and 'continue' were being prefixed with 'sudo'.

Added comprehensive exclusion list including for/while/until/case/select
loops, conditionals (if/then/else/elif/fi), and loop control keywords
(break/continue). Also excludes comment lines starting with '#'.

All 37 unit tests pass, including new tests for each bash control structure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2025-11-26 13:44:53 +01:00
parent 5760b96536
commit 01635e8b80
2 changed files with 224 additions and 2 deletions

View File

@@ -31,6 +31,20 @@ function parseCommandsByLineForSudo(Collection $commands, Server $server): array
'true',
'if',
'fi',
'for',
'do',
'done',
'while',
'until',
'case',
'esac',
'select',
'then',
'else',
'elif',
'break',
'continue',
'#',
])
) {
return "sudo $line";