clarify why monkeysphere-server publish_key is currently non-functional.
[monkeysphere.git] / src / common
index 7a904534d4f9b3fb1302dd7b30b1612923d69916..c39506d729a14503ebc992adbb92fc3d3e1ae256 100644 (file)
@@ -73,7 +73,7 @@ unescape() {
 }
 
 # remove all lines with specified string from specified file
-remove_file_line() {
+remove_line() {
     local file
     local string
 
@@ -120,7 +120,7 @@ ssh2authorized_keys() {
     key="$2"
 
     echo -n "$key" | tr -d '\n'
-    echo " MonkeySphere${DATE}: ${userID}"
+    echo " MonkeySphere${DATE} ${userID}"
 }
 
 # convert key from gpg to ssh known_hosts format
@@ -153,7 +153,7 @@ gpg2authorized_keys() {
     # following regexp:
     # '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}$'
     gpg2ssh "$keyID" | tr -d '\n'
-    echo " MonkeySphere${DATE}: ${userID}"
+    echo " MonkeySphere${DATE} ${userID}"
 }
 
 ### GPG UTILITIES
@@ -395,7 +395,7 @@ remove_userid() {
 
     # remove user ID from file
     log -n " removing user ID '$userID'... "
-    remove_file_line "$AUTHORIZED_USER_IDS" "^${userID}$"
+    remove_line "$AUTHORIZED_USER_IDS" "^${userID}$"
     loge "done."
 }
 
@@ -416,7 +416,7 @@ process_host_known_hosts() {
     while read -r ok keyid ; do
        sshKey=$(gpg2ssh "$keyid")
        # remove the old host key line
-       remove_file_line "$KNOWN_HOSTS" "$sshKey"
+       remove_line "$KNOWN_HOSTS" "$sshKey"
        # if key OK, add new host line
        if [ "$ok" -eq '0' ] ; then
            # hash if specified
@@ -449,7 +449,7 @@ process_uid_authorized_keys() {
     while read -r ok keyid ; do
        sshKey=$(gpg2ssh "$keyid")
        # remove the old host key line
-       remove_file_line "$AUTHORIZED_KEYS" "$sshKey"
+       remove_line "$AUTHORIZED_KEYS" "$sshKey"
        # if key OK, add new host line
        if [ "$ok" -eq '0' ] ; then
            ssh2authorized_keys "$userID" "$sshKey" >> "$AUTHORIZED_KEYS"
@@ -507,7 +507,7 @@ process_authorized_keys() {
            comment="$key"
        fi
 
-       if echo "$comment" | egrep -v -q '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}:' ; then
+       if echo "$comment" | egrep -v -q '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}' ; then
            continue
        fi
        userID=$(echo "$comment" | awk "{ print $2 }")
@@ -561,6 +561,8 @@ 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 --send-keys --keyserver "$KEYSERVER" $(hostname -f)
-    echo "NOT PUBLISHED: gpg --send-keys --keyserver $KEYSERVER $(hostname -f)"
+    #gpg --keyserver "$KEYSERVER" --send-keys $(hostname -f)
+    echo "NOT PUBLISHED (to avoid permanent publication errors during monkeysphere development).
+To publish manually, do: gpg --keyserver $KEYSERVER --send-keys $(hostname -f)"
+    return 1
 }