From 793f16b844ad0ac63d3962693e4e13e930068c25 Mon Sep 17 00:00:00 2001 From: Colin P. Mccabe Date: Sun, 1 Apr 2018 17:53:37 -0700 Subject: [PATCH] Add passtool.sh --- passtool.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-) create mode 100755 passtool.sh diff --git a/passtool.sh b/passtool.sh new file mode 100755 index 0000000..552568e --- /dev/null +++ b/passtool.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +die() { + echo $1 + exit 1 +} + +usage() +{ + cat < "${TEMPFILE}"; then + if [[ -z ${SEARCH_PATTERN} ]]; then + ${EDITOR} "${TEMPFILE}" + openssl enc -aes-256-ecb -k "${PASSWORD}" -salt \ + < "${TEMPFILE}" > "${TEMPFILE_ENC}" || + die "Re-encryption failed. Changes lost." + mv -f "${TEMPFILE_ENC}" "${PASSWORD_PATH}" || \ + die "failed to move ${TEMPFILE_ENC} to ${PASSWORD_PATH}: changes lost." + else + echo + egrep ${SEARCH_PATTERN} "${TEMPFILE}" + fi +else + die "Failed to decrypt ${PASSWORD_PATH}. Was the password correct?" +fi -- 1.6.6.rc1.39.g9a42