1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-05 09:18:06 +03:00

PEP8: fix E128: continuation line under-indented for visual indent

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
Joe Guo 2018-07-30 18:16:12 +12:00 committed by Douglas Bagnall
parent bbb9f57603
commit 5d532543ab
117 changed files with 2223 additions and 2135 deletions

View File

@ -769,19 +769,24 @@ class MatchRulesTests(samba.tests.TestCase):
self.assertEqual(len(res1), 0) self.assertEqual(len(res1), 0)
def test_nul_text(self): def test_nul_text(self):
self.assertRaises(TypeError, lambda: self.ldb.search("cn=g4,%s" % self.ou_groups, self.assertRaises(TypeError,
lambda: self.ldb.search("cn=g4,%s" % self.ou_groups,
scope=SCOPE_BASE, scope=SCOPE_BASE,
expression="\00member:1.2.840.113556.1.4.1941:=cn=u1,%s" % self.ou_users)) expression="\00member:1.2.840.113556.1.4.1941:=cn=u1,%s" % self.ou_users))
self.assertRaises(TypeError, lambda: self.ldb.search("cn=g4,%s" % self.ou_groups, self.assertRaises(TypeError,
lambda: self.ldb.search("cn=g4,%s" % self.ou_groups,
scope=SCOPE_BASE, scope=SCOPE_BASE,
expression="member:1.2.840\00.113556.1.4.1941:=cn=u1,%s" % self.ou_users)) expression="member:1.2.840\00.113556.1.4.1941:=cn=u1,%s" % self.ou_users))
self.assertRaises(TypeError, lambda: self.ldb.search("cn=g4,%s" % self.ou_groups, self.assertRaises(TypeError,
lambda: self.ldb.search("cn=g4,%s" % self.ou_groups,
scope=SCOPE_BASE, scope=SCOPE_BASE,
expression="member:1.2.840.113556.1.4.1941:=cn=u1\00,%s" % self.ou_users)) expression="member:1.2.840.113556.1.4.1941:=cn=u1\00,%s" % self.ou_users))
self.assertRaises(LdbError, lambda: self.ldb.search("cn=\00g4,%s" % self.ou_groups, self.assertRaises(LdbError,
lambda: self.ldb.search("cn=\00g4,%s" % self.ou_groups,
scope=SCOPE_BASE, scope=SCOPE_BASE,
expression="member:1.2.840.113556.1.4.1941:=cn=u1,%s" % self.ou_users)) expression="member:1.2.840.113556.1.4.1941:=cn=u1,%s" % self.ou_users))
self.assertRaises(LdbError, lambda: self.ldb.search("cn=g4,%s" % self.ou_groups, self.assertRaises(LdbError,
lambda: self.ldb.search("cn=g4,%s" % self.ou_groups,
scope=SCOPE_BASE, scope=SCOPE_BASE,
expression="member:1.2.840.113556.1.4.1941:")) expression="member:1.2.840.113556.1.4.1941:"))
res1 = self.ldb.search("cn=g4,%s" % self.ou_groups, res1 = self.ldb.search("cn=g4,%s" % self.ou_groups,
@ -800,16 +805,20 @@ class MatchRulesTests(samba.tests.TestCase):
scope=SCOPE_BASE, scope=SCOPE_BASE,
expression="member=nonexistent") expression="member=nonexistent")
self.assertEqual(len(res1), 0) self.assertEqual(len(res1), 0)
self.assertRaises(LdbError, lambda: self.ldb.search("cn=\00g4,%s" % self.ou_groups, self.assertRaises(LdbError,
lambda: self.ldb.search("cn=\00g4,%s" % self.ou_groups,
scope=SCOPE_BASE, scope=SCOPE_BASE,
expression="member:1.2.840.113556.1.4.1941:cn=u1,%s" % self.ou_users)) expression="member:1.2.840.113556.1.4.1941:cn=u1,%s" % self.ou_users))
self.assertRaises(LdbError, lambda: self.ldb.search("cn=\00g4,%s" % self.ou_groups, self.assertRaises(LdbError,
lambda: self.ldb.search("cn=\00g4,%s" % self.ou_groups,
scope=SCOPE_BASE, scope=SCOPE_BASE,
expression="member:1.2.840.113556.1.4.1941:=cn=u1")) expression="member:1.2.840.113556.1.4.1941:=cn=u1"))
self.assertRaises(LdbError, lambda: self.ldb.search("cn=\00g4,%s" % self.ou_groups, self.assertRaises(LdbError,
lambda: self.ldb.search("cn=\00g4,%s" % self.ou_groups,
scope=SCOPE_BASE, scope=SCOPE_BASE,
expression="member:1.2.840.113556.1.4.1941:=cn=")) expression="member:1.2.840.113556.1.4.1941:=cn="))
self.assertRaises(LdbError, lambda: self.ldb.search("cn=\00g4,%s" % self.ou_groups, self.assertRaises(LdbError,
lambda: self.ldb.search("cn=\00g4,%s" % self.ou_groups,
scope=SCOPE_BASE, scope=SCOPE_BASE,
expression="member::=cn=u1,%s" % self.ou_users)) expression="member::=cn=u1,%s" % self.ou_users))

View File

@ -2109,7 +2109,8 @@ class cmd_domain_trust_list(DomainTrustCommand):
raise self.LocalRuntimeError(self, error, "failed to connect netlogon server") raise self.LocalRuntimeError(self, error, "failed to connect netlogon server")
try: try:
local_netlogon_trusts = local_netlogon.netr_DsrEnumerateDomainTrusts(local_server, local_netlogon_trusts = \
local_netlogon.netr_DsrEnumerateDomainTrusts(local_server,
netlogon.NETR_TRUST_FLAG_IN_FOREST | netlogon.NETR_TRUST_FLAG_IN_FOREST |
netlogon.NETR_TRUST_FLAG_OUTBOUND | netlogon.NETR_TRUST_FLAG_OUTBOUND |
netlogon.NETR_TRUST_FLAG_INBOUND) netlogon.NETR_TRUST_FLAG_INBOUND)
@ -2169,8 +2170,10 @@ class cmd_domain_trust_show(DomainTrustCommand):
lsaString = lsa.String() lsaString = lsa.String()
lsaString.string = domain lsaString.string = domain
try: try:
local_tdo_full = local_lsa.QueryTrustedDomainInfoByName(local_policy, local_tdo_full = \
lsaString, lsa.LSA_TRUSTED_DOMAIN_INFO_FULL_INFO) local_lsa.QueryTrustedDomainInfoByName(local_policy,
lsaString,
lsa.LSA_TRUSTED_DOMAIN_INFO_FULL_INFO)
local_tdo_info = local_tdo_full.info_ex local_tdo_info = local_tdo_full.info_ex
local_tdo_posix = local_tdo_full.posix_offset local_tdo_posix = local_tdo_full.posix_offset
except NTSTATUSError as error: except NTSTATUSError as error:
@ -2180,8 +2183,10 @@ class cmd_domain_trust_show(DomainTrustCommand):
raise self.LocalRuntimeError(self, error, "QueryTrustedDomainInfoByName(FULL_INFO) failed") raise self.LocalRuntimeError(self, error, "QueryTrustedDomainInfoByName(FULL_INFO) failed")
try: try:
local_tdo_enctypes = local_lsa.QueryTrustedDomainInfoByName(local_policy, local_tdo_enctypes = \
lsaString, lsa.LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES) local_lsa.QueryTrustedDomainInfoByName(local_policy,
lsaString,
lsa.LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES)
except NTSTATUSError as error: except NTSTATUSError as error:
if self.check_runtime_error(error, ntstatus.NT_STATUS_INVALID_PARAMETER): if self.check_runtime_error(error, ntstatus.NT_STATUS_INVALID_PARAMETER):
error = None error = None
@ -2198,8 +2203,10 @@ class cmd_domain_trust_show(DomainTrustCommand):
try: try:
local_tdo_forest = None local_tdo_forest = None
if local_tdo_info.trust_attributes & lsa.LSA_TRUST_ATTRIBUTE_FOREST_TRANSITIVE: if local_tdo_info.trust_attributes & lsa.LSA_TRUST_ATTRIBUTE_FOREST_TRANSITIVE:
local_tdo_forest = local_lsa.lsaRQueryForestTrustInformation(local_policy, local_tdo_forest = \
lsaString, lsa.LSA_FOREST_TRUST_DOMAIN_INFO) local_lsa.lsaRQueryForestTrustInformation(local_policy,
lsaString,
lsa.LSA_FOREST_TRUST_DOMAIN_INFO)
except RuntimeError as error: except RuntimeError as error:
if self.check_runtime_error(error, ntstatus.NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE): if self.check_runtime_error(error, ntstatus.NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE):
error = None error = None
@ -2458,8 +2465,10 @@ class cmd_domain_trust_create(DomainTrustCommand):
try: try:
lsaString.string = local_trust_info.domain_name.string lsaString.string = local_trust_info.domain_name.string
local_old_netbios = local_lsa.QueryTrustedDomainInfoByName(local_policy, local_old_netbios = \
lsaString, lsa.LSA_TRUSTED_DOMAIN_INFO_FULL_INFO) local_lsa.QueryTrustedDomainInfoByName(local_policy,
lsaString,
lsa.LSA_TRUSTED_DOMAIN_INFO_FULL_INFO)
raise CommandError("TrustedDomain %s already exist'" % lsaString.string) raise CommandError("TrustedDomain %s already exist'" % lsaString.string)
except NTSTATUSError as error: except NTSTATUSError as error:
if not self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND): if not self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND):
@ -2469,8 +2478,10 @@ class cmd_domain_trust_create(DomainTrustCommand):
try: try:
lsaString.string = local_trust_info.netbios_name.string lsaString.string = local_trust_info.netbios_name.string
local_old_dns = local_lsa.QueryTrustedDomainInfoByName(local_policy, local_old_dns = \
lsaString, lsa.LSA_TRUSTED_DOMAIN_INFO_FULL_INFO) local_lsa.QueryTrustedDomainInfoByName(local_policy,
lsaString,
lsa.LSA_TRUSTED_DOMAIN_INFO_FULL_INFO)
raise CommandError("TrustedDomain %s already exist'" % lsaString.string) raise CommandError("TrustedDomain %s already exist'" % lsaString.string)
except NTSTATUSError as error: except NTSTATUSError as error:
if not self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND): if not self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND):
@ -2481,8 +2492,10 @@ class cmd_domain_trust_create(DomainTrustCommand):
if remote_trust_info: if remote_trust_info:
try: try:
lsaString.string = remote_trust_info.domain_name.string lsaString.string = remote_trust_info.domain_name.string
remote_old_netbios = remote_lsa.QueryTrustedDomainInfoByName(remote_policy, remote_old_netbios = \
lsaString, lsa.LSA_TRUSTED_DOMAIN_INFO_FULL_INFO) remote_lsa.QueryTrustedDomainInfoByName(remote_policy,
lsaString,
lsa.LSA_TRUSTED_DOMAIN_INFO_FULL_INFO)
raise CommandError("TrustedDomain %s already exist'" % lsaString.string) raise CommandError("TrustedDomain %s already exist'" % lsaString.string)
except NTSTATUSError as error: except NTSTATUSError as error:
if not self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND): if not self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND):
@ -2492,8 +2505,10 @@ class cmd_domain_trust_create(DomainTrustCommand):
try: try:
lsaString.string = remote_trust_info.netbios_name.string lsaString.string = remote_trust_info.netbios_name.string
remote_old_dns = remote_lsa.QueryTrustedDomainInfoByName(remote_policy, remote_old_dns = \
lsaString, lsa.LSA_TRUSTED_DOMAIN_INFO_FULL_INFO) remote_lsa.QueryTrustedDomainInfoByName(remote_policy,
lsaString,
lsa.LSA_TRUSTED_DOMAIN_INFO_FULL_INFO)
raise CommandError("TrustedDomain %s already exist'" % lsaString.string) raise CommandError("TrustedDomain %s already exist'" % lsaString.string)
except NTSTATUSError as error: except NTSTATUSError as error:
if not self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND): if not self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND):
@ -2592,7 +2607,8 @@ class cmd_domain_trust_create(DomainTrustCommand):
if remote_trust_info: if remote_trust_info:
self.outf.write("Creating remote TDO.\n") self.outf.write("Creating remote TDO.\n")
current_request = { "location": "remote", "name": "CreateTrustedDomainEx2"} current_request = { "location": "remote", "name": "CreateTrustedDomainEx2"}
remote_tdo_handle = remote_lsa.CreateTrustedDomainEx2(remote_policy, remote_tdo_handle = \
remote_lsa.CreateTrustedDomainEx2(remote_policy,
remote_trust_info, remote_trust_info,
remote_auth_info, remote_auth_info,
lsa.LSA_TRUSTED_DOMAIN_ALL_ACCESS) lsa.LSA_TRUSTED_DOMAIN_ALL_ACCESS)
@ -2642,7 +2658,8 @@ class cmd_domain_trust_create(DomainTrustCommand):
# this triggers netr_GetForestTrustInformation to the remote domain # this triggers netr_GetForestTrustInformation to the remote domain
# and lsaRSetForestTrustInformation() locally, but new top level # and lsaRSetForestTrustInformation() locally, but new top level
# names are disabled by default. # names are disabled by default.
local_forest_info = local_netlogon.netr_DsRGetForestTrustInformation(local_netlogon_info.dc_unc, local_forest_info = \
local_netlogon.netr_DsRGetForestTrustInformation(local_netlogon_info.dc_unc,
remote_lsa_info.dns_domain.string, remote_lsa_info.dns_domain.string,
netlogon.DS_GFTI_UPDATE_TDO) netlogon.DS_GFTI_UPDATE_TDO)
except RuntimeError as error: except RuntimeError as error:
@ -2650,7 +2667,8 @@ class cmd_domain_trust_create(DomainTrustCommand):
try: try:
# here we try to enable all top level names # here we try to enable all top level names
local_forest_collision = local_lsa.lsaRSetForestTrustInformation(local_policy, local_forest_collision = \
local_lsa.lsaRSetForestTrustInformation(local_policy,
remote_lsa_info.dns_domain, remote_lsa_info.dns_domain,
lsa.LSA_FOREST_TRUST_DOMAIN_INFO, lsa.LSA_FOREST_TRUST_DOMAIN_INFO,
local_forest_info, local_forest_info,
@ -2669,7 +2687,8 @@ class cmd_domain_trust_create(DomainTrustCommand):
# this triggers netr_GetForestTrustInformation to our domain. # this triggers netr_GetForestTrustInformation to our domain.
# and lsaRSetForestTrustInformation() remotely, but new top level # and lsaRSetForestTrustInformation() remotely, but new top level
# names are disabled by default. # names are disabled by default.
remote_forest_info = remote_netlogon.netr_DsRGetForestTrustInformation(remote_netlogon_dc_unc, remote_forest_info = \
remote_netlogon.netr_DsRGetForestTrustInformation(remote_netlogon_dc_unc,
local_lsa_info.dns_domain.string, local_lsa_info.dns_domain.string,
netlogon.DS_GFTI_UPDATE_TDO) netlogon.DS_GFTI_UPDATE_TDO)
except RuntimeError as error: except RuntimeError as error:
@ -2677,7 +2696,8 @@ class cmd_domain_trust_create(DomainTrustCommand):
try: try:
# here we try to enable all top level names # here we try to enable all top level names
remote_forest_collision = remote_lsa.lsaRSetForestTrustInformation(remote_policy, remote_forest_collision = \
remote_lsa.lsaRSetForestTrustInformation(remote_policy,
local_lsa_info.dns_domain, local_lsa_info.dns_domain,
lsa.LSA_FOREST_TRUST_DOMAIN_INFO, lsa.LSA_FOREST_TRUST_DOMAIN_INFO,
remote_forest_info, remote_forest_info,
@ -2722,7 +2742,8 @@ class cmd_domain_trust_create(DomainTrustCommand):
if remote_trust_info.trust_direction & lsa.LSA_TRUST_DIRECTION_OUTBOUND: if remote_trust_info.trust_direction & lsa.LSA_TRUST_DIRECTION_OUTBOUND:
self.outf.write("Validating incoming trust...\n") self.outf.write("Validating incoming trust...\n")
try: try:
remote_trust_verify = remote_netlogon.netr_LogonControl2Ex(remote_netlogon_dc_unc, remote_trust_verify = \
remote_netlogon.netr_LogonControl2Ex(remote_netlogon_dc_unc,
netlogon.NETLOGON_CONTROL_TC_VERIFY, netlogon.NETLOGON_CONTROL_TC_VERIFY,
2, 2,
local_lsa_info.dns_domain.string) local_lsa_info.dns_domain.string)
@ -2863,8 +2884,10 @@ class cmd_domain_trust_delete(DomainTrustCommand):
try: try:
lsaString.string = local_lsa_info.dns_domain.string lsaString.string = local_lsa_info.dns_domain.string
remote_tdo_info = remote_lsa.QueryTrustedDomainInfoByName(remote_policy, remote_tdo_info = \
lsaString, lsa.LSA_TRUSTED_DOMAIN_INFO_INFO_EX) remote_lsa.QueryTrustedDomainInfoByName(remote_policy,
lsaString,
lsa.LSA_TRUSTED_DOMAIN_INFO_INFO_EX)
except NTSTATUSError as error: except NTSTATUSError as error:
if not self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND): if not self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND):
raise self.RemoteRuntimeError(self, error, "QueryTrustedDomainInfoByName(%s)" % ( raise self.RemoteRuntimeError(self, error, "QueryTrustedDomainInfoByName(%s)" % (
@ -2883,7 +2906,8 @@ class cmd_domain_trust_delete(DomainTrustCommand):
if local_tdo_info is not None: if local_tdo_info is not None:
try: try:
lsaString.string = local_tdo_info.domain_name.string lsaString.string = local_tdo_info.domain_name.string
local_tdo_handle = local_lsa.OpenTrustedDomainByName(local_policy, local_tdo_handle = \
local_lsa.OpenTrustedDomainByName(local_policy,
lsaString, lsaString,
security.SEC_STD_DELETE) security.SEC_STD_DELETE)
except RuntimeError as error: except RuntimeError as error:
@ -2896,7 +2920,8 @@ class cmd_domain_trust_delete(DomainTrustCommand):
if remote_tdo_info is not None: if remote_tdo_info is not None:
try: try:
lsaString.string = remote_tdo_info.domain_name.string lsaString.string = remote_tdo_info.domain_name.string
remote_tdo_handle = remote_lsa.OpenTrustedDomainByName(remote_policy, remote_tdo_handle = \
remote_lsa.OpenTrustedDomainByName(remote_policy,
lsaString, lsaString,
security.SEC_STD_DELETE) security.SEC_STD_DELETE)
except RuntimeError as error: except RuntimeError as error:
@ -2967,8 +2992,10 @@ class cmd_domain_trust_validate(DomainTrustCommand):
try: try:
lsaString = lsa.String() lsaString = lsa.String()
lsaString.string = domain lsaString.string = domain
local_tdo_info = local_lsa.QueryTrustedDomainInfoByName(local_policy, local_tdo_info = \
lsaString, lsa.LSA_TRUSTED_DOMAIN_INFO_INFO_EX) local_lsa.QueryTrustedDomainInfoByName(local_policy,
lsaString,
lsa.LSA_TRUSTED_DOMAIN_INFO_INFO_EX)
except NTSTATUSError as error: except NTSTATUSError as error:
if self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND): if self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND):
raise CommandError("trusted domain object does not exist for domain [%s]" % domain) raise CommandError("trusted domain object does not exist for domain [%s]" % domain)
@ -2986,7 +3013,8 @@ class cmd_domain_trust_validate(DomainTrustCommand):
raise self.LocalRuntimeError(self, error, "failed to connect netlogon server") raise self.LocalRuntimeError(self, error, "failed to connect netlogon server")
try: try:
local_trust_verify = local_netlogon.netr_LogonControl2Ex(local_server, local_trust_verify = \
local_netlogon.netr_LogonControl2Ex(local_server,
netlogon.NETLOGON_CONTROL_TC_VERIFY, netlogon.NETLOGON_CONTROL_TC_VERIFY,
2, 2,
local_tdo_info.domain_name.string) local_tdo_info.domain_name.string)
@ -3015,7 +3043,8 @@ class cmd_domain_trust_validate(DomainTrustCommand):
try: try:
server = local_trust_verify.trusted_dc_name.replace('\\', '') server = local_trust_verify.trusted_dc_name.replace('\\', '')
domain_and_server = "%s\\%s" % (local_tdo_info.domain_name.string, server) domain_and_server = "%s\\%s" % (local_tdo_info.domain_name.string, server)
local_trust_rediscover = local_netlogon.netr_LogonControl2Ex(local_server, local_trust_rediscover = \
local_netlogon.netr_LogonControl2Ex(local_server,
netlogon.NETLOGON_CONTROL_REDISCOVER, netlogon.NETLOGON_CONTROL_REDISCOVER,
2, 2,
domain_and_server) domain_and_server)
@ -3044,7 +3073,8 @@ class cmd_domain_trust_validate(DomainTrustCommand):
raise self.RemoteRuntimeError(self, error, "failed to connect netlogon server") raise self.RemoteRuntimeError(self, error, "failed to connect netlogon server")
try: try:
remote_trust_verify = remote_netlogon.netr_LogonControl2Ex(remote_server, remote_trust_verify = \
remote_netlogon.netr_LogonControl2Ex(remote_server,
netlogon.NETLOGON_CONTROL_TC_VERIFY, netlogon.NETLOGON_CONTROL_TC_VERIFY,
2, 2,
local_lsa_info.dns_domain.string) local_lsa_info.dns_domain.string)
@ -3073,7 +3103,8 @@ class cmd_domain_trust_validate(DomainTrustCommand):
try: try:
server = remote_trust_verify.trusted_dc_name.replace('\\', '') server = remote_trust_verify.trusted_dc_name.replace('\\', '')
domain_and_server = "%s\\%s" % (local_lsa_info.dns_domain.string, server) domain_and_server = "%s\\%s" % (local_lsa_info.dns_domain.string, server)
remote_trust_rediscover = remote_netlogon.netr_LogonControl2Ex(remote_server, remote_trust_rediscover = \
remote_netlogon.netr_LogonControl2Ex(remote_server,
netlogon.NETLOGON_CONTROL_REDISCOVER, netlogon.NETLOGON_CONTROL_REDISCOVER,
2, 2,
domain_and_server) domain_and_server)
@ -3529,8 +3560,10 @@ class cmd_domain_trust_namespaces(DomainTrustCommand):
try: try:
lsaString = lsa.String() lsaString = lsa.String()
lsaString.string = domain lsaString.string = domain
local_tdo_info = local_lsa.QueryTrustedDomainInfoByName(local_policy, local_tdo_info = \
lsaString, lsa.LSA_TRUSTED_DOMAIN_INFO_INFO_EX) local_lsa.QueryTrustedDomainInfoByName(local_policy,
lsaString,
lsa.LSA_TRUSTED_DOMAIN_INFO_INFO_EX)
except NTSTATUSError as error: except NTSTATUSError as error:
if self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND): if self.check_runtime_error(error, ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND):
raise CommandError("trusted domain object does not exist for domain [%s]" % domain) raise CommandError("trusted domain object does not exist for domain [%s]" % domain)
@ -3569,14 +3602,16 @@ class cmd_domain_trust_namespaces(DomainTrustCommand):
# this triggers netr_GetForestTrustInformation to the remote domain # this triggers netr_GetForestTrustInformation to the remote domain
# and lsaRSetForestTrustInformation() locally, but new top level # and lsaRSetForestTrustInformation() locally, but new top level
# names are disabled by default. # names are disabled by default.
fresh_forest_info = local_netlogon.netr_DsRGetForestTrustInformation(local_netlogon_info.dc_unc, fresh_forest_info = \
local_netlogon.netr_DsRGetForestTrustInformation(local_netlogon_info.dc_unc,
local_tdo_info.domain_name.string, local_tdo_info.domain_name.string,
netlogon_update_tdo) netlogon_update_tdo)
except RuntimeError as error: except RuntimeError as error:
raise self.LocalRuntimeError(self, error, "netr_DsRGetForestTrustInformation() failed") raise self.LocalRuntimeError(self, error, "netr_DsRGetForestTrustInformation() failed")
try: try:
fresh_forest_collision = local_lsa.lsaRSetForestTrustInformation(local_policy, fresh_forest_collision = \
local_lsa.lsaRSetForestTrustInformation(local_policy,
local_tdo_info.domain_name, local_tdo_info.domain_name,
lsa.LSA_FOREST_TRUST_DOMAIN_INFO, lsa.LSA_FOREST_TRUST_DOMAIN_INFO,
fresh_forest_info, fresh_forest_info,
@ -3593,7 +3628,8 @@ class cmd_domain_trust_namespaces(DomainTrustCommand):
try: try:
lsaString = lsa.String() lsaString = lsa.String()
lsaString.string = local_tdo_info.domain_name.string lsaString.string = local_tdo_info.domain_name.string
stored_forest_info = local_lsa.lsaRQueryForestTrustInformation(local_policy, stored_forest_info = \
local_lsa.lsaRQueryForestTrustInformation(local_policy,
lsaString, lsaString,
lsa.LSA_FOREST_TRUST_DOMAIN_INFO) lsa.LSA_FOREST_TRUST_DOMAIN_INFO)
except RuntimeError as error: except RuntimeError as error:
@ -3612,7 +3648,8 @@ class cmd_domain_trust_namespaces(DomainTrustCommand):
try: try:
lsaString = lsa.String() lsaString = lsa.String()
lsaString.string = local_tdo_info.domain_name.string lsaString.string = local_tdo_info.domain_name.string
local_forest_info = local_lsa.lsaRQueryForestTrustInformation(local_policy, local_forest_info = \
local_lsa.lsaRQueryForestTrustInformation(local_policy,
lsaString, lsaString,
lsa.LSA_FOREST_TRUST_DOMAIN_INFO) lsa.LSA_FOREST_TRUST_DOMAIN_INFO)
except RuntimeError as error: except RuntimeError as error:

View File

@ -371,8 +371,10 @@ def update_provision_usn(samdb, low, high, id, replace=False):
tab.append("%s-%s;%s" % (low, high, id)) tab.append("%s-%s;%s" % (low, high, id))
delta = ldb.Message() delta = ldb.Message()
delta.dn = ldb.Dn(samdb, "@PROVISION") delta.dn = ldb.Dn(samdb, "@PROVISION")
delta[LAST_PROVISION_USN_ATTRIBUTE] = ldb.MessageElement(tab, delta[LAST_PROVISION_USN_ATTRIBUTE] = \
ldb.FLAG_MOD_REPLACE, LAST_PROVISION_USN_ATTRIBUTE) ldb.MessageElement(tab,
ldb.FLAG_MOD_REPLACE,
LAST_PROVISION_USN_ATTRIBUTE)
entry = samdb.search(expression='provisionnerID=*', entry = samdb.search(expression='provisionnerID=*',
base="@PROVISION", scope=ldb.SCOPE_BASE, base="@PROVISION", scope=ldb.SCOPE_BASE,
attrs=["provisionnerID"]) attrs=["provisionnerID"])
@ -398,8 +400,10 @@ def set_provision_usn(samdb, low, high, id):
delta = ldb.Message() delta = ldb.Message()
delta.dn = ldb.Dn(samdb, "@PROVISION") delta.dn = ldb.Dn(samdb, "@PROVISION")
delta[LAST_PROVISION_USN_ATTRIBUTE] = ldb.MessageElement(tab, delta[LAST_PROVISION_USN_ATTRIBUTE] = \
ldb.FLAG_MOD_ADD, LAST_PROVISION_USN_ATTRIBUTE) ldb.MessageElement(tab,
ldb.FLAG_MOD_ADD,
LAST_PROVISION_USN_ATTRIBUTE)
samdb.add(delta) samdb.add(delta)

View File

@ -784,7 +784,8 @@ class FDSBackend(LDAPBackend):
self.credentials.set_bind_dn(self.names.ldapmanagerdn) self.credentials.set_bind_dn(self.names.ldapmanagerdn)
# Destory the target directory, or else setup-ds.pl will complain # Destory the target directory, or else setup-ds.pl will complain
fedora_ds_dir = os.path.join(self.ldapdir, fedora_ds_dir = \
os.path.join(self.ldapdir,
"slapd-" + self.ldap_instance) "slapd-" + self.ldap_instance)
shutil.rmtree(fedora_ds_dir, True) shutil.rmtree(fedora_ds_dir, True)
@ -795,7 +796,8 @@ class FDSBackend(LDAPBackend):
self.slapd_provision_command.append("-d0") self.slapd_provision_command.append("-d0")
#the command for the final run is the normal script #the command for the final run is the normal script
self.slapd_command = [os.path.join(self.ldapdir, self.slapd_command = \
[os.path.join(self.ldapdir,
"slapd-" + self.ldap_instance, "start-slapd")] "slapd-" + self.ldap_instance, "start-slapd")]
# If we were just looking for crashes up to this point, it's a # If we were just looking for crashes up to this point, it's a

View File

@ -314,7 +314,8 @@ def add_dns_container(samdb, domaindn, prefix, domain_sid, dnsadmins_sid, forest
# CN=MicrosoftDNS,<PREFIX>,<DOMAINDN> # CN=MicrosoftDNS,<PREFIX>,<DOMAINDN>
msg = ldb.Message(ldb.Dn(samdb, "CN=MicrosoftDNS,%s,%s" % (prefix, domaindn))) msg = ldb.Message(ldb.Dn(samdb, "CN=MicrosoftDNS,%s,%s" % (prefix, domaindn)))
msg["objectClass"] = ["top", "container"] msg["objectClass"] = ["top", "container"]
msg["nTSecurityDescriptor"] = ldb.MessageElement(sd_val, ldb.FLAG_MOD_ADD, msg["nTSecurityDescriptor"] = \
ldb.MessageElement(sd_val, ldb.FLAG_MOD_ADD,
"nTSecurityDescriptor") "nTSecurityDescriptor")
samdb.add(msg) samdb.add(msg)
@ -492,7 +493,9 @@ def add_domain_record(samdb, domaindn, prefix, dnsdomain, domainsid, dnsadmins_s
props.append(ndr_pack(AgingEnabledTimeProperty())) props.append(ndr_pack(AgingEnabledTimeProperty()))
msg = ldb.Message(ldb.Dn(samdb, "DC=%s,CN=MicrosoftDNS,%s,%s" % (dnsdomain, prefix, domaindn))) msg = ldb.Message(ldb.Dn(samdb, "DC=%s,CN=MicrosoftDNS,%s,%s" % (dnsdomain, prefix, domaindn)))
msg["objectClass"] = ["top", "dnsZone"] msg["objectClass"] = ["top", "dnsZone"]
msg["ntSecurityDescriptor"] = ldb.MessageElement(ndr_pack(sec), ldb.FLAG_MOD_ADD, msg["ntSecurityDescriptor"] = \
ldb.MessageElement(ndr_pack(sec),
ldb.FLAG_MOD_ADD,
"nTSecurityDescriptor") "nTSecurityDescriptor")
msg["dNSProperty"] = ldb.MessageElement(props, ldb.FLAG_MOD_ADD, "dNSProperty") msg["dNSProperty"] = ldb.MessageElement(props, ldb.FLAG_MOD_ADD, "dNSProperty")
samdb.add(msg) samdb.add(msg)

View File

@ -887,7 +887,8 @@ schemaUpdateNow: 1
replBlob = ndr_pack(repl) replBlob = ndr_pack(repl)
msg = ldb.Message() msg = ldb.Message()
msg.dn = res[0].dn msg.dn = res[0].dn
msg["replPropertyMetaData"] = ldb.MessageElement(replBlob, msg["replPropertyMetaData"] = \
ldb.MessageElement(replBlob,
ldb.FLAG_MOD_REPLACE, ldb.FLAG_MOD_REPLACE,
"replPropertyMetaData") "replPropertyMetaData")
self.modify(msg, ["local_oid:1.3.6.1.4.1.7165.4.3.14:0"]) self.modify(msg, ["local_oid:1.3.6.1.4.1.7165.4.3.14:0"])
@ -988,10 +989,13 @@ schemaUpdateNow: 1
m.dn = ldb.Dn(self, "CN=Directory Service,CN=Windows NT,CN=Services,%s" m.dn = ldb.Dn(self, "CN=Directory Service,CN=Windows NT,CN=Services,%s"
% self.get_config_basedn().get_linearized()) % self.get_config_basedn().get_linearized())
if dsheuristics is not None: if dsheuristics is not None:
m["dSHeuristics"] = ldb.MessageElement(dsheuristics, m["dSHeuristics"] = \
ldb.FLAG_MOD_REPLACE, "dSHeuristics") ldb.MessageElement(dsheuristics,
ldb.FLAG_MOD_REPLACE,
"dSHeuristics")
else: else:
m["dSHeuristics"] = ldb.MessageElement([], ldb.FLAG_MOD_DELETE, m["dSHeuristics"] = \
ldb.MessageElement([], ldb.FLAG_MOD_DELETE,
"dSHeuristics") "dSHeuristics")
self.modify(m) self.modify(m)

View File

@ -194,9 +194,15 @@ class SmbDotConfTests(TestCase):
section = "test" section = "test"
else: else:
self.fail("%s has no valid context" % param) self.fail("%s has no valid context" % param)
p = subprocess.Popen(program + ["-s", self.smbconf, p = subprocess.Popen(program + ["-s",
"--section-name", section, "--parameter-name", param], self.smbconf,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=self.topdir).communicate() "--section-name",
section,
"--parameter-name",
param],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=self.topdir).communicate()
result = p[0].decode().upper().strip() result = p[0].decode().upper().strip()
if result != default.upper(): if result != default.upper():
if not (result == "" and default == '""'): if not (result == "" and default == '""'):
@ -224,10 +230,17 @@ class SmbDotConfTests(TestCase):
section = "test" section = "test"
else: else:
self.fail("%s has no valid context" % param) self.fail("%s has no valid context" % param)
p = subprocess.Popen(program + ["-s", self.smbconf, p = subprocess.Popen(program + ["-s",
"--section-name", section, "--parameter-name", param, self.smbconf,
"--option", "%s = %s" % (param, default)], "--section-name",
stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=self.topdir).communicate() section,
"--parameter-name",
param,
"--option",
"%s = %s" % (param, default)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=self.topdir).communicate()
result = p[0].decode().upper().strip() result = p[0].decode().upper().strip()
if result != default.upper(): if result != default.upper():
if not (result == "" and default == '""'): if not (result == "" and default == '""'):
@ -283,10 +296,17 @@ class SmbDotConfTests(TestCase):
if value_to_use is None: if value_to_use is None:
self.fail("%s has an invalid type" % param) self.fail("%s has an invalid type" % param)
p = subprocess.Popen(program + ["-s", self.smbconf, p = subprocess.Popen(program + ["-s",
"--section-name", section, "--parameter-name", param, self.smbconf,
"--option", "%s = %s" % (param, value_to_use)], "--section-name",
stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=self.topdir).communicate() section,
"--parameter-name",
param,
"--option",
"%s = %s" % (param, value_to_use)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=self.topdir).communicate()
result = p[0].decode().upper().strip() result = p[0].decode().upper().strip()
if result != value_to_use.upper(): if result != value_to_use.upper():
# currently no way to distinguish command lists # currently no way to distinguish command lists
@ -315,9 +335,14 @@ class SmbDotConfTests(TestCase):
finally: finally:
g.close() g.close()
p = subprocess.Popen(program + ["-s", tempconf, "--suppress-prompt", p = subprocess.Popen(program + ["-s",
"--option", "%s = %s" % (param, value_to_use)], tempconf,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=self.topdir).communicate() "--suppress-prompt",
"--option",
"%s = %s" % (param, value_to_use)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=self.topdir).communicate()
os.unlink(tempconf) os.unlink(tempconf)
@ -351,8 +376,12 @@ class SmbDotConfTests(TestCase):
"Parameters that were unexpectedly not set:")) "Parameters that were unexpectedly not set:"))
def _test_empty(self, program): def _test_empty(self, program):
p = subprocess.Popen(program + ["-s", self.blankconf, "--suppress-prompt"], p = subprocess.Popen(program + ["-s",
stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=self.topdir).communicate() self.blankconf,
"--suppress-prompt"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=self.topdir).communicate()
output = "" output = ""
for line in p[0].decode().splitlines(): for line in p[0].decode().splitlines():