Skip to content

Commit

Permalink
dracut.sh: check kmoddir is properly formed
Browse files Browse the repository at this point in the history
Due to the way dracut-install handles modules from custom kmoddirs, add
a test that ensures the kmoddir argument seems sane.

In addition to erroring out, provide some guidance on how to proceed, as
well as a method of skipping the test via environment variable.
  • Loading branch information
Daniel Cordero authored and haraldh committed Jan 27, 2020
1 parent 1bef293 commit f668e71
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dracut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,21 @@ esac
[[ $reproducible == yes ]] && DRACUT_REPRODUCIBLE=1
case "${drivers_dir}" in
''|*lib/modules/${kernel}|*lib/modules/${kernel}/) ;;
*)
[[ "$DRACUT_KMODDIR_OVERRIDE" ]] || {
printf "%s\n" "dracut: -k/--kmoddir path must contain \"lib/modules\" as a parent of your kernel module directory,"
printf "%s\n" "dracut: or modules may not be placed in the correct location inside the initramfs."
printf "%s\n" "dracut: was given: ${drivers_dir}"
printf "%s\n" "dracut: expected: $(dirname ${drivers_dir})/lib/modules/${kernel}"
printf "%s\n" "dracut: Please move your modules into the correct directory structure and pass the new location,"
printf "%s\n" "dracut: or set DRACUT_KMODDIR_OVERRIDE=1 to ignore this check."
exit 1
}
;;
esac
readonly TMPDIR="$(realpath -e "$tmpdir")"
[ -d "$TMPDIR" ] || {
printf "%s\n" "dracut: Invalid tmpdir '$tmpdir'." >&2
Expand Down

0 comments on commit f668e71

Please sign in to comment.