remove split by command and space in role form

This commit is contained in:
miloschwartz
2026-06-24 17:52:21 -04:00
parent 4eba51de72
commit d0defa380a
2 changed files with 7 additions and 15 deletions
+2 -2
View File
@@ -2177,10 +2177,10 @@
"sshSudoModeCommandsDescription": "User can run only the specified commands with sudo.", "sshSudoModeCommandsDescription": "User can run only the specified commands with sudo.",
"sshSudo": "Allow sudo", "sshSudo": "Allow sudo",
"sshSudoCommands": "Sudo Commands", "sshSudoCommands": "Sudo Commands",
"sshSudoCommandsDescription": "List of commands the user is allowed to run with sudo, separated by commas, spaces, or new lines. Absolute paths must be used.", "sshSudoCommandsDescription": "List of commands the user is allowed to run with sudo, one per line. Absolute paths must be used.",
"sshCreateHomeDir": "Create Home Directory", "sshCreateHomeDir": "Create Home Directory",
"sshUnixGroups": "Unix Groups", "sshUnixGroups": "Unix Groups",
"sshUnixGroupsDescription": "Unix groups to add the user to on the target host, separated by commas, spaces, or new lines.", "sshUnixGroupsDescription": "Unix groups to add the user to on the target host, one per line.",
"roleTextFieldPlaceholder": "Enter values, or drop a .txt or .csv file", "roleTextFieldPlaceholder": "Enter values, or drop a .txt or .csv file",
"roleTextImportTitle": "Import from File", "roleTextImportTitle": "Import from File",
"roleTextImportDescription": "Importing {fileName} into {fieldLabel}.", "roleTextImportDescription": "Importing {fileName} into {fieldLabel}.",
+5 -13
View File
@@ -61,7 +61,7 @@ export function parseUnixGroups(value: string | undefined): string[] {
if (!value?.trim()) return []; if (!value?.trim()) return [];
return value return value
.split(/[,\s\n]+/) .split(/\r?\n/)
.map((group) => group.trim()) .map((group) => group.trim())
.filter(Boolean); .filter(Boolean);
} }
@@ -69,18 +69,10 @@ export function parseUnixGroups(value: string | undefined): string[] {
export function parseSudoCommands(value: string | undefined): string[] { export function parseSudoCommands(value: string | undefined): string[] {
if (!value?.trim()) return []; if (!value?.trim()) return [];
const commands: string[] = []; return value
for (const segment of value.split(/[,\n]+/)) { .split(/\r?\n/)
const trimmed = segment.trim(); .map((command) => command.trim())
if (!trimmed) continue; .filter(Boolean);
for (const part of trimmed.split(/ (?=\/)/)) {
const command = part.trim();
if (command) commands.push(command);
}
}
return commands;
} }
function hasOnlyAbsoluteSudoCommands(value: string | undefined): boolean { function hasOnlyAbsoluteSudoCommands(value: string | undefined): boolean {