Skip to content

refactor: generalize Distro add_user and shutdown_command#6800

Open
blackboxsw wants to merge 1 commit intocanonical:mainfrom
blackboxsw:owasp-logs-part1
Open

refactor: generalize Distro add_user and shutdown_command#6800
blackboxsw wants to merge 1 commit intocanonical:mainfrom
blackboxsw:owasp-logs-part1

Conversation

@blackboxsw
Copy link
Collaborator

Decomposed #6689 into part-1 and part-2 to aid reviewing.

Proposed Commit Message

Perform preliminary refactor to be used by securirity event logging.

Split add_user method into separate methods:
- _add_user_preprocess_kwargs: filter distro-specific args before cmd
- _build_add_user_cmd: return tuple of cmd and log_command for the useradd
- _post_add_user: distro-specific post-creation steps for Alpine
- _user_groups_to_list: normalize group input to a list

Move util.is_user check into create_user and make add_user raise on failure instead of returning bool.  Subclasse now only override the separate methods instead of duplicating add_user.

Refactor shutdown_command introducing a new _build_shutdown_command which is overridden in subclasses.

Additional Context

Test Steps

tox -e py3

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

Perform preliminary refactor to be used by securirity event logging.

Split add_user method into separate methods:
- _add_user_preprocess_kwargs: filter distro-specific args before cmd
- _build_add_user_cmd: return tuple of cmd and log_command for the useradd
- _post_add_user: distro-specific post-creation steps for Alpine
- _user_groups_to_list: normalize group input to a list

Move util.is_user check into create_user and make add_user raise
on failure instead of returning bool.  Subclasse now only override the
separate methods instead of duplicating add_user.

Refactor shutdown_command introducing a new _build_shutdown_command
which is overridden in subclasses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant