Blame SOURCES/0034-Handle-crypto-modules-with-and-without-modaliases.patch

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