fix: Quote usernames safely in setup scripts (#2089)

This commit is contained in:
Kroese
2026-08-07 04:49:54 +02:00
committed by GitHub
parent 0780a91124
commit 314c6c1fc1
+3 -2
View File
@@ -1932,7 +1932,7 @@ updateSetupScript() {
local domain="${DOMAIN:-}" local domain="${DOMAIN:-}"
local user="${USERNAME:-}" local user="${USERNAME:-}"
local content id local content id ps_user
if [ ! -s "$script" ]; then if [ ! -s "$script" ]; then
error "Failed to find staged setup script: $script" error "Failed to find staged setup script: $script"
@@ -1952,9 +1952,10 @@ updateSetupScript() {
case "${id,,}" in case "${id,,}" in
"win10"* | "win11"* | "win2016"* | "win2019"* | "win2022"* | "win2025"* ) "win10"* | "win11"* | "win2016"* | "win2019"* | "win2022"* | "win2025"* )
ps_user="${user//\'/\'\'}"
printf -v content '%s\n%s' \ printf -v content '%s\n%s' \
'rem Prevent the local user password from expiring.' \ 'rem Prevent the local user password from expiring.' \
"powershell.exe -ExecutionPolicy Unrestricted -NoLogo -NoProfile -NonInteractive Set-LocalUser -Name \"$user\" -PasswordNeverExpires 1" "powershell.exe -ExecutionPolicy Unrestricted -NoLogo -NoProfile -NonInteractive -Command \"Set-LocalUser -Name '$ps_user' -PasswordNeverExpires 1\""
;; ;;
* ) * )
printf -v content '%s\n%s' \ printf -v content '%s\n%s' \