]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(crypt-gpg): shellcheck for modules.d/91crypt-gpg
authorHarald Hoyer <harald@redhat.com>
Fri, 26 Mar 2021 09:29:23 +0000 (10:29 +0100)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 29 Mar 2021 12:45:07 +0000 (14:45 +0200)
modules.d/91crypt-gpg/.shchkdir [new file with mode: 0644]
modules.d/91crypt-gpg/crypt-gpg-lib.sh
modules.d/91crypt-gpg/module-setup.sh

diff --git a/modules.d/91crypt-gpg/.shchkdir b/modules.d/91crypt-gpg/.shchkdir
new file mode 100644 (file)
index 0000000..e69de29
index e66feb7d3c831cd052ff9b430d44c0e5df6cb5cb..0613803a6af895f44369fb31c87b5962e10bffbe 100755 (executable)
@@ -29,8 +29,10 @@ gpg_decrypt() {
     # program needed with GnuPG < 2.1), making for uncomplicated
     # integration with the existing codebase.
     local useSmartcard="0"
-    local gpgMajorVersion="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* ([0-9]*).*|\1|p')"
-    local gpgMinorVersion="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* [0-9]*\.([0-9]*).*|\1|p')"
+    local gpgMajorVersion
+    local gpgMinorVersion
+    gpgMajorVersion="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* ([0-9]*).*|\1|p')"
+    gpgMinorVersion="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* [0-9]*\.([0-9]*).*|\1|p')"
 
     if [ "${gpgMajorVersion}" -ge 2 ] && [ "${gpgMinorVersion}" -ge 1 ] \
         && [ -f /root/crypt-public-key.gpg ] && getargbool 1 rd.luks.smartcard; then
@@ -38,7 +40,8 @@ gpg_decrypt() {
         echo "allow-loopback-pinentry" >> "$gpghome/gpg-agent.conf"
         GNUPGHOME="$gpghome" gpg-agent --quiet --daemon
         GNUPGHOME="$gpghome" gpg --quiet --no-tty --import < /root/crypt-public-key.gpg
-        local smartcardSerialNumber="$(GNUPGHOME=$gpghome gpg --no-tty --card-status \
+        local smartcardSerialNumber
+        smartcardSerialNumber="$(GNUPGHOME=$gpghome gpg --no-tty --card-status \
             | sed -n -r -e 's|Serial number.*: ([0-9]*)|\1|p' | tr -d '\n')"
         if [ -n "${smartcardSerialNumber}" ]; then
             inputPrompt="PIN (OpenPGP card ${smartcardSerialNumber})"
index c2f91c276dd4521a5839d0a155f16e0f72c3d719..4d33df1753a9aa1eaeff65d32f07842647036607 100755 (executable)
@@ -40,8 +40,11 @@ sc_public_key() {
 
 # CCID Smartcard support requires GnuPG >= 2.1 with scdaemon and libusb
 sc_supported() {
-    local gpgMajor="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* ([0-9]*).*|\1|p')"
-    local gpgMinor="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* [0-9]*\.([0-9]*).*|\1|p')"
+    local gpgMajor
+    local gpgMinor
+    gpgMajor="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* ([0-9]*).*|\1|p')"
+    gpgMinor="$(gpg --version | sed -n 1p | sed -n -r -e 's|.* [0-9]*\.([0-9]*).*|\1|p')"
+
     if [[ ${gpgMajor} -gt 2 || ${gpgMajor} -eq 2 && ${gpgMinor} -ge 1 ]] \
         && require_binaries gpg-agent \
         && require_binaries gpg-connect-agent \