diff options
author | Joe Guo <joeg@catalyst.net.nz> | 2018-07-30 18:20:39 +1200 |
---|---|---|
committer | Douglas Bagnall <dbagnall@samba.org> | 2018-08-24 07:49:29 +0200 |
commit | 211c9a5f85bffbb012b4567bad265c9339588fbf (patch) | |
tree | d22f062161bdd07b60c6ac3bd42964ea902a402b | |
parent | 542e91ef9222302303d2ecc10dceb96d1b0d5bab (diff) | |
download | samba-211c9a5f85bffbb012b4567bad265c9339588fbf.tar.gz |
PEP8: fix E302: expected 2 blank lines, found 1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
180 files changed, 480 insertions, 0 deletions
diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py index 97122a9169e..7e47e804d5b 100644 --- a/.ycm_extra_conf.py +++ b/.ycm_extra_conf.py @@ -252,6 +252,7 @@ else: SOURCE_EXTENSIONS = [ '.C', '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ] + def DirectoryOfThisScript(): return os.path.dirname( os.path.abspath( __file__ ) ) diff --git a/auth/credentials/tests/bind.py b/auth/credentials/tests/bind.py index c397501844d..c5f79211185 100755 --- a/auth/credentials/tests/bind.py +++ b/auth/credentials/tests/bind.py @@ -46,6 +46,7 @@ creds_user2 = copy.deepcopy(creds) creds_user3 = copy.deepcopy(creds) creds_user4 = copy.deepcopy(creds) + class BindTests(samba.tests.TestCase): info_dc = None diff --git a/lib/ldb-samba/tests/match_rules.py b/lib/ldb-samba/tests/match_rules.py index 6d2ba1b920d..9088274a022 100755 --- a/lib/ldb-samba/tests/match_rules.py +++ b/lib/ldb-samba/tests/match_rules.py @@ -22,6 +22,8 @@ from ldb import SCOPE_BASE, SCOPE_SUBTREE, SCOPE_ONELEVEL # This should be fixed to work inline with Windows. # The literal strings are in the case Windows uses. # Windows appear to preserve casing of the RDN and uppercase the other keys. + + class MatchRulesTests(samba.tests.TestCase): def setUp(self): super(MatchRulesTests, self).setUp() @@ -943,6 +945,7 @@ class MatchRulesTests(samba.tests.TestCase): expression="memberOf:1.2.840.113556.1.4.1941:=cn=g1,%s" % self.ou_groups) self.assertEqual(len(res1), 0) + class MatchRuleConditionTests(samba.tests.TestCase): def setUp(self): super(MatchRuleConditionTests, self).setUp() diff --git a/lib/ldb/tests/python/api.py b/lib/ldb/tests/python/api.py index c88ddc7826e..cd0320715fa 100755 --- a/lib/ldb/tests/python/api.py +++ b/lib/ldb/tests/python/api.py @@ -22,6 +22,7 @@ MDB_INDEX_OBJ = { "@IDX_DN_GUID": [b"GUID"] } + def tempdir(): import tempfile try: @@ -685,6 +686,8 @@ class SimpleLdb(LdbBaseTest): self.assertRaises(ldb.LdbError, lambda: l.search("", ldb.SCOPE_SUBTREE, "&(dc=*)(dn=*)", ["dc"])) # Run the SimpleLdb tests against an lmdb backend + + class SimpleLdbLmdb(SimpleLdb): def setUp(self): @@ -695,6 +698,7 @@ class SimpleLdbLmdb(SimpleLdb): def tearDown(self): super(SimpleLdbLmdb, self).tearDown() + class SearchTests(LdbBaseTest): def tearDown(self): shutil.rmtree(self.testdir) @@ -1367,6 +1371,7 @@ class IndexedSearchTests(SearchTests): "@IDXATTR": [b"x", b"y", b"ou"]}) self.IDX = True + class IndexedCheckSearchTests(IndexedSearchTests): """Test searches using the index, to ensure the index doesn't break things (full scan disabled)""" @@ -1375,6 +1380,7 @@ class IndexedCheckSearchTests(IndexedSearchTests): self.IDXCHECK = True super(IndexedCheckSearchTests, self).setUp() + class IndexedSearchDnFilterTests(SearchTests): """Test searches using the index, to ensure the index doesn't break things""" @@ -1389,6 +1395,7 @@ class IndexedSearchDnFilterTests(SearchTests): "@IDXATTR": [b"x", b"y", b"ou"]}) self.IDX = True + class IndexedAndOneLevelSearchTests(SearchTests): """Test searches using the index including @IDXONE, to ensure the index doesn't break things""" @@ -1401,6 +1408,7 @@ class IndexedAndOneLevelSearchTests(SearchTests): self.IDX = True self.IDXONE = True + class IndexedCheckedAndOneLevelSearchTests(IndexedAndOneLevelSearchTests): """Test searches using the index including @IDXONE, to ensure the index doesn't break things (full scan disabled)""" @@ -1409,6 +1417,7 @@ class IndexedCheckedAndOneLevelSearchTests(IndexedAndOneLevelSearchTests): self.IDXCHECK = True super(IndexedCheckedAndOneLevelSearchTests, self).setUp() + class IndexedAndOneLevelDNFilterSearchTests(SearchTests): """Test searches using the index including @IDXONE, to ensure the index doesn't break things""" @@ -1427,6 +1436,7 @@ class IndexedAndOneLevelDNFilterSearchTests(SearchTests): self.IDX = True self.IDXONE = True + class GUIDIndexedSearchTests(SearchTests): """Test searches using the index, to ensure the index doesn't break things""" @@ -1460,6 +1470,7 @@ class GUIDIndexedDNFilterSearchTests(SearchTests): self.IDX = True self.IDXGUID = True + class GUIDAndOneLevelIndexedSearchTests(SearchTests): """Test searches using the index including @IDXONE, to ensure the index doesn't break things""" @@ -1479,6 +1490,7 @@ class GUIDAndOneLevelIndexedSearchTests(SearchTests): self.IDXGUID = True self.IDXONE = True + class GUIDIndexedSearchTestsLmdb(GUIDIndexedSearchTests): def setUp(self): @@ -1719,6 +1731,7 @@ class AddModifyTestsLmdb(AddModifyTests): def tearDown(self): super(AddModifyTestsLmdb, self).tearDown() + class IndexedAddModifyTests(AddModifyTests): """Test searches using the index, to ensure the index doesn't break things""" @@ -1798,6 +1811,7 @@ class IndexedAddModifyTests(AddModifyTests): "x": "z", "y": "a", "objectUUID": b"0123456789abcde2"}) + class GUIDIndexedAddModifyTests(IndexedAddModifyTests): """Test searches using the index, to ensure the index doesn't break things""" @@ -1822,6 +1836,7 @@ class GUIDTransIndexedAddModifyTests(GUIDIndexedAddModifyTests): self.l.transaction_commit() super(GUIDTransIndexedAddModifyTests, self).tearDown() + class TransIndexedAddModifyTests(IndexedAddModifyTests): """Test index behaviour insdie the transaction""" @@ -1833,6 +1848,7 @@ class TransIndexedAddModifyTests(IndexedAddModifyTests): self.l.transaction_commit() super(TransIndexedAddModifyTests, self).tearDown() + class GuidIndexedAddModifyTestsLmdb(GUIDIndexedAddModifyTests): def setUp(self): @@ -1842,6 +1858,7 @@ class GuidIndexedAddModifyTestsLmdb(GUIDIndexedAddModifyTests): def tearDown(self): super(GuidIndexedAddModifyTestsLmdb, self).tearDown() + class GuidTransIndexedAddModifyTestsLmdb(GUIDTransIndexedAddModifyTests): def setUp(self): @@ -1851,6 +1868,7 @@ class GuidTransIndexedAddModifyTestsLmdb(GUIDTransIndexedAddModifyTests): def tearDown(self): super(GuidTransIndexedAddModifyTestsLmdb, self).tearDown() + class BadIndexTests(LdbBaseTest): def setUp(self): super(BadIndexTests, self).setUp() @@ -2011,6 +2029,7 @@ class GUIDBadIndexTests(BadIndexTests): super(GUIDBadIndexTests, self).setUp() + class DnTests(TestCase): def setUp(self): @@ -2253,6 +2272,7 @@ class DnTests(TestCase): dn = ldb.Dn(self.ldb, '') self.assertTrue(dn.is_null()) + class LdbMsgTests(TestCase): def setUp(self): @@ -2621,6 +2641,7 @@ class ModuleTests(TestCase): l = ldb.Ldb(self.filename) self.assertEqual(["init"], ops) + class LdbResultTests(LdbBaseTest): def setUp(self): diff --git a/lib/talloc/test_pytalloc.py b/lib/talloc/test_pytalloc.py index 2e58d28c7e2..1acb96bc136 100644 --- a/lib/talloc/test_pytalloc.py +++ b/lib/talloc/test_pytalloc.py @@ -11,6 +11,7 @@ import gc import talloc import _test_pytalloc + def dummy_func(): pass @@ -109,6 +110,7 @@ class TallocComparisonTests(unittest.TestCase): self.assertFalse(obj1 >= obj2) self.assertFalse(obj1 > obj2) + class TallocBaseComparisonTests(unittest.TestCase): def test_compare_same(self): diff --git a/lib/tevent/bindings.py b/lib/tevent/bindings.py index 55aafbb64a6..6bea4771b9b 100644 --- a/lib/tevent/bindings.py +++ b/lib/tevent/bindings.py @@ -27,6 +27,7 @@ import gc import _tevent + class BackendListTests(TestCase): def test_backend_list(self): diff --git a/python/examples/samr.py b/python/examples/samr.py index 49559e82023..521ea641610 100755 --- a/python/examples/samr.py +++ b/python/examples/samr.py @@ -26,9 +26,11 @@ sys.path.insert(0, "bin/python") from samba.dcerpc import samr, security + def display_lsa_string(str): return str.string + def FillUserInfo(samr, dom_handle, users, level): """fill a user array with user information from samrQueryUserInfo""" for i in range(len(users)): @@ -39,6 +41,7 @@ def FillUserInfo(samr, dom_handle, users, level): users[i] = info samr.Close(user_handle) + def toArray((handle, array, num_entries)): ret = [] for x in range(num_entries): @@ -51,16 +54,19 @@ def test_Connect(samr): print "Testing samr_Connect" return samr.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED) + def test_LookupDomain(samr, handle, domain): """test the samr_LookupDomain interface""" print "Testing samr_LookupDomain" return samr.LookupDomain(handle, domain) + def test_OpenDomain(samr, handle, sid): """test the samr_OpenDomain interface""" print "Testing samr_OpenDomain" return samr.OpenDomain(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, sid) + def test_EnumDomainUsers(samr, dom_handle): """test the samr_EnumDomainUsers interface""" print "Testing samr_EnumDomainUsers" @@ -69,6 +75,7 @@ def test_EnumDomainUsers(samr, dom_handle): for idx, user in users: print "\t%s\t(%d)" % (user.string, idx) + def test_EnumDomainGroups(samr, dom_handle): """test the samr_EnumDomainGroups interface""" print "Testing samr_EnumDomainGroups" @@ -77,11 +84,13 @@ def test_EnumDomainGroups(samr, dom_handle): for idx, group in groups: print "\t%s\t(%d)" % (group.string, idx) + def test_domain_ops(samr, dom_handle): """test domain specific ops""" test_EnumDomainUsers(samr, dom_handle) test_EnumDomainGroups(samr, dom_handle) + def test_EnumDomains(samr, handle): """test the samr_EnumDomains interface""" print "Testing samr_EnumDomains" diff --git a/python/examples/winreg.py b/python/examples/winreg.py index e8029bac8bb..e419320b16f 100755 --- a/python/examples/winreg.py +++ b/python/examples/winreg.py @@ -32,6 +32,7 @@ binding = args[0] print "Connecting to " + binding conn = winreg.winreg(binding, sambaopts.get_loadparm()) + def list_values(key): (num_values, max_valnamelen, max_valbufsize) = conn.QueryInfoKey(key, winreg.String())[4:8] for i in range(num_values): @@ -53,6 +54,7 @@ def list_values(key): # printf("\t\t0x%llx (%lld)\n", v.value, v.value) # } + def list_path(key, path): count = 0 (num_subkeys, max_subkeylen, max_subkeysize) = conn.QueryInfoKey(key, winreg.String())[1:4] diff --git a/python/samba/__init__.py b/python/samba/__init__.py index f6fb58461a7..90f85851256 100644 --- a/python/samba/__init__.py +++ b/python/samba/__init__.py @@ -305,6 +305,8 @@ def setup_file(template, fname, subst_vars=None): f.close() MAX_NETBIOS_NAME_LEN = 15 + + def is_valid_netbios_char(c): return (c.isalnum() or c in " !#$%&'()-.@^_{}~") @@ -364,9 +366,11 @@ def dn_from_dns_name(dnsdomain): """return a DN from a DNS name domain/forest root""" return "DC=" + ",DC=".join(dnsdomain.split(".")) + def current_unix_time(): return int(time.time()) + def string_to_byte_array(string): blob = [0] * len(string) @@ -375,6 +379,7 @@ def string_to_byte_array(string): return blob + def arcfour_encrypt(key, data): from samba.crypto import arcfour_crypt_blob return arcfour_crypt_blob(data, key) diff --git a/python/samba/descriptor.py b/python/samba/descriptor.py index 7ab2ac430f4..09983481992 100644 --- a/python/samba/descriptor.py +++ b/python/samba/descriptor.py @@ -34,6 +34,7 @@ import re # Descriptors of naming contexts and other important objects + def sddl2binary(sddl_in, domain_sid, name_map): sddl = "%s" % sddl_in @@ -43,12 +44,14 @@ def sddl2binary(sddl_in, domain_sid, name_map): sec = security.descriptor.from_sddl(sddl, domain_sid) return ndr_pack(sec) + def get_empty_descriptor(domain_sid, name_map={}): sddl = "" return sddl2binary(sddl, domain_sid, name_map) # "get_schema_descriptor" is located in "schema.py" + def get_config_descriptor(domain_sid, name_map={}): sddl = "O:EAG:EAD:(OA;;CR;1131f6aa-9c07-11d1-f79f-00c04fc2dcd2;;ED)" \ "(OA;;CR;1131f6ab-9c07-11d1-f79f-00c04fc2dcd2;;ED)" \ @@ -67,6 +70,7 @@ def get_config_descriptor(domain_sid, name_map={}): "(OU;SA;CR;45ec5156-db7e-47bb-b53f-dbeb2d03c40f;;WD)" return sddl2binary(sddl, domain_sid, name_map) + def get_config_partitions_descriptor(domain_sid, name_map={}): sddl = "D:" \ "(A;;LCLORC;;;AU)" \ @@ -84,6 +88,7 @@ def get_config_partitions_descriptor(domain_sid, name_map={}): "(AU;CISA;WPCRCCDCWOWDSDDT;;;WD)" return sddl2binary(sddl, domain_sid, name_map) + def get_config_sites_descriptor(domain_sid, name_map={}): sddl = "D:" \ "(A;;RPLCLORC;;;AU)" \ @@ -98,6 +103,7 @@ def get_config_sites_descriptor(domain_sid, name_map={}): "(OU;CIIOSA;WP;3e10944c-c354-11d0-aff8-0000f80367c1;b7b13124-b82e-11d0-afee-0000f80367c1;WD)" return sddl2binary(sddl, domain_sid, name_map) + def get_config_ntds_quotas_descriptor(domain_sid, name_map={}): sddl = "D:" \ "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;EA)" \ @@ -105,6 +111,7 @@ def get_config_ntds_quotas_descriptor(domain_sid, name_map={}): "(OA;;CR;4ecc03fe-ffc0-4947-b630-eb672a8a9dbc;;WD)" return sddl2binary(sddl, domain_sid, name_map) + def get_config_delete_protected1_descriptor(domain_sid, name_map={}): sddl = "D:AI" \ "(A;;RPLCLORC;;;AU)" \ @@ -112,6 +119,7 @@ def get_config_delete_protected1_descriptor(domain_sid, name_map={}): "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)" return sddl2binary(sddl, domain_sid, name_map) + def get_config_delete_protected1wd_descriptor(domain_sid, name_map={}): sddl = "D:AI" \ "(A;;RPLCLORC;;;WD)" \ @@ -119,6 +127,7 @@ def get_config_delete_protected1wd_descriptor(domain_sid, name_map={}): "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)" return sddl2binary(sddl, domain_sid, name_map) + def get_config_delete_protected2_descriptor(domain_sid, name_map={}): sddl = "D:AI" \ "(A;;RPLCLORC;;;AU)" \ @@ -126,6 +135,7 @@ def get_config_delete_protected2_descriptor(domain_sid, name_map={}): "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)" return sddl2binary(sddl, domain_sid, name_map) + def get_domain_descriptor(domain_sid, name_map={}): sddl = "O:BAG:BAD:AI(OA;CIIO;RP;4c164200-20c0-11d0-a768-00aa006e0529;4828cc14-1437-45bc-9b07-ad6f015e5f28;RU)" \ "(OA;CIIO;RP;4c164200-20c0-11d0-a768-00aa006e0529;bf967aba-0de6-11d0-a285-00aa003049e2;RU)" \ @@ -178,6 +188,7 @@ def get_domain_descriptor(domain_sid, name_map={}): "(AU;SA;CR;;;DU)(AU;SA;CR;;;BA)(AU;SA;WPWOWD;;;WD)" return sddl2binary(sddl, domain_sid, name_map) + def get_domain_infrastructure_descriptor(domain_sid, name_map={}): sddl = "D:" \ "(A;;RPLCLORC;;;AU)" \ @@ -187,6 +198,7 @@ def get_domain_infrastructure_descriptor(domain_sid, name_map={}): "(AU;SA;WPCR;;;WD)" return sddl2binary(sddl, domain_sid, name_map) + def get_domain_builtin_descriptor(domain_sid, name_map={}): sddl = "D:" \ "(OA;CIIO;RP;4c164200-20c0-11d0-a768-00aa006e0529;4828cc14-1437-45bc-9b07-ad6f015e5f28;RU)" \ @@ -243,6 +255,7 @@ def get_domain_builtin_descriptor(domain_sid, name_map={}): "(AU;SA;WPWOWD;;;WD)" return sddl2binary(sddl, domain_sid, name_map) + def get_domain_computers_descriptor(domain_sid, name_map={}): sddl = "D:" \ "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)" \ @@ -256,6 +269,7 @@ def get_domain_computers_descriptor(domain_sid, name_map={}): "S:" return sddl2binary(sddl, domain_sid, name_map) + def get_domain_users_descriptor(domain_sid, name_map={}): sddl = "D:" \ "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)" \ @@ -268,6 +282,7 @@ def get_domain_users_descriptor(domain_sid, name_map={}): "S:" return sddl2binary(sddl, domain_sid, name_map) + def get_managed_service_accounts_descriptor(domain_sid, name_map={}): sddl = "D:" \ "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)" \ @@ -279,6 +294,7 @@ def get_managed_service_accounts_descriptor(domain_sid, name_map={}): "S:" return sddl2binary(sddl, domain_sid, name_map) + def get_domain_controllers_descriptor(domain_sid, name_map={}): sddl = "D:" \ "(A;;RPLCLORC;;;AU)" \ @@ -290,6 +306,7 @@ def get_domain_controllers_descriptor(domain_sid, name_map={}): "(AU;CISA;WP;;;WD)" return sddl2binary(sddl, domain_sid, name_map) + def get_domain_delete_protected1_descriptor(domain_sid, name_map={}): sddl = "D:AI" \ "(A;;RPLCLORC;;;AU)" \ @@ -297,6 +314,7 @@ def get_domain_delete_protected1_descriptor(domain_sid, name_map={}): "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)" return sddl2binary(sddl, domain_sid, name_map) + def get_domain_delete_protected2_descriptor(domain_sid, name_map={}): sddl = "D:AI" \ "(A;;RPLCLORC;;;AU)" \ @@ -304,6 +322,7 @@ def get_domain_delete_protected2_descriptor(domain_sid, name_map={}): "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)" return sddl2binary(sddl, domain_sid, name_map) + def get_dns_partition_descriptor(domain_sid, name_map={}): sddl = "O:SYG:BAD:AI" \ "(OA;CIIO;RP;4c164200-20c0-11d0-a768-00aa006e0529;4828cc14-1437-45bc-9b07-ad6f015e5f28;RU)" \ @@ -358,12 +377,14 @@ def get_dns_partition_descriptor(domain_sid, name_map={}): "(AU;SA;CR;;;DU)(AU;SA;CR;;;BA)(AU;SA;WPWOWD;;;WD)" return sddl2binary(sddl, domain_sid, name_map) + def get_dns_forest_microsoft_dns_descriptor(domain_sid, name_map={}): sddl = "O:SYG:SYD:AI" \ "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)" \ "(A;CI;RPWPCRCCDCLCRCWOWDSDDTSW;;;ED)" return sddl2binary(sddl, domain_sid, name_map) + def get_dns_domain_microsoft_dns_descriptor(domain_sid, name_map={}): sddl = "O:SYG:SYD:AI" \ "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;DA)" \ @@ -372,6 +393,7 @@ def get_dns_domain_microsoft_dns_descriptor(domain_sid, name_map={}): "(A;CI;RPWPCRCCDCLCRCWOWDSDDTSW;;;ED)" return sddl2binary(sddl, domain_sid, name_map) + def get_paritions_crossref_subdomain_descriptor(domain_sid, name_map={}): sddl = "O:SubdomainAdminsG:SubdomainAdminsD:AI" \ "(A;;RPWPCRCCLCLORCWOWDSW;;;SubdomainAdmins)" \ @@ -379,6 +401,7 @@ def get_paritions_crossref_subdomain_descriptor(domain_sid, name_map={}): "(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)" return sddl2binary(sddl, domain_sid, name_map) + def get_wellknown_sds(samdb): # Then subcontainers @@ -445,6 +468,7 @@ def get_wellknown_sds(samdb): return subcontainers + def chunck_acl(acl): """Return separate ACE of an ACL diff --git a/python/samba/dnsserver.py b/python/samba/dnsserver.py index 2b01eaf41fa..6d8a72919df 100644 --- a/python/samba/dnsserver.py +++ b/python/samba/dnsserver.py @@ -23,6 +23,7 @@ from samba.dcerpc import dnsserver, dnsp # to overcome the bug in pidl generated python bindings. # + class ARecord(dnsserver.DNS_RPC_RECORD): def __init__(self, ip_addr, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE, node_flag=0): diff --git a/python/samba/drs_utils.py b/python/samba/drs_utils.py index 0bc6af57747..8b812e43b86 100644 --- a/python/samba/drs_utils.py +++ b/python/samba/drs_utils.py @@ -27,6 +27,7 @@ import samba, ldb from samba.dcerpc.drsuapi import DRSUAPI_ATTID_name import re + class drsException(Exception): """Base element for drs errors""" diff --git a/python/samba/emulate/traffic_packets.py b/python/samba/emulate/traffic_packets.py index bc52de06ff0..aa1d9eeeb1f 100644 --- a/python/samba/emulate/traffic_packets.py +++ b/python/samba/emulate/traffic_packets.py @@ -39,6 +39,7 @@ import samba samba.ensure_third_party_module("dns", "dnspython") import dns.resolver + def uint32(v): return ctypes.c_uint32(v).value diff --git a/python/samba/gp_ext_loader.py b/python/samba/gp_ext_loader.py index 23fee230440..ce5d4191550 100644 --- a/python/samba/gp_ext_loader.py +++ b/python/samba/gp_ext_loader.py @@ -32,6 +32,7 @@ except ImportError: def import_file(name, location): return imp.load_source(name, location) + def get_gp_ext_from_module(name, mod): if mod: for k, v in vars(mod).items(): @@ -39,6 +40,7 @@ def get_gp_ext_from_module(name, mod): return v return None + def get_gp_client_side_extensions(logger, smb_conf): user_exts = [] machine_exts = [] diff --git a/python/samba/gp_sec_ext.py b/python/samba/gp_sec_ext.py index 79c6abaea22..7b65b768fee 100644 --- a/python/samba/gp_sec_ext.py +++ b/python/samba/gp_sec_ext.py @@ -18,6 +18,7 @@ import os.path from samba.gpclass import gp_ext_setter, gp_inf_ext + class inf_to_kdc_tdb(gp_ext_setter): def mins_to_hours(self): return '%d' % (int(self.val) / 60) @@ -47,6 +48,7 @@ class inf_to_kdc_tdb(gp_ext_setter): def __str__(self): return 'Kerberos Policy' + class inf_to_ldb(gp_ext_setter): '''This class takes the .inf file parameter (essentially a GPO file mapped to a GUID), hashmaps it to the Samba parameter, which then uses an ldb @@ -105,6 +107,7 @@ class inf_to_ldb(gp_ext_setter): def __str__(self): return 'System Access' + class gp_sec_ext(gp_inf_ext): '''This class does the following two things: 1) Identifies the GPO if it has a certain kind of filepath, diff --git a/python/samba/gpclass.py b/python/samba/gpclass.py index 0cadcd45fc7..751d0ad4aae 100644 --- a/python/samba/gpclass.py +++ b/python/samba/gpclass.py @@ -43,6 +43,7 @@ except ImportError: ENFORCE = 2 UNAPPLY = 3 + class gp_log: ''' Log settings overwritten by gpo apply The gp_log is an xml file that stores a history of gpo changes (and the @@ -255,6 +256,7 @@ class gp_log: ''' Write gp_log changes to disk ''' self.gpostore.store(self.username, etree.tostring(self.gpdb, 'utf-8')) + class GPOStorage: def __init__(self, log_file): if os.path.isfile(log_file): @@ -292,6 +294,7 @@ class GPOStorage: def __del__(self): self.log.close() + class gp_ext(object): __metaclass__ = ABCMeta @@ -325,6 +328,7 @@ class gp_ext(object): def __str__(self): pass + class gp_ext_setter(): __metaclass__ = ABCMeta @@ -351,6 +355,7 @@ class gp_ext_setter(): def __str__(self): pass + class gp_inf_ext(gp_ext): @abstractmethod def list(self, rootpath): @@ -398,6 +403,8 @@ class gp_inf_ext(gp_ext): pass ''' Fetch the hostname of a writable DC ''' + + def get_dc_hostname(creds, lp): net = Net(creds=creds, lp=lp) cldap_ret = net.finddc(domain=lp.get('realm'), flags=(nbt.NBT_SERVER_LDAP | @@ -405,6 +412,8 @@ def get_dc_hostname(creds, lp): return cldap_ret.pdc_dns_name ''' Fetch a list of GUIDs for applicable GPOs ''' + + def get_gpo_list(dc_hostname, creds, lp): gpos = [] ads = gpo.ADS_STRUCT(dc_hostname, lp, creds) @@ -441,6 +450,7 @@ def check_safe_path(path): return os.path.join(*dirs) raise OSError(path) + def check_refresh_gpo_list(dc_hostname, lp, creds, gpos): conn = smb.SMB(dc_hostname, 'sysvol', lp=lp, creds=creds, sign=True) cache_path = lp.cache_path('gpo_cache') @@ -449,12 +459,14 @@ def check_refresh_gpo_list(dc_hostname, lp, creds, gpos): continue cache_gpo_dir(conn, cache_path, check_safe_path(gpo.file_sys_path)) + def gpo_version(lp, path): # gpo.gpo_get_sysvol_gpt_version() reads the GPT.INI from a local file, # read from the gpo client cache. gpt_path = lp.cache_path(os.path.join('gpo_cache', path)) return int(gpo.gpo_get_sysvol_gpt_version(gpt_path)[1]) + def apply_gp(lp, creds, test_ldb, logger, store, gp_extensions): gp_db = store.get_gplog(creds.get_username()) dc_hostname = get_dc_hostname(creds, lp) @@ -491,6 +503,7 @@ def apply_gp(lp, creds, test_ldb, logger, store, gp_extensions): store.store(guid, '%i' % version) store.commit() + def unapply_log(gp_db): while True: item = gp_db.apply_log_pop() @@ -499,6 +512,7 @@ def unapply_log(gp_db): else: break + def unapply_gp(lp, creds, test_ldb, logger, store, gp_extensions): gp_db = store.get_gplog(creds.get_username()) gp_db.state(GPOSTATE.UNAPPLY) @@ -511,6 +525,7 @@ def unapply_gp(lp, creds, test_ldb, logger, store, gp_extensions): gp_db.delete(str(attr_obj), attr[0]) gp_db.commit() + def parse_gpext_conf(smb_conf): lp = LoadParm() if smb_conf is not None: @@ -522,12 +537,14 @@ def parse_gpext_conf(smb_conf): parser.read(ext_conf) return lp, parser + def atomic_write_conf(lp, parser): ext_conf = lp.state_path('gpext.conf') with NamedTemporaryFile(delete=False, dir=os.path.dirname(ext_conf)) as f: parser.write(f) os.rename(f.name, ext_conf) + def check_guid(guid): # Check for valid guid with curly braces if guid[0] != '{' or guid[-1] != '}' or len(guid) != 38: @@ -538,6 +555,7 @@ def check_guid(guid): return False return True + def register_gp_extension(guid, name, path, smb_conf=None, machine=True, user=True): # Check that the module exists @@ -558,6 +576,7 @@ def register_gp_extension(guid, name, path, return True + def list_gp_extensions(smb_conf=None): _, parser = parse_gpext_conf(smb_conf) results = {} @@ -571,6 +590,7 @@ def list_gp_extensions(smb_conf=None): results[guid]['UserPolicy'] = not int(parser.get(guid, 'NoUserPolicy')) return results + def unregister_gp_extension(guid, smb_conf=None): if not check_guid(guid): return False diff --git a/python/samba/graph.py b/python/samba/graph.py index 2f3bc9c67eb..538c9de750f 100644 --- a/python/samba/graph.py +++ b/python/samba/graph.py @@ -675,6 +675,7 @@ def transpose_dict_matrix(m): m2.setdefault(k2, {})[k1] = dist return m2 + def full_matrix(rows, utf8=False, colour=None, diff --git a/python/samba/hostconfig.py b/python/samba/hostconfig.py index 07916ab7cac..970f4892b91 100644 --- a/python/samba/hostconfig.py +++ b/python/samba/hostconfig.py @@ -19,6 +19,7 @@ from __future__ import absolute_import from .samdb import SamDB + class Hostconfig(object): """Aggregate object that contains all information about the configuration of a Samba host.""" diff --git a/python/samba/idmap.py b/python/samba/idmap.py index 26a3beb7d56..8abaf98cadb 100644 --- a/python/samba/idmap.py +++ b/python/samba/idmap.py @@ -23,6 +23,7 @@ __docformat__ = "restructuredText" import ldb import samba + class IDmapDB(samba.Ldb): """The IDmap database.""" diff --git a/python/samba/join.py b/python/samba/join.py index d5efee57737..45e54780883 100644 --- a/python/samba/join.py +++ b/python/samba/join.py @@ -47,6 +47,7 @@ import re import os import tempfile + class DCJoinException(Exception): def __init__(self, msg): @@ -1500,6 +1501,7 @@ def join_DC(logger=None, server=None, creds=None, lp=None, site=None, netbios_na ctx.do_join() logger.info("Joined domain %s (SID %s) as a DC" % (ctx.domain_name, ctx.domsid)) + def join_clone(logger=None, server=None, creds=None, lp=None, targetdir=None, domain=None, include_secrets=False, dns_backend="NONE"): @@ -1518,6 +1520,7 @@ def join_clone(logger=None, server=None, creds=None, lp=None, logger.info("Cloned domain %s (SID %s)" % (ctx.domain_name, ctx.domsid)) return ctx + def join_subdomain(logger=None, server=None, creds=None, lp=None, site=None, netbios_name=None, targetdir=None, parent_domain=None, dnsdomain=None, netbios_domain=None, machinepass=None, adminpass=None, use_ntvfs=False, diff --git a/python/samba/ms_display_specifiers.py b/python/samba/ms_display_specifiers.py index 0d7b39aaae9..0eeeb88dc87 100644 --- a/python/samba/ms_display_specifiers.py +++ b/python/samba/ms_display_specifiers.py @@ -21,6 +21,7 @@ from __future__ import print_function import re + def __read_folded_line(f, buffer): """Read a line from an LDIF file, unfolding it""" line = buffer @@ -57,6 +58,7 @@ def __read_folded_line(f, buffer): # Will not match options after the attribute type. attr_type_re = re.compile("^([A-Za-z][A-Za-z0-9-]*):") + def __read_raw_entries(f): """Read an LDIF entry, only unfolding lines""" @@ -91,6 +93,7 @@ def __read_raw_entries(f): if l == "": break + def fix_dn(dn): """Fix a string DN to use ${CONFIGDN}""" @@ -100,6 +103,7 @@ def fix_dn(dn): else: return dn + def __write_ldif_one(entry): """Write out entry as LDIF""" out = [] @@ -113,6 +117,7 @@ def __write_ldif_one(entry): return "\n".join(out) + def __transform_entry(entry): """Perform required transformations to the Microsoft-provided LDIF""" @@ -164,6 +169,7 @@ def __transform_entry(entry): return entry + def read_ms_ldif(filename): """Read and transform Microsoft-provided LDIF file.""" diff --git a/python/samba/ms_schema.py b/python/samba/ms_schema.py index 850bdca3ae5..60bd1ead7e2 100644 --- a/python/samba/ms_schema.py +++ b/python/samba/ms_schema.py @@ -87,6 +87,7 @@ multivalued_attrs = set(["auxiliaryclass", "maycontain", "mustcontain", "posssup "systemauxiliaryclass", "systemmaycontain", "systemmustcontain", "systemposssuperiors"]) + def __read_folded_line(f, buffer): """ reads a line from an LDIF file, unfolding it""" line = buffer @@ -174,6 +175,7 @@ def fix_dn(dn): else: return dn + def __convert_bitfield(key, value): """Evaluate the OR expression in 'value'""" assert(isinstance(value, string_types)) @@ -193,6 +195,7 @@ def __convert_bitfield(key, value): return str(o) + def __write_ldif_one(entry): """Write out entry as LDIF""" out = [] @@ -213,6 +216,7 @@ def __write_ldif_one(entry): return "\n".join(out) + def __transform_entry(entry, objectClass): """Perform transformations required to convert the LDIF-like schema file entries to LDIF, including Samba-specific stuff.""" @@ -286,6 +290,7 @@ def __transform_entry(entry, objectClass): return entry + def __parse_schema_file(filename, objectClass): """Load and transform a schema file.""" diff --git a/python/samba/ms_schema_markdown.py b/python/samba/ms_schema_markdown.py index b6cb2222ca6..5283e24d858 100644 --- a/python/samba/ms_schema_markdown.py +++ b/python/samba/ms_schema_markdown.py @@ -26,11 +26,13 @@ import os import markdown import xml.etree.ElementTree as ET + def innertext(tag): return (tag.text or '') + \ ''.join(innertext(e) for e in tag) + \ (tag.tail or '') + def read_ms_markdown(in_file, out_folder): """Read Github documentation-derived schema files.""" diff --git a/python/samba/ndr.py b/python/samba/ndr.py index 8879caf59a5..35b2414e8ae 100644 --- a/python/samba/ndr.py +++ b/python/samba/ndr.py @@ -55,6 +55,7 @@ def ndr_print(object): raise TypeError("%r is not a NDR object" % object) return ndr_print() + def ndr_pack_in(object, bigendian=False, ndr64=False): """Pack the input of an NDR function object. diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py index cd1a2373550..6e133591155 100644 --- a/python/samba/netcmd/__init__.py +++ b/python/samba/netcmd/__init__.py @@ -23,10 +23,13 @@ from ldb import LdbError import sys, traceback import textwrap + class Option(optparse.Option): pass # This help formatter does text wrapping and preserves newlines + + class PlainHelpFormatter(optparse.IndentedHelpFormatter): def format_description(self, description=""): desc_width = self.width - self.current_indent @@ -47,6 +50,7 @@ class PlainHelpFormatter(optparse.IndentedHelpFormatter): else: return "" + class Command(object): """A samba-tool command.""" diff --git a/python/samba/netcmd/computer.py b/python/samba/netcmd/computer.py index 6212bd67eea..ed70400f9d8 100644 --- a/python/samba/netcmd/computer.py +++ b/python/samba/netcmd/computer.py @@ -435,6 +435,7 @@ class cmd_computer_list(Command): for msg in res: self.outf.write("%s\n" % msg.get("samaccountname", idx=0)) + class cmd_computer_show(Command): """Display a computer AD object. @@ -521,6 +522,7 @@ attribute. computer_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE) self.outf.write(computer_ldif) + class cmd_computer_move(Command): """Move a computer to an organizational unit/container.""" diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py index 26c7551bc22..072faef67ca 100644 --- a/python/samba/netcmd/dns.py +++ b/python/samba/netcmd/dns.py @@ -41,6 +41,7 @@ from samba.dcerpc import dnsp, dnsserver from samba.dnsserver import ARecord, AAAARecord, PTRRecord, CNameRecord, NSRecord, MXRecord, SOARecord, SRVRecord, TXTRecord + def dns_connect(server, lp, creds): if server.lower() == 'localhost': server = '127.0.0.1' diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py index 889aa922eac..dfcbf4617e7 100644 --- a/python/samba/netcmd/domain.py +++ b/python/samba/netcmd/domain.py @@ -143,6 +143,7 @@ common_ntvfs_options = [ action="store_true") ] + def get_testparm_var(testparm, smbconf, varname): errfile = open(os.devnull, 'w') p = subprocess.Popen([testparm, '-s', '-l', @@ -1276,6 +1277,7 @@ class cmd_domain_level(Command): else: raise CommandError("invalid argument: '%s' (choose from 'show', 'raise')" % subcommand) + class cmd_domain_passwordsettings_show(Command): """Display current password settings for the domain.""" @@ -1343,6 +1345,7 @@ class cmd_domain_passwordsettings_show(Command): self.message("Account lockout threshold (attempts): %d" % cur_account_lockout_threshold) self.message("Reset account lockout after (mins): %d" % cur_reset_account_lockout_after) + class cmd_domain_passwordsettings_set(Command): """Set password settings. @@ -1540,6 +1543,7 @@ class cmd_domain_passwordsettings_set(Command): msgs.append("All changes applied successfully!") self.message("\n".join(msgs)) + class cmd_domain_passwordsettings(SuperCommand): """Manage password policy settings.""" @@ -1548,6 +1552,7 @@ class cmd_domain_passwordsettings(SuperCommand): subcommands["show"] = cmd_domain_passwordsettings_show() subcommands["set"] = cmd_domain_passwordsettings_set() + class cmd_domain_classicupgrade(Command): """Upgrade from Samba classic (NT4-like) database to Samba AD DC database. @@ -1696,10 +1701,12 @@ class cmd_domain_samba3upgrade(cmd_domain_classicupgrade): hidden = True + class LocalDCCredentialsOptions(options.CredentialsOptions): def __init__(self, parser): options.CredentialsOptions.__init__(self, parser, special_name="local-dc") + class DomainTrustCommand(Command): """List domain trusts.""" @@ -2086,6 +2093,7 @@ class DomainTrustCommand(Command): d.domain_sid, collision_string)) return + class cmd_domain_trust_list(DomainTrustCommand): """List domain trusts.""" @@ -2132,6 +2140,7 @@ class cmd_domain_trust_list(DomainTrustCommand): "Name[%s]" % self.netr_DomainTrust_to_name(t))) return + class cmd_domain_trust_show(DomainTrustCommand): """Show trusted domain details.""" @@ -2238,6 +2247,7 @@ class cmd_domain_trust_show(DomainTrustCommand): return + class cmd_domain_trust_create(DomainTrustCommand): """Create a domain or forest trust.""" @@ -2785,6 +2795,7 @@ class cmd_domain_trust_create(DomainTrustCommand): self.outf.write("Success.\n") return + class cmd_domain_trust_delete(DomainTrustCommand): """Delete a domain trust.""" @@ -2946,6 +2957,7 @@ class cmd_domain_trust_delete(DomainTrustCommand): return + class cmd_domain_trust_validate(DomainTrustCommand): """Validate a domain trust.""" @@ -3124,6 +3136,7 @@ class cmd_domain_trust_validate(DomainTrustCommand): return + class cmd_domain_trust_namespaces(DomainTrustCommand): """Manage forest trust namespaces.""" @@ -3869,6 +3882,7 @@ class cmd_domain_trust_namespaces(DomainTrustCommand): tln=local_tdo_info.domain_name.string) return + class cmd_domain_tombstones_expunge(Command): """Expunge tombstones from the database. @@ -3953,12 +3967,14 @@ class cmd_domain_trust(SuperCommand): subcommands["validate"] = cmd_domain_trust_validate() subcommands["namespaces"] = cmd_domain_trust_namespaces() + class cmd_domain_tombstones(SuperCommand): """Domain tombstone and recycled object management.""" subcommands = {} subcommands["expunge"] = cmd_domain_tombstones_expunge() + class ldif_schema_update: """Helper class for applying LDIF schema updates""" @@ -4014,6 +4030,7 @@ class ldif_schema_update: return 1 + class cmd_domain_schema_upgrade(Command): """Domain schema upgrading""" @@ -4264,6 +4281,7 @@ class cmd_domain_schema_upgrade(Command): if error_encountered: raise CommandError('Failed to upgrade schema') + class cmd_domain_functional_prep(Command): """Domain functional level preparation""" @@ -4370,6 +4388,7 @@ class cmd_domain_functional_prep(Command): if error_encountered: raise CommandError('Failed to perform functional prep') + class cmd_domain(SuperCommand): """Domain management.""" diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py index 7f4ca3fc120..bbb85f99936 100644 --- a/python/samba/netcmd/drs.py +++ b/python/samba/netcmd/drs.py @@ -48,6 +48,7 @@ def drsuapi_connect(ctx): except Exception as e: raise CommandError("DRS connection to %s failed" % ctx.server, e) + def samdb_connect(ctx): '''make a ldap connection to the server''' try: @@ -57,6 +58,7 @@ def samdb_connect(ctx): except Exception as e: raise CommandError("LDAP connection to %s failed" % ctx.server, e) + def drs_errmsg(werr): '''return "was successful" or an error string''' (ecode, estring) = werr @@ -86,6 +88,7 @@ def drs_parse_ntds_dn(ntds_dn): DEFAULT_SHOWREPL_FORMAT = 'classic' + class cmd_drs_showrepl(Command): """Show replication status.""" diff --git a/python/samba/netcmd/forest.py b/python/samba/netcmd/forest.py index 2ab0abd0052..4a5293c0290 100644 --- a/python/samba/netcmd/forest.py +++ b/python/samba/netcmd/forest.py @@ -27,6 +27,7 @@ from samba.netcmd import ( Option ) + class cmd_forest_show(Command): """Display forest settings. @@ -74,6 +75,7 @@ class cmd_forest_show(Command): except KeyError: self.outf.write("%s: <NO VALUE>\n" % attr) + class cmd_forest_set(Command): """Modify forest settings. @@ -129,6 +131,7 @@ class cmd_forest_show_directory_service(cmd_forest_show): objectdn = "CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration" attributes = ['dsheuristics'] + class cmd_forest_set_directory_service_dsheuristics(cmd_forest_set): """Set the value of dsheuristics on the Directory Service. @@ -148,6 +151,7 @@ class cmd_forest_set_directory_service_dsheuristics(cmd_forest_set): objectdn = "CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration" attribute = 'dsheuristics' + class cmd_forest_directory_service(SuperCommand): """Forest configuration partition management.""" @@ -155,6 +159,7 @@ class cmd_forest_directory_service(SuperCommand): subcommands["show"] = cmd_forest_show_directory_service() subcommands["dsheuristics"] = cmd_forest_set_directory_service_dsheuristics() + class cmd_forest(SuperCommand): """Forest management.""" diff --git a/python/samba/netcmd/fsmo.py b/python/samba/netcmd/fsmo.py index 5f67b30dedb..9d39dc2b298 100644 --- a/python/samba/netcmd/fsmo.py +++ b/python/samba/netcmd/fsmo.py @@ -31,6 +31,7 @@ from samba.netcmd import ( ) from samba.samdb import SamDB + def get_fsmo_roleowner(samdb, roledn, role): """Gets the owner of an FSMO role @@ -151,6 +152,7 @@ def transfer_dns_role(outf, sambaopts, credopts, role, samdb): outf.write("This DC already has the '%s' FSMO role\n" % role) return False + def transfer_role(outf, role, samdb): """Transfer standard FSMO role. """ @@ -213,6 +215,7 @@ def transfer_role(outf, role, samdb): outf.write("This DC already has the '%s' FSMO role\n" % role) return False + class cmd_fsmo_seize(Command): """Seize the role.""" @@ -474,6 +477,7 @@ class cmd_fsmo_show(Command): except CommandError as e: self.message("%s: * %s" % (long_name, e.message)) + class cmd_fsmo_transfer(Command): """Transfer the role.""" diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index 06b4fe508b9..c0394772656 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -305,6 +305,7 @@ attr_flags = smb.FILE_ATTRIBUTE_SYSTEM | \ smb.FILE_ATTRIBUTE_ARCHIVE | \ smb.FILE_ATTRIBUTE_HIDDEN + def copy_directory_remote_to_local(conn, remotedir, localdir): if not os.path.isdir(localdir): os.mkdir(localdir) diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py index 9022699267f..bbeab76a05d 100644 --- a/python/samba/netcmd/group.py +++ b/python/samba/netcmd/group.py @@ -359,6 +359,7 @@ class cmd_group_list(Command): for msg in res: self.outf.write("%s\n" % msg.get("samaccountname", idx=0)) + class cmd_group_list_members(Command): """List all members of an AD group. @@ -422,6 +423,7 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com except Exception as e: raise CommandError('Failed to list members of "%s" group ' % groupname, e) + class cmd_group_move(Command): """Move a group to an organizational unit/container. @@ -501,6 +503,7 @@ class cmd_group_move(Command): self.outf.write('Moved group "%s" into "%s"\n' % (groupname, full_new_parent_dn)) + class cmd_group_show(Command): """Display a group AD object. @@ -580,6 +583,7 @@ Example3 shows how to display a users objectGUID and member attributes. user_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE) self.outf.write(user_ldif) + class cmd_group(SuperCommand): """Group management.""" diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py index 3b0e0d536cf..bcd9c63150b 100644 --- a/python/samba/netcmd/ldapcmp.py +++ b/python/samba/netcmd/ldapcmp.py @@ -40,6 +40,7 @@ from samba.netcmd import ( global summary summary = {} + class LDAPBase(object): def __init__(self, host, creds, lp, @@ -262,6 +263,7 @@ class LDAPBase(object): except KeyError: pass + class Descriptor(object): def __init__(self, connection, dn, outf=sys.stdout, errf=sys.stderr): self.outf = outf @@ -380,6 +382,7 @@ class Descriptor(object): res += 8 * " " + ace + "\n" return (self_aces == [] and other_aces == [], res) + class LDAPObject(object): def __init__(self, connection, dn, summary, filter_list, outf=sys.stdout, errf=sys.stderr): diff --git a/python/samba/netcmd/main.py b/python/samba/netcmd/main.py index ae20940ab97..261cb78163d 100644 --- a/python/samba/netcmd/main.py +++ b/python/samba/netcmd/main.py @@ -21,6 +21,7 @@ from samba import getopt as options from samba.netcmd import SuperCommand + class cache_loader(dict): """ We only load subcommand tools if they are actually used. diff --git a/python/samba/netcmd/nettime.py b/python/samba/netcmd/nettime.py index dcf9f6c5cdf..74e3e16d13b 100644 --- a/python/samba/netcmd/nettime.py +++ b/python/samba/netcmd/nettime.py @@ -24,6 +24,7 @@ from samba.netcmd import ( Command, ) + class cmd_time(Command): """Retrieve the time on a server. diff --git a/python/samba/netcmd/ntacl.py b/python/samba/netcmd/ntacl.py index e7f410382c4..ab8f317014d 100644 --- a/python/samba/netcmd/ntacl.py +++ b/python/samba/netcmd/ntacl.py @@ -116,6 +116,7 @@ class cmd_dosinfo_get(Command): if dosinfo: self.outf.write(ndr_print(dosinfo)) + class cmd_ntacl_get(Command): """Get ACLs of a file.""" synopsis = "%prog <file> [options]" @@ -238,6 +239,7 @@ class cmd_ntacl_sysvolreset(Command): lp.get("realm").lower(), samdb.domain_dn(), lp, use_ntvfs=use_ntvfs) + class cmd_ntacl_sysvolcheck(Command): """Check sysvol ACLs match defaults (including correct ACLs on GPOs).""" synopsis = "%prog <file> [options]" diff --git a/python/samba/netcmd/ou.py b/python/samba/netcmd/ou.py index 9fd9d6bc3ff..0224701b69e 100644 --- a/python/samba/netcmd/ou.py +++ b/python/samba/netcmd/ou.py @@ -30,6 +30,7 @@ from samba.samdb import SamDB from samba import dsdb from operator import attrgetter + class cmd_rename(Command): """Rename an organizational unit. @@ -93,6 +94,7 @@ class cmd_rename(Command): self.outf.write('Renamed ou "%s" to "%s"\n' % (full_old_ou_dn, full_new_ou_dn)) + class cmd_move(Command): """Move an organizational unit. @@ -160,6 +162,7 @@ class cmd_move(Command): self.outf.write('Moved ou "%s" into "%s"\n' % (full_old_ou_dn, full_new_parent_dn)) + class cmd_create(Command): """Create an organizational unit. @@ -209,6 +212,7 @@ class cmd_create(Command): self.outf.write('Created ou "%s"\n' % full_ou_dn) + class cmd_listobjects(Command): """List all objects in an organizational unit. @@ -278,6 +282,7 @@ class cmd_listobjects(Command): raise CommandError('Failed to list contents of ou "%s"' % full_ou_dn, e) + class cmd_list(Command): """List all organizational units. @@ -322,6 +327,7 @@ class cmd_list(Command): msg.dn.remove_base_components(len(domain_dn)) self.outf.write("%s\n" % str(msg.dn)) + class cmd_delete(Command): """Delete an organizational unit. diff --git a/python/samba/netcmd/processes.py b/python/samba/netcmd/processes.py index 174142731c1..68569857ca0 100644 --- a/python/samba/netcmd/processes.py +++ b/python/samba/netcmd/processes.py @@ -32,6 +32,7 @@ import samba.getopt as options from samba.netcmd import Command, CommandError, Option from samba.messaging import Messaging + class cmd_processes(Command): """List processes (to aid debugging on systems without setproctitle).""" diff --git a/python/samba/netcmd/rodc.py b/python/samba/netcmd/rodc.py index 372c7efb81b..c36d0b67820 100644 --- a/python/samba/netcmd/rodc.py +++ b/python/samba/netcmd/rodc.py @@ -25,6 +25,7 @@ from samba.dcerpc import misc, drsuapi from samba.drs_utils import drs_Replicate import sys + class RODCException(Exception): def __init__(self, value): self.value = value @@ -32,12 +33,15 @@ class RODCException(Exception): def __str__(self): return "%s: %s" % (self.__class__.__name__, self.value) + class NamingError(RODCException): pass + class ReplicationError(RODCException): pass + class cmd_rodc_preload(Command): """Preload accounts for an RODC. Multiple accounts may be requested.""" diff --git a/python/samba/netcmd/schema.py b/python/samba/netcmd/schema.py index aeb947ee723..5768169c4c3 100644 --- a/python/samba/netcmd/schema.py +++ b/python/samba/netcmd/schema.py @@ -28,6 +28,7 @@ from samba.netcmd import ( Option ) + class cmd_schema_attribute_modify(Command): """Modify attribute settings in the schema partition. @@ -128,6 +129,7 @@ class cmd_schema_attribute_modify(Command): samdb.set_schema_update_now() self.outf.write("modified %s" % attr_dn) + class cmd_schema_attribute_show(Command): """Show details about an attribute from the schema. @@ -203,6 +205,7 @@ class cmd_schema_attribute_show(Command): user_ldif = samdb.write_ldif(res[0], ldb.CHANGETYPE_NONE) self.outf.write(user_ldif) + class cmd_schema_attribute_show_oc(Command): """Show what objectclasses MAY or MUST contain an attribute. @@ -293,6 +296,7 @@ class cmd_schema_objectclass_show(Command): user_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE) self.outf.write(user_ldif) + class cmd_schema_attribute(SuperCommand): """Query and manage attributes in the schema partition.""" subcommands = {} @@ -300,11 +304,13 @@ class cmd_schema_attribute(SuperCommand): subcommands["show"] = cmd_schema_attribute_show() subcommands["show_oc"] = cmd_schema_attribute_show_oc() + class cmd_schema_objectclass(SuperCommand): """Query and manage objectclasses in the schema partition.""" subcommands = {} subcommands["show"] = cmd_schema_objectclass_show() + class cmd_schema(SuperCommand): """Schema querying and management.""" diff --git a/python/samba/netcmd/sites.py b/python/samba/netcmd/sites.py index 423a0593f3b..b5a2508ee3a 100644 --- a/python/samba/netcmd/sites.py +++ b/python/samba/netcmd/sites.py @@ -221,6 +221,7 @@ class cmd_sites_subnet(SuperCommand): "set-site": cmd_sites_subnet_set_site(), } + class cmd_sites(SuperCommand): """Sites management.""" subcommands = {} diff --git a/python/samba/netcmd/testparm.py b/python/samba/netcmd/testparm.py index e2abd8a9a25..bf566f38d78 100644 --- a/python/samba/netcmd/testparm.py +++ b/python/samba/netcmd/testparm.py @@ -37,6 +37,7 @@ import samba import samba.getopt as options from samba.netcmd import Command, CommandError, Option + class cmd_testparm(Command): """Syntax check the configuration file.""" diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index ab00a07b8f6..f254bae21a6 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -95,17 +95,20 @@ if get_random_bytes_fn is None: except ImportError as e: pass + def check_random(): if get_random_bytes_fn is not None: return None return "Crypto.Random or M2Crypto.Rand required" + def get_random_bytes(num): random_reason = check_random() if random_reason is not None: raise ImportError(random_reason) return get_random_bytes_fn(num) + def get_crypt_value(alg, utf8pw, rounds=0): algs = { "5": {"length": 43}, @@ -139,6 +142,8 @@ def get_crypt_value(alg, utf8pw, rounds=0): # i.e. options = "rounds=20;other=ignored;" will return 20 # if the rounds option is not found or the value is not a number, 0 is returned # which indicates that the default number of rounds should be used. + + def get_rounds(options): if not options: return 0 @@ -204,6 +209,7 @@ virtual_attributes_help += "Possible supported virtual attributes: %s" % ", ".jo if len(disabled_virtual_attributes) != 0: virtual_attributes_help += "Unsupported virtual attributes: %s" % ", ".join(sorted(disabled_virtual_attributes.keys())) + class cmd_user_create(Command): """Create a new user. @@ -854,6 +860,7 @@ Example3 shows how an administrator would reset TestUser3 user's password to pas raise CommandError("%s: %s" % (command, msg)) self.outf.write("Changed password OK\n") + class GetPasswordCommand(Command): def __init__(self): @@ -1312,6 +1319,7 @@ class GetPasswordCommand(Command): return password_attrs + class cmd_user_getpassword(GetPasswordCommand): """Get the password fields of a user/computer account. @@ -1464,6 +1472,7 @@ samba-tool user getpassword --filter=samaccountname=TestUser3 --attributes=msDS- self.outf.write("%s" % ldif) self.outf.write("Got password OK\n") + class cmd_user_syncpasswords(GetPasswordCommand): """Sync the password of user accounts. @@ -2296,6 +2305,7 @@ samba-tool user syncpasswords --terminate \\ update_pid(None) return + class cmd_user_edit(Command): """Modify User AD object. @@ -2429,6 +2439,7 @@ LDAP server using the 'nano' editor. self.outf.write("Modified User '%s' successfully\n" % username) + class cmd_user_show(Command): """Display a user AD object. @@ -2507,6 +2518,7 @@ Example3 shows how to display a users objectSid and memberOf attributes. user_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE) self.outf.write(user_ldif) + class cmd_user_move(Command): """Move a user to an organizational unit/container. @@ -2586,6 +2598,7 @@ class cmd_user_move(Command): self.outf.write('Moved user "%s" into "%s"\n' % (username, full_new_parent_dn)) + class cmd_user(SuperCommand): """User management.""" diff --git a/python/samba/ntacls.py b/python/samba/ntacls.py index 1fddeddc859..9b592629296 100644 --- a/python/samba/ntacls.py +++ b/python/samba/ntacls.py @@ -80,6 +80,7 @@ def checkset_backend(lp, backend, eadbfile): else: raise XattrBackendError("Invalid xattr backend choice %s" %backend) + def getdosinfo(lp, file): try: attribute = samba.xattr_native.wrap_getxattr(file, @@ -89,6 +90,7 @@ def getdosinfo(lp, file): return ndr_unpack(xattr.DOSATTRIB, attribute) + def getntacl(lp, file, backend=None, eadbfile=None, direct_db_access=True, service=None): if direct_db_access: (backend_obj, dbname) = checkset_backend(lp, backend, eadbfile) diff --git a/python/samba/provision/__init__.py b/python/samba/provision/__init__.py index 0d80200ef95..25d1f61e76f 100644 --- a/python/samba/provision/__init__.py +++ b/python/samba/provision/__init__.py @@ -709,6 +709,7 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, return names + def make_smbconf(smbconf, hostname, domain, realm, targetdir, serverrole=None, eadb=False, use_ntvfs=False, lp=None, global_param=None): @@ -1061,6 +1062,7 @@ def setup_privileges(path, session_info, lp): privilege_ldb.erase() privilege_ldb.load_ldif_file_add(setup_path("provision_privilege.ldif")) + def setup_encrypted_secrets_key(path): """Setup the encrypted secrets key file. @@ -1582,6 +1584,7 @@ SYSVOL_ACL = "O:LAG:BAD:P(A;OICI;0x001f01ff;;;BA)(A;OICI;0x001200a9;;;SO)(A;OICI POLICIES_ACL = "O:LAG:BAD:P(A;OICI;0x001f01ff;;;BA)(A;OICI;0x001200a9;;;SO)(A;OICI;0x001f01ff;;;SY)(A;OICI;0x001200a9;;;AU)(A;OICI;0x001301bf;;;PA)" SYSVOL_SERVICE = "sysvol" + def set_dir_acl(path, acl, lp, domsid, use_ntvfs, passdb, service=SYSVOL_SERVICE): setntacl(lp, path, acl, domsid, use_ntvfs=use_ntvfs, skip_invalid_chown=True, passdb=passdb, service=service) for root, dirs, files in os.walk(path, topdown=False): @@ -1729,12 +1732,14 @@ def setsysvolacl(samdb, netlogon, sysvol, uid, gid, domainsid, dnsdomain, # Set acls on Policy folder and policies folders set_gpos_acl(sysvol, dnsdomain, domainsid, domaindn, samdb, lp, use_ntvfs, passdb=s4_passdb) + def acl_type(direct_db_access): if direct_db_access: return "DB" else: return "VFS" + def check_dir_acl(path, acl, lp, domainsid, direct_db_access): fsacl = getntacl(lp, path, direct_db_access=direct_db_access, service=SYSVOL_SERVICE) fsacl_sddl = fsacl.as_sddl(domainsid) @@ -2053,6 +2058,7 @@ def provision_fake_ypserver(logger, samdb, domaindn, netbiosname, nisdomain, else: samdb.transaction_commit() + def directory_create_or_exists(path, mode=0o755): if not os.path.exists(path): try: @@ -2063,6 +2069,7 @@ def directory_create_or_exists(path, mode=0o755): else: raise ProvisioningError("Failed to create directory %s: %s" % (path, e.strerror)) + def determine_host_ip(logger, lp, hostip=None): if hostip is None: logger.info("Looking up IPv4 addresses") @@ -2079,6 +2086,7 @@ def determine_host_ip(logger, lp, hostip=None): return hostip + def determine_host_ip6(logger, lp, hostip6=None): if hostip6 is None: logger.info("Looking up IPv6 addresses") @@ -2092,6 +2100,7 @@ def determine_host_ip6(logger, lp, hostip6=None): return hostip6 + def provision(logger, session_info, smbconf=None, targetdir=None, samdb_fill=FILL_FULL, realm=None, rootdn=None, domaindn=None, schemadn=None, configdn=None, serverdn=None, diff --git a/python/samba/provision/kerberos.py b/python/samba/provision/kerberos.py index 4ed4d57a03c..6b8ceb28733 100644 --- a/python/samba/provision/kerberos.py +++ b/python/samba/provision/kerberos.py @@ -23,6 +23,7 @@ from samba.provision.kerberos_implementation import ( from samba import is_heimdal_built import os + def create_kdc_conf(kdcconf, realm, domain, logdir): if is_heimdal_built(): diff --git a/python/samba/provision/sambadns.py b/python/samba/provision/sambadns.py index 3afe94cb9b4..ff38e22ce92 100644 --- a/python/samba/provision/sambadns.py +++ b/python/samba/provision/sambadns.py @@ -61,6 +61,7 @@ from samba.provision.common import ( from samba.samdb import get_default_backend_store + def get_domainguid(samdb, domaindn): res = samdb.search(base=domaindn, scope=ldb.SCOPE_BASE, attrs=["objectGUID"]) domainguid = str(ndr_unpack(misc.GUID, res[0]["objectGUID"][0])) @@ -390,6 +391,7 @@ def add_rootservers(samdb, domaindn, prefix): msg["dnsRecord"] = ldb.MessageElement(record, ldb.FLAG_MOD_ADD, "dnsRecord") samdb.add(msg) + def add_at_record(samdb, container_dn, prefix, hostname, dnsdomain, hostip, hostip6): fqdn_hostname = "%s.%s" % (hostname, dnsdomain) diff --git a/python/samba/remove_dc.py b/python/samba/remove_dc.py index 12fefbed0f6..038177f262e 100644 --- a/python/samba/remove_dc.py +++ b/python/samba/remove_dc.py @@ -25,6 +25,7 @@ from samba.dcerpc import misc, dnsp from samba.dcerpc.dnsp import DNS_TYPE_NS, DNS_TYPE_A, DNS_TYPE_AAAA, \ DNS_TYPE_CNAME, DNS_TYPE_SRV, DNS_TYPE_PTR + class DemoteException(Exception): """Base element for demote errors""" @@ -284,6 +285,7 @@ def offline_remove_server(samdb, logger, if remove_sysvol_obj: remove_sysvol_references(samdb, logger, dc_name) + def offline_remove_ntds_dc(samdb, logger, ntds_dn, diff --git a/python/samba/samba3/__init__.py b/python/samba/samba3/__init__.py index 283185aa823..1f8c5100bcb 100644 --- a/python/samba/samba3/__init__.py +++ b/python/samba/samba3/__init__.py @@ -29,6 +29,7 @@ import tdb import samba.samba3.passdb from samba.samba3 import param as s3param + def fetch_uint32(db, key): try: data = db[key] @@ -134,6 +135,7 @@ IDMAP_USER_PREFIX = b"UID " # idmap version determines auto-conversion IDMAP_VERSION_V2 = 2 + class IdmapDatabase(DbDatabase): """Samba 3 ID map database reader.""" diff --git a/python/samba/samdb.py b/python/samba/samdb.py index 2e0ec579f81..4f674e34449 100644 --- a/python/samba/samdb.py +++ b/python/samba/samdb.py @@ -41,6 +41,7 @@ __docformat__ = "restructuredText" def get_default_backend_store(): return "tdb" + class SamDB(samba.Ldb): """The SAM database.""" diff --git a/python/samba/schema.py b/python/samba/schema.py index 55cb52e0fc4..59b53faf5cd 100644 --- a/python/samba/schema.py +++ b/python/samba/schema.py @@ -32,6 +32,7 @@ from samba import dsdb from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL import os + def get_schema_descriptor(domain_sid, name_map={}): sddl = "O:SAG:SAD:AI(OA;;CR;e12b56b6-0a95-11d1-adbb-00c04fd8d5cd;;SA)" \ "(OA;;CR;1131f6aa-9c07-11d1-f79f-00c04fc2dcd2;;ED)" \ diff --git a/python/samba/subnets.py b/python/samba/subnets.py index 32865bc3bcd..dfd3a610ce8 100644 --- a/python/samba/subnets.py +++ b/python/samba/subnets.py @@ -24,6 +24,7 @@ import ldb from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, LdbError from sites import SiteNotFoundException + class SubnetException(Exception): """Base element for Subnet errors""" pass @@ -129,6 +130,7 @@ def delete_subnet(samdb, configDn, subnet_name): samdb.delete(dnsubnet) + def rename_subnet(samdb, configDn, subnet_name, new_name): """Rename a subnet. @@ -164,6 +166,7 @@ def rename_subnet(samdb, configDn, subnet_name, new_name): else: raise + def set_subnet_site(samdb, configDn, subnet_name, site_name): """Assign a subnet to a site. diff --git a/python/samba/tdb_util.py b/python/samba/tdb_util.py index 60ecee11880..badfbd66bba 100644 --- a/python/samba/tdb_util.py +++ b/python/samba/tdb_util.py @@ -22,6 +22,7 @@ import samba import subprocess import os + def tdb_copy(file1, file2, readonly=False): """Copy tdb file using tdbbackup utility and rename it """ diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index bd17a870d66..75f5e98ca06 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -58,6 +58,7 @@ except ImportError: HEXDUMP_FILTER = bytearray([x if ((len(repr(chr(x))) == 3) and (x < 127)) else ord('.') for x in range(256)]) + class TestCase(unittest.TestCase): """A Samba test case.""" @@ -320,6 +321,7 @@ def env_get_var_value(var_name, allow_missing=False): cmdline_credentials = None + class RpcInterfaceTestCase(TestCase): """DCE/RPC Test case.""" @@ -359,6 +361,7 @@ class BlackboxProcessError(Exception): return s + class BlackboxTestCase(TestCaseInTempDir): """Base test case for blackbox tests.""" @@ -490,6 +493,7 @@ def delete_force(samdb, dn, **kwargs): (num, errstr) = error.args assert num == ldb.ERR_NO_SUCH_OBJECT, "ldb.delete() failed: %s" % errstr + def create_test_ou(samdb, name): """Creates a unique OU for the test""" diff --git a/python/samba/tests/auth.py b/python/samba/tests/auth.py index 5b3cedd8754..099826e0c62 100644 --- a/python/samba/tests/auth.py +++ b/python/samba/tests/auth.py @@ -24,6 +24,7 @@ the functionality, that's already done in other tests. from samba import auth import samba.tests + class AuthSystemSessionTests(samba.tests.TestCase): def setUp(self): @@ -57,6 +58,7 @@ class AuthSystemSessionTests(samba.tests.TestCase): self.assertTrue(self.system_session.security_token.is_system()) self.assertFalse(self.system_session.security_token.is_anonymous()) + class AuthAdminSessionTests(samba.tests.TestCase): def setUp(self): diff --git a/python/samba/tests/blackbox/samba_dnsupdate.py b/python/samba/tests/blackbox/samba_dnsupdate.py index c4f14b319dc..26496740bb4 100644 --- a/python/samba/tests/blackbox/samba_dnsupdate.py +++ b/python/samba/tests/blackbox/samba_dnsupdate.py @@ -25,6 +25,7 @@ from samba.samdb import SamDB import ldb import shutil, os + class SambaDnsUpdateTests(samba.tests.BlackboxTestCase): """Blackbox test case for samba_dnsupdate.""" diff --git a/python/samba/tests/core.py b/python/samba/tests/core.py index 4abb05420d2..2614e9c9962 100644 --- a/python/samba/tests/core.py +++ b/python/samba/tests/core.py @@ -23,6 +23,7 @@ import samba from samba import arcfour_encrypt, string_to_byte_array from samba.tests import TestCase, TestCaseInTempDir + class SubstituteVarTestCase(TestCase): def test_empty(self): @@ -49,6 +50,7 @@ class SubstituteVarTestCase(TestCase): self.assertRaises(Exception, samba.check_all_substituted, "Not subsituted: ${FOOBAR}") + class ArcfourTestCase(TestCase): def test_arcfour_direct(self): @@ -58,6 +60,7 @@ class ArcfourTestCase(TestCase): crypt_calculated = arcfour_encrypt(key, plain) self.assertEquals(crypt_expected, crypt_calculated) + class StringToByteArrayTestCase(TestCase): def test_byte_array(self): @@ -65,6 +68,7 @@ class StringToByteArrayTestCase(TestCase): calculated = string_to_byte_array('\xda\x91Z\xb0l\xd7\xb9\xcf\x99') self.assertEquals(expected, calculated) + class LdbExtensionTests(TestCaseInTempDir): def test_searchone(self): diff --git a/python/samba/tests/credentials.py b/python/samba/tests/credentials.py index 7c89da54ee3..0b5352bf045 100644 --- a/python/samba/tests/credentials.py +++ b/python/samba/tests/credentials.py @@ -28,6 +28,7 @@ import binascii from samba.compat import PY3 from samba.dcerpc import misc + class CredentialsTests(samba.tests.TestCaseInTempDir): def setUp(self): diff --git a/python/samba/tests/dcerpc/array.py b/python/samba/tests/dcerpc/array.py index fed03531afb..6f31546c4db 100644 --- a/python/samba/tests/dcerpc/array.py +++ b/python/samba/tests/dcerpc/array.py @@ -23,6 +23,7 @@ from samba.ndr import ndr_unpack, ndr_pack import talloc import gc + class ArrayTests(samba.tests.TestCase): def setUp(self): diff --git a/python/samba/tests/dcerpc/bare.py b/python/samba/tests/dcerpc/bare.py index 00968f15f0e..bb25546ddc7 100644 --- a/python/samba/tests/dcerpc/bare.py +++ b/python/samba/tests/dcerpc/bare.py @@ -23,6 +23,7 @@ import os from samba.dcerpc import ClientConnection import samba.tests + class BareTestCase(samba.tests.TestCase): def test_bare(self): diff --git a/python/samba/tests/dcerpc/dnsserver.py b/python/samba/tests/dcerpc/dnsserver.py index e0fff73ad78..f68c301a944 100644 --- a/python/samba/tests/dcerpc/dnsserver.py +++ b/python/samba/tests/dcerpc/dnsserver.py @@ -29,6 +29,7 @@ from samba.tests import RpcInterfaceTestCase, env_get_var_value from samba.netcmd.dns import ARecord, AAAARecord, PTRRecord, CNameRecord, NSRecord, MXRecord, SRVRecord, TXTRecord from samba import sd_utils, descriptor + class DnsserverTests(RpcInterfaceTestCase): @classmethod diff --git a/python/samba/tests/dcerpc/integer.py b/python/samba/tests/dcerpc/integer.py index ca5d571b7e8..62d1e67a36b 100644 --- a/python/samba/tests/dcerpc/integer.py +++ b/python/samba/tests/dcerpc/integer.py @@ -20,6 +20,7 @@ from samba.dcerpc import server_id, misc, srvsvc, samr import samba.tests + class IntegerTests(samba.tests.TestCase): def test_uint32_into_hyper(self): diff --git a/python/samba/tests/dcerpc/raw_protocol.py b/python/samba/tests/dcerpc/raw_protocol.py index f4ba1fbe33d..3b2579fa762 100755 --- a/python/samba/tests/dcerpc/raw_protocol.py +++ b/python/samba/tests/dcerpc/raw_protocol.py @@ -36,6 +36,7 @@ from samba.tests.dcerpc.raw_testcase import RawDCERPCTest global_ndr_print = False global_hexdump = False + class TestDCERPC_BIND(RawDCERPCTest): def setUp(self): diff --git a/python/samba/tests/dcerpc/raw_testcase.py b/python/samba/tests/dcerpc/raw_testcase.py index 795f45cb3eb..589f337e8d1 100644 --- a/python/samba/tests/dcerpc/raw_testcase.py +++ b/python/samba/tests/dcerpc/raw_testcase.py @@ -28,6 +28,7 @@ from samba.credentials import Credentials from samba.tests import TestCase from samba.ndr import ndr_pack, ndr_unpack, ndr_unpack_out + class RawDCERPCTest(TestCase): """A raw DCE/RPC Test case.""" diff --git a/python/samba/tests/dcerpc/testrpc.py b/python/samba/tests/dcerpc/testrpc.py index 1ebe34e6247..1560df647c3 100644 --- a/python/samba/tests/dcerpc/testrpc.py +++ b/python/samba/tests/dcerpc/testrpc.py @@ -26,6 +26,7 @@ import talloc talloc.enable_null_tracking() + class RpcTests(object): '''test type behaviour of pidl generated python RPC code''' diff --git a/python/samba/tests/dcerpc/unix.py b/python/samba/tests/dcerpc/unix.py index e8ef4da8630..c7e938af851 100644 --- a/python/samba/tests/dcerpc/unix.py +++ b/python/samba/tests/dcerpc/unix.py @@ -21,6 +21,7 @@ from samba.dcerpc import unixinfo from samba.tests import RpcInterfaceTestCase + class UnixinfoTests(RpcInterfaceTestCase): def setUp(self): diff --git a/python/samba/tests/dckeytab.py b/python/samba/tests/dckeytab.py index 11bc99a2d20..239d3113dad 100644 --- a/python/samba/tests/dckeytab.py +++ b/python/samba/tests/dckeytab.py @@ -22,12 +22,14 @@ import samba.dckeytab from samba import tests from samba.param import LoadParm + def open_bytes(filename): if sys.version_info[0] == 3: return open(filename, errors='ignore') else: return open(filename, 'rb') + class DCKeytabTests(tests.TestCase): def setUp(self): super(DCKeytabTests, self).setUp() diff --git a/python/samba/tests/dns_forwarder.py b/python/samba/tests/dns_forwarder.py index 50e390a2cc6..1539710a213 100644 --- a/python/samba/tests/dns_forwarder.py +++ b/python/samba/tests/dns_forwarder.py @@ -66,6 +66,7 @@ dns_servers = args[2:] creds.set_krb_forwardable(credentials.NO_KRB_FORWARDABLE) + def make_txt_record(records): rdata_txt = dns.txt_record() s_list = dnsp.string_list() diff --git a/python/samba/tests/dns_forwarder_helpers/server.py b/python/samba/tests/dns_forwarder_helpers/server.py index 7bd27e53b50..4d6e57d325d 100644 --- a/python/samba/tests/dns_forwarder_helpers/server.py +++ b/python/samba/tests/dns_forwarder_helpers/server.py @@ -29,6 +29,7 @@ import re VERBOSE = False + def debug(msg): if VERBOSE: sys.stdout.flush() @@ -85,6 +86,7 @@ class DnsHandler(SocketServer.BaseRequestHandler): t = Timer(timeout, self.really_handle, [data, socket]) t.start() + def main(): global SERVER_ID host, port, SERVER_ID = sys.argv[1:] diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py index 6a0fcf11099..c14e3c50e06 100644 --- a/python/samba/tests/docs.py +++ b/python/samba/tests/docs.py @@ -27,6 +27,7 @@ import re import subprocess import xml.etree.ElementTree as ET + class TestCase(samba.tests.TestCaseInTempDir): def _format_message(self, parameters, message): @@ -96,6 +97,7 @@ def get_documented_tuples(sourcedir, omit_no_default=True): yield name, default_text, context, param_type p.close() + class SmbDotConfTests(TestCase): # defines the cases where the defaults may differ from the documentation diff --git a/python/samba/tests/dsdb.py b/python/samba/tests/dsdb.py index 4110e8d209a..1537838ddb8 100644 --- a/python/samba/tests/dsdb.py +++ b/python/samba/tests/dsdb.py @@ -30,6 +30,7 @@ import ldb import samba import uuid + class DsdbTests(TestCase): def setUp(self): @@ -726,6 +727,7 @@ class DsdbTests(TestCase): str(part_dn) + "," + str(domain_dn)), self.samdb.normalize_dn_in_domain(part_dn)) + class DsdbFullScanTests(TestCase): def setUp(self): diff --git a/python/samba/tests/dsdb_lock.py b/python/samba/tests/dsdb_lock.py index 332526ed795..6728875b98e 100644 --- a/python/samba/tests/dsdb_lock.py +++ b/python/samba/tests/dsdb_lock.py @@ -25,6 +25,7 @@ import samba import gc import time + class DsdbLockTestCase(SamDBTestCase): def test_db_lock1(self): basedn = self.samdb.get_default_basedn() diff --git a/python/samba/tests/dsdb_schema_attributes.py b/python/samba/tests/dsdb_schema_attributes.py index d5ad336b13c..5fd199a211f 100644 --- a/python/samba/tests/dsdb_schema_attributes.py +++ b/python/samba/tests/dsdb_schema_attributes.py @@ -33,6 +33,7 @@ from ldb import SCOPE_BASE, LdbError import samba.tests + class SchemaAttributesTestCase(samba.tests.TestCase): def setUp(self): diff --git a/python/samba/tests/gensec.py b/python/samba/tests/gensec.py index 9cb6eea93ab..7375f1dfab0 100644 --- a/python/samba/tests/gensec.py +++ b/python/samba/tests/gensec.py @@ -25,6 +25,7 @@ from samba.credentials import Credentials from samba import gensec, auth import samba.tests + class GensecTests(samba.tests.TestCase): def setUp(self): diff --git a/python/samba/tests/get_opt.py b/python/samba/tests/get_opt.py index ca55c8d08b1..e51c7068aba 100644 --- a/python/samba/tests/get_opt.py +++ b/python/samba/tests/get_opt.py @@ -28,6 +28,7 @@ from samba.getopt import ( ) import samba.tests + class KerberosOptionTests(samba.tests.TestCase): def test_parse_true(self): diff --git a/python/samba/tests/gpo.py b/python/samba/tests/gpo.py index ed5f8702b99..7c884f70c2f 100644 --- a/python/samba/tests/gpo.py +++ b/python/samba/tests/gpo.py @@ -26,6 +26,7 @@ poldir = r'\\addom.samba.example.com\sysvol\addom.samba.example.com\Policies' dspath = 'CN=Policies,CN=System,DC=addom,DC=samba,DC=example,DC=com' gpt_data = '[General]\nVersion=%d' + class GPOTests(tests.TestCase): def setUp(self): super(GPOTests, self).setUp() diff --git a/python/samba/tests/join.py b/python/samba/tests/join.py index 31b89213e45..e2432d22f9a 100644 --- a/python/samba/tests/join.py +++ b/python/samba/tests/join.py @@ -25,6 +25,7 @@ from samba.join import DCJoinContext from samba.dcerpc import drsuapi, misc, dns from samba.credentials import Credentials + def get_logger(name="subunit"): """Get a logger object.""" import logging @@ -32,6 +33,7 @@ def get_logger(name="subunit"): logger.addHandler(logging.StreamHandler(sys.stderr)) return logger + class JoinTestCase(DNSTKeyTest): def setUp(self): self.server = samba.tests.env_get_var_value("SERVER") diff --git a/python/samba/tests/kcc/__init__.py b/python/samba/tests/kcc/__init__.py index b2518022805..a196eedb353 100644 --- a/python/samba/tests/kcc/__init__.py +++ b/python/samba/tests/kcc/__init__.py @@ -48,6 +48,7 @@ ENV_DSAS = { 'CN=LOCALVAMPIREDC,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=samba,DC=example,DC=com'], } + class KCCTests(samba.tests.TestCase): def setUp(self): super(KCCTests, self).setUp() diff --git a/python/samba/tests/krb5_credentials.py b/python/samba/tests/krb5_credentials.py index 01694fe7009..85d1dbcdbaa 100644 --- a/python/samba/tests/krb5_credentials.py +++ b/python/samba/tests/krb5_credentials.py @@ -39,6 +39,7 @@ KDC MACHINE_NAME = "krb5credstest" + class PyKrb5CredentialsTests(TestCase): def setUp(self): diff --git a/python/samba/tests/libsmb_samba_internal.py b/python/samba/tests/libsmb_samba_internal.py index d883dae2fd7..ec277230d81 100644 --- a/python/samba/tests/libsmb_samba_internal.py +++ b/python/samba/tests/libsmb_samba_internal.py @@ -26,6 +26,7 @@ import threading import sys import os + class LibsmbTestCase(samba.tests.TestCase): class OpenClose(threading.Thread): diff --git a/python/samba/tests/loadparm.py b/python/samba/tests/loadparm.py index daa0162b09f..fc79e28efb6 100644 --- a/python/samba/tests/loadparm.py +++ b/python/samba/tests/loadparm.py @@ -22,6 +22,8 @@ import os # the python bindings for LoadParm objects map (by default) to a single global # object in the underlying C code. E.g. if we create 2 different LoadParm # objects in python, really they're just the same object underneath. + + class LoadParmTest(TestCaseInTempDir): def test_global_loadparm(self): diff --git a/python/samba/tests/lsa_string.py b/python/samba/tests/lsa_string.py index 130f8807a21..b29e03bb349 100644 --- a/python/samba/tests/lsa_string.py +++ b/python/samba/tests/lsa_string.py @@ -24,6 +24,7 @@ Tests for the C helper functions in source4/librpc/ndr/py_lsa.c for samba.dcerpc.lsa.String """ + class LsaStringTests(TestCase): def test_default_constructor(self): diff --git a/python/samba/tests/net_join.py b/python/samba/tests/net_join.py index 41220280e62..640e96d56f5 100644 --- a/python/samba/tests/net_join.py +++ b/python/samba/tests/net_join.py @@ -27,6 +27,7 @@ from samba.credentials import DONT_USE_KERBEROS from samba import NTSTATUSError, ntstatus import ctypes + class NetJoinTests(samba.tests.TestCaseInTempDir): def setUp(self): diff --git a/python/samba/tests/net_join_no_spnego.py b/python/samba/tests/net_join_no_spnego.py index e4dd078f2f6..6dbb9b0e983 100644 --- a/python/samba/tests/net_join_no_spnego.py +++ b/python/samba/tests/net_join_no_spnego.py @@ -27,6 +27,7 @@ from samba.credentials import DONT_USE_KERBEROS from samba import NTSTATUSError, ntstatus import ctypes + class NetJoinNoSpnegoTests(samba.tests.TestCaseInTempDir): def setUp(self): diff --git a/python/samba/tests/netbios.py b/python/samba/tests/netbios.py index f2882ebe2e6..82a0ef528ba 100644 --- a/python/samba/tests/netbios.py +++ b/python/samba/tests/netbios.py @@ -18,6 +18,7 @@ import samba, os, random, sys from samba import netbios + class NetBiosTests(samba.tests.TestCase): def setUp(self): super(NetBiosTests, self).setUp() diff --git a/python/samba/tests/netcmd.py b/python/samba/tests/netcmd.py index 8e2862306b2..433bf3977c8 100644 --- a/python/samba/tests/netcmd.py +++ b/python/samba/tests/netcmd.py @@ -23,6 +23,7 @@ from samba.netcmd.testparm import cmd_testparm from samba.netcmd.main import cmd_sambatool import samba.tests + class NetCmdTestCase(samba.tests.TestCase): def run_netcmd(self, cmd_klass, args, retcode=0): diff --git a/python/samba/tests/netlogonsvc.py b/python/samba/tests/netlogonsvc.py index 3dac66c71cc..342e2efc849 100644 --- a/python/samba/tests/netlogonsvc.py +++ b/python/samba/tests/netlogonsvc.py @@ -28,6 +28,7 @@ import ctypes Tests whether the netlogon service is running """ + class NetlogonServiceTests(TestCase): def setUp(self): diff --git a/python/samba/tests/ntlmdisabled.py b/python/samba/tests/ntlmdisabled.py index dadebb327f5..6d2afe9054d 100644 --- a/python/samba/tests/ntlmdisabled.py +++ b/python/samba/tests/ntlmdisabled.py @@ -31,6 +31,7 @@ from samba.dcerpc import srvsvc, samr, lsa Tests behaviour when NTLM is disabled """ + class NtlmDisabledTests(TestCase): def setUp(self): diff --git a/python/samba/tests/pam_winbind.py b/python/samba/tests/pam_winbind.py index 0f38469da0b..4ee7c8d784b 100644 --- a/python/samba/tests/pam_winbind.py +++ b/python/samba/tests/pam_winbind.py @@ -20,6 +20,7 @@ import samba.tests import pypamtest import os + class SimplePamTests(samba.tests.TestCase): def test_authenticate(self): domain = os.environ["DOMAIN"] diff --git a/python/samba/tests/pam_winbind_warn_pwd_expire.py b/python/samba/tests/pam_winbind_warn_pwd_expire.py index c3b7e1dbfca..849099446da 100644 --- a/python/samba/tests/pam_winbind_warn_pwd_expire.py +++ b/python/samba/tests/pam_winbind_warn_pwd_expire.py @@ -20,6 +20,7 @@ import samba.tests import pypamtest import os + class PasswordExpirePamTests(samba.tests.TestCase): def test_auth_expire_warning(self): domain = os.environ["DOMAIN"] diff --git a/python/samba/tests/password_hash.py b/python/samba/tests/password_hash.py index 485d7b1a3e2..07d92e6ddf3 100644 --- a/python/samba/tests/password_hash.py +++ b/python/samba/tests/password_hash.py @@ -45,6 +45,8 @@ UPN = "PWHash@User.Principle" # Get named package from the passed supplemental credentials # # returns the package and it's position within the supplemental credentials + + def get_package(sc, name): if sc is None: return None @@ -59,6 +61,8 @@ def get_package(sc, name): # Calculate the MD5 password digest from the supplied user, realm and password # + + def calc_digest(user, realm, password): data = "%s:%s:%s" % (user, realm, password) diff --git a/python/samba/tests/password_hash_fl2008.py b/python/samba/tests/password_hash_fl2008.py index 91064b4f11b..fcfb60fdde3 100644 --- a/python/samba/tests/password_hash_fl2008.py +++ b/python/samba/tests/password_hash_fl2008.py @@ -34,6 +34,7 @@ from samba.ndr import ndr_unpack from samba.dcerpc import drsblobs import binascii + class PassWordHashFl2008Tests(PassWordHashTests): def setUp(self): diff --git a/python/samba/tests/password_hash_gpgme.py b/python/samba/tests/password_hash_gpgme.py index 6dafaa81aca..2834ab557c0 100644 --- a/python/samba/tests/password_hash_gpgme.py +++ b/python/samba/tests/password_hash_gpgme.py @@ -37,6 +37,7 @@ import binascii from samba.tests.pso import PasswordSettings import samba + class PassWordHashGpgmeTests(PassWordHashTests): def setUp(self): diff --git a/python/samba/tests/password_hash_ldap.py b/python/samba/tests/password_hash_ldap.py index c2c0f781628..bb641e0db23 100644 --- a/python/samba/tests/password_hash_ldap.py +++ b/python/samba/tests/password_hash_ldap.py @@ -49,9 +49,11 @@ from samba.credentials import Credentials import binascii import os + def attid_equal(a1, a2): return (a1 & 0xffffffff) == (a2 & 0xffffffff) + class PassWordHashLDAPTests(PassWordHashTests): def setUp(self): diff --git a/python/samba/tests/password_quality.py b/python/samba/tests/password_quality.py index 890060e2796..bc8ced0aa15 100644 --- a/python/samba/tests/password_quality.py +++ b/python/samba/tests/password_quality.py @@ -23,6 +23,7 @@ from samba import check_password_quality from samba.tests import TestCase, TestCaseInTempDir + class PasswordQualityTests(TestCase): def test_check_password_quality(self): self.assertFalse(check_password_quality(""), diff --git a/python/samba/tests/password_test.py b/python/samba/tests/password_test.py index 3e78277adf6..730bd4d4789 100644 --- a/python/samba/tests/password_test.py +++ b/python/samba/tests/password_test.py @@ -21,6 +21,7 @@ import samba.tests from samba.samdb import SamDB + class PasswordCommon: @staticmethod diff --git a/python/samba/tests/posixacl.py b/python/samba/tests/posixacl.py index 68dbaa63543..26138139056 100644 --- a/python/samba/tests/posixacl.py +++ b/python/samba/tests/posixacl.py @@ -841,6 +841,7 @@ class SessionedPosixAclMappingTests(PosixAclMappingTests): return auth.user_session(self.samdb, lp_ctx=self.lp, dn=dn, session_info_flags=flags) + class UnixSessionedPosixAclMappingTests(PosixAclMappingTests): """ Run same test suite with session enabled. diff --git a/python/samba/tests/provision.py b/python/samba/tests/provision.py index bd39abf9920..f51098629d8 100644 --- a/python/samba/tests/provision.py +++ b/python/samba/tests/provision.py @@ -30,6 +30,7 @@ from samba.provision import ( import samba.tests from samba.tests import env_loadparm, TestCase + def create_dummy_secretsdb(path, lp=None): """Create a dummy secrets database for use in tests. @@ -73,6 +74,7 @@ class ProvisionTestCase(samba.tests.TestCaseInTempDir): if os.path.exists(secrets_tdb_path): os.unlink(secrets_tdb_path) + class FindNssTests(TestCase): """Test findnss() function.""" diff --git a/python/samba/tests/py_credentials.py b/python/samba/tests/py_credentials.py index c2091e49825..71a3efb132f 100644 --- a/python/samba/tests/py_credentials.py +++ b/python/samba/tests/py_credentials.py @@ -48,6 +48,7 @@ Integration tests for pycredentials MACHINE_NAME = "PCTM" USER_NAME = "PCTU" + class PyCredentialsTests(TestCase): def setUp(self): @@ -357,6 +358,8 @@ class PyCredentialsTests(TestCase): # # Build the logon data required by NetrLogonSamLogonWithFlags + + def samlogon_logon_info(domain_name, computer_name, creds, flags=CLI_CRED_NTLMv2_AUTH): @@ -385,6 +388,8 @@ def samlogon_logon_info(domain_name, computer_name, creds, # # Build the samlogon target info. + + def samlogon_target(domain_name, computer_name): target_info = ntlmssp.AV_PAIR_LIST() target_info.count = 3 diff --git a/python/samba/tests/s3idmapdb.py b/python/samba/tests/s3idmapdb.py index cda4b3154ba..63c7758c075 100644 --- a/python/samba/tests/s3idmapdb.py +++ b/python/samba/tests/s3idmapdb.py @@ -27,6 +27,7 @@ for p in ["../../../../../testdata/samba3", "../../../../testdata/samba3"]: if os.path.exists(DATADIR): break + class IdmapDbTestCase(TestCase): def setUp(self): diff --git a/python/samba/tests/samba3sam.py b/python/samba/tests/samba3sam.py index 8ea6cad060f..10b6408ca79 100644 --- a/python/samba/tests/samba3sam.py +++ b/python/samba/tests/samba3sam.py @@ -41,6 +41,7 @@ def read_datafile(filename): break return open(os.path.join(datadir, filename), 'r').read() + def ldb_debug(l, text): print(text) diff --git a/python/samba/tests/samba_tool/computer.py b/python/samba/tests/samba_tool/computer.py index beb984c3c69..678a023cc1e 100644 --- a/python/samba/tests/samba_tool/computer.py +++ b/python/samba/tests/samba_tool/computer.py @@ -26,6 +26,7 @@ from samba import dsdb from samba.ndr import ndr_unpack, ndr_pack from samba.dcerpc import dnsp + class ComputerCmdTestCase(SambaToolCmdTest): """Tests for samba-tool computer subcommands""" computers = [] diff --git a/python/samba/tests/samba_tool/dnscmd.py b/python/samba/tests/samba_tool/dnscmd.py index ccd7e8f2c1e..aace2d6cdef 100644 --- a/python/samba/tests/samba_tool/dnscmd.py +++ b/python/samba/tests/samba_tool/dnscmd.py @@ -24,6 +24,7 @@ from samba.ndr import ndr_unpack, ndr_pack from samba.dcerpc import dnsp from samba.tests.samba_tool.base import SambaToolCmdTest + class DnsCmdTestCase(SambaToolCmdTest): def setUp(self): super(DnsCmdTestCase, self).setUp() diff --git a/python/samba/tests/samba_tool/forest.py b/python/samba/tests/samba_tool/forest.py index 11c77e6105e..8817636bd63 100644 --- a/python/samba/tests/samba_tool/forest.py +++ b/python/samba/tests/samba_tool/forest.py @@ -19,6 +19,7 @@ import os import ldb from samba.tests.samba_tool.base import SambaToolCmdTest + class ForestCmdTestCase(SambaToolCmdTest): """Tests for samba-tool dsacl subcommands""" samdb = None diff --git a/python/samba/tests/samba_tool/fsmo.py b/python/samba/tests/samba_tool/fsmo.py index 51b735ebcfb..ef475e89c69 100644 --- a/python/samba/tests/samba_tool/fsmo.py +++ b/python/samba/tests/samba_tool/fsmo.py @@ -18,6 +18,7 @@ import os, ldb from samba.tests.samba_tool.base import SambaToolCmdTest + class FsmoCmdTestCase(SambaToolCmdTest): """Test for samba-tool fsmo show subcommand""" diff --git a/python/samba/tests/samba_tool/gpo.py b/python/samba/tests/samba_tool/gpo.py index 07e937a117e..73aad386450 100644 --- a/python/samba/tests/samba_tool/gpo.py +++ b/python/samba/tests/samba_tool/gpo.py @@ -23,6 +23,7 @@ import samba from samba.tests.samba_tool.base import SambaToolCmdTest import shutil + def has_difference(path1, path2, binary=True, xml=True, sortlines=False): """Use this function to determine if the GPO backup differs from another. @@ -72,6 +73,7 @@ def has_difference(path1, path2, binary=True, xml=True, sortlines=False): return None + class GpoCmdTestCase(SambaToolCmdTest): """Tests for samba-tool time subcommands""" diff --git a/python/samba/tests/samba_tool/group.py b/python/samba/tests/samba_tool/group.py index 8b6fc889cf1..28315c2bcd9 100644 --- a/python/samba/tests/samba_tool/group.py +++ b/python/samba/tests/samba_tool/group.py @@ -24,6 +24,7 @@ from samba import ( dsdb ) + class GroupCmdTestCase(SambaToolCmdTest): """Tests for samba-tool group subcommands""" groups = [] diff --git a/python/samba/tests/samba_tool/join.py b/python/samba/tests/samba_tool/join.py index bfb534cd297..8491f092658 100644 --- a/python/samba/tests/samba_tool/join.py +++ b/python/samba/tests/samba_tool/join.py @@ -18,6 +18,7 @@ import os, ldb from samba.tests.samba_tool.base import SambaToolCmdTest + class JoinCmdTestCase(SambaToolCmdTest): """Test for samba-tool fsmo show subcommand""" diff --git a/python/samba/tests/samba_tool/ntacl.py b/python/samba/tests/samba_tool/ntacl.py index 91115cba01d..a5e5eff7d88 100644 --- a/python/samba/tests/samba_tool/ntacl.py +++ b/python/samba/tests/samba_tool/ntacl.py @@ -24,6 +24,7 @@ import ldb from samba.tests.samba_tool.base import SambaToolCmdTest import random + class NtACLCmdSysvolTestCase(SambaToolCmdTest): """Tests for samba-tool ntacl sysvol* subcommands""" @@ -69,6 +70,7 @@ class NtACLCmdSysvolTestCase(SambaToolCmdTest): self.assertEquals(err, "", "Shouldn't be any error messages") self.assertEquals(out, "", "Shouldn't be any output messages") + class NtACLCmdGetSetTestCase(SambaToolCmdTest): """Tests for samba-tool ntacl get/set subcommands""" diff --git a/python/samba/tests/samba_tool/ou.py b/python/samba/tests/samba_tool/ou.py index 82b90e467a2..4896e1a3a9b 100644 --- a/python/samba/tests/samba_tool/ou.py +++ b/python/samba/tests/samba_tool/ou.py @@ -23,6 +23,7 @@ import os import ldb from samba.tests.samba_tool.base import SambaToolCmdTest + class OUCmdTestCase(SambaToolCmdTest): """Tests for samba-tool ou subcommands""" ous = [] diff --git a/python/samba/tests/samba_tool/processes.py b/python/samba/tests/samba_tool/processes.py index cff9cad1b27..440779752b0 100644 --- a/python/samba/tests/samba_tool/processes.py +++ b/python/samba/tests/samba_tool/processes.py @@ -21,6 +21,7 @@ import os from samba.tests.samba_tool.base import SambaToolCmdTest + class ProcessCmdTestCase(SambaToolCmdTest): """Tests for samba-tool process subcommands""" diff --git a/python/samba/tests/samba_tool/provision_password_check.py b/python/samba/tests/samba_tool/provision_password_check.py index b24e5804072..b2a88699ab4 100644 --- a/python/samba/tests/samba_tool/provision_password_check.py +++ b/python/samba/tests/samba_tool/provision_password_check.py @@ -19,6 +19,7 @@ from samba.tests.samba_tool.base import SambaToolCmdTest import os import shutil + class ProvisionPasswordTestCase(SambaToolCmdTest): """Test for password validation in domain provision subcommand""" diff --git a/python/samba/tests/samba_tool/rodc.py b/python/samba/tests/samba_tool/rodc.py index 2259f06aa7d..dbeb763e364 100644 --- a/python/samba/tests/samba_tool/rodc.py +++ b/python/samba/tests/samba_tool/rodc.py @@ -24,6 +24,7 @@ from samba.tests.samba_tool.base import SambaToolCmdTest from samba.credentials import Credentials from samba.auth import system_session + class RodcCmdTestCase(SambaToolCmdTest): def setUp(self): super(RodcCmdTestCase, self).setUp() diff --git a/python/samba/tests/samba_tool/schema.py b/python/samba/tests/samba_tool/schema.py index ae095994e53..54a103b8187 100644 --- a/python/samba/tests/samba_tool/schema.py +++ b/python/samba/tests/samba_tool/schema.py @@ -19,6 +19,7 @@ import os import ldb from samba.tests.samba_tool.base import SambaToolCmdTest + class SchemaCmdTestCase(SambaToolCmdTest): """Tests for samba-tool dsacl subcommands""" samdb = None diff --git a/python/samba/tests/samba_tool/timecmd.py b/python/samba/tests/samba_tool/timecmd.py index 68dcb06c402..1db51dc73e9 100644 --- a/python/samba/tests/samba_tool/timecmd.py +++ b/python/samba/tests/samba_tool/timecmd.py @@ -19,6 +19,7 @@ import os from time import localtime, strptime, mktime from samba.tests.samba_tool.base import SambaToolCmdTest + class TimeCmdTestCase(SambaToolCmdTest): """Tests for samba-tool time subcommands""" diff --git a/python/samba/tests/samba_tool/user.py b/python/samba/tests/samba_tool/user.py index 0cd283f2ad4..d04e835b2e8 100644 --- a/python/samba/tests/samba_tool/user.py +++ b/python/samba/tests/samba_tool/user.py @@ -28,6 +28,7 @@ from samba import ( from samba.ndr import ndr_unpack from samba.dcerpc import drsblobs + class UserCmdTestCase(SambaToolCmdTest): """Tests for samba-tool user subcommands""" users = [] diff --git a/python/samba/tests/samba_tool/user_check_password_script.py b/python/samba/tests/samba_tool/user_check_password_script.py index c84c7f687a0..aaf791aff9e 100644 --- a/python/samba/tests/samba_tool/user_check_password_script.py +++ b/python/samba/tests/samba_tool/user_check_password_script.py @@ -25,6 +25,7 @@ from samba import ( dsdb ) + class UserCheckPwdTestCase(SambaToolCmdTest): """Tests for samba-tool user subcommands""" users = [] diff --git a/python/samba/tests/samba_tool/user_virtualCryptSHA.py b/python/samba/tests/samba_tool/user_virtualCryptSHA.py index f66fc0e9ccf..0a707628dcf 100644 --- a/python/samba/tests/samba_tool/user_virtualCryptSHA.py +++ b/python/samba/tests/samba_tool/user_virtualCryptSHA.py @@ -51,6 +51,8 @@ HASH_OPTION = "password hash userPassword schemes" # Get the value of an attribute from the output string # Note: Does not correctly handle values spanning multiple lines, # which is acceptable for it's usage in these tests. + + def _get_attribute(out, name): p = re.compile("^" + name + ":\s+(\S+)") for line in out.split("\n"): @@ -59,6 +61,7 @@ def _get_attribute(out, name): return m.group(1) return "" + class UserCmdCryptShaTestCase(SambaToolCmdTest): """ Tests for samba-tool user subcommands generation of the virtualCryptSHA256 diff --git a/python/samba/tests/samba_tool/user_wdigest.py b/python/samba/tests/samba_tool/user_wdigest.py index a6f83edb631..b1fadc35d86 100644 --- a/python/samba/tests/samba_tool/user_wdigest.py +++ b/python/samba/tests/samba_tool/user_wdigest.py @@ -44,6 +44,8 @@ USER_PASS = ''.join(random.choice(string.ascii_uppercase + # Calculate the MD5 password digest from the supplied user, realm and password # + + def calc_digest(user, realm, password): data = "%s:%s:%s" % (user, realm, password) if isinstance(data, text_type): diff --git a/python/samba/tests/smb.py b/python/samba/tests/smb.py index 59fd6ed9d41..559bb2558a4 100644 --- a/python/samba/tests/smb.py +++ b/python/samba/tests/smb.py @@ -28,6 +28,7 @@ binary_contents = binary_contents + "Hello cruel world of python3".encode('utf8' test_dir = os.path.join(addom, 'testing_%d' % random.randint(0, 0xFFFF)) test_file = os.path.join(test_dir, 'testing').replace('/', '\\') + class SMBTests(samba.tests.TestCase): def setUp(self): super(SMBTests, self).setUp() diff --git a/python/samba/tests/strings.py b/python/samba/tests/strings.py index 5f7d18c3a66..67c73319b04 100644 --- a/python/samba/tests/strings.py +++ b/python/samba/tests/strings.py @@ -29,6 +29,7 @@ from unicodenames import * import samba.tests from samba import strcasecmp_m, strstr_m + def signum(a): if a < 0: return -1 @@ -63,6 +64,7 @@ class strcasecmp_m_Tests(samba.tests.TestCase): b.encode('utf-8'))), expect) + class strstr_m_Tests(samba.tests.TestCase): """strstr_m tests in simple ASCII and unicode strings""" diff --git a/python/samba/tests/upgradeprovision.py b/python/samba/tests/upgradeprovision.py index 39739af0273..12dd3ecb0ec 100644 --- a/python/samba/tests/upgradeprovision.py +++ b/python/samba/tests/upgradeprovision.py @@ -29,6 +29,7 @@ from ldb import SCOPE_BASE import samba.tests from samba.dcerpc import security + def dummymessage(a=None, b=None): pass diff --git a/python/samba/tests/upgradeprovisionneeddc.py b/python/samba/tests/upgradeprovisionneeddc.py index 73a3152ca46..c4d3604d98b 100644 --- a/python/samba/tests/upgradeprovisionneeddc.py +++ b/python/samba/tests/upgradeprovisionneeddc.py @@ -42,6 +42,7 @@ def dummymessage(a=None, b=None): smb_conf_path = "%s/%s/%s" % (os.environ["SELFTEST_PREFIX"], "ad_dc_ntvfs", "etc/smb.conf") + class UpgradeProvisionBasicLdbHelpersTestCase(TestCaseInTempDir): """Some simple tests for individual functions in the provisioning code. """ diff --git a/python/samba/tests/xattr.py b/python/samba/tests/xattr.py index ff34194328e..c137dd58484 100644 --- a/python/samba/tests/xattr.py +++ b/python/samba/tests/xattr.py @@ -30,6 +30,7 @@ import random import shutil import os + class XattrTests(TestCase): def _tmpfilename(self): diff --git a/python/samba/upgrade.py b/python/samba/upgrade.py index 2e17f186a95..98d8761045c 100644 --- a/python/samba/upgrade.py +++ b/python/samba/upgrade.py @@ -129,6 +129,7 @@ def add_posix_attrs(logger, samdb, sid, name, nisdomain, xid_type, home=None, 'Could not add posix attrs for AD entry for sid=%s, (%s)', str(sid), str(e)) + def add_ad_posix_idmap_entry(samdb, sid, xid, xid_type, logger): """Create idmap entry @@ -399,6 +400,7 @@ def import_registry(samba4_registry, samba3_regdb): for (value_name, (value_type, value_data)) in samba3_regdb.values(key).items(): key_handle.set_value(value_name, value_type, value_data) + def get_posix_attr_from_ldap_backend(logger, ldb_object, base_dn, user, attr): """Get posix attributes from a samba3 ldap backend :param ldbs: a list of ldb connection objects diff --git a/python/samba/upgradehelpers.py b/python/samba/upgradehelpers.py index 262f664fc10..3f376072afc 100644 --- a/python/samba/upgradehelpers.py +++ b/python/samba/upgradehelpers.py @@ -212,6 +212,7 @@ def get_paths(param, targetdir=None, smbconf=None): paths = provision_paths_from_lp(lp, lp.get("realm")) return paths + def update_policyids(names, samdb): """Update policy ids that could have changed after sam update @@ -454,6 +455,7 @@ def updateOEMInfo(samdb, rootdn): "oEMInformation") samdb.modify(delta) + def update_gpo(paths, samdb, names, lp, message): """Create missing GPO file object if needed """ @@ -467,6 +469,7 @@ def update_gpo(paths, samdb, names, lp, message): if not os.path.isdir(dir): create_gpo_struct(dir) + def increment_calculated_keyversion_number(samdb, rootdn, hashDns): """For a given hash associating dn and a number, this function will update the replPropertyMetaData of each dn in the hash, so that the @@ -499,6 +502,8 @@ def increment_calculated_keyversion_number(samdb, rootdn, hashDns): samdb.set_attribute_replmetadata_version(str(e.dn), "unicodePwd", version, True) + + def delta_update_basesamdb(refsampath, sampath, creds, session, lp, message): """Update the provision container db: sam.ldb This function is aimed for alpha9 and newer; @@ -564,6 +569,7 @@ def construct_existor_expr(attrs): expr = "%s)" %expr return expr + def update_machine_account_password(samdb, secrets_ldb, names): """Update (change) the password of the current DC both in the SAM db and in secret one @@ -606,6 +612,7 @@ def update_machine_account_password(samdb, secrets_ldb, names): raise ProvisioningError("Unable to find a Secure Channel" "of type SEC_CHAN_BDC") + def update_dns_account_password(samdb, secrets_ldb, names): """Update (change) the password of the dns both in the SAM db and in secret one @@ -645,6 +652,7 @@ def update_dns_account_password(samdb, secrets_ldb, names): secrets_ldb.modify(msg) + def update_krbtgt_account_password(samdb): """Update (change) the password of the krbtgt account @@ -663,6 +671,7 @@ def update_krbtgt_account_password(samdb): samdb.modify(msg) + def search_constructed_attrs_stored(samdb, rootdn, attrs): """Search a given sam DB for calculated attributes that are still stored in the db. @@ -697,6 +706,7 @@ def search_constructed_attrs_stored(samdb, rootdn, attrs): return hashAtt + def findprovisionrange(samdb, basedn): """ Find ranges of usn grouped by invocation id and then by timestamp rouned at 1 minute @@ -756,6 +766,7 @@ def findprovisionrange(samdb, basedn): return (hash_id, nb_obj) + def print_provision_ranges(dic, limit_print, dest, samdb_path, invocationid): """ print the differents ranges passed as parameter @@ -813,6 +824,7 @@ def print_provision_ranges(dic, limit_print, dest, samdb_path, invocationid): ldif = "dn: @PROVISION\nprovisionnerID: %s\n%s" % (invocationid, ldif) open(file, 'w').write(ldif) + def int64range2str(value): """Display the int64 range stored in value as xxx-yyy diff --git a/python/samba/web_server/__init__.py b/python/samba/web_server/__init__.py index 4344fccfaa7..d4873fadc2b 100644 --- a/python/samba/web_server/__init__.py +++ b/python/samba/web_server/__init__.py @@ -21,6 +21,7 @@ from __future__ import print_function + def render_placeholder(environ, start_response): """Send the user a simple placeholder about missing SWAT.""" status = '200 OK' diff --git a/script/autobuild.py b/script/autobuild.py index d3b46e69f26..fb08af47ec0 100755 --- a/script/autobuild.py +++ b/script/autobuild.py @@ -378,11 +378,13 @@ tasks = { 'fail': [("fail", 'echo failing && /bin/false', "text/plain")] } + def do_print(msg): print("%s" % msg) sys.stdout.flush() sys.stderr.flush() + def run_cmd(cmd, dir=".", show=None, output=False, checkfail=True): if show is None: show = options.verbose @@ -628,6 +630,7 @@ def daemonize(logfile): os.dup2(0, 1) os.dup2(0, 2) + def write_pidfile(fname): '''write a pid file, cleanup on exit''' f = open(fname, mode='w') @@ -666,6 +669,7 @@ def rebase_tree(rebase_url, rebase_branch="master"): (rebase_remote, rebase_branch), show=True, dir=test_master) + def push_to(push_url, push_branch="master"): push_remote = "pushto" do_print("Pushing to %s" % push_url) @@ -725,6 +729,7 @@ parser.add_option("", "--attach-logs", help="Attach logs to mails sent on succes parser.add_option("", "--restrict-tests", help="run as make test with this TESTS= regex", default='') + def send_email(subject, text, log_tar): if options.email is None: do_print("not sending email because the recipient is not set") @@ -751,6 +756,7 @@ def send_email(subject, text, log_tar): s.set_debuglevel(1) s.quit() + def email_failure(status, failed_task, failed_stage, failed_tag, errstr, elapsed_time, log_base=None, add_log_tail=True): '''send an email to options.email about the failure''' @@ -816,6 +822,7 @@ The last 50 lines of log messages: % (options.branch, platform.node(), failed_task, failed_stage), text, logs) + def email_success(elapsed_time, log_base=None): '''send an email to options.email about a successful build''' user = os.getenv("USER") diff --git a/script/bisect-test.py b/script/bisect-test.py index e06d7834117..84496fe253a 100755 --- a/script/bisect-test.py +++ b/script/bisect-test.py @@ -41,6 +41,7 @@ def run_cmd(cmd, dir=".", show=True, output=False, checkfail=True): else: return call(cmd, shell=True, cwd=dir) + def find_git_root(): '''get to the top of the git repo''' p = os.getcwd() @@ -72,6 +73,7 @@ f.write("%s || exit 1\n" % opts.test_command) f.write("exit 0\n") f.close() + def cleanup(): run_cmd("git bisect reset", dir=gitroot) os.unlink(f.name) diff --git a/script/generate_param.py b/script/generate_param.py index 90f626f9df7..6cd9ace382c 100644 --- a/script/generate_param.py +++ b/script/generate_param.py @@ -47,6 +47,7 @@ if options.filename is None: if options.output is None: parser.error("No output file specified") + def iterate_all(path): """Iterate and yield all the parameters. @@ -116,6 +117,7 @@ param_type_dict = { "ustring" : "_STRING", } + def generate_functions(path_in, path_out): f = open(path_out, 'w') try: @@ -160,6 +162,7 @@ mapping = { 'ustring' : 'char *', } + def make_s3_param_proto(path_in, path_out): file_out = open(path_out, 'w') try: @@ -256,11 +259,13 @@ def make_lib_proto(path_in, path_out): finally: file_out.close() + def get_header(path): header = os.path.basename(path).upper() header = header.replace(".", "_").replace("\\", "_").replace("-", "_") return "__%s__" % header + def make_param_defs(path_in, path_out, scope): file_out = open(path_out, 'w') try: @@ -324,6 +329,7 @@ type_dict = { "ustring" : "P_USTRING", } + def make_param_table(path_in, path_out): file_out = open(path_out, 'w') try: diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py index 2d6e2b12053..490bc64ebda 100644 --- a/selftest/selftesthelpers.py +++ b/selftest/selftesthelpers.py @@ -23,18 +23,23 @@ import os import subprocess import sys + def srcdir(): return os.path.normpath(os.getenv("SRCDIR", os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))) + def source4dir(): return os.path.normpath(os.path.join(srcdir(), "source4")) + def source3dir(): return os.path.normpath(os.path.join(srcdir(), "source3")) + def bindir(): return os.path.normpath(os.getenv("BINDIR", "./bin")) + def binpath(name): return os.path.join(bindir(), name) diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py index 3ac2d963a90..830dd4ba63d 100644 --- a/selftest/subunithelper.py +++ b/selftest/subunithelper.py @@ -33,6 +33,7 @@ VALID_RESULTS = set(['success', 'successful', 'failure', 'fail', 'skip', 'testsuite-success', 'testsuite-error', 'uxsuccess', 'testsuite-uxsuccess']) + class TestsuiteEnabledTestResult(unittest.TestResult): def start_testsuite(self, name): diff --git a/source3/build/charset.py b/source3/build/charset.py index 1a23405448f..0f4f3194205 100644 --- a/source3/build/charset.py +++ b/source3/build/charset.py @@ -2,6 +2,7 @@ from Configure import conf + @conf def CHECK_SAMBA3_CHARSET(conf, crossbuild=False): '''Check for default charsets for Samba3 diff --git a/source3/script/tests/test_wbinfo_sids2xids_int.py b/source3/script/tests/test_wbinfo_sids2xids_int.py index bc3710d716f..f0f51429273 100755 --- a/source3/script/tests/test_wbinfo_sids2xids_int.py +++ b/source3/script/tests/test_wbinfo_sids2xids_int.py @@ -11,6 +11,7 @@ if len(sys.argv) != 3: wbinfo = sys.argv[1] netcmd = sys.argv[2] + def flush_cache(sids=[], uids=[], gids=[]): for sid in sids: os.system(netcmd + (" cache del IDMAP/SID2XID/%s" % (sid))) @@ -19,6 +20,7 @@ def flush_cache(sids=[], uids=[], gids=[]): for gids in gids: os.system(netcmd + (" cache del IDMAP/GID2SID/%s" % (gid))) + def fill_cache(inids, idtype='gid'): for inid in inids: if inid is None: @@ -70,6 +72,8 @@ for line in sids2xids.split('\n'): # Check the list produced by the sids-to-xids call with the # singular variant (sid-to-xid) for each sid in turn. + + def check_singular(sids, ids, idtype='gid'): i = 0 for sid in sids: @@ -86,6 +90,8 @@ def check_singular(sids, ids, idtype='gid'): # Check the list produced by the sids-to-xids call with the # multiple variant (sid-to-xid) for each sid in turn. + + def check_multiple(sids, idtypes): sids2xids = subprocess.Popen([wbinfo, '--sids-to-unix-ids=' + ','.join(sids)], stdout=subprocess.PIPE).communicate()[0].strip() diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 066d0beaf5e..34a2f31246b 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -27,6 +27,7 @@ smbtorture4_options.extend([ '--option=torture:writetimeupdatedelay=500000', ]) + def plansmbtorture4testsuite(name, env, options, description=''): if description == '': modname = "samba3.%s" % (name, ) diff --git a/source3/torture/test_ntlm_auth.py b/source3/torture/test_ntlm_auth.py index 7d0ad8e520b..05594065108 100755 --- a/source3/torture/test_ntlm_auth.py +++ b/source3/torture/test_ntlm_auth.py @@ -26,12 +26,15 @@ import os import sys from optparse import OptionParser + class ReadChildError(Exception): pass + class WriteChildError(Exception): pass + def readLine(pipe): """readLine(pipe) -> str Read a line from the child's pipe, returns the string read. @@ -48,6 +51,7 @@ def readLine(pipe): return buf[:newline] + def writeLine(pipe, buf): """writeLine(pipe, buf) -> nul Write a line to the child's pipe. @@ -58,6 +62,7 @@ def writeLine(pipe, buf): raise WriteChildError() os.write(pipe, "\n") + def parseCommandLine(): """parseCommandLine() -> (opts, ntlm_auth_path) Parse the command line. diff --git a/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py b/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py index 6eb0b67cb85..09917f76ce8 100755 --- a/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py +++ b/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py @@ -50,6 +50,7 @@ if (len(args) > 1): else: objectclass = None + def uniq_list(alist): """return a unique list""" set = {} @@ -75,6 +76,7 @@ rootDse = res[0] schema_base = rootDse["schemaNamingContext"][0] + def possible_inferiors_search(db, oc): """return the possible inferiors via a search for the possibleInferiors attribute""" res = db.search(base=schema_base, @@ -112,6 +114,7 @@ def supclasses(classinfo, oc): classinfo[oc]["SUPCLASSES"] = list return list + def auxclasses(classinfo, oclist): list = [] if oclist == []: @@ -130,12 +133,14 @@ def auxclasses(classinfo, oclist): list.extend(list2) return list + def subclasses(classinfo, oclist): list = [] for oc in oclist: list.extend(classinfo[oc]["SUBCLASSES"]) return list + def posssuperiors(classinfo, oclist): list = [] for oc in oclist: @@ -156,6 +161,7 @@ def posssuperiors(classinfo, oclist): list.extend(list2) return list + def pull_classinfo(db): """At startup we build a classinfo[] dictionary that holds all the information needed to construct the possible inferiors""" classinfo = {} @@ -202,12 +208,14 @@ def pull_classinfo(db): return classinfo + def is_in_list(list, c): for a in list: if c == a: return True return False + def possible_inferiors_constructed(db, classinfo, c): list = [] for oc in classinfo: @@ -221,6 +229,7 @@ def possible_inferiors_constructed(db, classinfo, c): list.sort() return list + def test_class(db, classinfo, oc): """test to see if one objectclass returns the correct possibleInferiors""" print("test: objectClass.%s" % oc) @@ -238,6 +247,7 @@ def test_class(db, classinfo, oc): else: print("success: objectClass.%s" % oc) + def get_object_classes(db): """return a list of all object classes""" list = [] diff --git a/source4/dsdb/tests/python/acl.py b/source4/dsdb/tests/python/acl.py index 71020efb26d..617aa632796 100755 --- a/source4/dsdb/tests/python/acl.py +++ b/source4/dsdb/tests/python/acl.py @@ -66,6 +66,7 @@ creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL) # Tests start here # + class AclTests(samba.tests.TestCase): def setUp(self): @@ -117,6 +118,8 @@ class AclTests(samba.tests.TestCase): del self.ldb_admin # tests on ldap add operations + + class AclAddTests(AclTests): def setUp(self): @@ -270,6 +273,8 @@ class AclAddTests(AclTests): self.fail() # tests on ldap modify operations + + class AclModifyTests(AclTests): def setUp(self): @@ -647,6 +652,8 @@ Member: CN=test_modify_user2,CN=Users,""" + self.base_dn self.fail() # enable these when we have search implemented + + class AclSearchTests(AclTests): def setUp(self): @@ -1080,6 +1087,8 @@ class AclSearchTests(AclTests): # tests on ldap delete operations + + class AclDeleteTests(AclTests): def setUp(self): @@ -1150,6 +1159,8 @@ class AclDeleteTests(AclTests): self.fail() # tests on ldap rename operations + + class AclRenameTests(AclTests): def setUp(self): @@ -1698,6 +1709,7 @@ userPassword: thatsAcomplPASS1 (num, _) = e34.args self.assertEquals(num, ERR_CONSTRAINT_VIOLATION) + class AclExtendedTests(AclTests): def setUp(self): @@ -1762,6 +1774,7 @@ class AclExtendedTests(AclTests): self.assertEqual(len(res), 1) self.assertTrue("nTSecurityDescriptor" in res[0].keys()) + class AclUndeleteTests(AclTests): def setUp(self): @@ -1899,6 +1912,7 @@ class AclUndeleteTests(AclTests): (num, _) = e38.args self.assertEquals(num, ERR_INSUFFICIENT_ACCESS_RIGHTS) + class AclSPNTests(AclTests): def setUp(self): diff --git a/source4/dsdb/tests/python/ad_dc_medley_performance.py b/source4/dsdb/tests/python/ad_dc_medley_performance.py index f2a8fea60b5..f484cae9e08 100644 --- a/source4/dsdb/tests/python/ad_dc_medley_performance.py +++ b/source4/dsdb/tests/python/ad_dc_medley_performance.py @@ -87,6 +87,7 @@ class GlobalState(object): test_number = 0 active_links = set() + class UserTests(samba.tests.TestCase): def add_if_possible(self, *args, **kwargs): diff --git a/source4/dsdb/tests/python/ad_dc_multi_bind.py b/source4/dsdb/tests/python/ad_dc_multi_bind.py index e85c0e10fd9..fbe2e6cf0d4 100644 --- a/source4/dsdb/tests/python/ad_dc_multi_bind.py +++ b/source4/dsdb/tests/python/ad_dc_multi_bind.py @@ -60,6 +60,7 @@ host = args[0] lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) + class UserTests(samba.tests.TestCase): def setUp(self): diff --git a/source4/dsdb/tests/python/ad_dc_provision_performance.py b/source4/dsdb/tests/python/ad_dc_provision_performance.py index 25aeb96d335..748149e4b99 100644 --- a/source4/dsdb/tests/python/ad_dc_provision_performance.py +++ b/source4/dsdb/tests/python/ad_dc_provision_performance.py @@ -60,6 +60,7 @@ random.seed(1) class PerfTestException(Exception): pass + class UserTests(samba.tests.TestCase): def setUp(self): diff --git a/source4/dsdb/tests/python/deletetest.py b/source4/dsdb/tests/python/deletetest.py index 01e7a1d2378..7a5da0f24a8 100755 --- a/source4/dsdb/tests/python/deletetest.py +++ b/source4/dsdb/tests/python/deletetest.py @@ -41,6 +41,7 @@ host = args[0] lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) + class BaseDeleteTests(samba.tests.TestCase): def GUID_string(self, guid): @@ -270,6 +271,7 @@ class BasicDeleteTests(BaseDeleteTests): (num, _) = e15.args self.assertEquals(num, ERR_UNWILLING_TO_PERFORM) + class BasicTreeDeleteTests(BasicDeleteTests): def setUp(self): diff --git a/source4/dsdb/tests/python/dirsync.py b/source4/dsdb/tests/python/dirsync.py index 0f49fd7e630..8540c3729d9 100755 --- a/source4/dsdb/tests/python/dirsync.py +++ b/source4/dsdb/tests/python/dirsync.py @@ -73,6 +73,7 @@ creds = credopts.get_credentials(lp) # Tests start here # + class DirsyncBaseTests(samba.tests.TestCase): def setUp(self): diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py index 33dd0405721..315eafe6005 100755 --- a/source4/dsdb/tests/python/ldap.py +++ b/source4/dsdb/tests/python/ldap.py @@ -73,6 +73,7 @@ host = args[0] lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) + class BasicTests(samba.tests.TestCase): def setUp(self): @@ -3161,6 +3162,7 @@ nTSecurityDescriptor:: """ + desc_base64 self.assertTrue(len(res[0]["msTSExpireDate"]) == 1) self.assertEquals(res[0]["msTSExpireDate"][0], v_get) + class BaseDnTests(samba.tests.TestCase): def setUp(self): diff --git a/source4/dsdb/tests/python/ndr_pack_performance.py b/source4/dsdb/tests/python/ndr_pack_performance.py index 27fd79a56fd..0ae9f825d2a 100644 --- a/source4/dsdb/tests/python/ndr_pack_performance.py +++ b/source4/dsdb/tests/python/ndr_pack_performance.py @@ -141,6 +141,7 @@ e6-11d0-a285-00aa003049e2;ED)""".split()) # set SCALE = 100 for normal test, or 1 for testing the test. SCALE = 100 + class UserTests(samba.tests.TestCase): def get_file_blob(self, filename): diff --git a/source4/dsdb/tests/python/notification.py b/source4/dsdb/tests/python/notification.py index e8ff9ddf1ac..20fe7c5d8a3 100755 --- a/source4/dsdb/tests/python/notification.py +++ b/source4/dsdb/tests/python/notification.py @@ -63,6 +63,7 @@ lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL) + class LDAPNotificationTest(samba.tests.TestCase): def setUp(self): diff --git a/source4/dsdb/tests/python/password_lockout.py b/source4/dsdb/tests/python/password_lockout.py index 7feb8a5ce95..d60e55f6358 100755 --- a/source4/dsdb/tests/python/password_lockout.py +++ b/source4/dsdb/tests/python/password_lockout.py @@ -64,6 +64,7 @@ import password_lockout_base # Tests start here # + class PasswordTests(password_lockout_base.BasePasswordTestCase): def setUp(self): self.host = host diff --git a/source4/dsdb/tests/python/password_lockout_base.py b/source4/dsdb/tests/python/password_lockout_base.py index aee267958be..b83456505c6 100644 --- a/source4/dsdb/tests/python/password_lockout_base.py +++ b/source4/dsdb/tests/python/password_lockout_base.py @@ -18,6 +18,7 @@ from samba.tests.password_test import PasswordTestCase import time + class BasePasswordTestCase(PasswordTestCase): def _open_samr_user(self, res): self.assertTrue("objectSid" in res[0]) diff --git a/source4/dsdb/tests/python/passwords.py b/source4/dsdb/tests/python/passwords.py index 2ab1b77ea19..0509612ff95 100755 --- a/source4/dsdb/tests/python/passwords.py +++ b/source4/dsdb/tests/python/passwords.py @@ -66,6 +66,7 @@ creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL) # Tests start here # + class PasswordTests(PasswordTestCase): def setUp(self): diff --git a/source4/dsdb/tests/python/rodc_rwdc.py b/source4/dsdb/tests/python/rodc_rwdc.py index 0126f03195b..ada68734bec 100644 --- a/source4/dsdb/tests/python/rodc_rwdc.py +++ b/source4/dsdb/tests/python/rodc_rwdc.py @@ -30,6 +30,7 @@ from samba.dcerpc import security, samr import password_lockout_base + def passwd_encode(pw): return base64.b64encode(('"%s"' % pw).encode('utf-16-le')).decode('utf8') @@ -113,6 +114,7 @@ def get_server_ref_from_samdb(samdb): return res[0]['serverReference'][0] + class RodcRwdcCachedTests(password_lockout_base.BasePasswordTestCase): counter = itertools.count(1).next @@ -683,6 +685,7 @@ class RodcRwdcCachedTests(password_lockout_base.BasePasswordTestCase): userAccountControl=dsdb.UF_NORMAL_ACCOUNT, msDSUserAccountControlComputed=0) + class RodcRwdcTests(password_lockout_base.BasePasswordTestCase): counter = itertools.count(1).next @@ -1261,6 +1264,7 @@ class RodcRwdcTests(password_lockout_base.BasePasswordTestCase): self._test_multiple_logon(self.lockout1ntlm_creds) + def main(): global RODC, RWDC, CREDS, LP parser = optparse.OptionParser( diff --git a/source4/dsdb/tests/python/sam.py b/source4/dsdb/tests/python/sam.py index 77fd8f5b659..d894ada952e 100755 --- a/source4/dsdb/tests/python/sam.py +++ b/source4/dsdb/tests/python/sam.py @@ -74,6 +74,7 @@ lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL) + class SamTests(samba.tests.TestCase): def setUp(self): diff --git a/source4/dsdb/tests/python/sec_descriptor.py b/source4/dsdb/tests/python/sec_descriptor.py index a0b5ccc9412..ca1c616b168 100755 --- a/source4/dsdb/tests/python/sec_descriptor.py +++ b/source4/dsdb/tests/python/sec_descriptor.py @@ -60,6 +60,7 @@ creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL) # Tests start here # + class DescriptorTests(samba.tests.TestCase): def get_users_domain_dn(self, name): @@ -165,6 +166,7 @@ showInAdvancedViewOnly: TRUE # Default descriptor tests ##################################################################### + class OwnerGroupDescriptorTests(DescriptorTests): def deleteAll(self): @@ -1218,6 +1220,7 @@ class OwnerGroupDescriptorTests(DescriptorTests): ######################################################################################## # Inheritance tests for DACL + class DaclDescriptorTests(DescriptorTests): def deleteAll(self): @@ -1949,6 +1952,7 @@ class SdFlagsDescriptorTests(DescriptorTests): controls=["extended_dn:1:0", "sd_flags:1:0", "search_options:1:1"]) self.assertFalse("nTSecurityDescriptor" in res[0]) + class RightsAttributesTests(DescriptorTests): def deleteAll(self): @@ -2060,6 +2064,7 @@ class RightsAttributesTests(DescriptorTests): self.assertTrue("displayName" in res[0]["allowedAttributesEffective"]) self.assertTrue("managedBy" in res[0]["allowedAttributesEffective"]) + class SdAutoInheritTests(DescriptorTests): def deleteAll(self): delete_force(self.ldb_admin, self.sub_dn) diff --git a/source4/dsdb/tests/python/sites.py b/source4/dsdb/tests/python/sites.py index 4c2bb5e9cad..00673f356fc 100755 --- a/source4/dsdb/tests/python/sites.py +++ b/source4/dsdb/tests/python/sites.py @@ -67,6 +67,7 @@ creds = credopts.get_credentials(lp) # Tests start here # + class SitesBaseTests(samba.tests.TestCase): def setUp(self): diff --git a/source4/dsdb/tests/python/token_group.py b/source4/dsdb/tests/python/token_group.py index 47ed46d7578..7ddaf4e1db9 100755 --- a/source4/dsdb/tests/python/token_group.py +++ b/source4/dsdb/tests/python/token_group.py @@ -49,6 +49,7 @@ lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL) + def closure(vSet, wSet, aSet): for edge in aSet: start, end = edge @@ -57,6 +58,7 @@ def closure(vSet, wSet, aSet): wSet.add(end) closure(vSet, wSet, aSet) + class StaticTokenTest(samba.tests.TestCase): def setUp(self): @@ -172,6 +174,7 @@ class StaticTokenTest(samba.tests.TestCase): print("difference : %s" % sidset1.difference(sidset2)) self.fail(msg="calculated groups don't match against user PAC tokenGroups") + class DynamicTokenTest(samba.tests.TestCase): def get_creds(self, target_username, target_password): diff --git a/source4/dsdb/tests/python/tombstone_reanimation.py b/source4/dsdb/tests/python/tombstone_reanimation.py index 39960f2d12d..c82cb4cce98 100755 --- a/source4/dsdb/tests/python/tombstone_reanimation.py +++ b/source4/dsdb/tests/python/tombstone_reanimation.py @@ -554,6 +554,7 @@ class RestoreUserObjectTestCase(RestoredObjectAttributesBaseTestCase): self._check_metadata(obj_restore_rmd["replPropertyMetaData"], self._expected_user_restore_metadata()) + class RestoreUserPwdObjectTestCase(RestoredObjectAttributesBaseTestCase): """Test cases for delete/reanimate user objects with password""" @@ -762,6 +763,7 @@ class RestoreUserPwdObjectTestCase(RestoredObjectAttributesBaseTestCase): self._check_metadata(obj_restore_rmd["replPropertyMetaData"], self._expected_userpw_restore_metadata()) + class RestoreGroupObjectTestCase(RestoredObjectAttributesBaseTestCase): """Test different scenarios for delete/reanimate group objects""" diff --git a/source4/lib/wmi/wmi.py b/source4/lib/wmi/wmi.py index 54d806bdf7f..9d1871f5288 100644 --- a/source4/lib/wmi/wmi.py +++ b/source4/lib/wmi/wmi.py @@ -10,6 +10,8 @@ try: _swig_property = property except NameError: pass # Python < 2.2 doesn't have 'property'. + + def _swig_setattr_nondynamic(self, class_type, name, value, static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): @@ -23,15 +25,18 @@ def _swig_setattr_nondynamic(self, class_type, name, value, static=1): else: raise AttributeError("You cannot add attributes to %s" % self) + def _swig_setattr(self, class_type, name, value): return _swig_setattr_nondynamic(self, class_type, name, value, 0) + def _swig_getattr(self, class_type, name): if (name == "thisown"): return self.this.own() method = class_type.__swig_getmethods__.get(name, None) if method: return method(self) raise AttributeError(name) + def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except: strthis = "" @@ -58,6 +63,8 @@ def _swig_setattr_nondynamic_method(set): WBEM_ConnectServer = _wmi.WBEM_ConnectServer + + class IUnknown(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr @@ -69,6 +76,7 @@ IUnknown.Release = new_instancemethod(_wmi.IUnknown_Release, None, IUnknown) IUnknown_swigregister = _wmi.IUnknown_swigregister IUnknown_swigregister(IUnknown) + class IWbemServices(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr @@ -82,6 +90,7 @@ IWbemServices.CreateInstanceEnum = new_instancemethod(_wmi.IWbemServices_CreateI IWbemServices_swigregister = _wmi.IWbemServices_swigregister IWbemServices_swigregister(IWbemServices) + class IEnumWbemClassObject(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr diff --git a/source4/script/depfilter.py b/source4/script/depfilter.py index c74298dd8d3..e4f0d0aba44 100755 --- a/source4/script/depfilter.py +++ b/source4/script/depfilter.py @@ -32,6 +32,7 @@ for arc in lines[1:-1]: subgraph = {} + def add_deps(node): if node in graph and node not in subgraph: subgraph[node] = graph[node] diff --git a/source4/scripting/devel/demodirsync.py b/source4/scripting/devel/demodirsync.py index 83263ea9f03..8f1e7d7c451 100755 --- a/source4/scripting/devel/demodirsync.py +++ b/source4/scripting/devel/demodirsync.py @@ -28,6 +28,7 @@ creds = credopts.get_credentials(lp) opts = parser.parse_args()[0] + def printdirsync(ctl): arr = ctl.split(':') if arr[0] == 'dirsync': diff --git a/source4/scripting/devel/pfm_verify.py b/source4/scripting/devel/pfm_verify.py index a8aafede2cf..53f61dec67a 100755 --- a/source4/scripting/devel/pfm_verify.py +++ b/source4/scripting/devel/pfm_verify.py @@ -48,6 +48,7 @@ def _samdb_fetch_pfm(samdb): return (pfm.ctr, pfm_schi) + def _samdb_fetch_schi(samdb): """Fetch schemaInfo stored in SamDB using LDB connection""" res = samdb.search(base=samdb.get_schema_basedn(), expression="", scope=SCOPE_BASE, attrs=["*"]) @@ -60,6 +61,7 @@ def _samdb_fetch_schi(samdb): pfm_schi.marker = 0xFF; return pfm_schi + def _drs_fetch_pfm(server, samdb, creds, lp): """Fetch prefixMap using DRS interface""" binding_str = "ncacn_ip_tcp:%s[print,seal]" % server @@ -107,6 +109,7 @@ def _drs_fetch_pfm(server, samdb, creds, lp): pfm.num_mappings -= 1 return (pfm, pfm_schi) + def _pfm_verify(drs_pfm, ldb_pfm): errors = [] if drs_pfm.num_mappings != ldb_pfm.num_mappings: @@ -127,6 +130,7 @@ def _pfm_verify(drs_pfm, ldb_pfm): errors.append("[%2d] differences in (%s)" % (i, it_err)) return errors + def _pfm_schi_verify(drs_schi, ldb_schi): errors = [] print(drs_schi.revision) diff --git a/source4/scripting/devel/repl_cleartext_pwd.py b/source4/scripting/devel/repl_cleartext_pwd.py index c6c76e6db13..a31c1287a71 100755 --- a/source4/scripting/devel/repl_cleartext_pwd.py +++ b/source4/scripting/devel/repl_cleartext_pwd.py @@ -56,6 +56,7 @@ import os from ldif import LDIFWriter + class globals: def __init__(self): self.global_objs = {} @@ -72,6 +73,7 @@ class globals: continue self.global_objs = {} + def attid_equal(a1, a2): return (a1 & 0xffffffff) == (a2 & 0xffffffff) diff --git a/source4/scripting/devel/speedtest.py b/source4/scripting/devel/speedtest.py index fbbf67e3122..581529047cd 100755 --- a/source4/scripting/devel/speedtest.py +++ b/source4/scripting/devel/speedtest.py @@ -72,6 +72,7 @@ creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL) # Tests start here # + class SpeedTest(samba.tests.TestCase): def find_domain_sid(self, ldb): @@ -120,6 +121,7 @@ url: www.example.com for dn in dn_list: delete_force(self.ldb_admin, dn) + class SpeedTestAddDel(SpeedTest): def setUp(self): @@ -165,6 +167,7 @@ class SpeedTestAddDel(SpeedTest): """ self.run_bundle(10000) + class AclSearchSpeedTest(SpeedTest): def setUp(self): diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index 8418c246d97..d03de6ed0c5 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -26,6 +26,7 @@ from selftesthelpers import * print("OPTIONS %s" % " ".join(smbtorture4_options), file=sys.stderr) + def plansmbtorture4testsuite(name, env, options, modname=None): return selftesthelpers.plansmbtorture4testsuite(name, env, options, target='samba4', modname=modname) @@ -569,6 +570,8 @@ for env in ["ad_dc:local", "s4member:local", "nt4_dc:local", "ad_member:local", subunitrun = valgrindify(python) + " " + os.path.join(samba4srcdir, "scripting/bin/subunitrun") if extra_python is not None: subunitrun3 = valgrindify(extra_python) + " " + os.path.join(samba4srcdir, "scripting/bin/subunitrun") + + def planoldpythontestsuite(env, module, name=None, extra_path=[], environ={}, extra_args=[], py3_compatible=False): environ = dict(environ) py_path = list(extra_path) diff --git a/source4/torture/drs/python/cracknames.py b/source4/torture/drs/python/cracknames.py index f29e29b29c4..c030de0b54c 100644 --- a/source4/torture/drs/python/cracknames.py +++ b/source4/torture/drs/python/cracknames.py @@ -23,6 +23,7 @@ import drs_base from samba.dcerpc import drsuapi + class DrsCracknamesTestCase(drs_base.DrsBaseTestCase): def setUp(self): super(DrsCracknamesTestCase, self).setUp() diff --git a/source4/torture/drs/python/drs_base.py b/source4/torture/drs/python/drs_base.py index 45308e451fe..776d424ac7e 100644 --- a/source4/torture/drs/python/drs_base.py +++ b/source4/torture/drs/python/drs_base.py @@ -41,6 +41,7 @@ from ldb import ( ) from samba.compat import cmp_fn + class DrsBaseTestCase(SambaToolCmdTest): """Base class implementation for all DRS python tests. It is intended to provide common initialization and diff --git a/source4/torture/drs/python/fsmo.py b/source4/torture/drs/python/fsmo.py index c74bb9d1ec1..918b71465dd 100644 --- a/source4/torture/drs/python/fsmo.py +++ b/source4/torture/drs/python/fsmo.py @@ -36,6 +36,7 @@ from ldb import SCOPE_BASE import drs_base + class DrsFsmoTestCase(drs_base.DrsBaseTestCase): def setUp(self): diff --git a/source4/torture/drs/python/getnc_exop.py b/source4/torture/drs/python/getnc_exop.py index d72159540de..e396fc2f7e8 100644 --- a/source4/torture/drs/python/getnc_exop.py +++ b/source4/torture/drs/python/getnc_exop.py @@ -46,6 +46,7 @@ from samba.ndr import ndr_unpack, ndr_pack from samba.compat import cmp_to_key_fn from samba.compat import cmp_fn + def _linked_attribute_compare(la1, la2): """See CompareLinks() in MS-DRSR section 4.1.10.5.17""" la1, la1_target = la1 @@ -597,6 +598,7 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): self.assertEqual(ctr.source_dsa_guid, misc.GUID(fsmo_owner["ntds_guid"])) self.assertEqual(ctr.source_dsa_invocation_id, misc.GUID(fsmo_owner["invocation_id"])) + class DrsReplicaPrefixMapTestCase(drs_base.DrsBaseTestCase): def setUp(self): super(DrsReplicaPrefixMapTestCase, self).setUp() @@ -945,6 +947,7 @@ class DrsReplicaPrefixMapTestCase(drs_base.DrsBaseTestCase): pfm.ctr.num_mappings += 1 return pfm.ctr + class DrsReplicaSyncSortTestCase(drs_base.DrsBaseTestCase): def setUp(self): super(DrsReplicaSyncSortTestCase, self).setUp() diff --git a/source4/torture/drs/python/getnc_unpriv.py b/source4/torture/drs/python/getnc_unpriv.py index 17ad175b1f3..0cf112dbbd3 100644 --- a/source4/torture/drs/python/getnc_unpriv.py +++ b/source4/torture/drs/python/getnc_unpriv.py @@ -45,6 +45,7 @@ import random from samba.dcerpc import drsuapi, security from samba.credentials import DONT_USE_KERBEROS + class DrsReplicaSyncUnprivTestCase(drs_base.DrsBaseTestCase): """Confirm the behaviour of DsGetNCChanges for unprivileged users""" diff --git a/source4/torture/drs/python/linked_attributes_drs.py b/source4/torture/drs/python/linked_attributes_drs.py index 66731e326c8..cf79d5ef8f4 100644 --- a/source4/torture/drs/python/linked_attributes_drs.py +++ b/source4/torture/drs/python/linked_attributes_drs.py @@ -26,6 +26,7 @@ import drs_base import time + class LATestException(Exception): pass diff --git a/source4/torture/drs/python/repl_move.py b/source4/torture/drs/python/repl_move.py index 74ba6789ce3..0f0d480e062 100644 --- a/source4/torture/drs/python/repl_move.py +++ b/source4/torture/drs/python/repl_move.py @@ -45,6 +45,7 @@ from ldb import ( import drs_base, ldb from samba.dcerpc.drsuapi import * + class DrsMoveObjectTestCase(drs_base.DrsBaseTestCase): def _ds_bind(self, server_name): diff --git a/source4/torture/drs/python/repl_rodc.py b/source4/torture/drs/python/repl_rodc.py index 0ecc0bc5051..f23b082822d 100644 --- a/source4/torture/drs/python/repl_rodc.py +++ b/source4/torture/drs/python/repl_rodc.py @@ -43,6 +43,7 @@ from samba.credentials import Credentials import random import time + def drs_get_rodc_partial_attribute_set(samdb, samdb1, exceptions=[]): '''get a list of attributes for RODC replication''' partial_attribute_set = drsuapi.DsPartialAttributeSet() @@ -84,6 +85,7 @@ def drs_get_rodc_partial_attribute_set(samdb, samdb1, exceptions=[]): partial_attribute_set.num_attids = len(attids) return partial_attribute_set + class DrsRodcTestCase(drs_base.DrsBaseTestCase): """Intended as a semi-black box test case for replication involving an RODC.""" diff --git a/source4/torture/drs/python/repl_schema.py b/source4/torture/drs/python/repl_schema.py index f66938cca2f..71095a07d73 100644 --- a/source4/torture/drs/python/repl_schema.py +++ b/source4/torture/drs/python/repl_schema.py @@ -44,6 +44,7 @@ from samba.dcerpc import drsuapi, misc from samba.drs_utils import drs_DsBind from samba import dsdb + class DrsReplSchemaTestCase(drs_base.DrsBaseTestCase): # prefix for all objects created diff --git a/source4/torture/drs/python/replica_sync.py b/source4/torture/drs/python/replica_sync.py index b3b5d0835ca..9d21c594ee8 100644 --- a/source4/torture/drs/python/replica_sync.py +++ b/source4/torture/drs/python/replica_sync.py @@ -36,6 +36,7 @@ import ldb from ldb import ( SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT) + class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): """Intended as a black box test case for DsReplicaSync implementation. It should test the behavior of this diff --git a/source4/torture/drs/python/replica_sync_rodc.py b/source4/torture/drs/python/replica_sync_rodc.py index 4930a3b5254..2763f23dd87 100644 --- a/source4/torture/drs/python/replica_sync_rodc.py +++ b/source4/torture/drs/python/replica_sync_rodc.py @@ -36,6 +36,7 @@ import ldb from ldb import ( SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT) + class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): """Intended as a black box test case for DsReplicaSync implementation. It should test the behavior of this diff --git a/source4/torture/drs/python/ridalloc_exop.py b/source4/torture/drs/python/ridalloc_exop.py index cbeaec99155..8a015f1dd05 100644 --- a/source4/torture/drs/python/ridalloc_exop.py +++ b/source4/torture/drs/python/ridalloc_exop.py @@ -45,6 +45,7 @@ from samba.dbchecker import dbcheck from samba.ndr import ndr_pack from samba.dcerpc import security + class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): """Intended as a semi-black box test case for DsGetNCChanges implementation for extended operations. It should be testing diff --git a/source4/torture/drs/python/samba_tool_drs.py b/source4/torture/drs/python/samba_tool_drs.py index a7ace22538b..f5a83aaccf6 100644 --- a/source4/torture/drs/python/samba_tool_drs.py +++ b/source4/torture/drs/python/samba_tool_drs.py @@ -24,6 +24,7 @@ import os import ldb import drs_base + class SambaToolDrsTests(drs_base.DrsBaseTestCase): """Blackbox test case for samba-tool drs.""" diff --git a/source4/torture/libnet/python/samr-test.py b/source4/torture/libnet/python/samr-test.py index fcd31c4b02f..22b754fb6fb 100644 --- a/source4/torture/libnet/python/samr-test.py +++ b/source4/torture/libnet/python/samr-test.py @@ -44,6 +44,7 @@ new_pass = os.environ["NEW_PASS"] # Tests start here # + class Libnet_SetPwdTest(samba.tests.TestCase): ######################################################################################## diff --git a/wintest/test-s3.py b/wintest/test-s3.py index 145aed96cb8..d1139b603c6 100755 --- a/wintest/test-s3.py +++ b/wintest/test-s3.py @@ -6,9 +6,11 @@ import sys, os import optparse import wintest + def set_libpath(t): t.putenv("LD_LIBRARY_PATH", "${PREFIX}/lib") + def set_krb5_conf(t): t.run_cmd("mkdir -p ${PREFIX}/etc") t.write_file("${PREFIX}/etc/krb5.conf", @@ -18,6 +20,7 @@ def set_krb5_conf(t): t.putenv("KRB5_CONFIG", '${PREFIX}/etc/krb5.conf') + def build_s3(t): '''build samba3''' t.info('Building s3') @@ -30,6 +33,7 @@ def build_s3(t): t.run_cmd('rm -rf ${PREFIX}') t.run_cmd('make install') + def start_s3(t): t.info('Starting Samba3') t.chdir("${PREFIX}") @@ -40,6 +44,7 @@ def start_s3(t): t.run_cmd(['sbin/smbd', "-D"]) t.port_wait("${INTERFACE_IP}", 139) + def test_wbinfo(t): t.info('Testing wbinfo') t.chdir('${PREFIX}') @@ -103,6 +108,7 @@ def test_smbclient(t): child.sendline("cd ..") child.sendline("rmdir testdir") + def create_shares(t): t.info("Adding test shares") t.chdir('${PREFIX}') @@ -147,6 +153,7 @@ def prep_join_as_member(t, vm): panic action = xterm -e gdb --pid %d ''') + def join_as_member(t, vm): '''join a windows domain as a member server''' t.setwinvars(vm) @@ -159,6 +166,7 @@ def join_as_member(t, vm): t.cmd_contains("host -t A ${HOSTNAME}.${WIN_REALM}", ['${HOSTNAME}.${WIN_REALM} has address']) + def create_root_account(t, vm): t.setwinvars(vm) t.info("Creating 'root' account for testing Samba3 member server") @@ -174,6 +182,7 @@ def create_root_account(t, vm): child.sendline("user edit disabled root no") child.expect("Set root's disabled flag") + def test_join_as_member(t, vm): '''test the domain join''' t.setwinvars(vm) diff --git a/wintest/test-s4-howto.py b/wintest/test-s4-howto.py index 0157fc73a9f..f2cbadfb4b8 100755 --- a/wintest/test-s4-howto.py +++ b/wintest/test-s4-howto.py @@ -5,9 +5,11 @@ import sys, os import wintest, pexpect, time, subprocess + def set_krb5_conf(t): t.putenv("KRB5_CONFIG", '${PREFIX}/private/krb5.conf') + def build_s4(t): '''build samba4''' t.info('Building s4') @@ -60,6 +62,7 @@ def start_s4(t): '--option', 'panic action=gnome-terminal -e "gdb --pid %d"', '--option', 'max protocol=nt1']) t.port_wait("${INTERFACE_IP}", 139) + def test_smbclient(t): '''test smbclient against localhost''' t.info('Testing smbclient') @@ -106,6 +109,7 @@ def test_dns(t): t.cmd_contains("host -t A ${HOSTNAME}.${LCREALM}", ['${HOSTNAME}.${LCREALM} has address']) + def test_kerberos(t): '''test that kerberos is OK''' t.info("Testing kerberos") @@ -129,6 +133,7 @@ def run_winjoin(t, vm): t.run_winjoin(t, "${LCREALM}") + def test_winjoin(t, vm): t.info("Checking the windows join is OK") smbclient = t.getvar("smbclient") @@ -406,6 +411,7 @@ def prep_join_as_dc(t, vm): child = t.open_telnet("${WIN_HOSTNAME}", "${WIN_DOMAIN}\\administrator", "${WIN_PASS}", set_time=True) t.get_ipconfig(child) + def join_as_dc(t, vm): '''join a windows domain as a DC''' t.setwinvars(vm) diff --git a/wintest/wintest.py b/wintest/wintest.py index 3c7ac553c5b..6efa0c0340a 100644 --- a/wintest/wintest.py +++ b/wintest/wintest.py @@ -6,6 +6,7 @@ import pexpect, subprocess import optparse import sys, os, time, re + class wintest(): '''testing of Samba against windows VMs''' |