X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=src%2Fmonkeysphere-host;h=1fa3aea32901cc858677116bc1dcf56dc45b1852;hb=d1f2eb3152412b62d17f15db519efa38a9bd6710;hp=eadd74bcedb1e4d1abdd896c199b7ebf4b18e63a;hpb=6880d38e7faed336e4cfee7b1da037e90008a1b3;p=monkeysphere.git diff --git a/src/monkeysphere-host b/src/monkeysphere-host index eadd74b..1fa3aea 100755 --- a/src/monkeysphere-host +++ b/src/monkeysphere-host @@ -34,9 +34,7 @@ MHSHAREDIR="${SYSSHAREDIR}/mh" MHDATADIR="${SYSDATADIR}/host" # host pub key files -HOST_KEY_FILE="${SYSDATADIR}/host_keys.pub.gpg" -# host pub key fingerprints file -HOST_KEY_FPR_FILE="${SYSDATADIR}/host_keys.fprs" +HOST_KEY_FILE="${SYSDATADIR}/host_keys.pub.pgp" # UTC date in ISO 8601 format if needed DATE=$(date -u '+%FT%T') @@ -91,21 +89,12 @@ gpg_host_edit() { gpg_host --command-fd 0 --edit-key "$@" } -# export the monkeysphere gpg pub key file -update_gpg_pub_file() { +# export the monkeysphere OpenPGP pub key file +update_pgp_pub_file() { log debug "updating openpgp public key file '$HOST_KEY_FILE'..." - gpg_host --export --armor --export-options export-minimal > "$HOST_KEY_FILE" - log debug "updating fingerprint file '$HOST_KEY_FPR_FILE'..." - gpg_host --list-secret-key --with-colons --with-fingerprint \ - | awk -F: '/^fpr:/{ print $10 }' > "$HOST_KEY_FPR_FILE" -} - -host_fingerprints() { - local fprs=($(cat "$HOST_KEY_FPR_FILE")) - - log debug "host key fingerprints:" - printf '%s\n' "${fprs[@]}" | log debug - printf '%s\n' "${fprs[@]}" + gpg_host --export --armor --export-options export-minimal \ + $(gpg_host --list-secret-keys --with-colons --fingerprint | grep ^fpr | cut -f10 -d:) \ + > "$HOST_KEY_FILE" } # check that the service name is well formed @@ -116,7 +105,7 @@ check_service_name() { # fail if host key not present check_no_keys() { - [ -s "$HOST_KEY_FILE" ] || [ -s "$HOST_KEY_FPR_FILE" ] \ + [ -s "$HOST_KEY_FILE" ] \ || failure "You don't appear to have a Monkeysphere host key on this server. Please run 'monkeysphere-host import-key' import a key." } @@ -126,7 +115,7 @@ Please run 'monkeysphere-host import-key' import a key." check_key_input() { local keyID="$1" # array of fingerprints - local fprs=($(host_fingerprints)) + local fprs=($(list_primary_fingerprints <"$HOST_KEY_FILE")) case ${#fprs[@]} in 0) @@ -139,7 +128,7 @@ Please run 'monkeysphere-host import-key' to import a key." *) if [ -z "$keyID" ] ; then failure "Your host keyring contains multiple keys. -Please specify one to act on (see 'monkeysphere-host show-key')." +Please specify one to act on (see 'monkeysphere-host show-keys')." fi ;; esac @@ -168,7 +157,7 @@ multi_key() { shift local keys=$@ local i=0 - local fprs=($(host_fingerprints)) + local fprs=($(list_primary_fingerprints <"$HOST_KEY_FILE")) local key check_no_keys @@ -334,8 +323,8 @@ case $COMMAND in diagnostics ;; - 'update-gpg-pub-file') - update_gpg_pub_file + 'update-pgp-pub-file') + update_pgp_pub_file ;; 'version'|'v')