Blob Blame Raw
From 02f17448e379c92745f8203f47e5de0725b1c1b6 Mon Sep 17 00:00:00 2001
From: Sergio Correia <scorreia@redhat.com>
Date: Fri, 18 Oct 2019 09:04:22 -0300
Subject: [PATCH] Improve error message when bind is given an invalid PIN

---
 src/luks/clevis-luks-bind | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/luks/clevis-luks-bind b/src/luks/clevis-luks-bind
index 7aae2ea..1b5caf2 100755
--- a/src/luks/clevis-luks-bind
+++ b/src/luks/clevis-luks-bind
@@ -19,6 +19,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+. clevis-luks-common-functions
+
 SUMMARY="Binds a LUKS device using the specified policy"
 UUID=cb6e8904-81ff-40da-a84a-07ab9ab5715e
 
@@ -68,6 +70,9 @@ fi
 if ! PIN=${@:$((OPTIND++)):1} || [ -z "$PIN" ]; then
     echo "Did not specify a pin!" >&2
     usage
+elif ! EXE=$(findexe clevis-encrypt-"${PIN}"); then
+    echo "'$PIN' is not a valid pin!" >&2
+    usage
 fi
 
 if ! CFG=${@:$((OPTIND++)):1} || [ -z "$CFG" ]; then
@@ -142,4 +147,4 @@ else
         cryptsetup luksRemoveKey "$DEV" <<<"$key"
         exit 1
     fi
-fi
\ No newline at end of file
+fi
-- 
2.21.0