Security Descriptor and CoInitializeSecurity

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Huayang Xia

    #1

    Security Descriptor and CoInitializeSecurity

    I'd like to call pythoncom.CoIni tializeSecurity with a
    PySecurityDescr iptor object to set the process-wide security values.
    But I'm not able to find a way to let the code go through.

    I have read MSDN and searched web, I've not been able to find answer. I
    cooked a security descriptor like this (assume aces is a tuple of tuple
    (access, sid) :



    sd = win32security.S ECURITY_DESCRIP TOR()
    sd.Initialize()
    sd.SetSecurityD escriptorOwner( sid_owner, False)
    sd.SetSecurityD escriptorGroup( sid_group, False)


    # create DACL
    dacl = win32security.A CL()
    dacl.Initialize ()
    for (access, acc_sid) in aces:
    # Add ACE which is access and SID
    dacl.AddAccessA llowedAce(win32 security.ACL_RE VISION, access,
    isinstance(acc_ sid, (unicode, str)) and
    win32security.C onvertStringSid ToSid(acc_sid) or acc_sid)

    sd.SetDacl(True , dacl, False) # SetSecurityDesc riptorDacl
    print sd.IsSelfRelati ve() # result is 1

    The sd is a self relative one.
    >From MSDN, after calling InitializeSecur ityDescriptor, the sd is
    absolute sd, and CoInitializeSec urity needs absolute sd. Pythonwin has
    not wrapped function like 'MakeAbsoluteSD '.

    Has someone ever had same problem. Could you give a hint for solving
    the problem. Thanks.

    Regards

  • Roger Upole

    #2
    Re: Security Descriptor and CoInitializeSec urity


    Huayang Xia wrote:
    I'd like to call pythoncom.CoIni tializeSecurity with a
    PySecurityDescr iptor object to set the process-wide security values.
    But I'm not able to find a way to let the code go through.
    >
    I have read MSDN and searched web, I've not been able to find answer. I
    cooked a security descriptor like this (assume aces is a tuple of tuple
    (access, sid) :
    >
    >
    >
    sd = win32security.S ECURITY_DESCRIP TOR()
    sd.Initialize()
    sd.SetSecurityD escriptorOwner( sid_owner, False)
    sd.SetSecurityD escriptorGroup( sid_group, False)
    >
    >
    # create DACL
    dacl = win32security.A CL()
    dacl.Initialize ()
    for (access, acc_sid) in aces:
    # Add ACE which is access and SID
    dacl.AddAccessA llowedAce(win32 security.ACL_RE VISION, access,
    isinstance(acc_ sid, (unicode, str)) and
    win32security.C onvertStringSid ToSid(acc_sid) or acc_sid)
    >
    sd.SetDacl(True , dacl, False) # SetSecurityDesc riptorDacl
    print sd.IsSelfRelati ve() # result is 1
    >
    The sd is a self relative one.
    >
    >>From MSDN, after calling InitializeSecur ityDescriptor, the sd is
    absolute sd, and CoInitializeSec urity needs absolute sd. Pythonwin has
    not wrapped function like 'MakeAbsoluteSD '.
    >
    Has someone ever had same problem. Could you give a hint for solving
    the problem. Thanks.
    >
    Regards
    PySECURITY_DESC RIPTOR's are always stored in self-relative format.
    They should be converted automatically in the few places that require an
    absolute SD, but looks like this one was missed.
    Could you file a bug report on SourceForge ?
    http://sourceforge.net/projects/pywin32/

    Roger




    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

    Comment

    Working...