stdlib/os: add isAdmin (#17012)

* stdlib/os: add isAdmin

* uint8 -> cuchar, assert isAdmin on Azure

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update lib/pure/os.nim docs

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Address comments on #17012

* Raise on errors in #17012

* Check the result of FreeSid in #17012

* Change case in #17012

* Fix memory leak in #17012

* Address comments in #17012

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
This commit is contained in:
Roman Inflianskas
2021-03-07 23:40:16 +02:00
committed by GitHub
parent d1e093207a
commit 31424b3808
4 changed files with 84 additions and 0 deletions

View File

@@ -655,3 +655,10 @@ block: # normalizeExe
doAssert "foo/../bar".dup(normalizeExe) == "foo/../bar"
when defined(windows):
doAssert "foo".dup(normalizeExe) == "foo"
block: # isAdmin
let isAzure = existsEnv("TF_BUILD") # xxx factor with testament.specs.isAzure
# In Azure on Windows tests run as an admin user
if isAzure and defined(windows): doAssert isAdmin()
# In Azure on POSIX tests run as a normal user
if isAzure and defined(posix): doAssert not isAdmin()