From c8ebadfd785f80943ba2b1b8a87b4e926d4918dd Mon Sep 17 00:00:00 2001
From: Frederik Lindenaar <frederik@lindenaar.nl>
Date: Thu, 15 Sep 2016 10:47:20 +0200
Subject: [PATCH] made the check on the result from PrivacyIDEA less sensitive for whitespaces being added / removed as this broke the script in PrivacyIDEA 2.1x.

---
 README.md            | 6 +++---
 privacyidea-checkotp | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
 mode change 100755 => 100644 privacyidea-checkotp

diff --git a/README.md b/README.md
index 38c282c..689758e 100644
--- a/README.md
+++ b/README.md
@@ -4,12 +4,12 @@ privacyidea-checkotp
 Shell script implementing the [PrivacyIDEA](http://www.privacyidea.org) OTP (One
 Time Password) check to integrate with [FreeRadius](http://www.freeradius.org)
 in environments where the FreeRadius Perl plugin is not available to use the
-standard check script (e.g. on OS X 10.9).
+standard check script (e.g. on OS X).
 
-**Version 1.0**, latest version, documentation and bugtracker available on my
+**Version 1.0a**, latest version, documentation and bugtracker available on my
 [GitLab instance](https://gitlab.lindenaar.net/scripts/privacyidea-checkotp)
 
-Copyright (c) 2015 Frederik Lindenaar. free for distribution under the GNU
+Copyright (c) 2015 - 2016 Frederik Lindenaar. free for distribution under the GNU
 License, see [below](#license)
 
 
diff --git a/privacyidea-checkotp b/privacyidea-checkotp
old mode 100755
new mode 100644
index b9928c2..6dae606
--- a/privacyidea-checkotp
+++ b/privacyidea-checkotp
@@ -49,7 +49,7 @@ fi
 otpresult=`/usr/bin/curl -s "$URL" --data-urlencode "user=$LOGIN" --data-urlencode "pass=$PASSWORD" --data-urlencode "client=$NAS"`
 
 # Extract the status of the request from the returned JSON
-otpstatus=`echo $otpresult | sed 's/^{.*"result": { "status": true, "value": \(.*\) },.*}/\1/'`
+otpstatus=`echo $otpresult | sed 's/^{.*"result": *{ *"status": *true, *"value": *\(.*\) *},.*}/\1/'`
 
 if [ "$otpstatus" = "true" ]; then 
 #  echo $LOGIN did authenticate $otpresult
--
libgit2 0.22.2