diff options
Diffstat (limited to 'source4/scripting/python')
-rw-r--r-- | source4/scripting/python/samba/netcmd/ntacl.py | 3 | ||||
-rw-r--r-- | source4/scripting/python/samba/ntacls.py | 22 | ||||
-rw-r--r-- | source4/scripting/python/samba/provision.py | 8 | ||||
-rw-r--r-- | source4/scripting/python/samba/samdb.py | 9 |
4 files changed, 27 insertions, 15 deletions
diff --git a/source4/scripting/python/samba/netcmd/ntacl.py b/source4/scripting/python/samba/netcmd/ntacl.py index ebb66864d7..ea6bcb6e37 100644 --- a/source4/scripting/python/samba/netcmd/ntacl.py +++ b/source4/scripting/python/samba/netcmd/ntacl.py @@ -63,7 +63,8 @@ class cmd_acl_set(Command): creds = credopts.get_credentials(lp) creds.set_kerberos_state(DONT_USE_KERBEROS) try: - ldb = Ldb(path, session_info=system_session(), credentials=creds,lp=lp) + ldb = Ldb(path, session_info=system_session(), credentials=creds, + lp=lp) except: # XXX: Should catch a particular exception type raise CommandError("Unable to read domain SID from configuration files") diff --git a/source4/scripting/python/samba/ntacls.py b/source4/scripting/python/samba/ntacls.py index edcd643b2a..16e9463f09 100644 --- a/source4/scripting/python/samba/ntacls.py +++ b/source4/scripting/python/samba/ntacls.py @@ -41,29 +41,37 @@ def checkset_backend(lp,backend,eadbfile): def getntacl(lp, file, backend=None, eadbfile=None): checkset_backend(lp, backend, eadbfile) eadbname = lp.get("posix:eadb") - if eadbname != None and eadbname != "" : + if eadbname is not None and eadbname != "": try: - attribute = samba.xattr_tdb.wrap_getxattr(eadbname,file,xattr.XATTR_NTACL_NAME) + attribute = samba.xattr_tdb.wrap_getxattr(eadbname, file, + xattr.XATTR_NTACL_NAME) except: + # FIXME: Don't catch all exceptions, just those related to opening + # xattrdb print "Fail to open %s" % eadbname - attribute = samba.xattr_native.wrap_getxattr(file,xattr.XATTR_NTACL_NAME) + attribute = samba.xattr_native.wrap_getxattr(file, + xattr.XATTR_NTACL_NAME) else: - attribute = samba.xattr_native.wrap_getxattr(file,xattr.XATTR_NTACL_NAME) + attribute = samba.xattr_native.wrap_getxattr(file, + xattr.XATTR_NTACL_NAME) ntacl = ndr_unpack(xattr.NTACL,attribute) return ntacl def setntacl(lp, file, sddl, domsid, backend=None, eadbfile=None): - checkset_backend(lp,backend,eadbfile) + checkset_backend(lp, backend, eadbfile) ntacl=xattr.NTACL() ntacl.version = 1 sid=security.dom_sid(domsid) sd = security.descriptor.from_sddl(sddl, sid) ntacl.info = sd eadbname = lp.get("posix:eadb") - if eadbname != None and eadbname != "": + if eadbname is not None and eadbname != "": try: - 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: + # FIXME: Don't catch all exceptions, just those related to opening + # xattrdb print "Fail to open %s"%eadbname samba.xattr_native.wrap_setxattr(file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl)) else: diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 71c04cfef9..abbcf52210 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -269,7 +269,8 @@ def setup_ldb(ldb, ldif_path, subst_vars): except: ldb.transaction_cancel() raise - ldb.transaction_commit() + else: + ldb.transaction_commit() def provision_paths_from_lp(lp, dnsdomain): @@ -550,12 +551,11 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info, message("Setting up sam.ldb rootDSE") setup_samdb_rootdse(samdb, setup_path, names) - except: samdb.transaction_cancel() raise - - samdb.transaction_commit() + else: + samdb.transaction_commit() def secretsdb_self_join(secretsdb, domain, diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py index 0dcea72ad7..2f33c31c63 100644 --- a/source4/scripting/python/samba/samdb.py +++ b/source4/scripting/python/samba/samdb.py @@ -150,7 +150,8 @@ pwdLastSet: 0 except: self.transaction_cancel() raise - self.transaction_commit() + else: + self.transaction_commit() def setpassword(self, filter, password, force_change_at_next_login=False): """Sets the password for a user @@ -188,7 +189,8 @@ userPassword:: %s except: self.transaction_cancel() raise - self.transaction_commit() + else: + self.transaction_commit() def setexpiry(self, filter, expiry_seconds, no_expiry_req=False): """Sets the account expiry for a user @@ -227,7 +229,8 @@ accountExpires: %u except: self.transaction_cancel() raise - self.transaction_commit() + else: + self.transaction_commit() def set_domain_sid(self, sid): """Change the domain SID used by this LDB. |