From cbcd8eec6ea7eb32d4860eefdec5009ff274e967 Mon Sep 17 00:00:00 2001 From: Tim Beale Date: Fri, 23 Nov 2018 09:46:38 +1300 Subject: [PATCH] tests: Work out DOMSID via samdb rather than environs Not all testenvs have the DOMSID set as an environment variable. However, it's easy enough to work out from querying the samdb. This is a slight change in that we use a source4-generated loadparm to connect to the DB (self.lp is source3-generated, presumably for some SMB connection dependency). This change is so we can run the ntacls_backup tests against a DC with SMBv1 disabled (the restoredc). Note that currently the tests fail in the smb.SMB() connection in the setUp(), so we can't run them as part of autobuild just yet (because we can't known-fail test errors). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale Reviewed-by: Andrew Bartlett --- python/samba/tests/ntacls_backup.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/python/samba/tests/ntacls_backup.py b/python/samba/tests/ntacls_backup.py index bb1bc97ef43..0ee044f1336 100644 --- a/python/samba/tests/ntacls_backup.py +++ b/python/samba/tests/ntacls_backup.py @@ -25,9 +25,8 @@ from samba import samdb from samba import ntacls from samba.auth import system_session -from samba.param import LoadParm from samba.dcerpc import security -from samba.tests import TestCaseInTempDir +from samba.tests import TestCaseInTempDir, env_loadparm class NtaclsBackupRestoreTests(TestCaseInTempDir): @@ -47,21 +46,20 @@ class NtaclsBackupRestoreTests(TestCaseInTempDir): os.environ["LOCAL_PATH"], self.service) self.smb_conf_path = os.environ['SMB_CONF_PATH'] - self.dom_sid = security.dom_sid(os.environ['DOMSID']) - self.creds = self.insta_creds(template=self.get_credentials()) + self.samdb_conn = samdb.SamDB( + url=samdb_url, session_info=system_session(), + credentials=self.creds, lp=env_loadparm()) + + self.dom_sid = security.dom_sid(self.samdb_conn.get_domain_sid()) + # helper will load conf into lp, that's how smbd can find services. self.ntacls_helper = ntacls.NtaclsHelper(self.service, self.smb_conf_path, self.dom_sid) - self.lp = self.ntacls_helper.lp - self.samdb_conn = samdb.SamDB( - url=samdb_url, session_info=system_session(), - credentials=self.creds, lp=self.lp) - self.smb_conn = smb.SMB( self.server, self.service, lp=self.lp, creds=self.creds) -- 2.47.2