mirror of
https://github.com/dockur/windows.git
synced 2026-08-24 07:39:00 +01:00
fix: Quote usernames safely in setup scripts (#2089)
This commit is contained in:
+3
-2
@@ -1932,7 +1932,7 @@ updateSetupScript() {
|
||||
|
||||
local domain="${DOMAIN:-}"
|
||||
local user="${USERNAME:-}"
|
||||
local content id
|
||||
local content id ps_user
|
||||
|
||||
if [ ! -s "$script" ]; then
|
||||
error "Failed to find staged setup script: $script"
|
||||
@@ -1952,9 +1952,10 @@ updateSetupScript() {
|
||||
|
||||
case "${id,,}" in
|
||||
"win10"* | "win11"* | "win2016"* | "win2019"* | "win2022"* | "win2025"* )
|
||||
ps_user="${user//\'/\'\'}"
|
||||
printf -v content '%s\n%s' \
|
||||
'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' \
|
||||
|
||||
Reference in New Issue
Block a user