The branch, master has been updated via c0d4f24 s4-python: Formatting fixes, break lines. via 0ff2ea5 samba.netcmd: Formatting fixes, break lines. via ebcb6a7 samba.provision.common: Fix formatting. via cd7dcf4 samba.provision.sambadns: Fix formatting. via 8581359 samba.provision.backend: Fix formatting. via fdb873a samba.provision: Fix formatting, NameErrors. from 520c9b0 replace: add some includes for poll.h
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit c0d4f2462f75e0bc0545402b76984b4e6fcb13f1 Author: Jelmer Vernooij <jel...@samba.org> Date: Sun Sep 16 14:18:51 2012 +0200 s4-python: Formatting fixes, break lines. Autobuild-User(master): Jelmer Vernooij <jel...@samba.org> Autobuild-Date(master): Sun Sep 16 15:58:04 CEST 2012 on sn-devel-104 commit 0ff2ea56d97cd8df7abeea8e819d7ec0bfd5b886 Author: Jelmer Vernooij <jel...@samba.org> Date: Sun Sep 16 14:18:39 2012 +0200 samba.netcmd: Formatting fixes, break lines. commit ebcb6a744791478bfc4be0b94733ace540ab06bc Author: Jelmer Vernooij <jel...@samba.org> Date: Sun Sep 16 00:34:14 2012 +0200 samba.provision.common: Fix formatting. commit cd7dcf4571b321f39eda07c489dd16833d8d4185 Author: Jelmer Vernooij <jel...@samba.org> Date: Sun Sep 16 00:34:00 2012 +0200 samba.provision.sambadns: Fix formatting. commit 858135920d54662a06252deac4dbf9191a251018 Author: Jelmer Vernooij <jel...@samba.org> Date: Sun Sep 16 00:33:09 2012 +0200 samba.provision.backend: Fix formatting. commit fdb873a203695f0b208967a561424c0357374e5b Author: Jelmer Vernooij <jel...@samba.org> Date: Sun Sep 16 00:32:52 2012 +0200 samba.provision: Fix formatting, NameErrors. ----------------------------------------------------------------------- Summary of changes: source4/scripting/python/samba/idmap.py | 2 - source4/scripting/python/samba/join.py | 51 +++--- .../scripting/python/samba/netcmd/delegation.py | 20 ++- source4/scripting/python/samba/netcmd/dns.py | 137 +++++++-------- source4/scripting/python/samba/netcmd/domain.py | 164 +++++++++--------- source4/scripting/python/samba/netcmd/sites.py | 5 +- source4/scripting/python/samba/netcmd/spn.py | 31 ++-- source4/scripting/python/samba/netcmd/testparm.py | 20 ++- source4/scripting/python/samba/netcmd/time.py | 3 +- source4/scripting/python/samba/netcmd/user.py | 23 ++- .../scripting/python/samba/provision/__init__.py | 148 +++++++++------- .../scripting/python/samba/provision/backend.py | 1 + source4/scripting/python/samba/provision/common.py | 2 - .../scripting/python/samba/provision/sambadns.py | 183 ++++++++++++++------ source4/scripting/python/samba/samba3/__init__.py | 5 + source4/scripting/python/samba/samdb.py | 1 - source4/scripting/python/samba/sd_utils.py | 9 +- source4/scripting/python/samba/tests/dns.py | 5 +- source4/scripting/python/samba/tests/gensec.py | 2 +- source4/scripting/python/samba/tests/hostconfig.py | 4 +- source4/scripting/python/samba/tests/messaging.py | 2 +- source4/scripting/python/samba/tests/posixacl.py | 6 +- source4/scripting/python/samba/tests/provision.py | 12 +- source4/scripting/python/samba/tests/registry.py | 2 +- source4/scripting/python/samba/tests/samba3.py | 1 + source4/scripting/python/samba/upgrade.py | 17 ++- 26 files changed, 485 insertions(+), 371 deletions(-) Changeset truncated at 500 lines: diff --git a/source4/scripting/python/samba/idmap.py b/source4/scripting/python/samba/idmap.py index b651b20..0cb729f 100644 --- a/source4/scripting/python/samba/idmap.py +++ b/source4/scripting/python/samba/idmap.py @@ -96,5 +96,3 @@ cn: %s """ % (sid, unixid, sid, type_string, sid) self.add(self.parse_ldif(mod).next()[1]) - - diff --git a/source4/scripting/python/samba/join.py b/source4/scripting/python/samba/join.py index ac822fb..5ddc5db 100644 --- a/source4/scripting/python/samba/join.py +++ b/source4/scripting/python/samba/join.py @@ -44,7 +44,7 @@ class DCJoinException(Exception): class dc_join(object): - '''perform a DC join''' + """Perform a DC join.""" def __init__(ctx, server=None, creds=None, lp=None, site=None, netbios_name=None, targetdir=None, domain=None, @@ -166,7 +166,7 @@ class dc_join(object): pass def cleanup_old_join(ctx): - '''remove any DNs from a previous join''' + """Remove any DNs from a previous join.""" try: # find the krbtgt link print("checking sAMAccountName") @@ -219,7 +219,7 @@ class dc_join(object): pass def promote_possible(ctx): - '''confirm that the account is just a bare NT4 BDC or a member server, so can be safely promoted''' + """confirm that the account is just a bare NT4 BDC or a member server, so can be safely promoted""" if ctx.subdomain: # This shouldn't happen raise Exception("Can not promote into a subdomain") @@ -233,12 +233,12 @@ class dc_join(object): raise Exception("Account '%s' appears to be an active DC, use 'samba-tool domain join' if you must re-create this account" % ctx.samname) if (int(res[0]["userAccountControl"][0]) & (samba.dsdb.UF_WORKSTATION_TRUST_ACCOUNT|samba.dsdb.UF_SERVER_TRUST_ACCOUNT) == 0): raise Exception("Account %s is not a domain member or a bare NT4 BDC, use 'samba-tool domain join' instead'" % ctx.samname) - + ctx.promote_from_dn = res[0].dn def find_dc(ctx, domain): - '''find a writeable DC for the given domain''' + """find a writeable DC for the given domain""" try: ctx.cldap_ret = ctx.net.finddc(domain=domain, flags=nbt.NBT_SERVER_LDAP | nbt.NBT_SERVER_DS | nbt.NBT_SERVER_WRITABLE) except Exception: @@ -484,7 +484,7 @@ class dc_join(object): rec["msDS-NeverRevealGroup"] = ctx.never_reveal_sid elif ctx.promote_existing: rec["msDS-NeverRevealGroup"] = [] - + if ctx.reveal_sid: rec["msDS-RevealOnDemandGroup"] = ctx.reveal_sid elif ctx.promote_existing: @@ -579,7 +579,7 @@ class dc_join(object): ctx.samdb.modify(m) def join_add_objects2(ctx): - '''add the various objects needed for the join, for subdomains post replication''' + """add the various objects needed for the join, for subdomains post replication""" print "Adding %s" % ctx.partition_dn # NOTE: windows sends a ntSecurityDescriptor here, we @@ -638,7 +638,7 @@ class dc_join(object): replica_flags=drsuapi.DRSUAPI_DRS_WRIT_REP) def join_provision(ctx): - '''provision the local SAM''' + """Provision the local SAM.""" print "Calling bare provision" @@ -662,7 +662,7 @@ class dc_join(object): ctx.names = presult.names def join_provision_own_domain(ctx): - '''provision the local SAM''' + """Provision the local SAM.""" # we now operate exclusively on the local database, which # we need to reopen in order to get the newly created schema @@ -697,7 +697,7 @@ class dc_join(object): print("Provision OK for domain %s" % ctx.names.dnsdomain) def join_replicate(ctx): - '''replicate the SAM''' + """Replicate the SAM.""" print "Starting replication" ctx.local_samdb.transaction_start() @@ -790,7 +790,7 @@ class dc_join(object): ctx.drsuapi.DsReplicaUpdateRefs(ctx.drsuapi_handle, 1, r) def join_finalise(ctx): - '''finalise the join, mark us synchronised and setup secrets db''' + """Finalise the join, mark us synchronised and setup secrets db.""" logger = logging.getLogger("provision") logger.addHandler(logging.StreamHandler(sys.stdout)) @@ -858,7 +858,7 @@ class dc_join(object): targetdir=ctx.targetdir) def join_setup_trusts(ctx): - '''provision the local SAM''' + """provision the local SAM.""" def arcfour_encrypt(key, data): from Crypto.Cipher import ARC4 @@ -988,7 +988,7 @@ class dc_join(object): ctx.promote_possible() else: ctx.cleanup_old_join() - + try: ctx.join_add_objects() ctx.join_provision() @@ -1008,7 +1008,7 @@ def join_RODC(server=None, creds=None, lp=None, site=None, netbios_name=None, targetdir=None, domain=None, domain_critical_only=False, machinepass=None, use_ntvfs=False, dns_backend=None, promote_existing=False): - """join as a RODC""" + """Join as a RODC.""" ctx = dc_join(server, creds, lp, site, netbios_name, targetdir, domain, machinepass, use_ntvfs, dns_backend, promote_existing) @@ -1022,11 +1022,12 @@ def join_RODC(server=None, creds=None, lp=None, site=None, netbios_name=None, ctx.krbtgt_dn = "CN=krbtgt_%s,CN=Users,%s" % (ctx.myname, ctx.base_dn) # setup some defaults for accounts that should be replicated to this RODC - ctx.never_reveal_sid = [ "<SID=%s-%s>" % (ctx.domsid, security.DOMAIN_RID_RODC_DENY), - "<SID=%s>" % security.SID_BUILTIN_ADMINISTRATORS, - "<SID=%s>" % security.SID_BUILTIN_SERVER_OPERATORS, - "<SID=%s>" % security.SID_BUILTIN_BACKUP_OPERATORS, - "<SID=%s>" % security.SID_BUILTIN_ACCOUNT_OPERATORS ] + ctx.never_reveal_sid = [ + "<SID=%s-%s>" % (ctx.domsid, security.DOMAIN_RID_RODC_DENY), + "<SID=%s>" % security.SID_BUILTIN_ADMINISTRATORS, + "<SID=%s>" % security.SID_BUILTIN_SERVER_OPERATORS, + "<SID=%s>" % security.SID_BUILTIN_BACKUP_OPERATORS, + "<SID=%s>" % security.SID_BUILTIN_ACCOUNT_OPERATORS] ctx.reveal_sid = "<SID=%s-%s>" % (ctx.domsid, security.DOMAIN_RID_RODC_ALLOW) mysid = ctx.get_mysid() @@ -1055,7 +1056,6 @@ def join_RODC(server=None, creds=None, lp=None, site=None, netbios_name=None, ctx.do_join() - print "Joined domain %s (SID %s) as an RODC" % (ctx.domain_name, ctx.domsid) @@ -1063,7 +1063,7 @@ def join_DC(server=None, creds=None, lp=None, site=None, netbios_name=None, targetdir=None, domain=None, domain_critical_only=False, machinepass=None, use_ntvfs=False, dns_backend=None, promote_existing=False): - """join as a DC""" + """Join as a DC.""" ctx = dc_join(server, creds, lp, site, netbios_name, targetdir, domain, machinepass, use_ntvfs, dns_backend, promote_existing) @@ -1090,10 +1090,11 @@ def join_DC(server=None, creds=None, lp=None, site=None, netbios_name=None, ctx.do_join() print "Joined domain %s (SID %s) as a DC" % (ctx.domain_name, ctx.domsid) -def join_subdomain(server=None, creds=None, lp=None, site=None, netbios_name=None, - targetdir=None, parent_domain=None, dnsdomain=None, netbios_domain=None, - machinepass=None, use_ntvfs=False, dns_backend=None): - """join as a DC""" +def join_subdomain(server=None, creds=None, lp=None, site=None, + netbios_name=None, targetdir=None, parent_domain=None, dnsdomain=None, + netbios_domain=None, machinepass=None, use_ntvfs=False, + dns_backend=None): + """Join as a DC.""" ctx = dc_join(server, creds, lp, site, netbios_name, targetdir, parent_domain, machinepass, use_ntvfs, dns_backend) ctx.subdomain = True diff --git a/source4/scripting/python/samba/netcmd/delegation.py b/source4/scripting/python/samba/netcmd/delegation.py index 7296624..25ae202 100644 --- a/source4/scripting/python/samba/netcmd/delegation.py +++ b/source4/scripting/python/samba/netcmd/delegation.py @@ -55,7 +55,7 @@ class cmd_delegation_show(Command): # TODO once I understand how, use the domain info to naildown # to the correct domain (cleanedaccount, realm, domain) = _get_user_realm_domain(accountname) - + res = sam.search(expression="sAMAccountName=%s" % ldb.binary_encode(cleanedaccount), scope=ldb.SCOPE_SUBTREE, @@ -63,7 +63,7 @@ class cmd_delegation_show(Command): if len(res) == 0: raise CommandError("Unable to find account name '%s'" % accountname) assert(len(res) == 1) - + uac = int(res[0].get("userAccountControl")[0]) allowed = res[0].get("msDS-AllowedToDelegateTo") @@ -91,7 +91,8 @@ class cmd_delegation_for_any_service(Command): takes_args = ["accountname", "onoff"] - def run(self, accountname, onoff, credopts=None, sambaopts=None, versionopts=None): + def run(self, accountname, onoff, credopts=None, sambaopts=None, + versionopts=None): on = False if onoff == "on": @@ -133,7 +134,8 @@ class cmd_delegation_for_any_protocol(Command): takes_args = ["accountname", "onoff"] - def run(self, accountname, onoff, credopts=None, sambaopts=None, versionopts=None): + def run(self, accountname, onoff, credopts=None, sambaopts=None, + versionopts=None): on = False if onoff == "on": @@ -175,7 +177,8 @@ class cmd_delegation_add_service(Command): takes_args = ["accountname", "principal"] - def run(self, accountname, principal, credopts=None, sambaopts=None, versionopts=None): + def run(self, accountname, principal, credopts=None, sambaopts=None, + versionopts=None): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) @@ -192,7 +195,7 @@ class cmd_delegation_add_service(Command): attrs=["msDS-AllowedToDelegateTo"]) if len(res) == 0: raise CommandError("Unable to find account name '%s'" % accountname) - assert(len(res) == 1) + assert(len(res) == 1) msg = ldb.Message() msg.dn = res[0].dn @@ -218,7 +221,8 @@ class cmd_delegation_del_service(Command): takes_args = ["accountname", "principal"] - def run(self, accountname, principal, credopts=None, sambaopts=None, versionopts=None): + def run(self, accountname, principal, credopts=None, sambaopts=None, + versionopts=None): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) @@ -235,7 +239,7 @@ class cmd_delegation_del_service(Command): attrs=["msDS-AllowedToDelegateTo"]) if len(res) == 0: raise CommandError("Unable to find account name '%s'" % accountname) - assert(len(res) == 1) + assert(len(res) == 1) msg = ldb.Message() msg.dn = res[0].dn diff --git a/source4/scripting/python/samba/netcmd/dns.py b/source4/scripting/python/samba/netcmd/dns.py index 8a79de0..b227e96 100644 --- a/source4/scripting/python/samba/netcmd/dns.py +++ b/source4/scripting/python/samba/netcmd/dns.py @@ -35,6 +35,7 @@ def dns_connect(server, lp, creds): dns_conn = dnsserver.dnsserver(binding_str, lp, creds) return dns_conn + def bool_string(flag): if flag == 0: ret = 'FALSE' @@ -44,6 +45,7 @@ def bool_string(flag): ret = 'UNKNOWN (0x%x)' % flag return ret + def enum_string(module, enum_defs, value): ret = None for e in enum_defs: @@ -54,6 +56,7 @@ def enum_string(module, enum_defs, value): ret = 'UNKNOWN (0x%x)' % value return ret + def bitmap_string(module, bitmap_defs, value): ret = '' for b in bitmap_defs: @@ -63,42 +66,50 @@ def bitmap_string(module, bitmap_defs, value): ret = 'NONE' return ret + def boot_method_string(boot_method): enum_defs = [ 'DNS_BOOT_METHOD_UNINITIALIZED', 'DNS_BOOT_METHOD_FILE', 'DNS_BOOT_METHOD_REGISTRY', 'DNS_BOOT_METHOD_DIRECTORY' ] return enum_string(dnsserver, enum_defs, boot_method) + def name_check_flag_string(check_flag): enum_defs = [ 'DNS_ALLOW_RFC_NAMES_ONLY', 'DNS_ALLOW_NONRFC_NAMES', 'DNS_ALLOW_MULTIBYTE_NAMES', 'DNS_ALLOW_ALL_NAMES' ] return enum_string(dnsserver, enum_defs, check_flag) + def zone_type_string(zone_type): enum_defs = [ 'DNS_ZONE_TYPE_CACHE', 'DNS_ZONE_TYPE_PRIMARY', 'DNS_ZONE_TYPE_SECONDARY', 'DNS_ZONE_TYPE_STUB', 'DNS_ZONE_TYPE_FORWARDER', 'DNS_ZONE_TYPE_SECONDARY_CACHE' ] return enum_string(dnsp, enum_defs, zone_type) + def zone_update_string(zone_update): enum_defs = [ 'DNS_ZONE_UPDATE_OFF', 'DNS_ZONE_UPDATE_SECURE', 'DNS_ZONE_UPDATE_SECURE' ] return enum_string(dnsp, enum_defs, zone_update) + def zone_secondary_security_string(security): enum_defs = [ 'DNS_ZONE_SECSECURE_NO_SECURITY', 'DNS_ZONE_SECSECURE_NS_ONLY', 'DNS_ZONE_SECSECURE_LIST_ONLY', 'DNS_ZONE_SECSECURE_NO_XFER' ] return enum_string(dnsserver, enum_defs, security) + def zone_notify_level_string(notify_level): enum_defs = [ 'DNS_ZONE_NOTIFY_OFF', 'DNS_ZONE_NOTIFY_ALL_SECONDARIES', 'DNS_ZONE_NOTIFY_LIST_ONLY' ] return enum_string(dnsserver, enum_defs, notify_level) + def dp_flags_string(dp_flags): bitmap_defs = [ 'DNS_DP_AUTOCREATED', 'DNS_DP_LEGACY', 'DNS_DP_DOMAIN_DEFAULT', 'DNS_DP_FOREST_DEFAULT', 'DNS_DP_ENLISTED', 'DNS_DP_DELETED' ] return bitmap_string(dnsserver, bitmap_defs, dp_flags) + def zone_flags_string(flags): bitmap_defs = [ 'DNS_RPC_ZONE_PAUSED', 'DNS_RPC_ZONE_SHUTDOWN', 'DNS_RPC_ZONE_REVERSE', 'DNS_RPC_ZONE_AUTOCREATED', @@ -107,6 +118,7 @@ def zone_flags_string(flags): 'DNS_RPC_ZONE_READONLY'] return bitmap_string(dnsserver, bitmap_defs, flags) + def ip4_array_string(array): ret = [] if not array: @@ -116,6 +128,7 @@ def ip4_array_string(array): ret.append(addr) return ret + def dns_addr_array_string(array): ret = [] if not array: @@ -132,6 +145,7 @@ def dns_addr_array_string(array): ret.append(addr) return ret + def dns_type_flag(rec_type): rtype = rec_type.upper() if rtype == 'A': @@ -158,6 +172,7 @@ def dns_type_flag(rec_type): raise CommandError('Unknown type of DNS record %s' % rec_type) return record_type + def dns_client_version(cli_version): version = cli_version.upper() if version == 'W2K': @@ -170,6 +185,7 @@ def dns_client_version(cli_version): raise CommandError('Unknown client version %s' % cli_version) return client_version + def print_serverinfo(outf, typeid, serverinfo): outf.write(' dwVersion : 0x%x\n' % serverinfo.dwVersion) outf.write(' fBootMethod : %s\n' % boot_method_string(serverinfo.fBootMethod)) @@ -384,7 +400,9 @@ class ARecord(dnsserver.DNS_RPC_RECORD): self._ip_addr = ip_addr[:] self.data = self._ip_addr + class AAAARecord(dnsserver.DNS_RPC_RECORD): + def __init__(self, ip6_addr, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE, node_flag=0): super(AAAARecord, self).__init__() @@ -395,7 +413,9 @@ class AAAARecord(dnsserver.DNS_RPC_RECORD): self._ip6_addr = ip6_addr[:] self.data = self._ip6_addr + class PTRRecord(dnsserver.DNS_RPC_RECORD): + def __init__(self, ptr, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE, node_flag=0): super(PTRRecord, self).__init__() @@ -409,7 +429,9 @@ class PTRRecord(dnsserver.DNS_RPC_RECORD): ptr_name.len = len(ptr) self.data = ptr_name + class CNameRecord(dnsserver.DNS_RPC_RECORD): + def __init__(self, cname, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE, node_flag=0): super(CNameRecord, self).__init__() @@ -423,7 +445,9 @@ class CNameRecord(dnsserver.DNS_RPC_RECORD): cname_name.len = len(cname) self.data = cname_name + class NSRecord(dnsserver.DNS_RPC_RECORD): + def __init__(self, dns_server, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE, node_flag=0): super(NSRecord, self).__init__() @@ -437,7 +461,9 @@ class NSRecord(dnsserver.DNS_RPC_RECORD): ns.len = len(dns_server) self.data = ns + class MXRecord(dnsserver.DNS_RPC_RECORD): + def __init__(self, mail_server, preference, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE, node_flag=0): super(MXRecord, self).__init__() @@ -452,7 +478,9 @@ class MXRecord(dnsserver.DNS_RPC_RECORD): mx.nameExchange.len = len(mail_server) self.data = mx + class SOARecord(dnsserver.DNS_RPC_RECORD): + def __init__(self, mname, rname, serial=1, refresh=900, retry=600, expire=86400, minimum=3600, ttl=3600, rank=dnsp.DNS_RANK_ZONE, node_flag=dnsp.DNS_RPC_FLAG_AUTH_ZONE_ROOT): @@ -474,7 +502,9 @@ class SOARecord(dnsserver.DNS_RPC_RECORD): soa.ZoneAdministratorEmail.len = len(rname) self.data = soa + class SRVRecord(dnsserver.DNS_RPC_RECORD): + def __init__(self, target, port, priority=0, weight=100, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE, node_flag=0): super(SRVRecord, self).__init__() @@ -491,7 +521,9 @@ class SRVRecord(dnsserver.DNS_RPC_RECORD): srv.nameTarget.len = len(target) self.data = srv + class TXTRecord(dnsserver.DNS_RPC_RECORD): + def __init__(self, slist, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE, node_flag=0): super(TXTRecord, self).__init__() @@ -576,16 +608,9 @@ def dns_record_match(dns_conn, server, zone, name, record_type, data): select_flags = dnsserver.DNS_RPC_VIEW_AUTHORITY_DATA try: - buflen, res = dns_conn.DnssrvEnumRecords2(dnsserver.DNS_CLIENT_VERSION_LONGHORN, - 0, - server, - zone, - name, - None, - record_type, - select_flags, - None, - None) + buflen, res = dns_conn.DnssrvEnumRecords2( + dnsserver.DNS_CLIENT_VERSION_LONGHORN, 0, server, zone, name, None, + record_type, select_flags, None, None) except RuntimeError, e: return None @@ -667,18 +692,16 @@ class cmd_serverinfo(Command): choices=['w2k','dotnet','longhorn'], dest='cli_ver'), ] - def run(self, server, cli_ver, sambaopts=None, credopts=None, versionopts=None): + def run(self, server, cli_ver, sambaopts=None, credopts=None, + versionopts=None): self.lp = sambaopts.get_loadparm() self.creds = credopts.get_credentials(self.lp) dns_conn = dns_connect(server, self.lp, self.creds) client_version = dns_client_version(cli_ver) -- Samba Shared Repository