384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
# File 'lib/chef/win32/security.rb', line 384
def self.get_token_information_primary_group(token)
group_result_size = FFI::MemoryPointer.new(:ulong)
if GetTokenInformation(token.handle.handle, :TokenPrimaryGroup, nil, 0, group_result_size)
raise "Expected ERROR_INSUFFICIENT_BUFFER from GetTokenInformation, and got no error!"
elsif FFI::LastError.error != ERROR_INSUFFICIENT_BUFFER
Chef::ReservedNames::Win32::Error.raise!
end
group_result_storage = FFI::MemoryPointer.new group_result_size.read_ulong
unless GetTokenInformation(token.handle.handle, :TokenPrimaryGroup, group_result_storage, group_result_size.read_ulong, group_result_size)
Chef::ReservedNames::Win32::Error.raise!
end
group_result = TOKEN_PRIMARY_GROUP.new group_result_storage
SID.new(group_result[:PrimaryGroup], group_result_storage)
end
|