Update of /cvsroot/pywin32/pywin32/win32/Demos/security
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15490/Demos/security
Modified Files:
Tag: py3k
GetTokenInformation.py account_rights.py explicit_entries.py
get_policy_info.py list_rights.py localized_names.py
lsaregevent.py query_information.py sa_inherit.py
security_enums.py set_file_audit.py set_file_owner.py
set_policy_info.py setkernelobjectsecurity.py
setnamedsecurityinfo.py setsecurityinfo.py
Log Message:
Changes to build for Python 3.0
Index: set_policy_info.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/set_policy_info.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** set_policy_info.py 10 Mar 2003 01:18:15 -0000 1.1
--- set_policy_info.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 3,7 ****
event_audit_info=win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyAuditEventsInformation)
! print event_audit_info
new_audit_info=list(event_audit_info[1])
--- 3,7 ----
event_audit_info=win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyAuditEventsInformation)
! print(event_audit_info)
new_audit_info=list(event_audit_info[1])
Index: setsecurityinfo.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/setsecurityinfo.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** setsecurityinfo.py 26 May 2004 22:50:33 -0000 1.1
--- setsecurityinfo.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 48,61 ****
if new_sd.GetSecurityDescriptorDacl().GetAceCount()!=dacl_ace_cnt+1:
! print 'New dacl doesn''t contain extra ace ????'
if new_sd.GetSecurityDescriptorSacl().GetAceCount()!=sacl_ace_cnt+1:
! print 'New Sacl doesn''t contain extra ace ????'
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorOwner())[0]!='Power Users':
! print 'Owner not successfully set to Power Users !!!!!'
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorGroup())[0]!='Power Users':
! print 'Group not successfully set to Power Users !!!!!'
win32security.SetSecurityInfo(ph,win32security.SE_KERNEL_OBJECT,win32security.SACL_SECURITY_INFORMATION, None, None, None, None)
new_sd_1=win32security.GetSecurityInfo(ph,win32security.SE_KERNEL_OBJECT,win32security.SACL_SECURITY_INFORMATION)
if new_sd_1.GetSecurityDescriptorSacl() is not None:
! print 'Unable to set Sacl to NULL !!!!!!!!'
--- 48,61 ----
if new_sd.GetSecurityDescriptorDacl().GetAceCount()!=dacl_ace_cnt+1:
! print('New dacl doesn''t contain extra ace ????')
if new_sd.GetSecurityDescriptorSacl().GetAceCount()!=sacl_ace_cnt+1:
! print('New Sacl doesn''t contain extra ace ????')
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorOwner())[0]!='Power Users':
! print('Owner not successfully set to Power Users !!!!!')
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorGroup())[0]!='Power Users':
! print('Group not successfully set to Power Users !!!!!')
win32security.SetSecurityInfo(ph,win32security.SE_KERNEL_OBJECT,win32security.SACL_SECURITY_INFORMATION, None, None, None, None)
new_sd_1=win32security.GetSecurityInfo(ph,win32security.SE_KERNEL_OBJECT,win32security.SACL_SECURITY_INFORMATION)
if new_sd_1.GetSecurityDescriptorSacl() is not None:
! print('Unable to set Sacl to NULL !!!!!!!!')
Index: set_file_audit.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/set_file_audit.py,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** set_file_audit.py 7 May 2006 21:14:28 -0000 1.2
--- set_file_audit.py 29 Aug 2008 04:59:24 -0000 1.2.4.1
***************
*** 34,38 ****
## Create a file in the dir and add some specific permissions to it
fname=win32api.GetTempFileName(dir_name,'sfa')[0]
! print fname
file_sd=win32security.GetNamedSecurityInfo(fname, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION|SACL_SECURITY_INFORMATION)
file_dacl=file_sd.GetSecurityDescriptorDacl()
--- 34,38 ----
## Create a file in the dir and add some specific permissions to it
fname=win32api.GetTempFileName(dir_name,'sfa')[0]
! print(fname)
file_sd=win32security.GetNamedSecurityInfo(fname, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION|SACL_SECURITY_INFORMATION)
file_dacl=file_sd.GetSecurityDescriptorDacl()
Index: setnamedsecurityinfo.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/setnamedsecurityinfo.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** setnamedsecurityinfo.py 26 May 2004 22:50:33 -0000 1.1
--- setnamedsecurityinfo.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 1,5 ****
import win32security,win32api,win32con, win32process
fname, tmp = win32api.GetTempFileName(win32api.GetTempPath(),'tmp')
! print fname
## You need SE_RESTORE_NAME to be able to set the owner of a security descriptor to anybody
## other than yourself or your primary group. Most admin logins don't have it by default, so
--- 1,5 ----
import win32security,win32api,win32con, win32process
fname, tmp = win32api.GetTempFileName(win32api.GetTempPath(),'tmp')
! print(fname)
## You need SE_RESTORE_NAME to be able to set the owner of a security descriptor to anybody
## other than yourself or your primary group. Most admin logins don't have it by default, so
***************
*** 47,60 ****
## could do additional checking to make sure added ACE contains expected info
if new_sd.GetSecurityDescriptorDacl().GetAceCount()!=dacl_ace_cnt+1:
! print 'New dacl doesn''t contain extra ace ????'
if new_sd.GetSecurityDescriptorSacl().GetAceCount()!=sacl_ace_cnt+1:
! print 'New Sacl doesn''t contain extra ace ????'
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorOwner())[0]!='Power Users':
! print 'Owner not successfully set to Power Users !!!!!'
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorGroup())[0]!='Power Users':
! print 'Group not successfully set to Power Users !!!!!'
win32security.SetNamedSecurityInfo(fname,win32security.SE_FILE_OBJECT,win32security.SACL_SECURITY_INFORMATION, None, None, None, None)
new_sd_1=win32security.GetNamedSecurityInfo(fname,win32security.SE_FILE_OBJECT,win32security.SACL_SECURITY_INFORMATION)
if new_sd_1.GetSecurityDescriptorSacl() is not None:
! print 'Unable to set Sacl to NULL !!!!!!!!'
--- 47,60 ----
## could do additional checking to make sure added ACE contains expected info
if new_sd.GetSecurityDescriptorDacl().GetAceCount()!=dacl_ace_cnt+1:
! print('New dacl doesn''t contain extra ace ????')
if new_sd.GetSecurityDescriptorSacl().GetAceCount()!=sacl_ace_cnt+1:
! print('New Sacl doesn''t contain extra ace ????')
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorOwner())[0]!='Power Users':
! print('Owner not successfully set to Power Users !!!!!')
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorGroup())[0]!='Power Users':
! print('Group not successfully set to Power Users !!!!!')
win32security.SetNamedSecurityInfo(fname,win32security.SE_FILE_OBJECT,win32security.SACL_SECURITY_INFORMATION, None, None, None, None)
new_sd_1=win32security.GetNamedSecurityInfo(fname,win32security.SE_FILE_OBJECT,win32security.SACL_SECURITY_INFORMATION)
if new_sd_1.GetSecurityDescriptorSacl() is not None:
! print('Unable to set Sacl to NULL !!!!!!!!')
Index: explicit_entries.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/explicit_entries.py,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** explicit_entries.py 23 Oct 2003 00:53:37 -0000 1.2
--- explicit_entries.py 29 Aug 2008 04:59:24 -0000 1.2.4.1
***************
*** 7,11 ****
f.write("Hello from Python\n");
f.close()
! print "Testing on file", fname
new_privs = ((win32security.LookupPrivilegeValue('',ntsecuritycon.SE_SECURITY_NAME),win32con.SE_PRIVILEGE_ENABLED),
--- 7,11 ----
f.write("Hello from Python\n");
f.close()
! print("Testing on file", fname)
new_privs = ((win32security.LookupPrivilegeValue('',ntsecuritycon.SE_SECURITY_NAME),win32con.SE_PRIVILEGE_ENABLED),
Index: setkernelobjectsecurity.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/setkernelobjectsecurity.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** setkernelobjectsecurity.py 26 May 2004 22:50:33 -0000 1.1
--- setkernelobjectsecurity.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 52,62 ****
if new_sd.GetSecurityDescriptorDacl().GetAceCount()!=dacl_ace_cnt+1:
! print 'New dacl doesn''t contain extra ace ????'
if new_sd.GetSecurityDescriptorSacl().GetAceCount()!=sacl_ace_cnt+1:
! print 'New Sacl doesn''t contain extra ace ????'
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorOwner())[0]!='Power Users':
! print 'Owner not successfully set to Power Users !!!!!'
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorGroup())[0]!='Power Users':
! print 'Group not successfully set to Power Users !!!!!'
sd.SetSecurityDescriptorSacl(0,None,0)
--- 52,62 ----
if new_sd.GetSecurityDescriptorDacl().GetAceCount()!=dacl_ace_cnt+1:
! print('New dacl doesn''t contain extra ace ????')
if new_sd.GetSecurityDescriptorSacl().GetAceCount()!=sacl_ace_cnt+1:
! print('New Sacl doesn''t contain extra ace ????')
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorOwner())[0]!='Power Users':
! print('Owner not successfully set to Power Users !!!!!')
if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorGroup())[0]!='Power Users':
! print('Group not successfully set to Power Users !!!!!')
sd.SetSecurityDescriptorSacl(0,None,0)
***************
*** 64,67 ****
new_sd_1=win32security.GetKernelObjectSecurity(ph,win32security.SACL_SECURITY_INFORMATION)
if new_sd_1.GetSecurityDescriptorSacl() is not None:
! print 'Unable to set Sacl to NULL !!!!!!!!'
--- 64,67 ----
new_sd_1=win32security.GetKernelObjectSecurity(ph,win32security.SACL_SECURITY_INFORMATION)
if new_sd_1.GetSecurityDescriptorSacl() is not None:
! print('Unable to set Sacl to NULL !!!!!!!!')
Index: localized_names.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/localized_names.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** localized_names.py 19 Sep 2006 00:38:45 -0000 1.1
--- localized_names.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 53,60 ****
name = LookupUserGroupFromRid(targetComputer, DOMAIN_USER_RID_ADMIN)
! print "'Administrator' user name = %s" % (name,)
name = LookupAliasFromRid(targetComputer, DOMAIN_ALIAS_RID_ADMINS)
! print "'Administrators' local group/alias name = %s" % (name,)
if __name__=='__main__':
--- 53,60 ----
name = LookupUserGroupFromRid(targetComputer, DOMAIN_USER_RID_ADMIN)
! print("'Administrator' user name = %s" % (name,))
name = LookupAliasFromRid(targetComputer, DOMAIN_ALIAS_RID_ADMINS)
! print("'Administrators' local group/alias name = %s" % (name,))
if __name__=='__main__':
Index: GetTokenInformation.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/GetTokenInformation.py,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -C2 -d -r1.1 -r1.1.2.1
*** GetTokenInformation.py 2 Aug 2007 07:08:18 -0000 1.1
--- GetTokenInformation.py 29 Aug 2008 04:59:24 -0000 1.1.2.1
***************
*** 11,23 ****
def dump_token(th):
token_type=win32security.GetTokenInformation(th, win32security.TokenType)
! print 'TokenType:', token_type, TOKEN_TYPE.lookup_name(token_type)
if token_type==win32security.TokenImpersonation:
imp_lvl=win32security.GetTokenInformation(th, win32security.TokenImpersonationLevel)
! print 'TokenImpersonationLevel:', imp_lvl, SECURITY_IMPERSONATION_LEVEL.lookup_name(imp_lvl)
! print 'TokenSessionId:', win32security.GetTokenInformation(th, win32security.TokenSessionId)
privs=win32security.GetTokenInformation(th,win32security.TokenPrivileges)
! print 'TokenPrivileges:'
for priv_luid, priv_flags in privs:
flag_names, unk=TOKEN_PRIVILEGE_ATTRIBUTES.lookup_flags(priv_flags)
--- 11,23 ----
def dump_token(th):
token_type=win32security.GetTokenInformation(th, win32security.TokenType)
! print('TokenType:', token_type, TOKEN_TYPE.lookup_name(token_type))
if token_type==win32security.TokenImpersonation:
imp_lvl=win32security.GetTokenInformation(th, win32security.TokenImpersonationLevel)
! print('TokenImpersonationLevel:', imp_lvl, SECURITY_IMPERSONATION_LEVEL.lookup_name(imp_lvl))
! print('TokenSessionId:', win32security.GetTokenInformation(th, win32security.TokenSessionId))
privs=win32security.GetTokenInformation(th,win32security.TokenPrivileges)
! print('TokenPrivileges:')
for priv_luid, priv_flags in privs:
flag_names, unk=TOKEN_PRIVILEGE_ATTRIBUTES.lookup_flags(priv_flags)
***************
*** 28,34 ****
priv_name=win32security.LookupPrivilegeName('',priv_luid)
priv_desc=win32security.LookupPrivilegeDisplayName('',priv_name)
! print '\t', priv_name, priv_desc, priv_flags, flag_desc
! print 'TokenGroups:'
groups=win32security.GetTokenInformation(th,win32security.TokenGroups)
for group_sid, group_attr in groups:
--- 28,34 ----
priv_name=win32security.LookupPrivilegeName('',priv_luid)
priv_desc=win32security.LookupPrivilegeDisplayName('',priv_name)
! print('\t', priv_name, priv_desc, priv_flags, flag_desc)
! print('TokenGroups:')
groups=win32security.GetTokenInformation(th,win32security.TokenGroups)
for group_sid, group_attr in groups:
***************
*** 41,64 ****
else:
sid_desc=win32security.LookupAccountSid('',group_sid)
! print '\t',group_sid, sid_desc, group_attr, flag_desc
## Vista token information types, will throw (87, 'GetTokenInformation', 'The parameter is incorrect.') on earier OS
try:
is_elevated=win32security.GetTokenInformation(th, win32security.TokenElevation)
! print 'TokenElevation:', is_elevated
! except pywintypes.error, details:
! if details[0] != winerror.ERROR_INVALID_PARAMETER:
raise
return None
! print 'TokenHasRestrictions:', win32security.GetTokenInformation(th, win32security.TokenHasRestrictions)
! print 'TokenMandatoryPolicy', win32security.GetTokenInformation(th, win32security.TokenMandatoryPolicy)
! print 'TokenVirtualizationAllowed:', win32security.GetTokenInformation(th, win32security.TokenVirtualizationAllowed)
! print 'TokenVirtualizationEnabled:', win32security.GetTokenInformation(th, win32security.TokenVirtualizationEnabled)
elevation_type = win32security.GetTokenInformation(th, win32security.TokenElevationType)
! print 'TokenElevationType:', elevation_type, TOKEN_ELEVATION_TYPE.lookup_name(elevation_type)
! if elevation_type<>win32security.TokenElevationTypeDefault:
lt=win32security.GetTokenInformation(th, win32security.TokenLinkedToken)
! print 'TokenLinkedToken:', lt
else:
lt=None
--- 41,64 ----
else:
sid_desc=win32security.LookupAccountSid('',group_sid)
! print('\t',group_sid, sid_desc, group_attr, flag_desc)
## Vista token information types, will throw (87, 'GetTokenInformation', 'The parameter is incorrect.') on earier OS
try:
is_elevated=win32security.GetTokenInformation(th, win32security.TokenElevation)
! print('TokenElevation:', is_elevated)
! except pywintypes.error as details:
! if details.args[0] != winerror.ERROR_INVALID_PARAMETER:
raise
return None
! print('TokenHasRestrictions:', win32security.GetTokenInformation(th, win32security.TokenHasRestrictions))
! print('TokenMandatoryPolicy', win32security.GetTokenInformation(th, win32security.TokenMandatoryPolicy))
! print('TokenVirtualizationAllowed:', win32security.GetTokenInformation(th, win32security.TokenVirtualizationAllowed))
! print('TokenVirtualizationEnabled:', win32security.GetTokenInformation(th, win32security.TokenVirtualizationEnabled))
elevation_type = win32security.GetTokenInformation(th, win32security.TokenElevationType)
! print('TokenElevationType:', elevation_type, TOKEN_ELEVATION_TYPE.lookup_name(elevation_type))
! if elevation_type!=win32security.TokenElevationTypeDefault:
lt=win32security.GetTokenInformation(th, win32security.TokenLinkedToken)
! print('TokenLinkedToken:', lt)
else:
lt=None
***************
*** 70,73 ****
lt = dump_token(th)
if lt:
! print '\n\nlinked token info:'
dump_token(lt)
--- 70,73 ----
lt = dump_token(th)
if lt:
! print('\n\nlinked token info:')
dump_token(lt)
Index: query_information.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/query_information.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** query_information.py 8 Oct 2004 23:24:05 -0000 1.1
--- query_information.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 7,11 ****
tok = win32security.OpenThreadToken(win32api.GetCurrentThread(),
TOKEN_QUERY, 1)
! except win32api.error, details:
if details[0] != winerror.ERROR_NO_TOKEN:
raise
--- 7,11 ----
tok = win32security.OpenThreadToken(win32api.GetCurrentThread(),
TOKEN_QUERY, 1)
! except win32api.error as details:
if details[0] != winerror.ERROR_NO_TOKEN:
raise
***************
*** 21,25 ****
if __name__=='__main__':
! print "Domain name is", GetDomainName()
--- 21,25 ----
if __name__=='__main__':
! print("Domain name is", GetDomainName())
Index: lsaregevent.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/lsaregevent.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** lsaregevent.py 23 Oct 2003 00:54:19 -0000 1.1
--- lsaregevent.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 2,8 ****
evt = win32event.CreateEvent(None,0,0,None)
win32security.LsaRegisterPolicyChangeNotification(win32security.PolicyNotifyAuditEventsInformation, evt)
! print "Waiting for you change Audit policy in Management console ..."
ret_code=win32event.WaitForSingleObject(evt,1000000000)
## should come back when you change Audit policy in Management console ...
! print ret_code
win32security.LsaUnregisterPolicyChangeNotification(win32security.PolicyNotifyAuditEventsInformation, evt)
--- 2,8 ----
evt = win32event.CreateEvent(None,0,0,None)
win32security.LsaRegisterPolicyChangeNotification(win32security.PolicyNotifyAuditEventsInformation, evt)
! print("Waiting for you change Audit policy in Management console ...")
ret_code=win32event.WaitForSingleObject(evt,1000000000)
## should come back when you change Audit policy in Management console ...
! print(ret_code)
win32security.LsaUnregisterPolicyChangeNotification(win32security.PolicyNotifyAuditEventsInformation, evt)
Index: get_policy_info.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/get_policy_info.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** get_policy_info.py 10 Mar 2003 01:18:15 -0000 1.1
--- get_policy_info.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 7,23 ****
domain_name,dns_domain_name, dns_forest_name, domain_guid, domain_sid = \
win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyDnsDomainInformation)
! print domain_name, dns_domain_name, dns_forest_name, domain_guid, domain_sid
event_audit_info=win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyAuditEventsInformation)
! print event_audit_info
domain_name,sid =win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyPrimaryDomainInformation)
! print domain_name, sid
domain_name,sid =win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyAccountDomainInformation)
! print domain_name, sid
server_role = win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyLsaServerRoleInformation)
! print 'server role: ',server_role
win32security.LsaClose(policy_handle)
--- 7,23 ----
domain_name,dns_domain_name, dns_forest_name, domain_guid, domain_sid = \
win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyDnsDomainInformation)
! print(domain_name, dns_domain_name, dns_forest_name, domain_guid, domain_sid)
event_audit_info=win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyAuditEventsInformation)
! print(event_audit_info)
domain_name,sid =win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyPrimaryDomainInformation)
! print(domain_name, sid)
domain_name,sid =win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyAccountDomainInformation)
! print(domain_name, sid)
server_role = win32security.LsaQueryInformationPolicy(policy_handle,win32security.PolicyLsaServerRoleInformation)
! print('server role: ',server_role)
win32security.LsaClose(policy_handle)
Index: set_file_owner.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/set_file_owner.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** set_file_owner.py 10 Mar 2003 01:18:15 -0000 1.1
--- set_file_owner.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 26,30 ****
new_sd=win32security.SECURITY_DESCRIPTOR()
! print "relative, valid, size: ",new_sd.IsSelfRelative(), new_sd.IsValid(), new_sd.GetLength()
my_sid = win32security.GetTokenInformation(th,ntsecuritycon.TokenUser)[0]
--- 26,30 ----
new_sd=win32security.SECURITY_DESCRIPTOR()
! print("relative, valid, size: ",new_sd.IsSelfRelative(), new_sd.IsValid(), new_sd.GetLength())
my_sid = win32security.GetTokenInformation(th,ntsecuritycon.TokenUser)[0]
Index: sa_inherit.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/sa_inherit.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** sa_inherit.py 10 Mar 2003 01:18:15 -0000 1.1
--- sa_inherit.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 4,7 ****
sa.SetSecurityDescriptorOwner(tmp_sid,0)
sid=sa.SECURITY_DESCRIPTOR.GetSecurityDescriptorOwner()
! print win32security.LookupAccountSid('',sid)
--- 4,7 ----
sa.SetSecurityDescriptorOwner(tmp_sid,0)
sid=sa.SECURITY_DESCRIPTOR.GetSecurityDescriptorOwner()
! print(win32security.LookupAccountSid('',sid))
Index: list_rights.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/list_rights.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** list_rights.py 10 Mar 2003 01:18:15 -0000 1.1
--- list_rights.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 1,4 ****
import win32security,win32file,win32api,ntsecuritycon,win32con
! from security_enums import TRUSTEE_TYPE,TRUSTEE_FORM,ACE_FLAGS,ACCESS_MODE
new_privs = ((win32security.LookupPrivilegeValue('',ntsecuritycon.SE_SECURITY_NAME),win32con.SE_PRIVILEGE_ENABLED),
--- 1,4 ----
import win32security,win32file,win32api,ntsecuritycon,win32con
! from .security_enums import TRUSTEE_TYPE,TRUSTEE_FORM,ACE_FLAGS,ACCESS_MODE
new_privs = ((win32security.LookupPrivilegeValue('',ntsecuritycon.SE_SECURITY_NAME),win32con.SE_PRIVILEGE_ENABLED),
***************
*** 15,19 ****
sidlist=win32security.LsaEnumerateAccountsWithUserRight(policy_handle,ntsecuritycon.SE_RESTORE_NAME)
for sid in sidlist:
! print win32security.LookupAccountSid('',sid)
win32security.LsaClose(policy_handle)
--- 15,19 ----
sidlist=win32security.LsaEnumerateAccountsWithUserRight(policy_handle,ntsecuritycon.SE_RESTORE_NAME)
for sid in sidlist:
! print(win32security.LookupAccountSid('',sid))
win32security.LsaClose(policy_handle)
Index: security_enums.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/security_enums.py,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** security_enums.py 2 Aug 2007 07:04:16 -0000 1.2
--- security_enums.py 29 Aug 2008 04:59:24 -0000 1.2.2.1
***************
*** 15,27 ****
const_val=getattr(winnt, const_name)
except AttributeError:
! raise AttributeError, 'Constant "%s" not found in win32security, ntsecuritycon, or winnt.' %const_name
setattr(self, const_name, const_val)
def lookup_name(self, const_val):
"""Looks up the name of a particular value."""
! for k,v in self.__dict__.items():
if v==const_val:
return k
! raise AttributeError, 'Value %s not found in enum' %const_val
def lookup_flags(self, flags):
--- 15,27 ----
const_val=getattr(winnt, const_name)
except AttributeError:
! raise AttributeError('Constant "%s" not found in win32security, ntsecuritycon, or winnt.' %const_name)
setattr(self, const_name, const_val)
def lookup_name(self, const_val):
"""Looks up the name of a particular value."""
! for k,v in list(self.__dict__.items()):
if v==const_val:
return k
! raise AttributeError('Value %s not found in enum' %const_val)
def lookup_flags(self, flags):
***************
*** 29,33 ****
flag_names=[]
unknown_flags=flags
! for k,v in self.__dict__.items():
if flags & v == v:
flag_names.append(k)
--- 29,33 ----
flag_names=[]
unknown_flags=flags
! for k,v in list(self.__dict__.items()):
if flags & v == v:
flag_names.append(k)
Index: account_rights.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/Demos/security/account_rights.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** account_rights.py 10 Mar 2003 01:18:15 -0000 1.1
--- account_rights.py 29 Aug 2008 04:59:24 -0000 1.1.4.1
***************
*** 19,23 ****
privlist=win32security.LsaEnumerateAccountRights(policy_handle,tmp_sid)
for priv in privlist:
! print priv
privs=[ntsecuritycon.SE_DEBUG_NAME,ntsecuritycon.SE_TCB_NAME]
--- 19,23 ----
privlist=win32security.LsaEnumerateAccountRights(policy_handle,tmp_sid)
for priv in privlist:
! print(priv)
privs=[ntsecuritycon.SE_DEBUG_NAME,ntsecuritycon.SE_TCB_NAME]
***************
*** 26,30 ****
privlist=win32security.LsaEnumerateAccountRights(policy_handle,tmp_sid)
for priv in privlist:
! print priv
win32security.LsaClose(policy_handle)
--- 26,30 ----
privlist=win32security.LsaEnumerateAccountRights(policy_handle,tmp_sid)
for priv in privlist:
! print(priv)
win32security.LsaClose(policy_handle)
|