win32-security 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24c9e39da5dad049f0d5458344d7e260d3827657
4
- data.tar.gz: 58219464a85da5b713726db30ad824bd9799bfb8
3
+ metadata.gz: 55e26f7dee9565c7f2bbcb65430d048ee8fde06e
4
+ data.tar.gz: f56540e1e2536ad249d493f772b12ff132797cec
5
5
  SHA512:
6
- metadata.gz: e4aa6445f22883bdf06b1538e0d08480f9cb0b36e33844c58f645816ac1d74cacff3edc81e04c4c40d6ceae9caf57a101de263837c34e3f1bfadf7bf40f00c18
7
- data.tar.gz: 839ff7dcc84f298254c7813668bbcf8ed819193be4268b3608255fc21d9dd1f987abab833c8df72c1ed085b18fe8df9b927cf5c7c8de2cd9c40da21bae771562
6
+ metadata.gz: 7c2956d92cbcce0951f7b67150bdd324754e42c8faac2d5e2068e25d2bada7d12588c44775bb1c6d427415f0965f8792473a7c98c0ff57925b1f2861e0b2b605
7
+ data.tar.gz: e9676d488e07a8648b5e19227e5a396bb815b1377740044ac68e479bfc2489019a5fcf818ece2f63f70a4afd03788b820973c4d292d65975f83c8ff9a03ab193
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.2.5 - 24-Feb-2014
2
+ * Fixed a bug in the SID#string_to_sid method. Thanks go to Rob Reynolds
3
+ for the spot.
4
+
1
5
  == 0.2.4 - 8-Nov-2013
2
6
  * Added rake as a development dependency.
3
7
  * Attempted to make FFI related constants and structs more private.
data/README CHANGED
@@ -20,8 +20,9 @@
20
20
  repo if you're interested in taking a look.
21
21
 
22
22
  == Known Issues
23
- None that I'm aware of. Please file any bug reports on the project page
24
- at http://www.rubyforge.org/projects/win32utils.
23
+ None that I'm aware of. Please file any bug reports on the project page at:
24
+
25
+ https://github.com/djberg96/win32-security
25
26
 
26
27
  == Contributions
27
28
  Although this library is free, please consider having your company
@@ -33,7 +34,7 @@
33
34
  Artistic 2.0
34
35
 
35
36
  == Copyright
36
- (C) 2003-2013 Daniel J. Berger
37
+ (C) 2003-2014 Daniel J. Berger
37
38
  All Rights Reserved
38
39
 
39
40
  == Authors
@@ -20,7 +20,7 @@ module Win32
20
20
  extend Windows::Security::Functions
21
21
 
22
22
  # The version of the win32-security library
23
- VERSION = '0.2.4'
23
+ VERSION = '0.2.5'
24
24
 
25
25
  # Used by OpenProcessToken
26
26
  TOKEN_QUERY = 8
@@ -60,14 +60,14 @@ module Win32
60
60
 
61
61
  pbool.read_long != 0
62
62
  else
63
- token = FFI::MemoryPointer.new(:ulong)
63
+ token = FFI::MemoryPointer.new(:uintptr_t)
64
64
 
65
65
  unless OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, token)
66
66
  raise SystemCallError.new("OpenProcessToken", FFI.errno)
67
67
  end
68
68
 
69
69
  begin
70
- token = token.read_ulong
70
+ token = token.read_pointer.to_i
71
71
 
72
72
  # Since the TokenElevation struct only has 1 member, we use a pointer.
73
73
  te = FFI::MemoryPointer.new(:ulong)
@@ -17,7 +17,7 @@ module Win32
17
17
  extend Windows::Security::Functions
18
18
 
19
19
  # The version of the Win32::Security::SID class.
20
- VERSION = '0.2.0'
20
+ VERSION = '0.2.1'
21
21
 
22
22
  # Some constant SID's for your convenience, in string format.
23
23
  # See http://support.microsoft.com/kb/243330 for details.
@@ -96,7 +96,9 @@ module Win32
96
96
  raise SystemCallError.new("ConvertStringSidToSid", FFI.errno)
97
97
  end
98
98
 
99
- sid.read_pointer.read_string
99
+ ptr = sid.read_pointer
100
+
101
+ ptr.read_bytes(GetLengthSid(ptr))
100
102
  end
101
103
 
102
104
  # Creates a new SID with +authority+ and up to 8 +subauthorities+,
@@ -172,7 +174,7 @@ module Win32
172
174
  def initialize(account=nil, host=Socket.gethostname)
173
175
  if account.nil?
174
176
  begin
175
- ptoken = FFI::MemoryPointer.new(:ulong)
177
+ ptoken = FFI::MemoryPointer.new(:uintptr_t)
176
178
 
177
179
  # Try the thread token first, default to the process token.
178
180
  bool = OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, true, ptoken)
@@ -180,13 +182,13 @@ module Win32
180
182
  if !bool && FFI.errno != ERROR_NO_TOKEN
181
183
  raise SystemCallError.new("OpenThreadToken", FFI.errno)
182
184
  else
183
- ptoken = FFI::MemoryPointer.new(:ulong)
185
+ ptoken = FFI::MemoryPointer.new(:uintptr_t)
184
186
  unless OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, ptoken)
185
187
  raise SystemCallError.new("OpenProcessToken", FFI.errno)
186
188
  end
187
189
  end
188
190
 
189
- token = ptoken.read_ulong
191
+ token = ptoken.read_pointer.to_i
190
192
  pinfo = FFI::MemoryPointer.new(:pointer)
191
193
  plength = FFI::MemoryPointer.new(:ulong)
192
194
 
@@ -18,6 +18,7 @@ module Windows
18
18
  typedef :pointer, :ptr
19
19
 
20
20
  ffi_lib :kernel32
21
+ ffi_convention :stdcall
21
22
 
22
23
  enum :token_info_class, [
23
24
  :TokenUser, 1,
@@ -9,7 +9,7 @@ require 'win32/security'
9
9
 
10
10
  class TC_Win32_Security < Test::Unit::TestCase
11
11
  test "version constant is set to expected value" do
12
- assert_equal('0.2.4', Win32::Security::VERSION)
12
+ assert_equal('0.2.5', Win32::Security::VERSION)
13
13
  end
14
14
 
15
15
  test "elevated security basic functionality" do
data/test/test_sid.rb CHANGED
@@ -20,7 +20,7 @@ class TC_Win32_Security_Sid < Test::Unit::TestCase
20
20
  end
21
21
 
22
22
  test "version is set to expected value" do
23
- assert_equal('0.2.0', Security::SID::VERSION)
23
+ assert_equal('0.2.1', Security::SID::VERSION)
24
24
  end
25
25
 
26
26
  test "sid method basic functionality" do
@@ -59,6 +59,11 @@ class TC_Win32_Security_Sid < Test::Unit::TestCase
59
59
  assert_kind_of(String, Security::SID.string_to_sid(@sid.to_s))
60
60
  end
61
61
 
62
+ test "we can convert back and forth between a sid and a string" do
63
+ str = Security::SID.sid_to_string(@sid.sid)
64
+ assert_equal(@sid.sid, Security::SID.string_to_sid(str))
65
+ end
66
+
62
67
  test "to_s works as expected" do
63
68
  assert_respond_to(@sid, :to_s)
64
69
  assert_kind_of(String, @sid.to_s)
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'win32-security'
5
- spec.version = '0.2.4'
5
+ spec.version = '0.2.5'
6
6
  spec.authors = ['Daniel J. Berger', 'Park Heesob']
7
7
  spec.license = 'Artistic 2.0'
8
8
  spec.email = 'djberg96@gmail.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-security
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-08 00:00:00.000000000 Z
12
+ date: 2014-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi