Blame 0020-Handle-crypto-modules-with-and-without-modaliases.patch

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