-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add os.isAdmin
to tell whether we are admin (windows) or root (posix)
#329
Comments
This is a shell feature, there is nothing preventing the caller from modifying this environment variable. The POSIX way is to use the
This is a terrible way to do it, if a malicious actor modify the PATH (or if there's a |
If the computer is already compromised nothing is totally secure but yeah... 🤷 |
See nim-lang/Nim#17012 for the implementation. |
refs nim-lang/Nim#16859 (comment)
on windows:
refs https://stackoverflow.com/a/16285248/1426932
running
execShellCmd("net session")
can tell you: if not admin you get:else you might get an answer such as:
There are no entries in the list.
on posix:
refs: https://stackoverflow.com/a/21622456/1426932
running
getEnv("EUID") == "0"
or similar will tell you if you're root(it's readonly, can't be set)
use cases
links
The text was updated successfully, but these errors were encountered: