X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=src%2Fmonkeysphere;h=5d865c96a3a7a747aa7054213500149baaec3ca4;hb=19efa03fdeda1017c876066936b6b8bf4e9ba912;hp=d652ab31ad57b236f6c1c12c3ff6f4f4cf934c98;hpb=be186e427ac34812e2b2a55489ae55fe2341f6a0;p=monkeysphere.git diff --git a/src/monkeysphere b/src/monkeysphere index d652ab3..5d865c9 100755 --- a/src/monkeysphere +++ b/src/monkeysphere @@ -34,15 +34,70 @@ usage: $PGRM [args] Monkeysphere client tool. subcommands: - update-known-hosts (k) [HOST]... update known_hosts file - update-authorized-keys (a) update authorized_keys file + update-known_hosts (k) [HOST]... update known_hosts file update-userids (u) [USERID]... add/update userid - gen-ae-subkey (g) generate an 'ae' capable subkey + update-authorized_keys (a) update authorized_keys file + gen-ae-subkey (g) KEYID generate an 'ae' capable subkey help (h,?) this help EOF } +# generate a subkey with the 'a' and 'e' usage flags set +gen_ae_subkey(){ + local keyID + local gpgOut + local userID + + log "warning: this function is still not working." + + keyID="$1" + + # set subkey defaults + SUBKEY_TYPE=${KEY_TYPE:-"RSA"} + SUBKEY_LENGTH=${KEY_LENGTH:-"1024"} + SUBKEY_USAGE=${KEY_USAGE:-"encrypt,auth"} + + gpgOut=$(gpg --fixed-list-mode --list-keys --with-colons \ + "$keyID" 2> /dev/null) + + # return 1 if there only "tru" lines are output from gpg + if [ -z "$(echo "$gpgOut" | grep -v '^tru:')" ] ; then + loge " key not found." + return 1 + fi + + userID=$(echo "$gpgOut" | grep "^uid:" | cut -d: -f10) + + # set key parameters + keyParameters=$(cat < "$msAuthorizedKeys" - echo "done." - else - log "no gpg keys to add." - fi - if [ "$USER_CONTROLLED_AUTHORIZED_KEYS" ] ; then - userAuthorizedKeys=${USER_CONTROLLED_AUTHORIZED_KEYS/\%h/"$HOME"} - if [ -s "$userAuthorizedKeys" ] ; then - log -n "adding user authorized_keys file... " - cat "$userAuthorizedKeys" >> "$msAuthorizedKeys" - echo "done." - fi - fi - log "monkeysphere authorized_keys file generated:" - log "$msAuthorizedKeys" + # update authorized_keys + update_authorized_keys "$msAuthorizedKeys" "$userAuthorizedKeys" "$userKeysCacheDir" ;; 'update-userids'|'u') @@ -146,8 +182,12 @@ case $COMMAND in done ;; - 'gen-ae-subkey'|) - failure "function not implemented yet." + 'gen-ae-subkey'|'g') + keyID="$1" + if [ -z "$keyID" ] ; then + failure "you must specify keyid of primary key." + fi + gen_ae_subkey "$keyID" ;; 'help'|'h'|'?')