mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Merge pull request #1480 from PowerShell/psget
Updating Test-RunningAsElevated to return true on *nix and OS X.
This commit is contained in:
commit
7a8d58f3c7
2 files changed
+5
-2
No files matched your search
Binary file not shown.
@@ -16,6 +16,7 @@ $script:isNanoServer = $null -ne ('System.Runtime.Loader.AssemblyLoadContext' -a
|
||||
|
||||
function IsWindows { $PSVariable = Get-Variable -Name IsWindows -ErrorAction Ignore; return (-not $PSVariable -or $PSVariable.Value) }
|
||||
function IsLinux { $PSVariable = Get-Variable -Name IsLinux -ErrorAction Ignore; return ($PSVariable -and $PSVariable.Value) }
|
||||
function IsOSX { $PSVariable = Get-Variable -Name IsOSX -ErrorAction Ignore; return ($PSVariable -and $PSVariable.Value) }
|
||||
function IsCore { $PSVariable = Get-Variable -Name IsCore -ErrorAction Ignore; return ($PSVariable -and $PSVariable.Value) }
|
||||
|
||||
if(IsWindows)
|
||||
@@ -7469,9 +7470,11 @@ function Test-RunningAsElevated
|
||||
$adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator
|
||||
return $prp.IsInRole($adm)
|
||||
}
|
||||
elseif(IsLinux)
|
||||
elseif((IsLinux) -or (IsOSX))
|
||||
{
|
||||
return ($env:SUDO_UID -eq '1000')
|
||||
# Permission models on *nix can be very complex, to the point that you could never possibly guess without simply trying what you need to try;
|
||||
# This is totally different from Windows where you can know what you can or cannot do with/without admin rights.
|
||||
return $true
|
||||
}
|
||||
|
||||
return $false
|
||||
|
||||
Reference in new issue
Block a user