[Pkg-puppet-devel] [facter] 145/180: (FACT-570) Remove windows-pr dependency
Stig Sandbeck Mathisen
ssm at debian.org
Mon Jun 30 15:06:41 UTC 2014
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository facter.
commit 60976022a8da8eb90a8647b0483eff31e0778d17
Author: Josh Cooper <josh at puppetlabs.com>
Date: Mon Jun 16 16:40:24 2014 -0700
(FACT-570) Remove windows-pr dependency
Previously, we used the windows-pr gem to detect which windows version we
were running on, and then either called into the win32-security gem for
windows versions < 6.0 (2003), or used windows-pr gem to determine if
we were running with elevated privileges.
However, the `Win32::Security.elevated_security?` method now correctly
handles Vista and up, so we can just call that directly, avoiding
windows-pr, and in the process eliminating win32-api.
---
Gemfile | 1 -
lib/facter/util/windows_root.rb | 32 +-------------------------------
2 files changed, 1 insertion(+), 32 deletions(-)
diff --git a/Gemfile b/Gemfile
index ef8a0d4..1f15099 100644
--- a/Gemfile
+++ b/Gemfile
@@ -41,7 +41,6 @@ mingw << :x64_mingw if Bundler::Dsl::VALID_PLATFORMS.include?(:x64_mingw)
platform(*mingw) do
gem 'ffi', '~> 1.9.3'
gem 'win32-dir', '~> 0.4.8'
- gem 'windows-pr', '~> 1.2'
gem 'win32-security', '~> 0.2.5'
end
diff --git a/lib/facter/util/windows_root.rb b/lib/facter/util/windows_root.rb
index a1b096d..7f14993 100644
--- a/lib/facter/util/windows_root.rb
+++ b/lib/facter/util/windows_root.rb
@@ -1,37 +1,7 @@
-require 'windows/system_info'
-require 'windows/security'
require 'win32/security'
module Facter::Util::Root
- extend ::Windows::SystemInfo
- extend ::Windows::Security
-
def self.root?
- # if Vista or later, check for unrestricted process token
- return Win32::Security.elevated_security? unless windows_version < 6.0
-
- # otherwise 2003 or less
- check_token_membership
- end
-
- def self.check_token_membership
- sid = 0.chr * 80
- size = [80].pack('L')
- member = 0.chr * 4
-
- unless CreateWellKnownSid(Windows::Security::WinBuiltinAdministratorsSid, nil, sid, size)
- raise "Failed to create administrators SID"
- end
-
- unless IsValidSid(sid)
- raise "Invalid SID"
- end
-
- unless CheckTokenMembership(nil, sid, member)
- raise "Failed to check membership"
- end
-
- # Is administrators SID enabled in calling thread's access token?
- member.unpack('L')[0] == 1
+ Win32::Security.elevated_security?
end
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git
More information about the Pkg-puppet-devel
mailing list