Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(debug xtrace): failures with mksh and with rd.live.debug #2287

Closed
wants to merge 1 commit into from

Conversation

FGrose
Copy link
Contributor

@FGrose FGrose commented Mar 23, 2023

Drop debug_on() debug_off() project-wide as setting xtrace is only
local in mksh. Use set -x directly instead. And use the shell's
local - feature to automate the restoration of local xtrace
option changes on function returns.

This fixes the bug with rd.live.debug where the debug_on() call
in the first getarg() call would fail to restore xtracing because
RD_DEBUG was not set. This also allows rd.live.debug to be
independent of rd.debug and eliminates 18 debug_off/debug_on calls.

This feature is present in bash and dash and not needed in mksh.
In mksh, local - (- alone) is an alias for typeset -p (synonymous
with declare -p in bash). Use local - with additional arguments to
avoid this alternate behavior in mksh.

This code works with dash since v0.5.2 (2005-09-26) and with bash
since v4.4 (2016-09-15).

Replace the nulling of debug_on()/debug_off() functions in
TEST-98-GETARG by overriding set +x in a temporary working copy of
the relevant code to aid in debugging a getarg() failure.

Checklist

  • [✔] I have tested it locally.
  • [✔] I have provided new testing code to replace the dropped functions.

@github-actions github-actions bot added base Issues related to the base module bash Issues related to the bash module modules Issue tracker for all modules labels Mar 23, 2023
@LaszloGombos
Copy link
Collaborator

LaszloGombos commented Mar 23, 2023

What happens when /bin/sh points to mksh ?

@github-actions github-actions bot added crypt Issues related to the crypt module test Issues related to testing labels Apr 13, 2023
@FGrose FGrose changed the title refactor(dracut-lib debug muting): use local '-' to restore xtrace fix(debug xtrace): failures with mksh and with rd.live.debug Apr 13, 2023
@FGrose FGrose force-pushed the debug branch 4 times, most recently from 5f6fa41 to 82d2828 Compare April 14, 2023 14:42
@stale
Copy link

stale bot commented May 18, 2023

This issue is being marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. If this is still an issue in the latest release of Dracut and you would like to keep it open please comment on this issue within the next 7 days. Thank you for your contributions.

@stale stale bot added the stale communication is stuck label May 18, 2023
@FGrose
Copy link
Contributor Author

FGrose commented May 21, 2023

@LaszloGombos > What happens when /bin/sh points to mksh ?

Independent of this code, with, ln -sf mksh /bin/sh, if module mksh is not requested, resolve_deps() will test the wrong file for script installs with a shebang, #!/bin/sh or #!/usr/bin/sh.

Pull Request #2359 addresses this bug.

@stale stale bot removed the stale communication is stuck label May 21, 2023
@FGrose
Copy link
Contributor Author

FGrose commented May 22, 2023

@LaszloGombos > What happens when /bin/sh points to mksh ? -- bug 2

Independent of this code, when these conditions apply,

  1. host has ln -sf mksh /bin/sh, and
  2. if a shell program is NOT specified, and
  3. if NO modules are called with a dependency for the 99base module (where bash would be specified), then

resolve_deps() will install mksh, as the source for /bin/sh as in Script installs with a shebang.

Pull Request #2362 addresses this bug.

@stale
Copy link

stale bot commented Jul 14, 2023

This issue is being marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. If this is still an issue in the latest release of Dracut and you would like to keep it open please comment on this issue within the next 7 days. Thank you for your contributions.

@stale stale bot added the stale communication is stuck label Jul 14, 2023
@FGrose FGrose marked this pull request as draft July 15, 2023 12:28
@stale stale bot removed the stale communication is stuck label Jul 15, 2023
Drop debug_on() debug_off() project-wide as setting xtrace is only
local in mksh.  Use set -x directly instead. And use the shell's
'local -' feature to automate the restoration of local xtrace
option changes on function returns.

This fixes the bug with rd.live.debug where the debug_on() call
in the first getarg() call would fail to restore xtracing because
RD_DEBUG was not set. This also allows rd.live.debug to be
independent of rd.debug and eliminates 18 debug_off/debug_on calls.

This feature is present in bash and dash and not needed in mksh.
In mksh, local - (- alone) is an alias for typeset -p (synonymous
with declare -p in bash). Use local - with additional arguments to
avoid this alternate behavior in mksh.

This code works with dash since v0.5.2 (2005-09-26) and with bash
since v4.4 (2016-09-15).

Replace the nulling of debug_on()/debug_off() functions in
TEST-98-GETARG by overriding set +x in a temporary working copy of
the relevant code to aid in debugging a getarg() failure.
@github-actions github-actions bot removed the bash Issues related to the bash module label Jul 27, 2023
@FGrose FGrose marked this pull request as ready for review July 27, 2023 20:55
@FGrose FGrose mentioned this pull request Jul 31, 2023
3 tasks
@stale
Copy link

stale bot commented Sep 16, 2023

This issue is being marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. If this is still an issue in the latest release of Dracut and you would like to keep it open please comment on this issue within the next 7 days. Thank you for your contributions.

@stale stale bot added the stale communication is stuck label Sep 16, 2023
@stale stale bot closed this Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
base Issues related to the base module crypt Issues related to the crypt module modules Issue tracker for all modules stale communication is stuck test Issues related to testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants