setup() {
# make all needed directories
- log debug "make authentication directory structure..."
+ log debug "checking authentication directory structure..."
mkdir -p "${MADATADIR}"
- chmod 750 "${MADATADIR}"
+ chmod 0750 "${MADATADIR}"
chgrp "$MONKEYSPHERE_USER" "${MADATADIR}"
mkdir -p "${MATMPDIR}"
- chmod 750 "${MATMPDIR}"
+ chmod 0750 "${MATMPDIR}"
chgrp "$MONKEYSPHERE_USER" "${MATMPDIR}"
mkdir -p "${GNUPGHOME_CORE}"
- chmod 700 "${GNUPGHOME_CORE}"
+ chmod 0700 "${GNUPGHOME_CORE}"
mkdir -p "${GNUPGHOME_SPHERE}"
- chmod 700 "${GNUPGHOME_SPHERE}"
+ chmod 0700 "${GNUPGHOME_SPHERE}"
+ mkdir -p "${SYSDATADIR}"/authorized_keys
# deliberately replace the config files via truncation
# FIXME: should we be dumping to tmp files and then moving atomically?
if [ -z "$CORE_FPR" ] ; then
log info "setting up Monkeysphere authentication trust core..."
- local CORE_UID=$(printf "Monkeysphere authentication trust core UID (random string: %s)" $(head -c21 </dev/urandom | base64))
+ local CORE_UID=$(printf "Monkeysphere authentication trust core UID (random string: %s)" $(head -c21 </dev/urandom | perl -MMIME::Base64 -ne 'print encode_base64($_)'))
log debug "generating monkeysphere authentication trust core key ($CORE_KEYLENGTH bits)..."
PEM2OPENPGP_USAGE_FLAGS=certify \