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
Report the correct result if the "server" service is not running #4
Report the correct result if the "server" service is not running #4
Conversation
AIUI it'd be better to fall back to |
Up to @sindresorhus. I'm happy with both approaches. |
Ping @sindresorhus |
Sorry, too many PRs to deal with.
👍 |
If the "server" service is not running, this module will report `false` even when the user is the administrator. By investigating further, `net.exe session` fails with the following message: ``` The Server service is not started. More help is available by typing NET HELPMSG 2114. ``` which is caught by the `.catch()` block, which returns `false` without inspecting the error object. The main issue is that `net.exe session` returns an exit code 2 both when the user has no permissions and when the server service is not running, making it impossibly to distinguish between both scenarios without inspecting the output of the command. The StackOverflow question linked from the source code addresses this concern in another answer, by proposing the use of the following command: ``` fsutil dirty query %systemdrive% >nul ``` `fsutil` is ensured to be present on Windows XP and later, and returns an exit code 0 if the user is the administrator, and exit code 1 otherwise. This commit introduces the recommended `fsutil` command, and falls back to an `fltmc` approach discussed on the same thread if `fsutil` doesn't exist (e.g: we get `ENOENT` for it). Fixes: #3 See: http://stackoverflow.com/a/21295806/1641422 Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
@sindresorhus @lurch Turns out the |
Thanks :) |
This version contains a fix for correctly checking whether a process is running with administrator right or not, without depending on the "Server" service. Fixes: #1180 See: sindresorhus/is-admin#4 Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This version contains a fix for correctly checking whether a process is running with administrator right or not, without depending on the "Server" service. Fixes: #1180 See: sindresorhus/is-admin#4 Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This version contains a fix for correctly checking whether a process is running with administrator right or not, without depending on the "Server" service. Fixes: #1180 See: sindresorhus/is-admin#4 Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This version contains a fix for correctly checking whether a process is running with administrator right or not, without depending on the "Server" service. Fixes: #1180 See: sindresorhus/is-admin#4 Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
If the "server" service is not running, this module will report
false
even when the user is the administrator.
By investigating further,
net.exe session
fails with the followingmessage:
which is caught by the
.catch()
block, which returnsfalse
withoutinspecting the error object.
The main issue is that
net.exe session
returns an exit code 2 bothwhen the user has no permissions and when the server service is not
running, making it impossibly to distinguish between both scenarios
without inspecting the output of the command.
The StackOverflow question linked from the source code addresses this
concern in another answer, by proposing the use of the following
command:
fsutil
is ensured to be present on Windows XP and later, and returnsan exit code 0 if the user is the administrator, and exit code 1
otherwise.
This commit introduces the recommended
fsutil
command, and falls backto an
fltmc
approach discussed on the same thread iffsutil
doesn'texist (e.g: we get
ENOENT
for it).Fixes: #3
See: http://stackoverflow.com/a/21295806/1641422
Signed-off-by: Juan Cruz Viotti jviotti@openmailbox.org