Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/test/check/test-journal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ rlJournalStart
rlAssertGrep "Configured persistent journal storage with sudo" $rlRun_LOG
fi

rlFileExists "$config_test/checks/journal.txt"
rlAssertExists "$config_test/checks/journal.txt"

rlRun -s "cat $config_test_check/output.txt"
rlAssertGrep "^\[Journal\]$" $rlRun_LOG
rlAssertGrep "\[Journal\]" $rlRun_LOG
rlAssertGrep "^Storage=persistent$" $rlRun_LOG
rlAssertGrep "^Compress=yes$" $rlRun_LOG
rlPhaseEnd
Expand Down
10 changes: 6 additions & 4 deletions tmt/guest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,8 +1291,10 @@ class GuestData(
is_flag=True,
option=('-b', '--become'),
help="""
Whether to run tests and shell scripts in prepare and
finish steps with ``sudo``.
If set, user-provided commands - ``prepare`` and ``finish``
scripts and tests - will be invoked with elevated, superuser
privileges. If the access plugin has is not a superuser
Comment thread
happz marked this conversation as resolved.
already, passwordless ``sudo`` will be used.
Comment on lines +1296 to +1297
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.

""",
)

Expand Down Expand Up @@ -3739,9 +3741,9 @@ def reboot(
f"Guest '{self.multihost_name}' does not support hard reboot."
)

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.

default_reboot_command = ShellScript(
f'sudo {default_reboot_command.to_shell_command()}'
f'{self.facts.sudo_prefix} {default_reboot_command.to_shell_command()}'
)

command = command or default_reboot_command
Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3778,6 +3778,6 @@ def safe_filename(template: str, phase: Phase, guest: 'Guest', **variables: Any)
rendering the filename.
"""

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.


return Path(render_template(template, PHASE=phase, GUEST=guest, **variables))
7 changes: 1 addition & 6 deletions tmt/steps/context/pidfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,8 @@
OUTER_WRAPPER_TEMPLATE = jinja2.Template("""
{% macro log_to_dmesg(msg) %}
{%- if not GUEST.facts.is_superuser %}
{%- if GUEST.become %}
# Logging test into kernel log
sudo bash -c "echo \\\"{{ msg }}\\\" > /dev/kmsg"
{%- else %}
# Not logging into kernel log: not a superuser, 'become' not enabled
# echo \"{{ msg }}\" > /dev/kmsg
{%- endif %}
{{ GUEST.facts.sudo_prefix }} bash -c "echo \\\"{{ msg }}\\\" > /dev/kmsg"
{%- else %}
# Logging test into kernel log
echo "{{ msg }}" > /dev/kmsg
Expand Down
4 changes: 1 addition & 3 deletions tmt/steps/prepare/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ def _invoke_script(
pull_options.exclude.append(str(script_log_filepath))

if guest.become and not guest.facts.is_superuser:
command = tmt.utils.ShellScript(
f'{guest.facts.sudo_prefix} {script.to_shell_command()}'
)
command = tmt.utils.ShellScript(f'sudo -E {script.to_shell_command()}')
Comment thread
happz marked this conversation as resolved.
else:
command = script

Expand Down
Loading