summaryrefslogtreecommitdiff
path: root/src/share
diff options
context:
space:
mode:
Diffstat (limited to 'src/share')
-rw-r--r--src/share/common46
-rw-r--r--src/share/m/gen_subkey12
-rw-r--r--src/share/m/ssh_proxycommand26
-rw-r--r--src/share/ma/add_certifier4
-rw-r--r--src/share/ma/remove_certifier2
-rw-r--r--src/share/ma/setup2
-rw-r--r--src/share/mh/add_hostname4
-rw-r--r--src/share/mh/add_revoker2
-rw-r--r--src/share/mh/publish_key4
-rw-r--r--src/share/mh/revoke_hostname4
-rw-r--r--src/share/mh/set_expire2
11 files changed, 78 insertions, 30 deletions
diff --git a/src/share/common b/src/share/common
index a2f4494..1c16ac6 100644
--- a/src/share/common
+++ b/src/share/common
@@ -23,6 +23,21 @@ export SYSCONFIGDIR
# monkeysphere version
VERSION=0.23~pre
+# default log level
+LOG_LEVEL="INFO"
+
+# default keyserver
+KEYSERVER="pool.sks-keyservers.net"
+
+# whether or not to check keyservers by defaul
+CHECK_KEYSERVER="true"
+
+# default monkeysphere user
+MONKEYSPHERE_USER="monkeysphere"
+
+# default about whether or not to prompt
+PROMPT="true"
+
########################################################################
### UTILITY FUNCTIONS
@@ -276,7 +291,7 @@ get_gpg_expiration() {
keyExpire="$1"
- if [ -z "$keyExpire" ]; then
+ if [ -z "$keyExpire" -a "$PROMPT" = 'true' ]; then
cat >&2 <<EOF
Please specify how long the key should be valid.
0 = key does not expire
@@ -800,6 +815,9 @@ process_host_known_hosts() {
local sshKey
local tmpfile
+ # set the key processing mode
+ export MODE='known_hosts'
+
host="$1"
userID="ssh://${host}"
@@ -879,6 +897,13 @@ update_known_hosts() {
nHostsOK=0
nHostsBAD=0
+ # touch the known_hosts file so that the file permission check
+ # below won't fail upon not finding the file
+ (umask 0022 && touch "$KNOWN_HOSTS")
+
+ # check permissions on the known_hosts file path
+ check_key_file_permissions "$USER" "$KNOWN_HOSTS" || failure
+
# create a lockfile on known_hosts:
lock create "$KNOWN_HOSTS"
# FIXME: we're discarding any pre-existing EXIT trap; is this bad?
@@ -933,6 +958,11 @@ update_known_hosts() {
process_known_hosts() {
local hosts
+ # exit if the known_hosts file does not exist
+ if [ ! -e "$KNOWN_HOSTS" ] ; then
+ failure "known_hosts file '$KNOWN_HOSTS' does not exist."
+ fi
+
log debug "processing known_hosts file..."
hosts=$(meat "$KNOWN_HOSTS" | cut -d ' ' -f 1 | grep -v '^|.*$' | tr , ' ' | tr '\n' ' ')
@@ -956,6 +986,9 @@ process_uid_authorized_keys() {
local ok
local sshKey
+ # set the key processing mode
+ export MODE='authorized_keys'
+
userID="$1"
log verbose "processing: $userID"
@@ -1017,6 +1050,9 @@ update_authorized_keys() {
nIDsOK=0
nIDsBAD=0
+ # check permissions on the authorized_keys file path
+ check_key_file_permissions "$USER" "$AUTHORIZED_KEYS" || failure
+
# create a lockfile on authorized_keys
lock create "$AUTHORIZED_KEYS"
# FIXME: we're discarding any pre-existing EXIT trap; is this bad?
@@ -1082,6 +1118,14 @@ process_authorized_user_ids() {
authorizedUserIDs="$1"
+ # exit if the authorized_user_ids file is empty
+ if [ ! -e "$authorizedUserIDs" ] ; then
+ failure "authorized_user_ids file '$authorizedUserIDs' does not exist."
+ fi
+
+ # check permissions on the authorized_user_ids file path
+ check_key_file_permissions "$USER" "$authorizedUserIDs" || failure
+
log debug "processing authorized_user_ids file..."
if ! meat "$authorizedUserIDs" > /dev/null ; then
diff --git a/src/share/m/gen_subkey b/src/share/m/gen_subkey
index 19d384d..d926ad5 100644
--- a/src/share/m/gen_subkey
+++ b/src/share/m/gen_subkey
@@ -86,12 +86,16 @@ Type '$PGRM help' for usage."
fi
# if authentication key is valid, prompt to continue
if [ "$validity" = 'u' ] ; then
- echo "A valid authentication key already exists for primary key '$keyID'."
- read -p "Are you sure you would like to generate another one? (y/N) " OK; OK=${OK:N}
- if [ "${OK/y/Y}" != 'Y' ] ; then
+ log error "A valid authentication key already exists for primary key '$keyID'."
+ if [ "$PROMPT" = "true" ] ; then
+ read -p "Are you sure you would like to generate another one? (y/N) " OK; OK=${OK:N}
+ if [ "${OK/y/Y}" != 'Y' ] ; then
+ failure "aborting."
+ fi
+ break
+ else
failure "aborting."
fi
- break
fi
done
diff --git a/src/share/m/ssh_proxycommand b/src/share/m/ssh_proxycommand
index cd0a1fb..29040d8 100644
--- a/src/share/m/ssh_proxycommand
+++ b/src/share/m/ssh_proxycommand
@@ -15,8 +15,6 @@
# established. Can be added to ~/.ssh/config as follows:
# ProxyCommand monkeysphere ssh-proxycommand %h %p
-ssh_proxycommand() {
-
# "marginal case" ouput in the case that there is not a full
# validation path to the host
output_no_valid_key() {
@@ -136,10 +134,9 @@ EOF
EOF
}
-########################################################################
-# export the monkeysphere log level
-export MONKEYSPHERE_LOG_LEVEL
+# the ssh proxycommand function itself
+ssh_proxycommand() {
if [ "$1" = '--no-connect' ] ; then
NO_CONNECT='true'
@@ -170,12 +167,13 @@ URI="ssh://${HOSTP}"
# intentionally different than that of running monkeyesphere normally,
# and keyserver checking is intentionally done under certain
# circumstances. This can be overridden by setting the
-# MONKEYSPHERE_CHECK_KEYSERVER environment variable.
+# MONKEYSPHERE_CHECK_KEYSERVER environment variable, or by setting the
+# CHECK_KEYSERVER variable in the monkeysphere.conf file.
# if the host is in the gpg keyring...
if gpg --list-key ="${URI}" 2>&1 >/dev/null ; then
# do not check the keyserver
- CHECK_KEYSERVER="false"
+ CHECK_KEYSERVER=${CHECK_KEYSERVER:="false"}
# if the host is NOT in the keyring...
else
@@ -188,20 +186,22 @@ else
# FIXME: more nuanced checking should be done here to properly
# take into consideration hosts that join monkeysphere by
# converting an existing and known ssh key
- CHECK_KEYSERVER="false"
+ CHECK_KEYSERVER=${CHECK_KEYSERVER:="false"}
# if the host key is not found in the known_hosts file...
else
# check the keyserver
- CHECK_KEYSERVER="true"
+ CHECK_KEYSERVER=${CHECK_KEYSERVER:="true"}
fi
fi
-# set and export the variable for use by monkeysphere
-MONKEYSPHERE_CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:="$CHECK_KEYSERVER"}
-export MONKEYSPHERE_CHECK_KEYSERVER
+
+# finally look in the MONKEYSPHERE_ environment variable for a
+# CHECK_KEYSERVER setting to override all else
+CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=$CHECK_KEYSERVER}
# update the known_hosts file for the host
-monkeysphere update-known_hosts "$HOSTP"
+source "${MSHAREDIR}/update_known_hosts"
+update_known_hosts "$HOSTP"
# output on depending on the return of the update-known_hosts
# subcommand, which is (ultimately) the return code of the
diff --git a/src/share/ma/add_certifier b/src/share/ma/add_certifier
index e543d94..bd41f23 100644
--- a/src/share/ma/add_certifier
+++ b/src/share/ma/add_certifier
@@ -100,7 +100,7 @@ gpg_sphere "--fingerprint 0x${fingerprint}!"
if [ "$PROMPT" = "true" ] ; then
echo "Are you sure you want to add the above key as a"
- read -p "certifier of users on this system? (y/N) " OK; OK=${OK:-N}
+ read -p "certifier of users on this system? (Y/n) " OK; OK=${OK:-Y}
if [ "${OK/y/Y}" != 'Y' ] ; then
failure "Identity certifier not added."
fi
@@ -148,7 +148,7 @@ if echo "$ltsignCommand" | \
# update the sphere trustdb
log debug "updating sphere trustdb..."
- gpg_sphere "--check-trustdb"
+ gpg_sphere "--check-trustdb" 2>&1 | log debug
log info "Identity certifier added."
else
diff --git a/src/share/ma/remove_certifier b/src/share/ma/remove_certifier
index 10aa67b..95f6dff 100644
--- a/src/share/ma/remove_certifier
+++ b/src/share/ma/remove_certifier
@@ -27,7 +27,7 @@ fi
gpg_core --list-key --fingerprint "0x${keyID}!" || failure
if [ "$PROMPT" = "true" ] ; then
- read -p "Really remove above listed identity certifier? (y/N) " OK; OK=${OK:-N}
+ read -p "Really remove above listed identity certifier? (Y/n) " OK; OK=${OK:-Y}
if [ "${OK/y/Y}" != 'Y' ] ; then
failure "Identity certifier not removed."
fi
diff --git a/src/share/ma/setup b/src/share/ma/setup
index 248406f..441df28 100644
--- a/src/share/ma/setup
+++ b/src/share/ma/setup
@@ -80,7 +80,7 @@ EOF
# ensure that the authentication sphere checker has absolute ownertrust on the expected key.
log debug "setting ultimate owner trust on core key in gpg_sphere..."
printf "%s:6:\n" "$CORE_FPR" | gpg_sphere "--import-ownertrust"
- gpg_sphere "--export-ownertrust"
+ gpg_sphere "--export-ownertrust" 2>&1 | log debug
# check the owner trust
log debug "checking gpg_sphere owner trust set properly..."
diff --git a/src/share/mh/add_hostname b/src/share/mh/add_hostname
index 70bbec3..0da6a06 100644
--- a/src/share/mh/add_hostname
+++ b/src/share/mh/add_hostname
@@ -34,8 +34,8 @@ find_host_userid > /dev/null && \
if [ "$PROMPT" = "true" ] ; then
echo "The following user ID will be added to the host key:"
echo " $userID"
- read -p "Are you sure you would like to add this user ID? (y/N) " OK; OK=${OK:=N}
- if [ ${OK/y/Y} != 'Y' ] ; then
+ read -p "Are you sure you would like to add this user ID? (Y/n) " OK; OK=${OK:=Y}
+ if [ "${OK/y/Y}" != 'Y' ] ; then
failure "User ID not added."
fi
else
diff --git a/src/share/mh/add_revoker b/src/share/mh/add_revoker
index bdcb749..21dc0bb 100644
--- a/src/share/mh/add_revoker
+++ b/src/share/mh/add_revoker
@@ -79,7 +79,7 @@ gpg_host --fingerprint "0x${fingerprint}!"
if [ "$PROMPT" = "true" ] ; then
echo "Are you sure you want to add the above key as a"
- read -p "revoker of the host key? (y/N) " OK; OK=${OK:-N}
+ read -p "revoker of the host key? (Y/n) " OK; OK=${OK:-Y}
if [ "${OK/y/Y}" != 'Y' ] ; then
failure "revoker not added."
fi
diff --git a/src/share/mh/publish_key b/src/share/mh/publish_key
index 37b8a72..05faa0b 100644
--- a/src/share/mh/publish_key
+++ b/src/share/mh/publish_key
@@ -18,8 +18,8 @@ publish_key() {
local GNUPGHOME
if [ "$PROMPT" = "true" ] ; then
- read -p "Really publish host key to $KEYSERVER? (y/N) " OK; OK=${OK:=N}
- if [ ${OK/y/Y} != 'Y' ] ; then
+ read -p "Really publish host key to $KEYSERVER? (Y/n) " OK; OK=${OK:=Y}
+ if [ "${OK/y/Y}" != 'Y' ] ; then
failure "key not published."
fi
else
diff --git a/src/share/mh/revoke_hostname b/src/share/mh/revoke_hostname
index 77f1f0d..92383a0 100644
--- a/src/share/mh/revoke_hostname
+++ b/src/share/mh/revoke_hostname
@@ -45,8 +45,8 @@ uidIndex=$(find_host_userid) || \
if [ "$PROMPT" = "true" ] ; then
echo "The following host key user ID will be revoked:"
echo " $userID"
- read -p "Are you sure you would like to revoke this user ID? (y/N) " OK; OK=${OK:=N}
- if [ ${OK/y/Y} != 'Y' ] ; then
+ read -p "Are you sure you would like to revoke this user ID? (N/y) " OK; OK=${OK:=Y}
+ if [ "${OK/y/Y}" != 'Y' ] ; then
failure "User ID not revoked."
fi
else
diff --git a/src/share/mh/set_expire b/src/share/mh/set_expire
index ae7c13a..63e5c55 100644
--- a/src/share/mh/set_expire
+++ b/src/share/mh/set_expire
@@ -22,7 +22,7 @@ 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:-N}
+ read -p "Are you sure you want to change the expiration on the host key to '$extendTo'? (Y/n) " OK; OK=${OK:-Y}
if [ "${OK/y/Y}" != 'Y' ] ; then
failure "expiration not set."
fi