Skip to content

Commit

Permalink
sudo: be language-agnostic again (see issue #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesampson committed Feb 25, 2014
1 parent cd692be commit 3d8b3de
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sudo.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
if(!$args) { "usage: sudo <cmd...>"; exit 1 }

function is_admin {
$res = net localgroup administrators |? { $_ -match $env:username }
if($res) { $true }
$admin_group = (gwmi win32_group -filter "LocalAccount=True AND SID='S-1-5-32-544'").name # be language-agnostic
$admins = (net localgroup $admin_group) -join "`n" | sls '(?s)-+\n(.*)' |% { $_.matches.groups[1].value }
return $admins -split "`n" -match "^$env:username`$"
}

function sudo_do($parent_pid, $dir, $cmd) {
Expand Down

0 comments on commit 3d8b3de

Please sign in to comment.