Merge commit 'jrollins/master'
authorMatthew Goins <mjgoins@openflows.com>
Sat, 11 Jul 2009 23:04:26 +0000 (19:04 -0400)
committerMatthew Goins <mjgoins@openflows.com>
Sat, 11 Jul 2009 23:04:26 +0000 (19:04 -0400)
17 files changed:
packaging/debian/changelog
packaging/debian/control
src/monkeysphere
src/monkeysphere-authentication
src/monkeysphere-host
src/share/common
src/share/m/ssh_proxycommand
src/share/ma/add_certifier
src/share/ma/remove_certifier
src/share/ma/setup
src/share/mh/add_hostname
src/share/mh/add_revoker
src/share/mh/publish_key
src/share/mh/revoke_hostname
src/share/mh/revoke_key
src/share/mh/set_expire
tests/common

index f4efc0d614e41430b5d63e60f52754595f7ee665..b5d067bf92a620823066098807868410c539f54a 100644 (file)
@@ -12,10 +12,13 @@ monkeysphere (0.25-1~pre) UNRELEASED; urgency=low
     - some portability improvements
     - properly handle translation of keys with fingerprints with leading
       all-zero bytes.
-    - resolve symlinks when checking paths (thanks Silvio Rhatto) (closes MS #917)
-  * update Standard-Version to 3.8.1
+    - resolve symlinks when checking paths (thanks Silvio Rhatto)
+      (closes MS #917)
+    - explicitly set and use MONKEYSPHERE_GROUP from system "groups"
+      (closes: #534008)
+  * update Standard-Version to 3.8.2
 
- -- Jameson Graef Rollins <jrollins@finestructure.net>  Mon, 29 Jun 2009 11:27:33 -0400
+ -- Jameson Graef Rollins <jrollins@finestructure.net>  Sat, 11 Jul 2009 18:55:25 -0400
 
 monkeysphere (0.24-1) unstable; urgency=low
 
index 3601c10a3ed2178979ff8f3a5fc219b6c277a760..5f1444cf6f3e21bb69ed2d71e93b0adeb47f1545 100644 (file)
@@ -4,7 +4,7 @@ Priority: extra
 Maintainer: Jameson Graef Rollins <jrollins@finestructure.net>
 Uploaders: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
 Build-Depends: debhelper (>= 7.0), socat, openssh-server, gnupg, libcrypt-openssl-rsa-perl, libdigest-sha1-perl, lockfile-progs | procmail
-Standards-Version: 3.8.1
+Standards-Version: 3.8.2
 Homepage: http://web.monkeysphere.info/
 Vcs-Git: git://git.monkeysphere.info/monkeysphere
 Dm-Upload-Allowed: yes
index 6f43632307b25d235ed5094457e96fe77de5b7a8..341b9fdbd4fefa8366a5d38205e99559d19e84d0 100755 (executable)
@@ -144,7 +144,8 @@ check_gpg_authentication_subkey() {
        if [ "$validity" = 'u' ] ; then
            echo "A valid authentication key already exists for primary key '$keyID'." 1>&2
            if [ "$PROMPT" = "true" ] ; then
-               read -p "Are you sure you would like to generate another one? (y/N) " OK; OK=${OK:N}
+               printf "Are you sure you would like to generate another one? (y/N) " >&2
+               read OK; OK=${OK:N}
                if [ "${OK/y/Y}" != 'Y' ] ; then
                    failure "aborting."
                fi
index 5b981537db831c2c26f280662b8f61b5ff594ee5..5b30628a188341d2e8c64dbc339d377220caa2f7 100755 (executable)
@@ -120,6 +120,7 @@ LOG_LEVEL=${MONKEYSPHERE_LOG_LEVEL:=$LOG_LEVEL}
 KEYSERVER=${MONKEYSPHERE_KEYSERVER:=$KEYSERVER}
 CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=$CHECK_KEYSERVER}
 MONKEYSPHERE_USER=${MONKEYSPHERE_MONKEYSPHERE_USER:=$MONKEYSPHERE_USER}
+MONKEYSPHERE_GROUP=$(get_primary_group "$MONKEYSPHERE_USER")
 PROMPT=${MONKEYSPHERE_PROMPT:=$PROMPT}
 AUTHORIZED_USER_IDS=${MONKEYSPHERE_AUTHORIZED_USER_IDS:=$AUTHORIZED_USER_IDS}
 RAW_AUTHORIZED_KEYS=${MONKEYSPHERE_RAW_AUTHORIZED_KEYS:=$RAW_AUTHORIZED_KEYS}
@@ -137,6 +138,7 @@ export MODE
 export LOG_LEVEL
 export KEYSERVER
 export MONKEYSPHERE_USER
+export MONKEYSPHERE_GROUP
 export PROMPT
 export CHECK_KEYSERVER
 export REQUIRED_USER_KEY_CAPABILITY
index 507b47f8f73eabfd6a62e7d9feaf4d53d12bca84..d49806560a64b5af26111914bb834fb76dbcc36d 100755 (executable)
@@ -226,6 +226,7 @@ LOG_LEVEL=${MONKEYSPHERE_LOG_LEVEL:=$LOG_LEVEL}
 KEYSERVER=${MONKEYSPHERE_KEYSERVER:=$KEYSERVER}
 CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=$CHECK_KEYSERVER}
 MONKEYSPHERE_USER=${MONKEYSPHERE_MONKEYSPHERE_USER:=$MONKEYSPHERE_USER}
+MONKEYSPHERE_GROUP=$(get_primary_group "$MONKEYSPHERE_USER")
 PROMPT=${MONKEYSPHERE_PROMPT:=$PROMPT}
 
 # other variables
@@ -238,6 +239,7 @@ export LOG_LEVEL
 export KEYSERVER
 export CHECK_KEYSERVER
 export MONKEYSPHERE_USER
+export MONKEYSPHERE_GROUP
 export PROMPT
 export GNUPGHOME_HOST
 export GNUPGHOME
@@ -304,6 +306,7 @@ case $COMMAND in
        ;;
 
     'diagnostics'|'d')
+       check_host_no_key
        load_fingerprint
        source "${MHSHAREDIR}/diagnostics"
        diagnostics
index bd887d39b410d333badc6048b08d5e777322ce4b..8e2232d659350558e472bd5f37c365d050317b8d 100644 (file)
@@ -291,7 +291,8 @@ Please specify how long the key should be valid.
       <n>y = key expires in n years
 EOF
        while [ -z "$keyExpire" ] ; do
-           read -p "Key is valid for? (0) " keyExpire
+           printf "Key is valid for? (0) " >&2
+           read keyExpire
            if ! test_gpg_expire ${keyExpire:=0} ; then
                echo "invalid value" >&2
                unset keyExpire
@@ -483,6 +484,12 @@ get_homedir() {
     eval "echo ~${uname}"
 }
 
+# return the primary group of a user
+get_primary_group() {
+    local uname=${1:-`whoami`}
+    groups "$uname" | sed 's/^..* : //' | awk '{ print $1 }'
+}
+
 ### CONVERSION UTILITIES
 
 # output the ssh key for a given key ID
index 74b0f85cd9d685b5702f26eecc61ec2719a20fde..322937b054a9ed448425da00fa65e2d44c4c075a 100644 (file)
 # established.  Can be added to ~/.ssh/config as follows:
 #  ProxyCommand monkeysphere ssh-proxycommand %h %p
 
+# output the key info, including the RSA fingerprint
+show_key_info() {
+    local keyid="$1"
+    local sshKeyGPGFile
+    local sshFingerprint
+    local gpgSigOut
+    local otherUids
+
+    # get the ssh key of the gpg key
+    sshKeyGPGFile=$(msmktempfile)
+    gpg2ssh "$keyid" >"$sshKeyGPGFile"
+    sshFingerprint=$(ssh-keygen -l -f "$sshKeyGPGFile" | \
+        awk '{ print $2 }')
+    rm -f "$sshKeyGPGFile"
+
+    # get the sigs for the matching key
+    gpgSigOut=$(gpg_user --check-sigs \
+        --list-options show-uid-validity \
+        "$keyid")
+
+    echo | log info
+
+    # output the sigs, but only those on the user ID
+    # we are looking for
+    echo "$gpgSigOut" | awk '
+{
+if (match($0,"^pub")) { print; }
+if (match($0,"^uid")) { ok=0; }
+if (match($0,"^uid.*'$userID'$")) { ok=1; print; }
+if (ok) { if (match($0,"^sig")) { print; } }
+}
+'
+
+    # output ssh fingerprint
+    cat <<EOF
+RSA key fingerprint is ${sshFingerprint}.
+EOF
+
+    # output the other user IDs for reference
+    otherUids=$(echo "$gpgSigOut" | grep "^uid" | grep -v "$userID")
+    if [ "$otherUids" ] ; then
+       log info <<EOF
+Other user IDs on this key:
+EOF
+       echo "$otherUids" | log info
+    fi
+
+}
+
 # "marginal case" ouput in the case that there is not a full
 # validation path to the host
 output_no_valid_key() {
@@ -28,8 +77,6 @@ output_no_valid_key() {
     local usage
     local sshKeyGPG
     local tmpkey
-    local sshFingerprint
-    local gpgSigOut
     local returnCode=0
 
     userID="ssh://${HOSTP}"
@@ -51,63 +98,34 @@ output_no_valid_key() {
 Monkeysphere found OpenPGP keys for this hostname, but none had full validity.
 EOF
 
-    # if the host key is retrieved from the host, check against known
-    # OpenPGP keys
-    if [ "$sshKeyOffered" ] ; then
-       # find all 'pub' and 'sub' lines in the gpg output, which each
-       # represent a retrieved key for the user ID
-       echo "$gpgOut" | cut -d: -f1,2,5,10,12 | \
-       while IFS=: read -r type validity keyid uidfpr usage ; do
-           case $type in
-               'pub'|'sub')
-                   # get the ssh key of the gpg key
-                   sshKeyGPG=$(gpg2ssh "$keyid")
+    # output message if host key could not be retrieved from the host
+    if [ -z "$sshKeyOffered" ] ; then
+       log info <<EOF
+Could not retrieve RSA host key from $HOST.
+The following keys were found with marginal validity:
+EOF
+    fi
+
+    # find all 'pub' and 'sub' lines in the gpg output, which each
+    # represent a retrieved key for the user ID
+    echo "$gpgOut" | cut -d: -f1,2,5,10,12 | \
+    while IFS=: read -r type validity keyid uidfpr usage ; do
+       case $type in
+           'pub'|'sub')
+               # get the ssh key of the gpg key
+               sshKeyGPG=$(gpg2ssh "$keyid")
+
+               # if a key was retrieved from the host...
+               if [ "$sshKeyOffered" ] ; then
 
                    # if one of keys found matches the one offered by the
                    # host, then output info
                    if [ "$sshKeyGPG" = "$sshKeyOffered" ] ; then
                        log info <<EOF
 An OpenPGP key matching the ssh key offered by the host was found:
-
 EOF
 
-                       sshKeyGPGFile=$(msmktempfile)
-                       printf "%s" "$sshKeyGPG" >"$sshKeyGPGFile"
-                       sshFingerprint=$(ssh-keygen -l -f "$sshKeyGPGFile" | \
-                           awk '{ print $2 }')
-                       rm -f "$sshKeyGPGFile"
-
-                       # get the sigs for the matching key
-                       gpgSigOut=$(gpg_user --check-sigs \
-                           --list-options show-uid-validity \
-                           "$keyid")
-
-                       # output the sigs, but only those on the user ID
-                       # we are looking for
-                       echo "$gpgSigOut" | awk '
-{
-if (match($0,"^pub")) {        print; }
-if (match($0,"^uid")) { ok=0; }
-if (match($0,"^uid.*'$userID'$")) { ok=1; print; }
-if (ok) { if (match($0,"^sig")) { print; } }
-}
-' | log info
-                       echo | log info
-
-                       # output the other user IDs for reference
-                       if (echo "$gpgSigOut" | grep "^uid" | grep -v -q "$userID") ; then
-                           log info <<EOF
-Other user IDs on this key:
-
-EOF
-                           echo "$gpgSigOut" | grep "^uid" | grep -v "$userID" | log info
-                           echo | log info
-                       fi
-
-                       # output ssh fingerprint
-                       log info <<EOF
-RSA key fingerprint is ${sshFingerprint}.
-EOF
+                       show_key_info "$keyid" | log info
 
                        # this whole process is in a "while read"
                        # subshell.  the only way to get information
@@ -117,30 +135,47 @@ EOF
                        # for the ssh key offered by the host
                        return 1
                    fi
-                   ;;
-           esac
-       done || returnCode="$?"
 
-       # if no key match was made (and the "while read" subshell
-       # returned 1) output how many keys were found
-       if (( returnCode != 1 )) ; then
+               # else if a key was not retrieved from the host
+               else
+
+                   # if the current key is marginal, show info
+                   if [ "$validity" = 'm' -o "$validity" = 'f' ] ; then
+                       show_key_info "$keyid" | log info
+                    fi
+
+               fi
+               ;;
+       esac
+    done || returnCode="$?"
+
+    # if no key match was made (and the "while read" subshell
+    # returned 1) output how many keys were found
+    if (( returnCode != 1 )) ; then
+
+       echo | log info
+
+       # output different footer messages depending on if a key had
+       # been retrieved from the host
+       if [ "$sshKeyOffered" ] ; then
            log info <<EOF
 None of the found keys matched the key offered by the host.
-Run the following command for more info about the found keys:
-gpg --check-sigs --list-options show-uid-validity =${userID}
 EOF
-
-           # FIXME: should we do anything extra here if the retrieved
-           # host key is actually in the known_hosts file and the ssh
-           # connection will succeed?  Should the user be warned?
-           # prompted?
+       else
+           log info <<EOF
+There may be other keys with less than marginal validity for this hostname.
+EOF
        fi
 
-    # if host key could not be retrieved from the host, output message
-    else
        log info <<EOF
-Could not retrieve RSA host key from $HOST.
+Run the following command for more info about the found keys:
+gpg --check-sigs --list-options show-uid-validity =${userID}
 EOF
+
+       # FIXME: should we do anything extra here if the retrieved
+       # host key is actually in the known_hosts file and the ssh
+       # connection will succeed?  Should the user be warned?
+       # prompted?
     fi
 
     # output footer
index 402da08e552cdccdf48329f89df4af28aca0fc12..16019976c4a084e376bbd0caa35aacecb3a9e435 100644 (file)
@@ -136,8 +136,8 @@ EOF
     gpg_sphere "--fingerprint 0x${fingerprint}!"
 
     if [ "$PROMPT" = "true" ] ; then
-       echo "Are you sure you want to add the above key as a certifier"
-       read -p "of users on this system? (Y/n) " OK; OK=${OK:-Y}
+       printf "Are you sure you want to add the above key as a certifier\nof users on this system? (Y/n) " >&2
+       read OK; OK=${OK:-Y}
        if [ "${OK/y/Y}" != 'Y' ] ; then
            failure "Identity certifier not added."
        fi
index 6c90358bc2c54c6552caa5a91fc0cfa74eaa593e..79f1cdac8b7ff866f9ab739467977039b2266859 100644 (file)
@@ -27,7 +27,8 @@ fi
 gpg_core --list-key --fingerprint "0x${keyID}!" || failure
 
 if [ "$PROMPT" = "true" ] ; then
-    read -p "Really remove the above listed identity certifier? (Y/n) " OK; OK=${OK:-Y}
+    printf "Really remove the above listed identity certifier? (Y/n) " >&2 
+    read OK; OK=${OK:-Y}
     if [ "${OK/y/Y}" != 'Y' ] ; then
        failure "Identity certifier not removed."
     fi
index 4c87009dc9235b7de4231d582da221f1472663ee..0ed0406c3335d924f98044ecd22cf237bba5a428 100644 (file)
@@ -16,10 +16,10 @@ setup() {
     log debug "checking authentication directory structure..."
     mkdir -p "${MADATADIR}"
     chmod 0750 "${MADATADIR}"
-    chgrp "$MONKEYSPHERE_USER" "${MADATADIR}"
+    chgrp "$MONKEYSPHERE_GROUP" "${MADATADIR}"
     mkdir -p "${MATMPDIR}"
     chmod 0750 "${MATMPDIR}"
-    chgrp "$MONKEYSPHERE_USER" "${MATMPDIR}"
+    chgrp "$MONKEYSPHERE_GROUP" "${MATMPDIR}"
     mkdir -p "${GNUPGHOME_CORE}"
     chmod 0700 "${GNUPGHOME_CORE}"
     mkdir -p "${GNUPGHOME_SPHERE}"
@@ -48,7 +48,7 @@ EOF
     # make sure the monkeysphere user owns everything in the sphere
     # gnupghome
     log debug "fixing sphere gnupg home ownership..."
-    chown "$MONKEYSPHERE_USER:$MONKEYSPHERE_USER" "${GNUPGHOME_SPHERE}" "${GNUPGHOME_SPHERE}"/gpg.conf
+    chown "$MONKEYSPHERE_USER:$MONKEYSPHERE_GROUP" "${GNUPGHOME_SPHERE}" "${GNUPGHOME_SPHERE}"/gpg.conf
 
     # get fingerprint of core key.  this should be empty on unconfigured systems.
     local CORE_FPR=$(core_fingerprint)
index 36f174de9049f433b13e068aa12d11a22a036be8..9465d9635ac0bab68034c9ac29ef9356d7f80fd3 100644 (file)
@@ -32,9 +32,8 @@ find_host_userid > /dev/null && \
     failure "Host userID '$userID' already exists."
 
 if [ "$PROMPT" = "true" ] ; then
-    read -p "The following user ID will be added to the host key:
-  $userID
-Are you sure you would like to add this user ID? (Y/n) " OK; OK=${OK:=Y}
+    printf "The following user ID will be added to the host key:\n  %s\nAre you sure you would like to add this user ID? (Y/n) " "$userID" >&2
+    read OK; OK=${OK:=Y}
     if [ "${OK/y/Y}" != 'Y' ] ; then
        failure "User ID not added."
     fi
index 077b0d06b4409732f1c31febcf38b9b5e0e48333..89e6fcf03210bc6d83da36b883b01a2d7b947f1e 100644 (file)
@@ -64,7 +64,7 @@ else
     # 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_USER" "$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..."
@@ -90,8 +90,8 @@ EOF
     su_monkeysphere_user "GNUPGHOME=$tmpDir gpg --fingerprint 0x${fingerprint}!"
 
     if [ "$PROMPT" = "true" ] ; then
-       read -p "Are you sure you want to add the above key as a revoker
-of the host key? (Y/n) " OK; OK=${OK:-Y}
+       printf "Are you sure you want to add the above key as a revoker\nof the host key? (Y/n) " >&2
+       read OK; OK=${OK:-Y}
        if [ "${OK/y/Y}" != 'Y' ] ; then
            failure "revoker not added."
        fi
index b0ffd93b96ae124f4717b85e2256e88c67d6187a..48e4cbb16169222895fb0902aa171a8647c17879 100644 (file)
@@ -18,7 +18,8 @@ publish_key() {
 local GNUPGHOME
 
 if [ "$PROMPT" = "true" ] ; then
-    read -p "Really publish host key to $KEYSERVER? (Y/n) " OK; OK=${OK:=Y}
+    printf "Really publish host key to $KEYSERVER? (Y/n) " >&2
+    read OK; OK=${OK:=Y}
     if [ "${OK/y/Y}" != 'Y' ] ; then
        failure "key not published."
     fi
@@ -29,7 +30,7 @@ fi
 # create a temporary gnupg directory from which to publish the key
 export GNUPGHOME=$(msmktempdir)
 chmod 0700 "$GNUPGHOME"
-chown "$MONKEYSPHERE_USER":"$MONKEYSPHERE_USER" "$GNUPGHOME"
+chown "$MONKEYSPHERE_USER":"$MONKEYSPHERE_GROUP" "$GNUPGHOME"
 
 # trap to remove tmp dir if break
 trap "rm -rf $GNUPGHOME" EXIT
index 5dc327f02c8a65a97e1fa4dd4dae1289bb15bc85..44ba3122ad6b4c5543ecd913ebe7cb4816e5256f 100644 (file)
@@ -27,11 +27,12 @@ if [ -z "$1" ] ; then
     failure "You must specify a hostname to revoke."
 fi
 
-echo "WARNING: There is a known bug in this function."
-echo "This function has been known to occasionally revoke the wrong hostname."
-echo "Please see the following bug report for more information:"
-echo "https://labs.riseup.net/code/issues/show/422"
-read -p "Are you sure you would like to proceed? (y/N) " OK; OK=${OK:=N}
+echo "WARNING: There is a known bug in this function.
+This function has been known to occasionally revoke the wrong hostname.
+Please see the following bug report for more information:
+https://labs.riseup.net/code/issues/show/422" >&2
+printf "Are you sure you would like to proceed? (y/N) " >&2
+read OK; OK=${OK:=N}
 if [ ${OK/y/Y} != 'Y' ] ; then
     failure "aborting."
 fi
@@ -43,9 +44,8 @@ uidIndex=$(find_host_userid) || \
     failure "No non-revoked user ID found matching '$userID'."
 
 if [ "$PROMPT" = "true" ] ; then
-    read -p "The following host key user ID will be revoked:
-  $userID
-Are you sure you would like to revoke this user ID? (Y/n) " OK; OK=${OK:=Y}
+    printf "The following host key user ID will be revoked:\n  %s\nAre you sure you would like to revoke this user ID? (Y/n) " "$userID" >&2
+    read OK; OK=${OK:=Y}
     if [ "${OK/y/Y}" != 'Y' ] ; then
        failure "User ID not revoked."
     fi
index ad68d5f27a4804312ed0a7620146c3c257e558d2..5460e51b182c05faaabd2180d4ef06814a678096 100644 (file)
@@ -33,7 +33,8 @@ Publishing this certificate will IMMEDIATELY and PERMANENTLY revoke
 your host key!
 
 EOF
-       read -p "Publish the certificate after generation? (y/n/Q) " publish
+       printf "Publish the certificate after generation? (y/n/Q) " >&2
+       read publish
        
        if ! [ "${publish/y/Y}" = 'Y' -o "${publish/n/N}" = 'N' ] ; then
            failure "aborting at user request"
@@ -87,7 +88,8 @@ y
 
     if [ "${publish/y/Y}" = 'Y' ] ; then
        printf "\n" >&2
-       read -p "Really publish this cert to $KEYSERVER ? (Y/n) " really
+       printf "Really publish this cert to $KEYSERVER ? (Y/n) " >&2
+       read really
        if [ "${really/n/N}" = 'N' ] ; then
            printf "Not publishing.\n" >&2
        else
index a6bf1f13ae5e33f42fade4091350f7a62993dbc0..9889e76e62bb28391bd83d3de0c654f9a853550e 100644 (file)
@@ -22,7 +22,8 @@ local extendTo
 extendTo=$(get_gpg_expiration "$1")
 
 if [ "$PROMPT" = "true" ] ; then
-    read -p "Are you sure you want to change the expiration on the host key to '$extendTo'? (Y/n) " OK; OK=${OK:-Y}
+    printf "Are you sure you want to change the expiration on the host key to '%s'? (Y/n) " "$extendTo" >&2
+    read OK; OK=${OK:-Y}
     if [ "${OK/y/Y}" != 'Y' ] ; then
        failure "expiration not set."
     fi
index 6d732c82682ea73407bc8de16c4b9a0b5fcd36a0..727ad0f33cec5cad0502ad0b6089f5447811408b 100644 (file)
@@ -4,7 +4,8 @@ failed_cleanup() {
     # FIXME: can we be more verbose here?
     echo 'FAILED!'
     if [ -z "$MONKEYSPHERE_TEST_NO_EXAMINE" ] ; then
-       read -p "press enter to cleanup and remove tmp (or type 'bash' for a subshell to examine): " XX
+       printf "press enter to cleanup and remove tmp (or type 'bash' for a subshell to examine): " >&2
+       read XX
        if [ "$XX" = bash ] ; then
            echo "Entering subshell..."
            cd "$TEMPDIR"