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

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