[SCM] Samba Shared Repository - branch master updated
Björn Jacke
bjacke at samba.org
Tue Sep 24 13:41:02 UTC 2019
The branch, master has been updated
via 4f5c4df316d wscript_build: string concatenation efficiency cleanup
via c9088c6aa84 pfm_verif: string concatenation efficiency cleanup
via c7fa030aecd scripting: avoid inefficient string redefinition
via 5ad629dcb95 wscript: avoid inefficient string concatenations
via b3b6b700c47 s3/wscript: avoid inefficient string concatenations
via 32d1c3f873f posixacl.py: avoid inefficient string concatenations
via dd9e0f0ae1c auth_log_winbind.py: avoid inefficient string concatenations
via cf51f73e02c schema.py: avoid inefficient string concatenations
via d2d8ebcca1c user.py: avoid inefficient string concatenations
via ce56d336f23 gpo.py: avoid inefficient string concatenations
via 1825a7f4e2a kcc_utils.py: avoid inefficient string concatenations
via 4c34a2d7256 traffic.py: avoid inefficient string concatenations
from b8f4f141a2d ctdb-tests: Switch TEST_VAR_DIR to a local script variable
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 4f5c4df316dc029f7b5ed6e8e48636dc61ecfe22
Author: Björn Jacke <bj at sernet.de>
Date: Fri Aug 23 02:19:20 2019 +0200
wscript_build: string concatenation efficiency cleanup
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Matthias Dieter Wallnöfer <mdw at samba.org>
Autobuild-User(master): Björn Jacke <bjacke at samba.org>
Autobuild-Date(master): Tue Sep 24 13:40:21 UTC 2019 on sn-devel-184
commit c9088c6aa847685613ec34d61b61e31fe0395035
Author: Björn Jacke <bj at sernet.de>
Date: Fri Aug 23 02:21:17 2019 +0200
pfm_verif: string concatenation efficiency cleanup
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Matthias Dieter Wallnöfer <mdw at samba.org>
commit c7fa030aecd1de5ed32e2509ecd83828aa42c1a3
Author: Björn Jacke <bj at sernet.de>
Date: Sun Aug 25 23:10:19 2019 +0200
scripting: avoid inefficient string redefinition
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Matthias Dieter Wallnöfer <mdw at samba.org>
commit 5ad629dcb957e45637f3a71309fa51abd87b267d
Author: Björn Jacke <bj at sernet.de>
Date: Sun Aug 25 23:09:19 2019 +0200
wscript: avoid inefficient string concatenations
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Matthias Dieter Wallnöfer <mdw at samba.org>
commit b3b6b700c47ba771baf632b3a165106c21c9ae04
Author: Björn Jacke <bj at sernet.de>
Date: Sun Aug 25 23:08:18 2019 +0200
s3/wscript: avoid inefficient string concatenations
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Matthias Dieter Wallnöfer <mdw at samba.org>
commit 32d1c3f873fc8bd89a7dc985cb8258e990dc12cd
Author: Björn Jacke <bj at sernet.de>
Date: Sun Aug 25 23:07:48 2019 +0200
posixacl.py: avoid inefficient string concatenations
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Matthias Dieter Wallnöfer <mdw at samba.org>
commit dd9e0f0ae1cca23920883a0e04fe5862663e400e
Author: Björn Jacke <bj at sernet.de>
Date: Sun Aug 25 23:07:13 2019 +0200
auth_log_winbind.py: avoid inefficient string concatenations
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit cf51f73e02cab85f508bcbef362ff75a7ae18d7f
Author: Björn Jacke <bj at sernet.de>
Date: Sun Aug 25 23:06:19 2019 +0200
schema.py: avoid inefficient string concatenations
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit d2d8ebcca1cc4539a7a6b48fa364e03adda1db6c
Author: Björn Jacke <bj at sernet.de>
Date: Sun Aug 25 23:06:00 2019 +0200
user.py: avoid inefficient string concatenations
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit ce56d336f234febfd4cb3da11dd584842c24ce1d
Author: Björn Jacke <bj at sernet.de>
Date: Sun Aug 25 23:05:31 2019 +0200
gpo.py: avoid inefficient string concatenations
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 1825a7f4e2a39d03f01da37b68ba4f65dbafd04a
Author: Björn Jacke <bj at sernet.de>
Date: Sun Aug 25 23:05:10 2019 +0200
kcc_utils.py: avoid inefficient string concatenations
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 4c34a2d72569f31d59b904c3ca1c140f6084b3dd
Author: Björn Jacke <bj at sernet.de>
Date: Sun Aug 25 23:04:25 2019 +0200
traffic.py: avoid inefficient string concatenations
Signed-off-by: Bjoern Jacke <bjacke at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
-----------------------------------------------------------------------
Summary of changes:
docs-xml/wscript_build | 20 ++-
python/samba/emulate/traffic.py | 4 +-
python/samba/kcc/kcc_utils.py | 195 +++++++++++++--------------
python/samba/netcmd/gpo.py | 9 +-
python/samba/netcmd/user.py | 58 ++++----
python/samba/schema.py | 7 +-
python/samba/tests/auth_log_winbind.py | 3 +-
python/samba/tests/posixacl.py | 4 +-
source3/wscript | 4 +-
source4/scripting/bin/samba_upgradeprovision | 8 +-
source4/scripting/devel/config_base | 9 +-
source4/scripting/devel/pfm_verify.py | 4 +-
wscript | 5 +-
13 files changed, 147 insertions(+), 183 deletions(-)
Changeset truncated at 500 lines:
diff --git a/docs-xml/wscript_build b/docs-xml/wscript_build
index f207e51ff21..b85309d4ead 100644
--- a/docs-xml/wscript_build
+++ b/docs-xml/wscript_build
@@ -115,26 +115,22 @@ def smbdotconf_generate_parameter_list(task):
articles = task.inputs
entities = bld.pathconfig_entities()
- t = "<!DOCTYPE section [\n"
-
- for entity in entities:
- t += "%s\n" % entity
# We need this if we build with Heimdal
mit_kdc_path = '"/usr/sbin/krb5kdc"'
-
# The MIT krb5kdc path is set if we build with MIT Kerberos
if bld.CONFIG_SET('MIT_KDC_PATH'):
mit_kdc_path = bld.CONFIG_GET('MIT_KDC_PATH')
- t += "<!ENTITY pathconfig.MITKDCPATH %s>\n" % mit_kdc_path
-
- t += "]>\n"
- t += "<section>\n"
- for article in articles:
- t += article.read()
+ t = "<!DOCTYPE section [\n" +\
+ "\n".join(entities) +\
+ "\n" +\
+ "<!ENTITY pathconfig.MITKDCPATH " + mit_kdc_path + ">\n" +\
+ "]>\n" +\
+ "<section>\n" +\
+ "".join(art.read() for art in articles) +\
+ "</section>\n"
- t += "</section>\n"
save_file(parameter_all, t , create_dir=True)
return 0
diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py
index d0a2ffc8f2c..c428b4e369e 100644
--- a/python/samba/emulate/traffic.py
+++ b/python/samba/emulate/traffic.py
@@ -453,9 +453,7 @@ class ReplayContext(object):
# lookup all the GPO DNs
res = db.search(db.domain_dn(), scope=ldb.SCOPE_SUBTREE, attrs=['dn'],
expression='(objectclass=groupPolicyContainer)')
- gpos_by_dn = ""
- for msg in res:
- gpos_by_dn += "(distinguishedName={0})".format(msg['dn'])
+ gpos_by_dn = "".join("(distinguishedName={0})".format(msg['dn']) for msg in res)
# a search for the 'gPCFileSysPath' attribute is probably a GPO search
# (as per the MS-GPOL spec) which searches for GPOs by DN
diff --git a/python/samba/kcc/kcc_utils.py b/python/samba/kcc/kcc_utils.py
index 3e9a988b778..e0712e49c82 100644
--- a/python/samba/kcc/kcc_utils.py
+++ b/python/samba/kcc/kcc_utils.py
@@ -66,9 +66,9 @@ class NamingContext(object):
def __str__(self):
'''Debug dump string output of class'''
- text = "%s:" % (self.__class__.__name__,)
- text = text + "\n\tnc_dnstr=%s" % self.nc_dnstr
- text = text + "\n\tnc_guid=%s" % str(self.nc_guid)
+ text = "%s:" % (self.__class__.__name__,) +\
+ "\n\tnc_dnstr=%s" % self.nc_dnstr +\
+ "\n\tnc_guid=%s" % str(self.nc_guid)
if self.nc_sid is None:
text = text + "\n\tnc_sid=<absent>"
@@ -200,20 +200,16 @@ class NCReplica(NamingContext):
def __str__(self):
'''Debug dump string output of class'''
- text = "%s:" % self.__class__.__name__
- text = text + "\n\tdsa_dnstr=%s" % self.rep_dsa_dnstr
- text = text + "\n\tdsa_guid=%s" % self.rep_dsa_guid
- text = text + "\n\tdefault=%s" % self.rep_default
- text = text + "\n\tro=%s" % self.rep_ro
- text = text + "\n\tpartial=%s" % self.rep_partial
- text = text + "\n\tpresent=%s" % self.is_present()
- text = text + "\n\tfsmo_role_owner=%s" % self.rep_fsmo_role_owner
-
- for rep in self.rep_repsFrom:
- text = text + "\n%s" % rep
-
- for rep in self.rep_repsTo:
- text = text + "\n%s" % rep
+ text = "%s:" % self.__class__.__name__ +\
+ "\n\tdsa_dnstr=%s" % self.rep_dsa_dnstr +\
+ "\n\tdsa_guid=%s" % self.rep_dsa_guid +\
+ "\n\tdefault=%s" % self.rep_default +\
+ "\n\tro=%s" % self.rep_ro +\
+ "\n\tpartial=%s" % self.rep_partial +\
+ "\n\tpresent=%s" % self.is_present() +\
+ "\n\tfsmo_role_owner=%s" % self.rep_fsmo_role_owner +\
+ "".join("\n%s" % rep for rep in self.rep_repsFrom) +\
+ "".join("\n%s" % rep for rep in self.rep_repsTo)
return "%s\n%s" % (NamingContext.__str__(self), text)
@@ -589,16 +585,15 @@ class DirectoryServiceAgent(object):
if self.dsa_ivid is not None:
text = text + "\n\tdsa_ivid=%s" % str(self.dsa_ivid)
- text = text + "\n\tro=%s" % self.is_ro()
- text = text + "\n\tgc=%s" % self.is_gc()
- text = text + "\n\tistg=%s" % self.is_istg()
-
- text = text + "\ncurrent_replica_table:"
- text = text + "\n%s" % self.dumpstr_current_replica_table()
- text = text + "\nneeded_replica_table:"
- text = text + "\n%s" % self.dumpstr_needed_replica_table()
- text = text + "\nconnect_table:"
- text = text + "\n%s" % self.dumpstr_connect_table()
+ text += "\n\tro=%s" % self.is_ro() +\
+ "\n\tgc=%s" % self.is_gc() +\
+ "\n\tistg=%s" % self.is_istg() +\
+ "\ncurrent_replica_table:" +\
+ "\n%s" % self.dumpstr_current_replica_table() +\
+ "\nneeded_replica_table:" +\
+ "\n%s" % self.dumpstr_needed_replica_table() +\
+ "\nconnect_table:" +\
+ "\n%s" % self.dumpstr_connect_table()
return text
@@ -919,39 +914,38 @@ class NTDSConnection(object):
def __str__(self):
'''Debug dump string output of NTDSConnection object'''
- text = "%s:\n\tdn=%s" % (self.__class__.__name__, self.dnstr)
- text = text + "\n\tenabled=%s" % self.enabled
- text = text + "\n\tto_be_added=%s" % self.to_be_added
- text = text + "\n\tto_be_deleted=%s" % self.to_be_deleted
- text = text + "\n\tto_be_modified=%s" % self.to_be_modified
- text = text + "\n\toptions=0x%08X" % self.options
- text = text + "\n\tsystem_flags=0x%08X" % self.system_flags
- text = text + "\n\twhenCreated=%d" % self.whenCreated
- text = text + "\n\ttransport_dn=%s" % self.transport_dnstr
+ text = "%s:\n\tdn=%s" % (self.__class__.__name__, self.dnstr) +\
+ "\n\tenabled=%s" % self.enabled +\
+ "\n\tto_be_added=%s" % self.to_be_added +\
+ "\n\tto_be_deleted=%s" % self.to_be_deleted +\
+ "\n\tto_be_modified=%s" % self.to_be_modified +\
+ "\n\toptions=0x%08X" % self.options +\
+ "\n\tsystem_flags=0x%08X" % self.system_flags +\
+ "\n\twhenCreated=%d" % self.whenCreated +\
+ "\n\ttransport_dn=%s" % self.transport_dnstr
if self.guid is not None:
- text = text + "\n\tguid=%s" % str(self.guid)
+ text += "\n\tguid=%s" % str(self.guid)
if self.transport_guid is not None:
- text = text + "\n\ttransport_guid=%s" % str(self.transport_guid)
+ text += "\n\ttransport_guid=%s" % str(self.transport_guid)
text = text + "\n\tfrom_dn=%s" % self.from_dnstr
if self.schedule is not None:
- text += "\n\tschedule.size=%s" % self.schedule.size
- text += "\n\tschedule.bandwidth=%s" % self.schedule.bandwidth
- text += ("\n\tschedule.numberOfSchedules=%s" %
+ text += "\n\tschedule.size=%s" % self.schedule.size +\
+ "\n\tschedule.bandwidth=%s" % self.schedule.bandwidth +\
+ ("\n\tschedule.numberOfSchedules=%s" %
self.schedule.numberOfSchedules)
for i, header in enumerate(self.schedule.headerArray):
text += ("\n\tschedule.headerArray[%d].type=%d" %
- (i, header.type))
- text += ("\n\tschedule.headerArray[%d].offset=%d" %
- (i, header.offset))
- text += "\n\tschedule.dataArray[%d].slots[ " % i
- for slot in self.schedule.dataArray[i].slots:
- text = text + "0x%X " % slot
- text = text + "]"
+ (i, header.type)) +\
+ ("\n\tschedule.headerArray[%d].offset=%d" %
+ (i, header.offset)) +\
+ "\n\tschedule.dataArray[%d].slots[ " % i +\
+ "".join("0x%X " % slot for slot in self.schedule.dataArray[i].slots) +\
+ "]"
return text
@@ -1458,12 +1452,10 @@ class Partition(NamingContext):
def __str__(self):
'''Debug dump string output of class'''
- text = "%s" % NamingContext.__str__(self)
- text = text + "\n\tpartdn=%s" % self.partstr
- for k in self.rw_location_list:
- text = text + "\n\tmsDS-NC-Replica-Locations=%s" % k
- for k in self.ro_location_list:
- text = text + "\n\tmsDS-NC-RO-Replica-Locations=%s" % k
+ text = "%s" % NamingContext.__str__(self) +\
+ "\n\tpartdn=%s" % self.partstr +\
+ "".join("\n\tmsDS-NC-Replica-Locations=%s" % k for k in self.rw_location_list) +\
+ "".join("\n\tmsDS-NC-RO-Replica-Locations=%s" % k for k in self.ro_location_list)
return text
@@ -1764,11 +1756,11 @@ class Site(object):
def __str__(self):
'''Debug dump string output of class'''
- text = "%s:" % self.__class__.__name__
- text = text + "\n\tdn=%s" % self.site_dnstr
- text = text + "\n\toptions=0x%X" % self.site_options
- text = text + "\n\ttopo_generator=%s" % self.site_topo_generator
- text = text + "\n\ttopo_failover=%d" % self.site_topo_failover
+ text = "%s:" % self.__class__.__name__ +\
+ "\n\tdn=%s" % self.site_dnstr +\
+ "\n\toptions=0x%X" % self.site_options +\
+ "\n\ttopo_generator=%s" % self.site_topo_generator +\
+ "\n\ttopo_failover=%d" % self.site_topo_failover
for key, dsa in self.dsa_table.items():
text = text + "\n%s" % dsa
return text
@@ -1792,9 +1784,9 @@ class GraphNode(object):
self.edge_from = []
def __str__(self):
- text = "%s:" % self.__class__.__name__
- text = text + "\n\tdsa_dnstr=%s" % self.dsa_dnstr
- text = text + "\n\tmax_edges=%d" % self.max_edges
+ text = "%s:" % self.__class__.__name__ +\
+ "\n\tdsa_dnstr=%s" % self.dsa_dnstr +\
+ "\n\tmax_edges=%d" % self.max_edges
for i, edge in enumerate(self.edge_from):
if isinstance(edge, str):
@@ -1894,13 +1886,12 @@ class Transport(object):
def __str__(self):
'''Debug dump string output of Transport object'''
- text = "%s:\n\tdn=%s" % (self.__class__.__name__, self.dnstr)
- text = text + "\n\tguid=%s" % str(self.guid)
- text = text + "\n\toptions=%d" % self.options
- text = text + "\n\taddress_attr=%s" % self.address_attr
- text = text + "\n\tname=%s" % self.name
- for dnstr in self.bridgehead_list:
- text = text + "\n\tbridgehead_list=%s" % dnstr
+ text = "%s:\n\tdn=%s" % (self.__class__.__name__, self.dnstr) +\
+ "\n\tguid=%s" % str(self.guid) +\
+ "\n\toptions=%d" % self.options +\
+ "\n\taddress_attr=%s" % self.address_attr +\
+ "\n\tname=%s" % self.name +\
+ "".join("\n\tbridgehead_list=%s" % dnstr for dnstr in self.bridgehead_list)
return text
@@ -2006,25 +1997,24 @@ class RepsFromTo(object):
def __str__(self):
'''Debug dump string output of class'''
- text = "%s:" % self.__class__.__name__
- text += "\n\tdnstr=%s" % self.nc_dnstr
- text += "\n\tupdate_flags=0x%X" % self.update_flags
- text += "\n\tversion=%d" % self.version
- text += "\n\tsource_dsa_obj_guid=%s" % self.source_dsa_obj_guid
- text += ("\n\tsource_dsa_invocation_id=%s" %
- self.source_dsa_invocation_id)
- text += "\n\ttransport_guid=%s" % self.transport_guid
- text += "\n\treplica_flags=0x%X" % self.replica_flags
- text += ("\n\tconsecutive_sync_failures=%d" %
- self.consecutive_sync_failures)
- text += "\n\tlast_success=%s" % self.last_success
- text += "\n\tlast_attempt=%s" % self.last_attempt
- text += "\n\tdns_name1=%s" % self.dns_name1
- text += "\n\tdns_name2=%s" % self.dns_name2
- text += "\n\tschedule[ "
- for slot in self.schedule:
- text += "0x%X " % slot
- text += "]"
+ text = "%s:" % self.__class__.__name__ +\
+ "\n\tdnstr=%s" % self.nc_dnstr +\
+ "\n\tupdate_flags=0x%X" % self.update_flags +\
+ "\n\tversion=%d" % self.version +\
+ "\n\tsource_dsa_obj_guid=%s" % self.source_dsa_obj_guid +\
+ ("\n\tsource_dsa_invocation_id=%s" %
+ self.source_dsa_invocation_id) +\
+ "\n\ttransport_guid=%s" % self.transport_guid +\
+ "\n\treplica_flags=0x%X" % self.replica_flags +\
+ ("\n\tconsecutive_sync_failures=%d" %
+ self.consecutive_sync_failures) +\
+ "\n\tlast_success=%s" % self.last_success +\
+ "\n\tlast_attempt=%s" % self.last_attempt +\
+ "\n\tdns_name1=%s" % self.dns_name1 +\
+ "\n\tdns_name2=%s" % self.dns_name2 +\
+ "\n\tschedule[ " +\
+ "".join("0x%X " % slot for slot in self.schedule) +\
+ "]"
return text
@@ -2138,27 +2128,26 @@ class SiteLink(object):
def __str__(self):
'''Debug dump string output of Transport object'''
- text = "%s:\n\tdn=%s" % (self.__class__.__name__, self.dnstr)
- text = text + "\n\toptions=%d" % self.options
- text = text + "\n\tsystem_flags=%d" % self.system_flags
- text = text + "\n\tcost=%d" % self.cost
- text = text + "\n\tinterval=%s" % self.interval
+ text = "%s:\n\tdn=%s" % (self.__class__.__name__, self.dnstr) +\
+ "\n\toptions=%d" % self.options +\
+ "\n\tsystem_flags=%d" % self.system_flags +\
+ "\n\tcost=%d" % self.cost +\
+ "\n\tinterval=%s" % self.interval
if self.schedule is not None:
- text += "\n\tschedule.size=%s" % self.schedule.size
- text += "\n\tschedule.bandwidth=%s" % self.schedule.bandwidth
- text += ("\n\tschedule.numberOfSchedules=%s" %
+ text += "\n\tschedule.size=%s" % self.schedule.size +\
+ "\n\tschedule.bandwidth=%s" % self.schedule.bandwidth +\
+ ("\n\tschedule.numberOfSchedules=%s" %
self.schedule.numberOfSchedules)
for i, header in enumerate(self.schedule.headerArray):
text += ("\n\tschedule.headerArray[%d].type=%d" %
- (i, header.type))
- text += ("\n\tschedule.headerArray[%d].offset=%d" %
- (i, header.offset))
- text = text + "\n\tschedule.dataArray[%d].slots[ " % i
- for slot in self.schedule.dataArray[i].slots:
- text = text + "0x%X " % slot
- text = text + "]"
+ (i, header.type)) +\
+ ("\n\tschedule.headerArray[%d].offset=%d" %
+ (i, header.offset)) +\
+ "\n\tschedule.dataArray[%d].slots[ " % i +\
+ "".join("0x%X " % slot for slot in self.schedule.dataArray[i].slots) +\
+ "]"
for guid, dn in self.site_list:
text = text + "\n\tsite_list=%s (%s)" % (guid, dn)
diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py
index 5a0258196c3..047f91951e8 100644
--- a/python/samba/netcmd/gpo.py
+++ b/python/samba/netcmd/gpo.py
@@ -110,9 +110,7 @@ def parse_gplink(gplink):
def encode_gplink(gplist):
'''Encode an array of dn and options into gPLink string'''
- ret = ''
- for g in gplist:
- ret += "[LDAP://%s;%d]" % (g['dn'], g['options'])
+ ret = "".join("[LDAP://%s;%d]" % (g['dn'], g['options']) for g in gplist)
return ret
@@ -1079,9 +1077,8 @@ class cmd_backup(GPOCommand):
entities = cmd_backup.generalize_xml_entities(self.outf, gpodir,
gpodir)
import operator
- ents = ''
- for ent in sorted(entities.items(), key=operator.itemgetter(1)):
- ents += '<!ENTITY {} "{}">\n'.format(ent[1].strip('&;'), ent[0])
+ ents = "".join('<!ENTITY {} "{}\n">'.format(ent[1].strip('&;'), ent[0]) \
+ for ent in sorted(entities.items(), key=operator.itemgetter(1)))
if ent_file:
with open(ent_file, 'w') as f:
diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py
index e59222f7727..6730ab718de 100644
--- a/python/samba/netcmd/user.py
+++ b/python/samba/netcmd/user.py
@@ -1899,15 +1899,13 @@ samba-tool user syncpasswords --terminate \\
self.password_attrs = password_attrs
self.decrypt_samba_gpg = decrypt_samba_gpg
self.sync_command = sync_command
- add_ldif = "dn: %s\n" % self.cache_dn
- add_ldif += "objectClass: userSyncPasswords\n"
- add_ldif += "samdbUrl:: %s\n" % base64.b64encode(get_bytes(self.samdb_url)).decode('utf8')
- add_ldif += "dirsyncFilter:: %s\n" % base64.b64encode(get_bytes(self.dirsync_filter)).decode('utf8')
- for a in self.dirsync_attrs:
- add_ldif += "dirsyncAttribute:: %s\n" % base64.b64encode(get_bytes(a)).decode('utf8')
- add_ldif += "dirsyncControl: %s\n" % self.dirsync_controls[0]
- for a in self.password_attrs:
- add_ldif += "passwordAttribute:: %s\n" % base64.b64encode(get_bytes(a)).decode('utf8')
+ add_ldif = "dn: %s\n" % self.cache_dn +\
+ "objectClass: userSyncPasswords\n" +\
+ "samdbUrl:: %s\n" % base64.b64encode(get_bytes(self.samdb_url)).decode('utf8') +\
+ "dirsyncFilter:: %s\n" % base64.b64encode(get_bytes(self.dirsync_filter)).decode('utf8') +\
+ "".join("dirsyncAttribute:: %s\n" % base64.b64encode(get_bytes(a)).decode('utf8') for a in self.dirsync_attrs) +\
+ "dirsyncControl: %s\n" % self.dirsync_controls[0] +\
+ "".join("passwordAttribute:: %s\n" % base64.b64encode(get_bytes(a)).decode('utf8') for a in self.password_attrs)
if self.decrypt_samba_gpg:
add_ldif += "decryptSambaGPG: TRUE\n"
else:
@@ -2104,13 +2102,13 @@ samba-tool user syncpasswords --terminate \\
if self.current_pid is not None:
log_msg("currentPid: %d\n" % self.current_pid)
- modify_ldif = "dn: %s\n" % (self.cache_dn)
- modify_ldif += "changetype: modify\n"
- modify_ldif += "replace: currentPid\n"
+ modify_ldif = "dn: %s\n" % (self.cache_dn) +\
+ "changetype: modify\n" +\
+ "replace: currentPid\n"
if self.current_pid is not None:
modify_ldif += "currentPid: %d\n" % (self.current_pid)
- modify_ldif += "replace: currentTime\n"
- modify_ldif += "currentTime: %s\n" % ldb.timestring(int(time.time()))
+ modify_ldif += "replace: currentTime\n" +\
+ "currentTime: %s\n" % ldb.timestring(int(time.time()))
self.cache.modify_ldif(modify_ldif)
return
@@ -2122,12 +2120,12 @@ samba-tool user syncpasswords --terminate \\
# This cookie can be extremely long
# log_msg("dirsyncControls: %r\n" % self.dirsync_controls)
- modify_ldif = "dn: %s\n" % (self.cache_dn)
- modify_ldif += "changetype: modify\n"
- modify_ldif += "replace: dirsyncControl\n"
- modify_ldif += "dirsyncControl: %s\n" % (self.dirsync_controls[0])
- modify_ldif += "replace: currentTime\n"
- modify_ldif += "currentTime: %s\n" % ldb.timestring(int(time.time()))
+ modify_ldif = "dn: %s\n" % (self.cache_dn) +\
+ "changetype: modify\n" +\
+ "replace: dirsyncControl\n" +\
+ "dirsyncControl: %s\n" % (self.dirsync_controls[0]) +\
+ "replace: currentTime\n" +\
+ "currentTime: %s\n" % ldb.timestring(int(time.time()))
self.cache.modify_ldif(modify_ldif)
return
@@ -2163,18 +2161,18 @@ samba-tool user syncpasswords --terminate \\
expression="(objectClass=*)",
attrs=["lastCookie"])
if len(res) == 0:
- add_ldif = "dn: %s\n" % (dn)
- add_ldif += "objectClass: userCookie\n"
- add_ldif += "lastCookie: %s\n" % (lastCookie)
- add_ldif += "currentTime: %s\n" % ldb.timestring(int(time.time()))
+ add_ldif = "dn: %s\n" % (dn) +\
+ "objectClass: userCookie\n" +\
+ "lastCookie: %s\n" % (lastCookie) +\
+ "currentTime: %s\n" % ldb.timestring(int(time.time()))
self.cache.add_ldif(add_ldif)
else:
- modify_ldif = "dn: %s\n" % (dn)
- modify_ldif += "changetype: modify\n"
- modify_ldif += "replace: lastCookie\n"
- modify_ldif += "lastCookie: %s\n" % (lastCookie)
- modify_ldif += "replace: currentTime\n"
- modify_ldif += "currentTime: %s\n" % ldb.timestring(int(time.time()))
+ modify_ldif = "dn: %s\n" % (dn) +\
+ "changetype: modify\n" +\
+ "replace: lastCookie\n" +\
+ "lastCookie: %s\n" % (lastCookie) +\
+ "replace: currentTime\n" +\
+ "currentTime: %s\n" % ldb.timestring(int(time.time()))
self.cache.modify_ldif(modify_ldif)
self.cache.transaction_commit()
except Exception as e:
diff --git a/python/samba/schema.py b/python/samba/schema.py
index aedee82bb8f..caea7e358ae 100644
--- a/python/samba/schema.py
+++ b/python/samba/schema.py
@@ -111,9 +111,7 @@ class Schema(object):
setup_path('ad-schema/%s' % Schema.base_schemas[base_schema][1]))
if files is not None:
- for file in files:
- data = get_string(open(file, 'rb').read())
- self.schema_data += data
+ self.schema_data = "".join(get_string(open(file, 'rb').read()) for file in files)
self.schema_data = substitute_var(self.schema_data,
{"SCHEMADN": schemadn})
@@ -135,8 +133,7 @@ class Schema(object):
self.prefixmap_data = open(setup_path("prefixMap.txt"), 'rb').read()
if additional_prefixmap is not None:
- for map in additional_prefixmap:
- self.prefixmap_data += "%s\n" % map
+ self.prefixmap_data += "".join("%s\n" % map for map in additional_prefixmap)
self.prefixmap_data = b64encode(self.prefixmap_data).decode('utf8')
diff --git a/python/samba/tests/auth_log_winbind.py b/python/samba/tests/auth_log_winbind.py
index a390197fe7f..4f4beff1e32 100644
--- a/python/samba/tests/auth_log_winbind.py
+++ b/python/samba/tests/auth_log_winbind.py
@@ -94,8 +94,7 @@ class AuthLogTestsWinbind(AuthLogTestBase, BlackboxTestCase):
msgs = list(filter(is_sam_logon, self.dc_msgs))
if msgs:
for m in msgs:
- m += "\n"
- os.write(w1, get_bytes(m))
+ os.write(w1, get_bytes(m+"\n"))
else:
os.write(w1, get_bytes("None\n"))
--
Samba Shared Repository
More information about the samba-cvs
mailing list