export SHARE
. "${SHARE}/common" || exit 1
-# date in UTF format if needed
+# UTC date in ISO 8601 format if needed
DATE=$(date -u '+%FT%T')
# unset some environment variables that could screw things up
if [ -z "$1" ] ; then
# find all secret keys
- keyID=$(gpg --with-colons --list-secret-keys | grep ^sec | cut -f5 -d:)
+ keyID=$(gpg --with-colons --list-secret-keys | grep ^sec | cut -f5 -d: | sort -u)
# if multiple sec keys exist, fail
if (( $(echo "$keyID" | wc -l) > 1 )) ; then
echo "Multiple secret keys found:"
# fail if multiple sec lines are returned, which means the id
# given is not unique
- if [ $(echo "$gpgOut" | grep '^sec:' | wc -l) -gt '1' ] ; then
+ if [ $(echo "$gpgOut" | grep -c '^sec:') -gt '1' ] ; then
failure "Key ID '$keyID' is not unique."
fi
EOF
)
- log info "generating subkey..."
+ log verbose "generating subkey..."
fifoDir=$(mktemp -d)
(umask 077 && mkfifo "$fifoDir/pass")
echo "$editCommands" | gpg --passphrase-fd 3 3< "$fifoDir/pass" --expert --command-fd 0 --edit-key "$keyID" &
rm -rf "$fifoDir"
wait
- log info "done."
+ log verbose "done."
}
function subkey_to_ssh_agent() {
[ -r "${ETC}/monkeysphere.conf" ] && . "${ETC}/monkeysphere.conf"
# set monkeysphere home directory
-MONKEYSPHERE_HOME=${MONKEYSPHERE_HOME:="${HOME}/.config/monkeysphere"}
+MONKEYSPHERE_HOME=${MONKEYSPHERE_HOME:="${HOME}/.monkeysphere"}
mkdir -p -m 0700 "$MONKEYSPHERE_HOME"
# load local config