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

Avoid using nullglob option and fix dracut-install #1762

Merged
merged 6 commits into from
Apr 4, 2022

Conversation

pvalena
Copy link
Contributor

@pvalena pvalena commented Mar 25, 2022

Glob is in most cases not expected to evaluate to null. To avoid unexpected failures, don't use the nullglob option.

I've found no code (WRT the modifications applied) where nullglob is needed, as the variable is either checked explicitly by [[ -f $file ]], or passed to inst_multiple -o where the file string is actually expected instead. I think more code is actually expecting an invalid argument instead of missing one (f.e. cp), so this increases resiliency.

Changes

  • removed nullglob option use
  • alternative implementation for findkeymap (10i18n module) with mapfile (recursion overwrites trap setting)
  • fixed dracut-install not to fail when -o is specified, but no source is specified

Checklist

  • I have tested it locally
  • I have reviewed and updated any documentation if relevant
  • I am providing new code and test(s) for it

Additional

E.g., a PR which I don't think should be needed: msekletar/prefixdevname#1

Tests

keymapfile: https://gist.github.com/f6048df4d7f2a2d609974283a674b9fd
dracut-install: https://gist.github.com/07171bb36863394728852810b21c026f

@github-actions github-actions bot added i18n Issues related to the i18n module modules Issue tracker for all modules test Issues related to testing labels Mar 25, 2022
@pvalena

This comment was marked as resolved.

@pvalena pvalena marked this pull request as draft March 28, 2022 12:32
@pvalena pvalena force-pushed the nullglob branch 2 times, most recently from 862001a to 5915072 Compare April 4, 2022 01:55
pvalena added 5 commits April 4, 2022 05:04
When running dracut-install with '-o' (optional source), and nullglob
at the same time, when all of the arguments evaluate <null>, dracut-install
should not fail even when the source is not specified.
This reverts commit 3506476, to replace
the implementation.
Avoid using shell options in findkeymap, instead of using a wrapper[*]
to restore the previous options. Using mapfile and find to generate the list
of files also has the benefit of being more readable in this case.

[*] Reverted commit 3506476
Original issue description from Michal Hecko <[email protected]>:

The findkeymap function manipulates the shell options and relies on
restoring them using the trap. However, as the function might be called
recursively, each recursive invocation changes the signal handler to its
own. As the recursion is entered with shell options already modified,
the changed trap handler is replaced with restoration to the modified
shell options, not the original ones.
@pvalena pvalena marked this pull request as ready for review April 4, 2022 03:34
@pvalena
Copy link
Contributor Author

pvalena commented Apr 4, 2022

I've run some tests (automated & manual) and fixed the remaining issues.

Tests

keymapfile: https://gist.github.com/f6048df4d7f2a2d609974283a674b9fd
dracut-install: https://gist.github.com/07171bb36863394728852810b21c026f

Copy link
Collaborator

@johannbg johannbg left a comment

Choose a reason for hiding this comment

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

LGTM

@johannbg johannbg enabled auto-merge (rebase) April 4, 2022 03:58
@pvalena
Copy link
Contributor Author

pvalena commented Apr 4, 2022

Thanks!

Copy link
Member

@lnykryn lnykryn left a comment

Choose a reason for hiding this comment

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

LGTM

@johannbg johannbg merged commit 79170aa into dracutdevs:master Apr 4, 2022
pvalena added a commit to pvalena/dracut that referenced this pull request Jul 21, 2022
as there's a check for file existence (and it being a regular file),
recommended in the scriplet and I think prefered.

Related: dracutdevs#1762
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n Issues related to the i18n module modules Issue tracker for all modules test Issues related to testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants