Skip to content

The agent that grows with you

fix: check perms before rehearsal

ethernetf5ea144fcb05
diff --git a/scripts/update-test/hermes-update-rehearsal.ps1 b/scripts/update-test/hermes-update-rehearsal.ps1
index 78eabe4c7ee..91a5a5c966e 100755
--- a/scripts/update-test/hermes-update-rehearsal.ps1
+++ b/scripts/update-test/hermes-update-rehearsal.ps1
@@ -107,6 +107,25 @@ function Resolve-Tar {
# paths
# ---------------------------------------------------------------------------
+function Test-TreeAccess {
+ param([string]$Root, [string]$Label)
+ Step "checking permissions on $Label"
+ $user = "$env:USERDOMAIN\$env:USERNAME"
+ $denied = icacls $Root /T 2>&1 |
+ Where-Object { $_ -match ': Access is denied\.$' } |
+ ForEach-Object { ($_ -replace ': Access is denied\.$', '').Trim() }
+
+ if ($denied) {
+ Warn "$($denied.Count) path(s) under $Root are not readable by $user`:"
+ $denied | ForEach-Object { Write-Host " $_" }
+ Say ''
+ Say 'run this in an elevated (Run as Administrator) PowerShell, then re-run pre:'
+ Say " icacls `"$Root`" /grant `"$user`:(OI)(CI)F`" /t /c"
+ Fail "$($denied.Count) unreadable path(s) under $Root -- fix with the command above"
+ }
+ Ok "all paths under $Root are readable"
+}
+
function Get-ResolvedPaths {
$suffix = if ($env:HERMES_DATA_DIR_SUFFIX) { $env:HERMES_DATA_DIR_SUFFIX } else { '' }
$userProfile = $env:USERPROFILE
@@ -405,6 +424,7 @@ function Invoke-Pre {
New-Item -ItemType Directory -Force -Path (Join-Path $script:Snap 'shims'), $script:Armed | Out-Null
Step 'copying your entire HERMES_HOME'
+ Test-TreeAccess -Root $P.Home -Label 'HERMES_HOME'
$started = Get-Date
$homeTar = Join-Path $script:Snap 'hermes-home.tar'
# No excludes: checkout, venv, PM store and node_modules come too, so post is
@@ -430,6 +450,7 @@ function Invoke-Pre {
Step "copying the desktop app's data"
if (Test-Path -LiteralPath $P.UserData) {
+ Test-TreeAccess -Root $P.UserData -Label 'Electron userData'
$udTar = Join-Path $script:Snap 'electron-userdata.tar'
& $script:Tar -cf $udTar -C $P.UserData .
if ($LASTEXITCODE -ne 0) { Fail 'userData backup failed' }