This commit is contained in:
+18
-2
@@ -43,6 +43,9 @@ need_root() {
|
||||
}
|
||||
|
||||
run_as_root() {
|
||||
if [ -r /dev/tty ]; then
|
||||
exec </dev/tty
|
||||
fi
|
||||
if need_root; then
|
||||
exec "$1" "\${TSRUN_ARGS[@]}"
|
||||
fi
|
||||
@@ -76,6 +79,19 @@ function Test-Administrator {
|
||||
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
}
|
||||
|
||||
function Get-TsrunTempDir {
|
||||
if ($env:TEMP) {
|
||||
return $env:TEMP
|
||||
}
|
||||
if ($env:TMPDIR) {
|
||||
return $env:TMPDIR
|
||||
}
|
||||
if ($IsWindows) {
|
||||
return [System.IO.Path]::GetTempPath()
|
||||
}
|
||||
return '/tmp'
|
||||
}
|
||||
|
||||
function Download-Tsrun {
|
||||
param(
|
||||
[string] $PrimaryUrl,
|
||||
@@ -136,7 +152,7 @@ function Start-Tsrun {
|
||||
|
||||
$url = ${psQuote(binURL)}
|
||||
$rawUrl = ${psQuote(rawBinURL)}
|
||||
$tempDir = Join-Path $env:TEMP 'tsrun-bootstrap'
|
||||
$tempDir = Join-Path (Get-TsrunTempDir) 'tsrun-bootstrap'
|
||||
$exePath = Join-Path $tempDir 'tsrun.exe'
|
||||
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
|
||||
|
||||
@@ -190,7 +206,7 @@ function detectBootstrapKind(req: Request, url: URL): "shell" | "powershell" | "
|
||||
if (forced === "windows") return "powershell";
|
||||
|
||||
const ua = (req.headers.get("user-agent") ?? "").toLowerCase();
|
||||
if (ua.includes("powershell") || ua.includes("windowspowershell")) return "powershell";
|
||||
if ((ua.includes("powershell") || ua.includes("windowspowershell")) && ua.includes("windows")) return "powershell";
|
||||
if (ua.includes("curl") || ua.includes("wget") || ua.includes("busybox")) return "shell";
|
||||
|
||||
return "text";
|
||||
|
||||
Reference in New Issue
Block a user