Skip to content

Update docs and semantics of become key#4905

Open
happz wants to merge 3 commits into
mainfrom
become-and-sudo
Open

Update docs and semantics of become key#4905
happz wants to merge 3 commits into
mainfrom
become-and-sudo

Conversation

@happz
Copy link
Copy Markdown
Contributor

@happz happz commented May 19, 2026

Instead of promising all scripts and tests would be running with sudo, it now states that user-provided scripts and tests would be invoked with superuser privileges. This makes the intent clearer, and gives us easier job: add sudo only when not already a superuser.

Pull Request Checklist

  • implement the feature

@happz happz added this to planning May 19, 2026
@happz happz added step | provision Stuff related to the provision step code | no functional change "No Functional Change" intended. Patch should not change tmt's behavior in any way. labels May 19, 2026
@github-project-automation github-project-automation Bot moved this to backlog in planning May 19, 2026
@happz happz added the ci | full test Pull request is ready for the full test execution label May 19, 2026
@happz happz moved this from backlog to review in planning May 19, 2026
Comment thread tmt/guest/__init__.py
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the handling of elevated privileges by replacing hardcoded 'sudo' commands with 'guest.facts.sudo_prefix' and updating the documentation for the '--become' option. Feedback includes using 'PHASE.parent.name' in filename templates to avoid potential AttributeErrors and ensuring environment variables are preserved when using 'sudo_prefix' in shell scripts.

Comment thread tmt/steps/__init__.py Outdated
Comment thread tmt/steps/prepare/shell.py
@happz happz changed the title Update docs and semantics of behave key Update docs and semantics of become key May 19, 2026
happz added 2 commits May 19, 2026 20:55
Instead of promising all scripts and tests would be running with `sudo`,
it now states that user-provided scripts and tests would be invoked with
superuser privileges. This makes the intent clearer, and gives us easier
job: add `sudo` only when not already a superuser.
@happz happz force-pushed the become-and-sudo branch from 09d6e4a to 3e45993 Compare May 19, 2026 18:55
Comment thread tmt/guest/__init__.py
Comment on lines +1296 to +1297
privileges. If the access plugin has is not a superuser
already, passwordless ``sudo`` will be used.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
privileges. If the access plugin has is not a superuser
already, passwordless ``sudo`` will be used.
privileges via passwordless ``sudo`` if necessary.

Comment thread tmt/steps/__init__.py
"""

template += '-{{ PHASE.safe_name }}-{{ GUEST.safe_name }}'
template += '-{{ PHASE.parent.name }}-{{ PHASE.safe_name }}-{{ GUEST.safe_name }}'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change sneaked in?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, seems like it should have been in #4351

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm, might be. #4351 needs it for sure, but I think it breaks some tests in this PR as well. Need to recall what it was.

Comment thread tmt/guest/__init__.py
)

if self.become:
if self.become and not self.facts.is_superuser:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is to be consistent with the other calls? sudo_prefix should already have the is_superuser check embedded in it.

Comment thread tmt/guest/__init__.py
@happz happz self-assigned this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci | full test Pull request is ready for the full test execution code | no functional change "No Functional Change" intended. Patch should not change tmt's behavior in any way. step | provision Stuff related to the provision step

Projects

Status: review

Development

Successfully merging this pull request may close these issues.

2 participants