From: Tim Beale Date: Mon, 5 Nov 2018 22:14:41 +0000 (+1300) Subject: traffic_replay: Make packet generation work on a pre-populated DB again X-Git-Tag: tdb-1.3.17~848 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d7fb66f7630a994dbb261ce417c26d17b409593;p=thirdparty%2Fsamba.git traffic_replay: Make packet generation work on a pre-populated DB again Generate separate machine accounts for populating a large DB vs replaying network traffic. We want to use different userAccountControl flags in each of the above cases (i.e. commit 3338a3e257fa9f28). However, this means that once you use the --generate-users-only option, you can't replay network packets against the machine accounts. We can avoid this problem by creating separate machine accounts for each of 2 different cases, e.g. STGM-0-x machines for traffic-replay, and PC-0-x machines for padding out the database. Signed-off-by: Tim Beale Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py index 77a1862f1a8..9ac8775ed60 100644 --- a/python/samba/emulate/traffic.py +++ b/python/samba/emulate/traffic.py @@ -1747,9 +1747,19 @@ def generate_users(ldb, instance_id, number, password): return users -def machine_name(instance_id, i): +def machine_name(instance_id, i, traffic_account=True): """Generate a machine account name from instance id.""" - return "STGM-%d-%d" % (instance_id, i) + if traffic_account: + # traffic accounts correspond to a given user, and use different + # userAccountControl flags to ensure packets get processed correctly + # by the DC + return "STGM-%d-%d" % (instance_id, i) + else: + # Otherwise we're just generating computer accounts to simulate a + # semi-realistic network. These use the default computer + # userAccountControl flags, so we use a different account name so that + # we don't try to use them when generating packets + return "PC-%d-%d" % (instance_id, i) def generate_machine_accounts(ldb, instance_id, number, password, @@ -1758,7 +1768,7 @@ def generate_machine_accounts(ldb, instance_id, number, password, existing_objects = search_objectclass(ldb, objectclass='computer') added = 0 for i in range(number, 0, -1): - name = machine_name(instance_id, i) + name = machine_name(instance_id, i, traffic_account) if name + "$" not in existing_objects: create_machine_account(ldb, instance_id, name, password, traffic_account)