Skip to content

Commit

Permalink
traffic_replay: Move 'traffic account' flag up a level
Browse files Browse the repository at this point in the history
We create machine accounts for 2 different purposes:
1). For traffic generation, i.e. testing realistic network packets.
2). For generating a realistic large DB.

Unfortunately, we want to use different userAccountControl flags for
the 2 different cases. Commit 3338a3e changed the flags used
for case #2, but this breaks case #1.

The problem is generate_users_and_groups() is called in both cases,
so we want the 'traffic account' flag passed into that function.
This ensures that the machine accounts get created with the appropriate
userAccountControl flags for the particular case you want to test.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
  • Loading branch information
tlbeale authored and abartlet committed Nov 7, 2018
1 parent 85b6d88 commit 51917fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions python/samba/emulate/traffic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,8 @@ def generate_users(ldb, instance_id, number, password):
return users


def generate_machine_accounts(ldb, instance_id, number, password):
def generate_machine_accounts(ldb, instance_id, number, password,
traffic_account=True):
"""Add machine accounts to the server"""
existing_objects = search_objectclass(ldb, objectclass='computer')
added = 0
Expand All @@ -1756,7 +1757,7 @@ def generate_machine_accounts(ldb, instance_id, number, password):
if name not in existing_objects:
name = "STGM-%d-%d" % (instance_id, i)
create_machine_account(ldb, instance_id, name, password,
traffic_account=False)
traffic_account)
added += 1
if added % 50 == 0:
LOGGER.info("Created %u/%u machine accounts" % (added, number))
Expand Down Expand Up @@ -1798,7 +1799,8 @@ def clean_up_accounts(ldb, instance_id):

def generate_users_and_groups(ldb, instance_id, password,
number_of_users, number_of_groups,
group_memberships, machine_accounts=0):
group_memberships, machine_accounts=0,
traffic_accounts=True):
"""Generate the required users and groups, allocating the users to
those groups."""
memberships_added = 0
Expand All @@ -1813,7 +1815,8 @@ def generate_users_and_groups(ldb, instance_id, password,
if machine_accounts > 0:
LOGGER.info("Generating dummy machine accounts")
computers_added = generate_machine_accounts(ldb, instance_id,
machine_accounts, password)
machine_accounts, password,
traffic_accounts)

if number_of_groups > 0:
LOGGER.info("Generating dummy groups")
Expand Down
6 changes: 4 additions & 2 deletions script/traffic_replay
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ def main():
opts.number_of_users,
opts.number_of_groups,
opts.group_memberships,
machine_accounts=computer_accounts)
machine_accounts=computer_accounts,
traffic_accounts=False)
sys.exit()

tempdir = tempfile.mkdtemp(prefix="samba_tg_")
Expand All @@ -344,7 +345,8 @@ def main():
opts.fixed_password,
number_of_users,
opts.number_of_groups,
opts.group_memberships)
opts.group_memberships,
traffic_accounts=True)

accounts = traffic.generate_replay_accounts(ldb,
opts.instance_id,
Expand Down

0 comments on commit 51917fc

Please sign in to comment.