From 2ffbe4e6e11f875cd0befd639fdac40ab9013a2c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 18 Nov 2015 20:26:54 -0800 Subject: [PATCH] core: more robust WIndows admin check [GH-5616] --- CHANGELOG.md | 1 + lib/vagrant/util/platform.rb | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f179b91ef..2a748bae9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ BUG FIXES: - core: fix crash when using invalid box checksum type [GH-6327] - core: don't check for metadata if the download URL is not HTTP [GH-6540] - core: don't make custom dotfile path if there is no Vagrantfile [GH-6542] + - core: more robust check for admin privs on Windows [GH-5616] - commands/rdp: prefer `xfreerdp` if it is available on Linux [GH-6475] - commands/up: the `--provision-with` flag works with provisioner names [GH-5981] - communicator/ssh: fix potential crash case with PTY [GH-6225] diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index 706445c3b..85bca065c 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -45,10 +45,13 @@ module Vagrant # detect-if-running-with-administrator-privileges-under-windows-xp begin Win32::Registry::HKEY_USERS.open("S-1-5-19") {} - return true rescue Win32::Registry::Error return false end + + # If we made it this far then we try a fallback approach + # since the above doesn't seem to be bullet proof. See GH-5616 + (`reg query HKU\\S-1-5-19 2>&1` =~ /ERROR/).nil? end # This takes any path and converts it from a Windows path to a