X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=src%2Fmonkeysphere-host;h=fab3ef70e96ad5d22a23e2abcd4d69dc709d82fa;hb=7dbd6806e538ff8732dd87fcf20bfd8271464552;hp=1fa3aea32901cc858677116bc1dcf56dc45b1852;hpb=d1f2eb3152412b62d17f15db519efa38a9bd6710;p=monkeysphere.git diff --git a/src/monkeysphere-host b/src/monkeysphere-host index 1fa3aea..fab3ef7 100755 --- a/src/monkeysphere-host +++ b/src/monkeysphere-host @@ -79,9 +79,14 @@ gpg_host() { # list the info about the a key, in colon format, to stdout gpg_host_list_keys() { - gpg_host --list-keys --with-colons --fixed-list-mode \ - --with-fingerprint --with-fingerprint \ - "$1" + if [ "$1" ] ; then + gpg_host --list-keys --with-colons --fixed-list-mode \ + --with-fingerprint --with-fingerprint \ + "$1" + else + gpg_host --list-keys --with-colons --fixed-list-mode \ + --with-fingerprint --with-fingerprint + fi } # edit key scripts, takes scripts on stdin, and keyID as first input @@ -151,6 +156,25 @@ check_key_userid() { grep -q -x -F "$tmpuidMatch" 2>/dev/null } +prompt_userid_exists() { + local userID="$1" + local gpgOut + local fingerprint + + if gpgOut=$(gpg_host_list_keys "=${userID}" 2>/dev/null) ; then + fingerprint=$(echo "$gpgOut" | grep '^fpr:' | cut -d: -f10) + if [ "$PROMPT" != "false" ] ; then + printf "Service name '%s' is already being used by key '%s'.\nAre you sure you want to use it again? (y/N) " "$fingerprint" "$userID" >&2 + read OK; OK=${OK:=N} + if [ "${OK/y/Y}" != 'Y' ] ; then + failure "Service name not added." + fi + else + log info "Key '%s' is already using the service name '%s'." "$fingerprint" "$userID" >&2 + fi + fi +} + # run command looped over keys multi_key() { local cmd="$1"