From dc0034286b60dc4186628de08db41ab501dffbaf Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Tue, 13 Feb 2018 10:19:23 +0000
Subject: [PATCH] Ask for the user account password first

---
 src/freedombone-app-bdsmail | 40 +++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/src/freedombone-app-bdsmail b/src/freedombone-app-bdsmail
index 53dda83e5..dd728cfa7 100755
--- a/src/freedombone-app-bdsmail
+++ b/src/freedombone-app-bdsmail
@@ -249,6 +249,28 @@ function install_bdsmail {
         remove_bdsmail
     fi
 
+    # ask to the ssh login password for the admin user
+    # This is then used to create the maildir account
+    user_account_password=''
+    data=$(tempfile 2>/dev/null)
+    trap "rm -f $data" 0 1 2 5 15
+    dialog --title $"Password" \
+           --clear \
+           --passwordbox $"Enter your ssh login password" 8 60 2> $data
+    ret=$?
+    case $ret in
+        0)
+            user_account_password=$(cat $data)
+            ;;
+    esac
+
+    if [ ${#user_account_password} -lt 2 ]; then
+        echo ''
+        echo $'A password must be provided for your user account.'
+        echo $'This is the same as the original ssh login password shown when you first installed the system.'
+        exit 3656358
+    fi
+
     if [ -d /repos/bdsmail ]; then
         mkdir $BDSMAIL_DIR
         cp -r -p /repos/bdsmail/. $BDSMAIL_DIR
@@ -369,23 +391,7 @@ function install_bdsmail {
 
     bdsmail_configure_users
 
-    # ask to the ssh login password for the admin user
-    # This is then used to create the maildir account
-    data=$(tempfile 2>/dev/null)
-    trap "rm -f $data" 0 1 2 5 15
-    dialog --title $"Password" \
-           --clear \
-           --passwordbox $"Enter your ssh login password" 8 60 2> $data
-    ret=$?
-    case $ret in
-        0)
-            $BDSMAIL_DIR/bin/newmail $MY_USERNAME /home/$MY_USERNAME/MailDir/i2p $(cat $data)
-            ;;
-        1)
-            exit 643856384;;
-        255)
-            exit 638762424;;
-    esac
+    $BDSMAIL_DIR/bin/newmail $MY_USERNAME /home/$MY_USERNAME/MailDir/i2p "$user_account_password"
 
     APP_INSTALLED=1
 }
-- 
GitLab