a56a5e
From ee916b72cc6ec89adf68d5b538044ebb5edcdbbd Mon Sep 17 00:00:00 2001
90b079
From: Harald Hoyer <harald@redhat.com>
90b079
Date: Wed, 30 Oct 2013 12:22:52 +0100
90b079
Subject: [PATCH] Handle crypto modules with and without modaliases
90b079
90b079
If new kernels have modules split out, handle the case, where modules
90b079
have to modalias and just install them.
90b079
90b079
Also add the crypto drivers and names to host_modalias.
90b079
---
90b079
 dracut-functions.sh      | 14 ++++++++++----
90b079
 dracut.sh                |  5 +++++
90b079
 modules.d/01fips/fips.sh |  1 -
90b079
 3 files changed, 15 insertions(+), 5 deletions(-)
90b079
90b079
diff --git a/dracut-functions.sh b/dracut-functions.sh
1755ca
index 2e6e8456..38095ba4 100755
90b079
--- a/dracut-functions.sh
90b079
+++ b/dracut-functions.sh
90b079
@@ -1480,7 +1480,7 @@ dracut_kernel_post() {
90b079
 
90b079
 module_is_host_only() {
90b079
     local _mod=$1
90b079
-    local _modenc a i
90b079
+    local _modenc a i _k _s _v _aliases
90b079
     _mod=${_mod##*/}
90b079
     _mod=${_mod%.ko}
90b079
     _modenc=${_mod//-/_}
90b079
@@ -1497,19 +1497,25 @@ module_is_host_only() {
90b079
         # this covers the case, where a new module is introduced
90b079
         # or a module was renamed
90b079
         # or a module changed from builtin to a module
90b079
+
90b079
         if [[ -d /lib/modules/$kernel_current ]]; then
90b079
             # if the modinfo can be parsed, but the module
90b079
             # is not loaded, then we can safely return 1
90b079
             modinfo -F filename "$_mod" &>/dev/null && return 1
90b079
         fi
90b079
 
90b079
-        # Finally check all modalias, if we install for a kernel
90b079
-        # different from the current one
90b079
-        for a in $(modinfo -k $kernel -F alias $_mod 2>/dev/null); do
90b079
+        _aliases=$(modinfo -k $kernel -F alias $_mod 2>/dev/null)
90b079
+
90b079
+        # if the module has no aliases, install it
90b079
+        [[ $_aliases ]] || return 0
90b079
+
90b079
+        # finally check all modalias
90b079
+        for a in $_aliases; do
90b079
             for i in "${!host_modalias[@]}"; do
90b079
                 [[ $i == $a ]]  && return 0
90b079
             done
90b079
         done
90b079
+
90b079
     fi
90b079
 
90b079
     return 1
90b079
diff --git a/dracut.sh b/dracut.sh
1755ca
index 173a259a..c6a388ab 100755
90b079
--- a/dracut.sh
90b079
+++ b/dracut.sh
90b079
@@ -968,6 +968,11 @@ if [[ $hostonly ]]; then
90b079
 
90b079
     rm -f -- "$initdir/.modalias"
90b079
 
90b079
+    while read _k _s _v; do
90b079
+        [ "$_k" != "name" -a "$_k" != "driver" ] && continue
90b079
+        host_modalias["$_v"]=1
90b079
+    done 
90b079
+
90b079
     # check /proc/modules
90b079
     declare -A host_modules
90b079
     while read m rest; do
90b079
diff --git a/modules.d/01fips/fips.sh b/modules.d/01fips/fips.sh
1755ca
index f0a4c5c2..98dd1c2f 100755
90b079
--- a/modules.d/01fips/fips.sh
90b079
+++ b/modules.d/01fips/fips.sh
90b079
@@ -96,7 +96,6 @@ do_fips()
90b079
                 _found=0
90b079
                 while read _k _s _v; do
90b079
                     [ "$_k" != "name" -a "$_k" != "driver" ] && continue
90b079
-                    [ "$_k" = "driver" ] && _v=$(str_replace "$_v" "_" "-")
90b079
                     [ "$_v" != "$_module" ] && continue
90b079
                     _found=1
90b079
                     break