From: Sean Anderson <seanga2@gmail.com>
Date: Fri, 12 Feb 2021 11:54:36 -0500
Subject: Undo 3.3.1 changes which break the script for no good reason

---
 keys/add_key.sh       | 53 ---------------------------------------------------
 keys/ahab_pki_tree.sh | 53 ---------------------------------------------------
 keys/hab4_pki_tree.sh | 53 ---------------------------------------------------
 3 files changed, 159 deletions(-)

diff --git a/keys/add_key.sh b/keys/add_key.sh
index 68c79c3..9417bed 100755
--- a/keys/add_key.sh
+++ b/keys/add_key.sh
@@ -305,48 +305,6 @@ else
     fi
 fi
 
-# Check existance of keys/, crts/ and ca/ directories of <cst> before generating keys and
-# switch current working directory to <cst>/keys directory, if needed.
-crt_dir=$(pwd)
-script_name=$(readlink "$0")
-if [ "${script_name}" = "" ]
-then
-	script_name=$0
-fi
-script_path=$(cd $(dirname "${script_name}") && pwd -P)
-keys_dir=${script_path}/../keys/
-crts_dir=${script_path}/../crts/
-ca_dir=${script_path}/../ca/
-
-if [ ! -d "${keys_dir}" ]
-then
-    echo ERROR: "Private keys directory ${keys_dir} is missing. Expecting script to be located inside <cst>/keys directory."
-    exit 1
-fi
-
-if [ ! -d "${crts_dir}" ]
-then
-    echo ERROR: "Public keys directory ${crts_dir} is missing. Expecting <cst>/crts directory to be already created."
-    exit 1 
-fi
-
-if [ ! -d "${ca_dir}" ]
-then
-    echo ERROR: "Openssl configuration directory ${ca_dir} is missing. Expecting <cst>/ca directory to hold openssl configuration files."
-    exit 1 
-fi
-
-# Switch current working directory to keys directory, if needed.
-if [ "${crt_dir}" != "${keys_dir}" ]
-then
-    cd "${keys_dir}" 
-    if [ $? -ge 1 ]
-    then
-        echo ERROR: "Cannot change directory to ${keys_dir}"
-        exit 1
-    fi 
-fi
-
 # Generate outputs
 if [ $kt = "ecc" ]
 then
@@ -404,15 +362,4 @@ mv ${key_fullname}_key_tmp.pem ${key_fullname}_key.pem
 
 # Clean up
 \rm -f *_req.pem
-
-# Switch back to initial working directory, if needed.
-if [ "${crt_dir}" != "${keys_dir}" ]
-then
-    cd "${crt_dir}" 
-    if [ $? -ge 1 ]
-    then
-        echo ERROR: "Cannot change directory to ${crt_dir}"
-        exit 1
-    fi
-fi
 exit 0
diff --git a/keys/ahab_pki_tree.sh b/keys/ahab_pki_tree.sh
index f5ab36c..0b9004f 100755
--- a/keys/ahab_pki_tree.sh
+++ b/keys/ahab_pki_tree.sh
@@ -277,48 +277,6 @@ then
     read srk_ca
 fi
 
-# Check existance of keys/, crts/ and ca/ directories of <cst> before generating keys and
-# switch current working directory to <cst>/keys directory, if needed.
-crt_dir=$(pwd)
-script_name=$(readlink "$0")
-if [ "${script_name}" = "" ]
-then
-	script_name=$0
-fi
-script_path=$(cd $(dirname "${script_name}") && pwd -P)
-keys_dir=${script_path}/../keys/
-crts_dir=${script_path}/../crts/
-ca_dir=${script_path}/../ca/
-
-if [ ! -d "${keys_dir}" ]
-then
-    echo ERROR: "Private keys directory ${keys_dir} is missing. Expecting script to be located inside <cst>/keys directory."
-    exit 1
-fi
-
-if [ ! -d "${crts_dir}" ]
-then
-    echo ERROR: "Public keys directory ${crts_dir} is missing. Expecting <cst>/crts directory to be already created."
-    exit 1 
-fi
-
-if [ ! -d "${ca_dir}" ]
-then
-    echo ERROR: "Openssl configuration directory ${ca_dir} is missing. Expecting <cst>/ca directory to hold openssl configuration files."
-    exit 1 
-fi
-
-# Switch current working directory to keys directory, if needed.
-if [ "${crt_dir}" != "${keys_dir}" ]
-then
-    cd "${keys_dir}" 
-    if [ $? -ge 1 ]
-    then
-        echo ERROR: "Cannot change directory to ${keys_dir}"
-        exit 1
-    fi 
-fi
-
 # Check that the file "serial" is present, if not create it:
 if [ ! -f serial ]
 then
@@ -613,15 +571,4 @@ do
     i=$((i+1))
 done
 fi
-
-# Switch back to initial working directory, if needed.
-if [ "${crt_dir}" != "${keys_dir}" ]
-then
-    cd "${crt_dir}" 
-    if [ $? -ge 1 ]
-    then
-        echo ERROR: "Cannot change directory to ${crt_dir}"
-        exit 1
-    fi
-fi
 exit 0
diff --git a/keys/hab4_pki_tree.sh b/keys/hab4_pki_tree.sh
index 944cc66..ca0058c 100755
--- a/keys/hab4_pki_tree.sh
+++ b/keys/hab4_pki_tree.sh
@@ -266,48 +266,6 @@ then
     read srk_ca
 fi
 
-# Check existance of keys/, crts/ and ca/ directories of <cst> before generating keys and
-# switch current working directory to <cst>/keys directory, if needed.
-crt_dir=$(pwd)
-script_name=$(readlink "$0")
-if [ "${script_name}" = "" ]
-then
-	script_name=$0
-fi
-script_path=$(cd $(dirname "${script_name}") && pwd -P)
-keys_dir=${script_path}/../keys/
-crts_dir=${script_path}/../crts/
-ca_dir=${script_path}/../ca/
-
-if [ ! -d "${keys_dir}" ]
-then
-    echo ERROR: "Private keys directory ${keys_dir} is missing. Expecting script to be located inside <cst>/keys directory."
-    exit 1
-fi
-
-if [ ! -d "${crts_dir}" ]
-then
-    echo ERROR: "Public keys directory ${crts_dir} is missing. Expecting <cst>/crts directory to be already created."
-    exit 1 
-fi
-
-if [ ! -d "${ca_dir}" ]
-then
-    echo ERROR: "Openssl configuration directory ${ca_dir} is missing. Expecting <cst>/ca directory to hold openssl configuration files."
-    exit 1 
-fi
-
-# Switch current working directory to keys directory, if needed.
-if [ "${crt_dir}" != "${keys_dir}" ]
-then
-    cd "${keys_dir}" 
-    if [ $? -ge 1 ]
-    then
-        echo ERROR: "Cannot change directory to ${keys_dir}"
-        exit 1
-    fi 
-fi
-
 # Check that the file "serial" is present, if not create it:
 if [ ! -f serial ]
 then
@@ -663,15 +621,4 @@ do
     i=$((i+1))
 done
 fi
-
-# Switch back to initial working directory, if needed.
-if [ "${crt_dir}" != "${keys_dir}" ]
-then
-    cd "${crt_dir}" 
-    if [ $? -ge 1 ]
-    then
-        echo ERROR: "Cannot change directory to ${crt_dir}"
-        exit 1
-    fi
-fi
 exit 0
