mirror of
https://github.com/samba-team/samba.git
synced 2025-07-31 20:22:15 +03:00
More formatting fixes, pointed out by pylint.
This commit is contained in:
@ -145,17 +145,20 @@ class Ldb(ldb.Ldb):
|
||||
try:
|
||||
res = self.search(base=dn, scope=ldb.SCOPE_SUBTREE, attrs=[],
|
||||
expression="(|(objectclass=user)(objectclass=computer))")
|
||||
except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
|
||||
# Ignore no such object errors
|
||||
return
|
||||
pass
|
||||
except ldb.LdbError, (errno, _):
|
||||
if errno == ldb.ERR_NO_SUCH_OBJECT:
|
||||
# Ignore no such object errors
|
||||
return
|
||||
else:
|
||||
raise
|
||||
|
||||
try:
|
||||
for msg in res:
|
||||
self.delete(msg.dn)
|
||||
except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
|
||||
# Ignore no such object errors
|
||||
return
|
||||
except ldb.LdbError, (errno, _):
|
||||
if errno != ldb.ERR_NO_SUCH_OBJECT:
|
||||
# Ignore no such object errors
|
||||
raise
|
||||
|
||||
def erase_except_schema_controlled(self):
|
||||
"""Erase this ldb, removing all records, except those that are controlled by Samba4's schema."""
|
||||
@ -171,9 +174,10 @@ class Ldb(ldb.Ldb):
|
||||
[], controls=["show_deleted:0"]):
|
||||
try:
|
||||
self.delete(msg.dn)
|
||||
except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
|
||||
# Ignore no such object errors
|
||||
pass
|
||||
except ldb.LdbError, (errno, _):
|
||||
if errno != ldb.ERR_NO_SUCH_OBJECT:
|
||||
# Ignore no such object errors
|
||||
raise
|
||||
|
||||
res = self.search(basedn, ldb.SCOPE_SUBTREE,
|
||||
"(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))",
|
||||
@ -185,9 +189,10 @@ class Ldb(ldb.Ldb):
|
||||
"@OPTIONS", "@PARTITION", "@KLUDGEACL"]:
|
||||
try:
|
||||
self.delete(attr)
|
||||
except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
|
||||
# Ignore missing dn errors
|
||||
pass
|
||||
except ldb.LdbError, (errno, _):
|
||||
if errno != ldb.ERR_NO_SUCH_OBJECT:
|
||||
# Ignore missing dn errors
|
||||
raise
|
||||
|
||||
def erase(self):
|
||||
"""Erase this ldb, removing all records."""
|
||||
@ -198,9 +203,10 @@ class Ldb(ldb.Ldb):
|
||||
for attr in ["@INDEXLIST", "@ATTRIBUTES"]:
|
||||
try:
|
||||
self.delete(attr)
|
||||
except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
|
||||
# Ignore missing dn errors
|
||||
pass
|
||||
except ldb.LdbError, (errno, _):
|
||||
if errno != ldb.ERR_NO_SUCH_OBJECT
|
||||
# Ignore missing dn errors
|
||||
raise
|
||||
|
||||
def erase_partitions(self):
|
||||
"""Erase an ldb, removing all records."""
|
||||
@ -209,18 +215,20 @@ class Ldb(ldb.Ldb):
|
||||
try:
|
||||
res = self.search(base=dn, scope=ldb.SCOPE_ONELEVEL, attrs=[],
|
||||
controls=["show_deleted:0"])
|
||||
except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
|
||||
# Ignore no such object errors
|
||||
return
|
||||
except ldb.LdbError, (errno, _):
|
||||
if errno == ldb.ERR_NO_SUCH_OBJECT:
|
||||
# Ignore no such object errors
|
||||
return
|
||||
|
||||
for msg in res:
|
||||
erase_recursive(self, msg.dn)
|
||||
|
||||
try:
|
||||
self.delete(dn)
|
||||
except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
|
||||
# Ignore no such object errors
|
||||
pass
|
||||
except ldb.LdbError, (errno, _):
|
||||
if errno != ldb.ERR_NO_SUCH_OBJECT:
|
||||
# Ignore no such object errors
|
||||
raise
|
||||
|
||||
res = self.search("", ldb.SCOPE_BASE, "(objectClass=*)",
|
||||
["namingContexts"])
|
||||
|
@ -25,9 +25,9 @@ __docformat__ = "restructuredText"
|
||||
import ldb
|
||||
|
||||
def messageEltFlagToString(flag):
|
||||
if flag == ldb.FLAG_MOD_ADD:
|
||||
return "MOD_ADD"
|
||||
elif flag == ldb.FLAG_MOD_REPLACE:
|
||||
return "MOD_REPLACE"
|
||||
elif flag == ldb.FLAG_MOD_DELETE:
|
||||
return "MOD_DELETE"
|
||||
if flag == ldb.FLAG_MOD_ADD:
|
||||
return "MOD_ADD"
|
||||
elif flag == ldb.FLAG_MOD_REPLACE:
|
||||
return "MOD_REPLACE"
|
||||
elif flag == ldb.FLAG_MOD_DELETE:
|
||||
return "MOD_DELETE"
|
||||
|
@ -52,7 +52,7 @@ def getntacl(lp, file, backend=None, eadbfile=None):
|
||||
ntacl = ndr_unpack(xattr.NTACL,attribute)
|
||||
return ntacl
|
||||
|
||||
def setntacl(lp,file,sddl,domsid,backend=None,eadbfile=None):
|
||||
def setntacl(lp, file, sddl, domsid, backend=None, eadbfile=None):
|
||||
checkset_backend(lp,backend,eadbfile)
|
||||
ntacl=xattr.NTACL()
|
||||
ntacl.version = 1
|
||||
@ -62,12 +62,12 @@ def setntacl(lp,file,sddl,domsid,backend=None,eadbfile=None):
|
||||
eadbname = lp.get("posix:eadb")
|
||||
if eadbname != None and eadbname != "":
|
||||
try:
|
||||
attribute = samba.xattr_tdb.wrap_setxattr(eadbname,file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
|
||||
samba.xattr_tdb.wrap_setxattr(eadbname,file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
|
||||
except:
|
||||
print "Fail to open %s"%eadbname
|
||||
attribute = samba.xattr_native.wrap_setxattr(file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
|
||||
samba.xattr_native.wrap_setxattr(file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
|
||||
else:
|
||||
attribute = samba.xattr_native.wrap_setxattr(file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
|
||||
samba.xattr_native.wrap_setxattr(file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
|
||||
|
||||
def ldapmask2filemask(ldm):
|
||||
"""Takes the access mask of a DS ACE and transform them in a File ACE mask"""
|
||||
@ -138,7 +138,7 @@ def dsacl2fsacl(dssddl, domsid):
|
||||
fdescr.revision = ref.revision
|
||||
fdescr.sacl = ref.sacl
|
||||
aces = ref.dacl.aces
|
||||
for i in range(0,len(aces)):
|
||||
for i in range(0, len(aces)):
|
||||
ace = aces[i]
|
||||
if not ace.type & security.SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT and str(ace.trustee) != security.SID_BUILTIN_PREW2K:
|
||||
# if fdescr.type & security.SEC_DESC_DACL_AUTO_INHERITED:
|
||||
|
@ -602,7 +602,7 @@ def secretsdb_self_join(secretsdb, domain,
|
||||
"privateKeytab"]
|
||||
|
||||
|
||||
msg = ldb.Message(ldb.Dn(secretsdb, "flatname=%s,cn=Primary Domains" % domain));
|
||||
msg = ldb.Message(ldb.Dn(secretsdb, "flatname=%s,cn=Primary Domains" % domain))
|
||||
msg["secureChannelType"] = str(secure_channel_type)
|
||||
msg["flatname"] = [domain]
|
||||
msg["objectClass"] = ["top", "primaryDomain"]
|
||||
@ -613,7 +613,7 @@ def secretsdb_self_join(secretsdb, domain,
|
||||
msg["realm"] = realm
|
||||
msg["saltPrincipal"] = "host/%s.%s@%s" % (netbiosname.lower(), dnsdomain.lower(), realm.upper())
|
||||
msg["msDS-KeyVersionNumber"] = [str(key_version_number)]
|
||||
msg["privateKeytab"] = ["secrets.keytab"];
|
||||
msg["privateKeytab"] = ["secrets.keytab"]
|
||||
|
||||
|
||||
msg["secret"] = [machinepass]
|
||||
@ -971,7 +971,7 @@ def setup_samdb(path, setup_path, session_info, provision_backend, lp,
|
||||
setup_add_ldif(samdb, setup_path("aggregate_schema.ldif"),
|
||||
{"SCHEMADN": names.schemadn})
|
||||
|
||||
message("Reopening sam.ldb with new schema");
|
||||
message("Reopening sam.ldb with new schema")
|
||||
samdb.transaction_commit()
|
||||
samdb = Ldb(session_info=admin_session_info,
|
||||
credentials=provision_backend.credentials, lp=lp)
|
||||
|
@ -119,7 +119,7 @@ class ExistingBackend(ProvisionBackend):
|
||||
def init(self):
|
||||
#Check to see that this 'existing' LDAP backend in fact exists
|
||||
ldapi_db = Ldb(self.ldapi_uri, credentials=self.credentials)
|
||||
search_ol_rootdse = ldapi_db.search(base="", scope=SCOPE_BASE,
|
||||
ldapi_db.search(base="", scope=SCOPE_BASE,
|
||||
expression="(objectClass=OpenLDAProotDSE)")
|
||||
|
||||
# If we have got here, then we must have a valid connection to the LDAP server, with valid credentials supplied
|
||||
@ -170,7 +170,7 @@ class LDAPBackend(ProvisionBackend):
|
||||
try:
|
||||
ldapi_db = Ldb(self.ldapi_uri)
|
||||
ldapi_db.search(base="", scope=SCOPE_BASE,
|
||||
expression="(objectClass=OpenLDAProotDSE)");
|
||||
expression="(objectClass=OpenLDAProotDSE)")
|
||||
try:
|
||||
f = open(self.paths.slapdpid, "r")
|
||||
p = f.read()
|
||||
@ -204,7 +204,7 @@ class LDAPBackend(ProvisionBackend):
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
self.schema.write_to_tmp_ldb(schemadb_path);
|
||||
self.schema.write_to_tmp_ldb(schemadb_path)
|
||||
|
||||
self.credentials = Credentials()
|
||||
self.credentials.guess(self.lp)
|
||||
@ -243,7 +243,6 @@ class LDAPBackend(ProvisionBackend):
|
||||
return
|
||||
except LdbError:
|
||||
time.sleep(1)
|
||||
pass
|
||||
|
||||
raise ProvisioningError("slapd died before we could make a connection to it")
|
||||
|
||||
@ -297,7 +296,7 @@ class OpenLDAPBackend(LDAPBackend):
|
||||
self.domainsid,
|
||||
schemadn=self.names.schemadn,
|
||||
serverdn=self.names.serverdn,
|
||||
files=[setup_path("schema_samba4.ldif")]);
|
||||
files=[setup_path("schema_samba4.ldif")])
|
||||
|
||||
def provision(self):
|
||||
# Wipe the directories so we can start
|
||||
@ -674,7 +673,7 @@ class FDSBackend(LDAPBackend):
|
||||
fedora_ds_dir = os.path.join(self.paths.ldapdir, "slapd-samba4")
|
||||
shutil.rmtree(fedora_ds_dir, True)
|
||||
|
||||
self.slapd_provision_command = [self.slapd_path, "-D", fedora_ds_dir, "-i", self.paths.slapdpid];
|
||||
self.slapd_provision_command = [self.slapd_path, "-D", fedora_ds_dir, "-i", self.paths.slapdpid]
|
||||
#In the 'provision' command line, stay in the foreground so we can easily kill it
|
||||
self.slapd_provision_command.append("-d0")
|
||||
|
||||
|
@ -229,5 +229,5 @@ accountExpires: %u
|
||||
except:
|
||||
self.transaction_cancel()
|
||||
raise
|
||||
self.transaction_commit();
|
||||
self.transaction_commit()
|
||||
|
||||
|
@ -62,6 +62,7 @@ class FindNssTests(unittest.TestCase):
|
||||
|
||||
|
||||
class Disabled(object):
|
||||
|
||||
def test_setup_templatesdb(self):
|
||||
raise NotImplementedError(self.test_setup_templatesdb)
|
||||
|
||||
|
@ -27,7 +27,6 @@ import string
|
||||
import re
|
||||
import shutil
|
||||
|
||||
import samba
|
||||
from samba import Ldb, DS_DOMAIN_FUNCTION_2000
|
||||
from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE
|
||||
import ldb
|
||||
|
Reference in New Issue
Block a user