home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2487 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.9 KB  |  28 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. fname = 'h:\\tmp.txt'
  5. import win32security
  6. import win32file
  7. import win32api
  8. import ntsecuritycon
  9. import win32con
  10. new_privs = ((win32security.LookupPrivilegeValue('', ntsecuritycon.SE_SECURITY_NAME), win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('', ntsecuritycon.SE_SHUTDOWN_NAME), win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('', ntsecuritycon.SE_TCB_NAME), win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('', ntsecuritycon.SE_RESTORE_NAME), win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('', ntsecuritycon.SE_TAKE_OWNERSHIP_NAME), win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('', ntsecuritycon.SE_CREATE_PERMANENT_NAME), win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('', 'SeEnableDelegationPrivilege'), win32con.SE_PRIVILEGE_ENABLED))
  11. ph = win32api.GetCurrentProcess()
  12. th = win32security.OpenProcessToken(ph, win32security.TOKEN_ALL_ACCESS | win32con.TOKEN_ADJUST_PRIVILEGES)
  13. win32security.AdjustTokenPrivileges(th, 0, new_privs)
  14. all_security_info = win32security.OWNER_SECURITY_INFORMATION | win32security.GROUP_SECURITY_INFORMATION | win32security.DACL_SECURITY_INFORMATION | win32security.SACL_SECURITY_INFORMATION
  15. sd = win32security.GetFileSecurity(fname, all_security_info)
  16. old_dacl = sd.GetSecurityDescriptorDacl()
  17. old_sacl = sd.GetSecurityDescriptorSacl()
  18. old_group = sd.GetSecurityDescriptorGroup()
  19. new_sd = win32security.SECURITY_DESCRIPTOR()
  20. print 'relative, valid, size: ', new_sd.IsSelfRelative(), new_sd.IsValid(), new_sd.GetLength()
  21. my_sid = win32security.GetTokenInformation(th, ntsecuritycon.TokenUser)[0]
  22. tmp_sid = win32security.LookupAccountName('', 'tmp')[0]
  23. new_sd.SetSecurityDescriptorSacl(1, old_sacl, 1)
  24. new_sd.SetSecurityDescriptorDacl(1, old_dacl, 1)
  25. new_sd.SetSecurityDescriptorOwner(tmp_sid, 0)
  26. new_sd.SetSecurityDescriptorGroup(old_group, 0)
  27. win32security.SetFileSecurity(fname, all_security_info, new_sd)
  28.