diff options
Diffstat (limited to 'source4/scripting/python/samba/netcmd')
-rw-r--r-- | source4/scripting/python/samba/netcmd/__init__.py | 2 | ||||
-rw-r--r-- | source4/scripting/python/samba/netcmd/delegation.py | 6 | ||||
-rw-r--r-- | source4/scripting/python/samba/netcmd/domain.py | 20 | ||||
-rw-r--r-- | source4/scripting/python/samba/netcmd/fsmo.py | 2 | ||||
-rw-r--r-- | source4/scripting/python/samba/netcmd/gpo.py | 4 | ||||
-rw-r--r-- | source4/scripting/python/samba/netcmd/ldapcmp.py | 7 | ||||
-rw-r--r-- | source4/scripting/python/samba/netcmd/ntacl.py | 18 | ||||
-rw-r--r-- | source4/scripting/python/samba/netcmd/spn.py | 14 |
8 files changed, 35 insertions, 38 deletions
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py index 358167806a..c542dc61f5 100644 --- a/source4/scripting/python/samba/netcmd/__init__.py +++ b/source4/scripting/python/samba/netcmd/__init__.py @@ -158,7 +158,7 @@ class Command(object): undetermined_max_args = True else: max_args += 1 - if (len(args) < min_args) or (undetermined_max_args == False and len(args) > max_args): + if (len(args) < min_args) or (not undetermined_max_args and len(args) > max_args): parser.print_usage() return -1 diff --git a/source4/scripting/python/samba/netcmd/delegation.py b/source4/scripting/python/samba/netcmd/delegation.py index 25ae2028c4..8b2a1bccef 100644 --- a/source4/scripting/python/samba/netcmd/delegation.py +++ b/source4/scripting/python/samba/netcmd/delegation.py @@ -56,7 +56,7 @@ class cmd_delegation_show(Command): # to the correct domain (cleanedaccount, realm, domain) = _get_user_realm_domain(accountname) - res = sam.search(expression="sAMAccountName=%s" % + res = sam.search(expression="sAMAccountName=%s" % ldb.binary_encode(cleanedaccount), scope=ldb.SCOPE_SUBTREE, attrs=["userAccountControl", "msDS-AllowedToDelegateTo"]) @@ -189,7 +189,7 @@ class cmd_delegation_add_service(Command): # to the correct domain (cleanedaccount, realm, domain) = _get_user_realm_domain(accountname) - res = sam.search(expression="sAMAccountName=%s" % + res = sam.search(expression="sAMAccountName=%s" % ldb.binary_encode(cleanedaccount), scope=ldb.SCOPE_SUBTREE, attrs=["msDS-AllowedToDelegateTo"]) @@ -233,7 +233,7 @@ class cmd_delegation_del_service(Command): # to the correct domain (cleanedaccount, realm, domain) = _get_user_realm_domain(accountname) - res = sam.search(expression="sAMAccountName=%s" % + res = sam.search(expression="sAMAccountName=%s" % ldb.binary_encode(cleanedaccount), scope=ldb.SCOPE_SUBTREE, attrs=["msDS-AllowedToDelegateTo"]) diff --git a/source4/scripting/python/samba/netcmd/domain.py b/source4/scripting/python/samba/netcmd/domain.py index ba4165ac06..be591ea257 100644 --- a/source4/scripting/python/samba/netcmd/domain.py +++ b/source4/scripting/python/samba/netcmd/domain.py @@ -173,9 +173,9 @@ class cmd_domain_provision(Command): help="choose machine password (otherwise random)"), Option("--dns-backend", type="choice", metavar="NAMESERVER-BACKEND", choices=["SAMBA_INTERNAL", "BIND9_FLATFILE", "BIND9_DLZ", "NONE"], - help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " \ - "BIND9_FLATFILE uses bind9 text database to store zone information, " \ - "BIND9_DLZ uses samba4 AD to store zone information, " \ + help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " + "BIND9_FLATFILE uses bind9 text database to store zone information, " + "BIND9_DLZ uses samba4 AD to store zone information, " "NONE skips the DNS setup entirely (not recommended)", default="SAMBA_INTERNAL"), Option("--dnspass", type="string", metavar="PASSWORD", @@ -452,8 +452,8 @@ class cmd_domain_dcpromo(Command): action="store_true"), Option("--dns-backend", type="choice", metavar="NAMESERVER-BACKEND", choices=["SAMBA_INTERNAL", "BIND9_DLZ", "NONE"], - help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " \ - "BIND9_DLZ uses samba4 AD to store zone information, " \ + help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " + "BIND9_DLZ uses samba4 AD to store zone information, " "NONE skips the DNS setup entirely (this DC will not be a DNS server)", default="SAMBA_INTERNAL") ] @@ -518,8 +518,8 @@ class cmd_domain_join(Command): action="store_true"), Option("--dns-backend", type="choice", metavar="NAMESERVER-BACKEND", choices=["SAMBA_INTERNAL", "BIND9_DLZ", "NONE"], - help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " \ - "BIND9_DLZ uses samba4 AD to store zone information, " \ + help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " + "BIND9_DLZ uses samba4 AD to store zone information, " "NONE skips the DNS setup entirely (this DC will not be a DNS server)", default="SAMBA_INTERNAL") ] @@ -1223,9 +1223,9 @@ class cmd_domain_classicupgrade(Command): action="store_true"), Option("--dns-backend", type="choice", metavar="NAMESERVER-BACKEND", choices=["SAMBA_INTERNAL", "BIND9_FLATFILE", "BIND9_DLZ", "NONE"], - help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " \ - "BIND9_FLATFILE uses bind9 text database to store zone information, " \ - "BIND9_DLZ uses samba4 AD to store zone information, " \ + help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " + "BIND9_FLATFILE uses bind9 text database to store zone information, " + "BIND9_DLZ uses samba4 AD to store zone information, " "NONE skips the DNS setup entirely (this DC will not be a DNS server)", default="SAMBA_INTERNAL") ] diff --git a/source4/scripting/python/samba/netcmd/fsmo.py b/source4/scripting/python/samba/netcmd/fsmo.py index 86c69492b4..a6105882bb 100644 --- a/source4/scripting/python/samba/netcmd/fsmo.py +++ b/source4/scripting/python/samba/netcmd/fsmo.py @@ -256,7 +256,7 @@ all=all of the above"""), creds = credopts.get_credentials(lp, fallback_machine=True) samdb = SamDB(url=H, session_info=system_session(), - credentials=creds, lp=lp) + credentials=creds, lp=lp) if role == "all": transfer_role(self.outf, "rid", samdb) diff --git a/source4/scripting/python/samba/netcmd/gpo.py b/source4/scripting/python/samba/netcmd/gpo.py index d2d19e2b03..ee0de982b9 100644 --- a/source4/scripting/python/samba/netcmd/gpo.py +++ b/source4/scripting/python/samba/netcmd/gpo.py @@ -879,7 +879,7 @@ class cmd_create(Command): Option("--tmpdir", help="Temporary directory for copying policy files", type=str) ] - def run(self, displayname, H=None, tmpdir=None, sambaopts=None, credopts=None, + def run(self, displayname, H=None, tmpdir=None, sambaopts=None, credopts=None, versionopts=None): self.lp = sambaopts.get_loadparm() @@ -926,7 +926,7 @@ class cmd_create(Command): gpt_contents = "[General]\r\nVersion=0\r\n" file(os.path.join(gpodir, "GPT.INI"), "w").write(gpt_contents) except Exception, e: - raise CommandError("Error Creating GPO files", e) + raise CommandError("Error Creating GPO files", e) # Connect to DC over SMB [dom_name, service, sharepath] = parse_unc(unc_path) diff --git a/source4/scripting/python/samba/netcmd/ldapcmp.py b/source4/scripting/python/samba/netcmd/ldapcmp.py index ea4f930eaf..d4a2dde53e 100644 --- a/source4/scripting/python/samba/netcmd/ldapcmp.py +++ b/source4/scripting/python/samba/netcmd/ldapcmp.py @@ -28,14 +28,13 @@ import sys import samba import samba.getopt as options from samba import Ldb -from samba.ndr import ndr_pack, ndr_unpack +from samba.ndr import ndr_unpack from samba.dcerpc import security from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, ERR_NO_SUCH_OBJECT, LdbError from samba.netcmd import ( Command, CommandError, Option, - SuperCommand, ) global summary @@ -103,7 +102,7 @@ class LDAPBase(object): def find_servers(self): """ """ - res = self.ldb.search(base="OU=Domain Controllers,%s" % self.base_dn, \ + res = self.ldb.search(base="OU=Domain Controllers,%s" % self.base_dn, scope=SCOPE_SUBTREE, expression="(objectClass=computer)", attrs=["cn"]) assert len(res) > 0 srv = [] @@ -112,7 +111,7 @@ class LDAPBase(object): return srv def find_netbios(self): - res = self.ldb.search(base="CN=Partitions,%s" % self.config_dn, \ + res = self.ldb.search(base="CN=Partitions,%s" % self.config_dn, scope=SCOPE_SUBTREE, attrs=["nETBIOSName"]) assert len(res) > 0 for x in res: diff --git a/source4/scripting/python/samba/netcmd/ntacl.py b/source4/scripting/python/samba/netcmd/ntacl.py index e596ce9d70..edbcd7edc8 100644 --- a/source4/scripting/python/samba/netcmd/ntacl.py +++ b/source4/scripting/python/samba/netcmd/ntacl.py @@ -172,7 +172,7 @@ class cmd_ntacl_sysvolreset(Command): netlogon = lp.get("path", "netlogon") sysvol = lp.get("path", "sysvol") try: - samdb = SamDB(session_info=system_session(), + samdb = SamDB(session_info=system_session(), lp=lp) except Exception, e: raise CommandError("Unable to open samdb:", e) @@ -207,10 +207,10 @@ class cmd_ntacl_sysvolreset(Command): if use_ntvfs: logger.warning("Please note that POSIX permissions have NOT been changed, only the stored NT ACL") - + provision.setsysvolacl(samdb, netlogon, sysvol, - LA_uid, BA_gid, domain_sid, - lp.get("realm").lower(), samdb.domain_dn(), + LA_uid, BA_gid, domain_sid, + lp.get("realm").lower(), samdb.domain_dn(), lp, use_ntvfs=use_ntvfs) class cmd_ntacl_sysvolcheck(Command): @@ -223,8 +223,7 @@ class cmd_ntacl_sysvolcheck(Command): "versionopts": options.VersionOptions, } - def run(self, - credopts=None, sambaopts=None, versionopts=None): + def run(self, credopts=None, sambaopts=None, versionopts=None): lp = sambaopts.get_loadparm() path = lp.private_path("secrets.ldb") creds = credopts.get_credentials(lp) @@ -234,16 +233,15 @@ class cmd_ntacl_sysvolcheck(Command): netlogon = lp.get("path", "netlogon") sysvol = lp.get("path", "sysvol") try: - samdb = SamDB(session_info=system_session(), - lp=lp) + samdb = SamDB(session_info=system_session(), lp=lp) except Exception, e: raise CommandError("Unable to open samdb:", e) domain_sid = security.dom_sid(samdb.domain_sid) provision.checksysvolacl(samdb, netlogon, sysvol, - domain_sid, - lp.get("realm").lower(), samdb.domain_dn(), + domain_sid, + lp.get("realm").lower(), samdb.domain_dn(), lp) diff --git a/source4/scripting/python/samba/netcmd/spn.py b/source4/scripting/python/samba/netcmd/spn.py index 79fa69912e..564fd5920c 100644 --- a/source4/scripting/python/samba/netcmd/spn.py +++ b/source4/scripting/python/samba/netcmd/spn.py @@ -60,7 +60,7 @@ class cmd_spn_list(Command): spns = res[0].get("servicePrincipalName") found = False flag = ldb.FLAG_MOD_ADD - if spns != None: + if spns is not None: self.outf.write( "User %s has the following servicePrincipalName: \n" % res[0].dn) @@ -84,7 +84,7 @@ class cmd_spn_add(Command): "versionopts": options.VersionOptions, } takes_options = [ - Option("--force", help="Force the addition of the spn"\ + Option("--force", help="Force the addition of the spn" " even it exists already", action="store_true"), ] takes_args = ["name", "user"] @@ -99,7 +99,7 @@ class cmd_spn_add(Command): res = sam.search( expression="servicePrincipalName=%s" % ldb.binary_encode(name), scope=ldb.SCOPE_SUBTREE) - if len(res) != 0 and not force: + if len(res) != 0 and not force: raise CommandError("Service principal %s already" " affected to another user" % name) @@ -114,7 +114,7 @@ class cmd_spn_add(Command): tab = [] found = False flag = ldb.FLAG_MOD_ADD - if spns != None: + if spns is not None: for e in spns: if str(e) == name: found = True @@ -172,8 +172,8 @@ class cmd_spn_delete(Command): listUser = "" for r in res: listUser = "%s\n%s" % (listUser, str(r.dn)) - raise CommandError("More than one user has the spn %s "\ - "and no specific user was specified, list of users"\ + raise CommandError("More than one user has the spn %s " + "and no specific user was specified, list of users" " with this spn:%s" % (name, listUser)) else: result=res[0] @@ -182,7 +182,7 @@ class cmd_spn_delete(Command): msg = ldb.Message() spns = result.get("servicePrincipalName") tab = [] - if spns != None: + if spns is not None: for e in spns: if str(e) != name: tab.append(str(e)) |