Ndr_unpack() problem

Zahari Zahariev zahari.zahariev at postpath.com
Mon Jan 26 13:41:41 GMT 2009


Hello Samba4,

It seems to be the problem that in a unittest file ldap.py alike I want 
to ndr_pack() a object of type security.descriptor initializing it with 
security.descriptor.from_sddl(). After that the already packed object is 
about to be unpacked with ndr_unpack() passing as first argument the 
same object type security.descriptor. Unfortunately it exits during 
ndr_unpack() with:

***
error: Adding user basic tests [
Traceback (most recent call last):
 File "./lib/ldb/tests/python/acl.py", line 101, in test_acl_useradd
   xUnpacked = ndr_unpack( security.descriptor, xPacked )
 File "bin/python/samba/ndr.py", line 27, in ndr_unpack
   object.__ndr_unpack__(data)
RuntimeError: (-1073741777, 'NT_STATUS_PORT_MESSAGE_TOO_LONG')
***

Why can't the packed date be unpacked ?


Example source code:
-----------------------

from samba.ndr import ndr_pack, ndr_unpack
from samba.dcerpc import security

from samba import Ldb
import unittest

class AclTests(unittest.TestCase):

   def delete_force(self, ldb, dn):
       try:
           ldb.delete(dn)
       except LdbError, (num, _):
           self.assertEquals(num, ERR_NO_SUCH_OBJECT)

   def find_basedn(self, ldb):
       res = ldb.search(base="", expression="", scope=SCOPE_BASE,
                        attrs=["defaultNamingContext"])
       self.assertEquals(len(res), 1)
       return res[0]["defaultNamingContext"][0]

   def setUp(self):
       self.ldb = ldb
       self.base_dn = self.find_basedn(self.ldb)
       self.dnUser1 = "cn=Anatoli,cn=users," + self.base_dn

  def test_acl_useradd(self):
       """Adding user basic tests"""
       # Creating descriptor object with a predefined SDDL string
       x = 
security.descriptor.from_sddl("O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)", 
security.dom_sid("S-1-0-0"))
       # This SDDL string comes out OK and it is like the one started with
       print '*** Representation of x:', x.as_sddl( 
security.dom_sid("S-1-0-0") )
       # Packing the descriptor object ready-to-go
       xPacked = ndr_pack(x)
       # This comes out OK in a hex format
       print '*** xPacked:', repr(xPacked)
       
       # !!! Here is there our example sucks and crashes with Runtime 
error !!
       xUnpacked = ndr_unpack( security.descriptor, xPacked ) # <-- 
Runtime error (see above the code)
       # Here I am supposed to get back the original SDDL like before 
packing
       print '*** xUnpacked.as_sddl():', xUnpacked.as_sddl( 
security.dom_sid("S-1-0-0") )



More information about the samba-technical mailing list