3 # monkeysphere-authentication: Monkeysphere authentication admin tool
5 # The monkeysphere scripts are written by:
6 # Jameson Rollins <jrollins@finestructure.net>
7 # Jamie McClelland <jm@mayfirst.org>
8 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
9 # Micah Anderson <micah@riseup.net>
11 # They are Copyright 2008-2009, and are all released under the GPL,
14 ########################################################################
17 # set the pipefail option so pipelines fail on first command failure
22 SYSSHAREDIR=${MONKEYSPHERE_SYSSHAREDIR:-"/usr/share/monkeysphere"}
24 . "${SYSSHAREDIR}/common" || exit 1
26 SYSDATADIR=${MONKEYSPHERE_SYSDATADIR:-"/var/lib/monkeysphere"}
29 # sharedir for authentication functions
30 MASHAREDIR="${SYSSHAREDIR}/ma"
32 # datadir for authentication functions
33 MADATADIR="${SYSDATADIR}/authentication"
35 # temp directory to enable atomic moves of authorized_keys files
36 MATMPDIR="${MADATADIR}/tmp"
39 # UTC date in ISO 8601 format if needed
40 DATE=$(date -u '+%FT%T')
42 # unset some environment variables that could screw things up
48 ########################################################################
50 ########################################################################
54 usage: $PGRM <subcommand> [options] [args]
55 Monkeysphere authentication admin tool.
58 update-users (u) [USER]... update user authorized_keys files
59 add-id-certifier (c+) KEYID import and tsign a certification key
60 --domain (-n) DOMAIN limit ID certifications to DOMAIN
61 --trust (-t) TRUST trust level of certifier (full)
62 --depth (-d) DEPTH trust depth for certifier (1)
63 remove-id-certifier (c-) KEYID remove a certification key
64 list-id-certifiers (c) list certification keys
66 version (v) show version number
69 See ${PGRM}(8) for more info.
73 # function to interact with the gpg core keyring
75 GNUPGHOME="$GNUPGHOME_CORE"
78 gpg --no-greeting --quiet --no-tty "$@"
81 # function to interact with the gpg sphere keyring
82 # FIXME: this function requires only a single argument because of
83 # problems with quote expansion. this needs to be fixed/improved.
85 GNUPGHOME="$GNUPGHOME_SPHERE"
88 su_monkeysphere_user "gpg --no-greeting --quiet --no-tty $@"
91 # output to stdout the core fingerprint from the gpg core secret
94 log debug "determining core key fingerprint..."
95 gpg_core --list-secret-key --with-colons \
96 --fixed-list-mode --with-fingerprint \
97 | grep ^fpr: | cut -d: -f10
100 # export signatures from core to sphere
101 gpg_core_sphere_sig_transfer() {
102 log debug "exporting core local sigs to sphere..."
103 gpg_core --export-options export-local-sigs --export | \
104 gpg_sphere "--import-options import-local-sigs --import"
107 ########################################################################
109 ########################################################################
111 # unset variables that should be defined only in config file of in
112 # MONKEYSPHERE_ variables
115 unset AUTHORIZED_USER_IDS
116 unset RAW_AUTHORIZED_KEYS
117 unset MONKEYSPHERE_USER
120 # load configuration file
121 [ -e ${MONKEYSPHERE_AUTHENTICATION_CONFIG:="${SYSCONFIGDIR}/monkeysphere-authentication.conf"} ] && . "$MONKEYSPHERE_AUTHENTICATION_CONFIG"
123 # set empty config variable with ones from the environment, or with
125 LOG_LEVEL=${MONKEYSPHERE_LOG_LEVEL:=${LOG_LEVEL:="INFO"}}
126 KEYSERVER=${MONKEYSPHERE_KEYSERVER:=${KEYSERVER:="pool.sks-keyservers.net"}}
127 AUTHORIZED_USER_IDS=${MONKEYSPHERE_AUTHORIZED_USER_IDS:=${AUTHORIZED_USER_IDS:="%h/.monkeysphere/authorized_user_ids"}}
128 RAW_AUTHORIZED_KEYS=${MONKEYSPHERE_RAW_AUTHORIZED_KEYS:=${RAW_AUTHORIZED_KEYS:="%h/.ssh/authorized_keys"}}
129 MONKEYSPHERE_USER=${MONKEYSPHERE_MONKEYSPHERE_USER:=${MONKEYSPHERE_USER:="monkeysphere"}}
130 PROMPT=${MONKEYSPHERE_PROMPT:=${PROMPT:="true"}}
133 CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:="true"}
134 REQUIRED_USER_KEY_CAPABILITY=${MONKEYSPHERE_REQUIRED_USER_KEY_CAPABILITY:="a"}
135 GNUPGHOME_CORE=${MONKEYSPHERE_GNUPGHOME_CORE:="${MADATADIR}/core"}
136 GNUPGHOME_SPHERE=${MONKEYSPHERE_GNUPGHOME_SPHERE:="${MADATADIR}/sphere"}
137 CORE_KEYLENGTH=${MONKEYSPHERE_CORE_KEYLENGTH:="2048"}
139 # export variables needed in su invocation
144 export MONKEYSPHERE_USER
146 export CHECK_KEYSERVER
147 export REQUIRED_USER_KEY_CAPABILITY
148 export GNUPGHOME_CORE
149 export GNUPGHOME_SPHERE
151 export CORE_KEYLENGTH
155 [ "$COMMAND" ] || failure "Type '$PGRM help' for usage."
160 source "${MASHAREDIR}/setup"
164 'update-users'|'update-user'|'u')
165 source "${MASHAREDIR}/setup"
167 source "${MASHAREDIR}/update_users"
171 'add-identity-certifier'|'add-id-certifier'|'add-certifier'|'c+')
172 source "${MASHAREDIR}/setup"
174 source "${MASHAREDIR}/add_certifier"
178 'remove-identity-certifier'|'remove-id-certifier'|'remove-certifier'|'c-')
179 source "${MASHAREDIR}/setup"
181 source "${MASHAREDIR}/remove_certifier"
182 remove_certifier "$@"
185 'list-identity-certifiers'|'list-id-certifiers'|'list-certifiers'|'list-certifier'|'c')
186 source "${MASHAREDIR}/setup"
188 source "${MASHAREDIR}/list_certifiers"
193 source "${MASHAREDIR}/setup"
195 source "${MASHAREDIR}/diagnostics"
200 source "${MASHAREDIR}/setup"
209 '--help'|'help'|'-h'|'h'|'?')
214 failure "Unknown command: '$COMMAND'
215 Type '$PGRM help' for usage."