Fixed bug introduced in token.privileges in ad592980 + associated tests

This commit is contained in:
clement rouault
2022-05-09 17:24:55 +02:00
parent ad59298015
commit 5fa4ca6aae
2 changed files with 10 additions and 1 deletions
+9
View File
@@ -82,6 +82,15 @@ def test_adjust_privilege(newtok):
assert newtok.privileges[PRIVILEGE_NAME] & gdef.SE_PRIVILEGE_ENABLED
def test_token_privilege_dict(newtok):
PRIVILEGE_NAME = b"SeShutdownPrivilege"
privdict = newtok.privileges
# These API use Token._lookup_name() that are not tested by other means
assert privdict.keys()
assert privdict.items()
assert PRIVILEGE_NAME in privdict.keys() # Implement contains ?
def test_token_groups(curtok):
groups = curtok.groups
groups_size = groups.GroupCount
+1 -1
View File
@@ -114,7 +114,7 @@ class TokenPrivileges(gdef.TOKEN_PRIVILEGES):
def _lookup_name(self, luid):
size = gdef.DWORD(0x100)
buff = ctypes.c_buffer(size.value)
buff = ctypes.create_unicode_buffer(size.value)
winproxy.LookupPrivilegeNameW(None, luid, buff, size)
return buff[:size.value]