refactor(windows scripts): remove BOM and improve UTF-8 handling
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<#
|
||||
<#
|
||||
LXS - Remote Access (Windows)
|
||||
Description: Remote Desktop and the OpenSSH server — status, enable,
|
||||
Description: Remote Desktop and the OpenSSH server - status, enable,
|
||||
disable. The Windows counterpart of root-ssh-login.sh.
|
||||
Repo: https://git.hyko.cx/hykocx/lxs
|
||||
#>
|
||||
@@ -20,7 +20,10 @@ if ($LxsLibPath -and (Test-Path $LxsLibPath)) {
|
||||
Write-Error 'Failed to fetch lib/common.ps1'
|
||||
exit 1
|
||||
}
|
||||
. ([scriptblock]::Create($LxsLibSource))
|
||||
# The library ships with a UTF-8 BOM (Windows PowerShell 5.1 needs it to
|
||||
# read the file as UTF-8); over HTTP that BOM arrives as a leading U+FEFF
|
||||
# character, which the parser will not accept.
|
||||
. ([scriptblock]::Create(($LxsLibSource -replace '^\uFEFF', '')))
|
||||
}
|
||||
|
||||
$env:LXS_LOG_FILE = Join-Path (Get-LxsTempDir) 'lxs_remote_access.log'
|
||||
@@ -60,7 +63,7 @@ function Show-LxsRemoteStatus {
|
||||
if (Get-LxsNlaState) {
|
||||
Write-LxsOk 'Network Level Authentication is on'
|
||||
} else {
|
||||
Write-LxsWarn 'Network Level Authentication is OFF — turn it on (option 2).'
|
||||
Write-LxsWarn 'Network Level Authentication is OFF - turn it on (option 2).'
|
||||
}
|
||||
try {
|
||||
$port = (Get-ItemProperty -Path $LxsRdpTcpKey -Name 'PortNumber' -ErrorAction Stop).PortNumber
|
||||
@@ -123,7 +126,7 @@ function Enable-LxsRdp {
|
||||
Write-LxsWarn "Could not enable the firewall rules: $($_.Exception.Message)"
|
||||
}
|
||||
Write-Host ''
|
||||
Write-LxsWarn 'Only expose RDP to the internet behind a VPN — it is a constant brute-force target.'
|
||||
Write-LxsWarn 'Only expose RDP to the internet behind a VPN - it is a constant brute-force target.'
|
||||
}
|
||||
|
||||
function Disable-LxsRdp {
|
||||
@@ -255,7 +258,7 @@ function Set-LxsSshDefaultShell {
|
||||
default { $null }
|
||||
}
|
||||
if (-not $shell) {
|
||||
if ($choice -eq '2') { Write-LxsErr 'pwsh.exe was not found — install PowerShell 7 first.' }
|
||||
if ($choice -eq '2') { Write-LxsErr 'pwsh.exe was not found - install PowerShell 7 first.' }
|
||||
else { Write-LxsInfo 'Cancelled.' }
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user