Merge commit 'dkg/master'
[monkeysphere.git] / src / monkeysphere-server
index 68c4b243ce5e50b8541f0ece0e7498c0621a4570..4d7acc6cb50276bb7a46ae589d3c6995ed540252 100755 (executable)
@@ -47,15 +47,13 @@ subcommands:
   publish-key (p)                       publish server's host key to keyserver
 
   add-identity-certifier (a) KEYID      import and tsign a certification key
-    -n|--domain DOMAIN                    domain of certifier ()
-    -t|--trust TRUST                      trust level of certifier (2)
+    -n|--domain DOMAIN                    limit ID certifications to IDs in DOMAIN ()
+    -t|--trust TRUST                      trust level of certifier (full)
     -d|--depth DEPTH                      trust depth for certifier (1)
   remove-identity-certifier (r) KEYID   remove a certification key
   list-identity-certifiers (l)          list certification keys
 
-  gpg-authentication-cmd                execute a gpg command to the
-                                        authentication keyring as the
-                                        monkeysphere user
+  gpg-authentication-cmd CMD            gnupg-authentication command
 
   help (h,?)                            this help
 
@@ -360,7 +358,7 @@ fingerprint_server_key() {
 
 # publish server key to keyserver
 publish_server_key() {
-    read -p "really publish key to $KEYSERVER? (y/N) " OK; OK=${OK:=N}
+    read -p "Really publish key to $KEYSERVER? (y/N) " OK; OK=${OK:=N}
     if [ ${OK/y/Y} != 'Y' ] ; then
        failure "aborting."
     fi
@@ -369,8 +367,11 @@ publish_server_key() {
     # FIXME: need to figure out better way to identify host key
     # dummy command so as not to publish fakes keys during testing
     # eventually:
-    #gpg_authentication "--keyring $GNUPGHOME_HOST/pubring.gpg --keyserver $KEYSERVER --send-keys $(hostname -f)"
-    failure "NOT PUBLISHED (to avoid permanent publication errors during monkeysphere development)."
+    #gpg_authentication "--keyserver $KEYSERVER --send-keys $(hostname -f)"
+    echo "NOT PUBLISHED (to avoid permanent publication errors during monkeysphere development)."
+    echo "The following command should publish the key:"
+    echo "monkeysphere-server gpg-authentication-cmd '--keyserver $KEYSERVER --send-keys $(hostname -f)'"
+    exit 255
 }
 
 # retrieve key from web of trust, import it into the host keyring, and
@@ -382,10 +383,11 @@ add_certifier() {
     local keyID
     local fingerprint
     local ltsignCommand
+    local trustval
 
     # set default values for trust depth and domain
     domain=
-    trust=2
+    trust=full
     depth=1
 
     # get options
@@ -422,6 +424,9 @@ add_certifier() {
     done
 
     keyID="$1"
+    if [ -z "$keyID" ] ; then
+       failure "You must specify the key ID of a key to add."
+    fi
     export keyID
 
     # export host ownertrust to authentication keyring
@@ -437,7 +442,8 @@ add_certifier() {
     echo "key found:"
     gpg_authentication "--fingerprint $fingerprint"
 
-    read -p "Are you sure you want to add this key as a certifier of users on this system? (y/N) " OK; OK=${OK:-N}
+    echo "Are you sure you want to add this key as a certifier of"
+    read -p "users on this system? (y/N) " OK; OK=${OK:-N}
     if [ "${OK/y/Y}" != 'Y' ] ; then
        failure "aborting."
     fi
@@ -445,12 +451,20 @@ add_certifier() {
     # export the key to the host keyring
     gpg_authentication "--export $keyID" | gpg_host --import
 
+    if [ "$trust" == marginal ]; then
+       trustval=1
+    elif [ "$trust" == full ]; then
+       trustval=2
+    else
+       failure "trust value requested ('$trust') was unclear (only 'marginal' or 'full' are supported)"
+    fi
+
     # ltsign command
     # NOTE: *all* user IDs will be ltsigned
     ltsignCommand=$(cat <<EOF
 ltsign
 y
-$trust
+$trustval
 $depth
 $domain
 y
@@ -471,6 +485,9 @@ remove_certifier() {
     local fingerprint
 
     keyID="$1"
+    if [ -z "$keyID" ] ; then
+       failure "You must specify the key ID of a key to remove."
+    fi
 
     # delete the requested key (with prompting)
     gpg_host --delete-key "$keyID"
@@ -549,16 +566,10 @@ case $COMMAND in
        ;;
 
     'add-identity-certifier'|'add-certifier'|'a')
-       if [ -z "$1" ] ; then
-           failure "You must specify a key ID."
-       fi
        add_certifier "$1"
        ;;
 
     'remove-identity-certifier'|'remove-certifier'|'r')
-       if [ -z "$1" ] ; then
-           failure "You must specify a key ID."
-       fi
        remove_certifier "$1"
        ;;