From 1a2598bc3082a2e3fffac1a6bea0b42032e388f0 Mon Sep 17 00:00:00 2001 From: Richard Kuhnt Date: Mon, 27 Aug 2018 14:15:58 +0200 Subject: [PATCH] Fix condition for persist_permission() again --- lib/install.ps1 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/install.ps1 b/lib/install.ps1 index 9cd6ff5429..cb1d03b63f 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -1224,13 +1224,12 @@ function persist_data($manifest, $original_dir, $persist_dir) { # check whether write permission for Users usergroup is set to global persist dir, if not then set function persist_permission($manifest, $global) { - if(($global -and !$manifest.persist) -or !(is_admin)) { - return + if($global -and $manifest.persist -and (is_admin)) { + $path = persistdir $null $global + $user = New-Object System.Security.Principal.SecurityIdentifier 'S-1-5-32-545' + $target_rule = New-Object System.Security.AccessControl.FileSystemAccessRule($user, 'Write', 'ObjectInherit', 'none', 'Allow') + $acl = Get-Acl -Path $path + $acl.SetAccessRule($target_rule) + $acl | Set-Acl -Path $path } - $path = persistdir $null $global - $user = New-Object System.Security.Principal.SecurityIdentifier 'S-1-5-32-545' - $target_rule = New-Object System.Security.AccessControl.FileSystemAccessRule($user, 'Write', 'ObjectInherit', 'none', 'Allow') - $acl = Get-Acl -Path $path - $acl.SetAccessRule($target_rule) - $acl | Set-Acl -Path $path }