win32-security 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f0cdfb7c3954a89c3d2e4320f2c27fcd2311be6
4
- data.tar.gz: 30b2df084b416d6822b3c975ad72d85f9e2d687a
3
+ metadata.gz: b99c41fd2bd78061d9b7b6fcb39816de3384c561
4
+ data.tar.gz: d11ca28544ad66864128d6000d3edde7f529fa74
5
5
  SHA512:
6
- metadata.gz: 785d0356537d86bd64e486bf5981c1a1c22fe3abb85e0c43357bd9cdb43a642b7cdca141e6de33a6cd878d3b5349a6626523a82cc5985fdd1093f8e38b4c677f
7
- data.tar.gz: bb52c0719a509d74f3372ae7f929a25e89eca96cacfa3be0f5da5c9c4b64979733b1d45685c41db6dd27fe516e3a0b560d8954a08f764b0de2e36eb76160a801
6
+ metadata.gz: 8fe3a69f36067b039c6bd86b0fd2dd0d018dd6afa57c0aa2c6beb30ebae232ed30fffdce8c0e4581c390718fce52e4aea18eb8fb8086f303e236783a27c242b6
7
+ data.tar.gz: e0b2987762703a34b80a32bfb7057c7f47f65328f7da9ed9dfea2c4607bb4320827583723065b4d17b1f3462f1e42ef641c8d4c9f1763ac71d1a1171be83e5bc
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGES CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.4.0 - 7-Mar-2016
2
+ * Added wide character support. Thanks go to Ethan J. Brown for finally forcing
3
+ me to get around to this.
4
+ * Removed some unused FFI functions.
5
+ * Added the String#wstrip helper method if not already defined.
6
+
1
7
  == 0.3.3 - 1-Mar-2016
2
8
  * Fixed a potential bug in the Win32::Security::SID constructor. Thanks go
3
9
  to nmeilick for the spot and patch.
@@ -1,21 +1,21 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
3
- c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NOCWoDVD75zHFueY0viwGDVP1BNGFC+yXcb7u2GlK+nEMCORqzURbYPf7
16
+ tL+/hzmePIRz7i30UM//64GI1NLv9jl7nIwjhPpXpf7/lu2I9hOTsvwSumb5UiKC
17
+ /sqBxI3sfj9pr79Wpv4MuikX1XPik7Ncb7NPsJPw06Lvyc3Hkg5X2XpPtLtS+Gr2
18
+ wKJnmzb5rIPS1cmsqv0M9LPWflzfwoZ/SpnmhagP+g05p8bRNKjZSA2iImM/GyYZ
19
+ EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
20
+ tGSHgAmcLlkdGgan182qsE/4kKM=
21
+ -----END CERTIFICATE-----
@@ -4,6 +4,7 @@
4
4
  require_relative 'security/windows/constants'
5
5
  require_relative 'security/windows/structs'
6
6
  require_relative 'security/windows/functions'
7
+ require_relative 'security/windows/helper'
7
8
 
8
9
  # The Win32 module serves as a namespace only.
9
10
  module Win32
@@ -20,7 +21,7 @@ module Win32
20
21
  extend Windows::Security::Functions
21
22
 
22
23
  # The version of the win32-security library
23
- VERSION = '0.3.3'
24
+ VERSION = '0.4.0'
24
25
 
25
26
  # Used by OpenProcessToken
26
27
  TOKEN_QUERY = 8
@@ -227,11 +227,11 @@ module Win32
227
227
 
228
228
  ordinal_val = account ? account[0].ord : nil
229
229
 
230
- sid = FFI::MemoryPointer.new(:uchar, 260)
230
+ sid = FFI::MemoryPointer.new(:uchar, 1024)
231
231
  sid_size = FFI::MemoryPointer.new(:ulong)
232
232
  sid_size.write_ulong(sid.size)
233
233
 
234
- domain = FFI::MemoryPointer.new(:uchar, 260)
234
+ domain = FFI::MemoryPointer.new(:uchar, 1024)
235
235
  domain_size = FFI::MemoryPointer.new(:ulong)
236
236
  domain_size.write_ulong(domain.size)
237
237
 
@@ -254,7 +254,7 @@ module Win32
254
254
  account_ptr = FFI::MemoryPointer.from_string(account)
255
255
 
256
256
  bool = LookupAccountSid(
257
- host,
257
+ host.encode('UTF-16LE'),
258
258
  account_ptr,
259
259
  sid,
260
260
  sid_size,
@@ -270,8 +270,8 @@ module Win32
270
270
  account_ptr.free
271
271
  else
272
272
  bool = LookupAccountName(
273
- host,
274
- account,
273
+ host.encode('UTF-16LE'),
274
+ account.encode('UTF-16LE'),
275
275
  sid,
276
276
  sid_size,
277
277
  domain,
@@ -287,18 +287,19 @@ module Win32
287
287
  if ordinal_val.nil?
288
288
  length = GetLengthSid(token_info)
289
289
  @sid = token_info.read_string(length)
290
- @account = sid.read_string(sid.size).strip
290
+ @account = sid.read_bytes(sid.size).wstrip
291
291
  elsif ordinal_val < 10
292
292
  @sid = account
293
- @account = sid.read_string(sid.size).strip
293
+ @account = sid.read_bytes(sid.size).wstrip
294
294
  else
295
295
  length = GetLengthSid(sid)
296
- @sid = sid.read_string(length)
296
+ @sid = sid.read_bytes(length)
297
297
  @account = account
298
298
  end
299
299
 
300
+
300
301
  @host = host
301
- @domain = domain.read_string
302
+ @domain = domain.read_bytes(domain.size).wstrip
302
303
 
303
304
  @account_type = get_account_type(use_ptr.read_ulong)
304
305
  end
@@ -101,16 +101,11 @@ module Windows
101
101
  attach_pfunc :IsValidAcl, [:ptr], :bool
102
102
  attach_pfunc :IsValidSid, [:ptr], :bool
103
103
  attach_pfunc :IsWellKnownSid, [:ptr, :int], :bool
104
- attach_pfunc :LookupAccountName, :LookupAccountNameA, [:string, :string, :ptr, :ptr, :ptr, :ptr, :ptr], :bool
105
- attach_pfunc :LookupAccountSid, :LookupAccountSidA, [:string, :ptr, :ptr, :ptr, :ptr, :ptr, :ptr], :bool
104
+ attach_pfunc :LookupAccountName, :LookupAccountNameW, [:buffer_in, :buffer_in, :ptr, :ptr, :ptr, :ptr, :ptr], :bool
105
+ attach_pfunc :LookupAccountSid, :LookupAccountSidW, [:buffer_in, :ptr, :ptr, :ptr, :ptr, :ptr, :ptr], :bool
106
106
  attach_pfunc :OpenProcessToken, [:handle, :dword, :ptr], :bool
107
107
  attach_pfunc :OpenThreadToken, [:handle, :dword, :int, :ptr], :bool
108
108
  attach_pfunc :SetAclInformation, [:ptr, :ptr, :dword, :int], :bool
109
-
110
- attach_pfunc :ConvertSecurityDescriptorToStringSecurityDescriptor,
111
- :ConvertSecurityDescriptorToStringSecurityDescriptorA, [:ptr, :dword, :dword, :ptr, :ptr], :bool
112
- attach_pfunc :ConvertStringSecurityDescriptorToSecurityDescriptor,
113
- :ConvertStringSecurityDescriptorToSecurityDescriptorA, [:string, :dword, :ptr, :ptr], :bool
114
109
  end
115
110
  end
116
111
  end
@@ -0,0 +1,10 @@
1
+ unless String.instance_methods.include?(:wstrip)
2
+ class String
3
+ def wstrip
4
+ self.force_encoding('UTF-16LE').encode('UTF-8',:invalid => :replace, :undef => :replace).
5
+ split("\x00")[0].encode(Encoding.default_external)
6
+ rescue
7
+ nil
8
+ end
9
+ end
10
+ end
@@ -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.3.3', Win32::Security::VERSION)
12
+ assert_equal('0.4.0', Win32::Security::VERSION)
13
13
  end
14
14
 
15
15
  test "elevated security basic functionality" do
@@ -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.3.3'
5
+ spec.version = '0.4.0'
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.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -31,7 +31,7 @@ cert_chain:
31
31
  EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
32
32
  tGSHgAmcLlkdGgan182qsE/4kKM=
33
33
  -----END CERTIFICATE-----
34
- date: 2016-03-01 00:00:00.000000000 Z
34
+ date: 2016-03-07 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ffi
@@ -114,6 +114,7 @@ files:
114
114
  - lib/win32/security/windows
115
115
  - lib/win32/security/windows/constants.rb
116
116
  - lib/win32/security/windows/functions.rb
117
+ - lib/win32/security/windows/helper.rb
117
118
  - lib/win32/security/windows/structs.rb
118
119
  - lib/win32/security.rb
119
120
  - lib/win32-security.rb
metadata.gz.sig CHANGED
Binary file