X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=src%2Fshare%2Fmh%2Fadd_revoker;h=89e6fcf03210bc6d83da36b883b01a2d7b947f1e;hb=f3a03d72bc9c01491fc1cfccdbcef353db058548;hp=638f052e078c70b68f4dd78ae7082e98cf67ed91;hpb=18f0c19e96b6eb1132e6a412e324f8c2b64762ff;p=monkeysphere.git diff --git a/src/share/mh/add_revoker b/src/share/mh/add_revoker index 638f052..89e6fcf 100644 --- a/src/share/mh/add_revoker +++ b/src/share/mh/add_revoker @@ -61,28 +61,37 @@ if [ -f "$keyID" -o "$keyID" = '-' ] ; then # else, get the key from the keyserver else - # create a temporary directory for storing the downloaded key - local GNUPGHOME="$tmpDir" - chmod 0700 "$GNUPGHOME" - chown "$MONKEYSPHERE_USER":"$MONKEYSPHERE_USER" "$GNUPGHOME" - export GNUPGHOME + # fix permissions and ownership on temporary directory which will + # be used by monkeysphere user for storing the downloaded key + chmod 0700 "$tmpDir" + chown "$MONKEYSPHERE_USER":"$MONKEYSPHERE_GROUP" "$tmpDir" # download the key from the keyserver as the monkeysphere user log verbose "searching keyserver $KEYSERVER for keyID $keyID..." - su_monkeysphere_user "gpg --quiet --keyserver $KEYSERVER --recv-key 0x${keyID}!" \ + su_monkeysphere_user "GNUPGHOME=$tmpDir gpg --quiet --keyserver $KEYSERVER --recv-key 0x${keyID}!" \ || failure "Could not receive a key with this ID from the '$KEYSERVER' keyserver." # get the full fingerprint of new revoker key log debug "getting fingerprint of revoker key..." - fingerprint=$(su_monkeysphere_user "gpg --list-key --with-colons --with-fingerprint 0x${keyID}!" \ - | grep '^fpr:' | grep "$keyID" | cut -d: -f10) + fingerprint=$(su_monkeysphere_user "GNUPGHOME=$tmpDir gpg --list-key --with-colons --with-fingerprint 0x${keyID}!" \ + | grep '^fpr:' | cut -d: -f10) + + # test that there is only a single fingerprint + if (( $(echo "$fingerprint" | wc -l) != 1 )) ; then + cat <&2 + read OK; OK=${OK:-Y} if [ "${OK/y/Y}" != 'Y' ] ; then failure "revoker not added." fi @@ -92,20 +101,17 @@ else # export the new key to the host keyring log debug "loading key into host keyring..." - su_monkeysphere_user "gpg --quiet --export 0x${fingerprint}!" \ + su_monkeysphere_user "GNUPGHOME=$tmpDir gpg --quiet --export 0x${fingerprint}!" \ | gpg_host --import fi # edit-key script to add revoker -addrevokerCommand=$(cat <