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
60 add-id-certifier (c+) [KEYID|FILE] import and tsign a certification key
61 --domain (-n) DOMAIN limit ID certifications to DOMAIN
62 --trust (-t) TRUST trust level of certifier (full)
63 --depth (-d) DEPTH trust depth for certifier (1)
64 remove-id-certifier (c-) KEYID remove a certification key
65 list-id-certifiers (c) list certification keys
67 version (v) show version number
70 See ${PGRM}(8) for more info.
74 # function to interact with the gpg core keyring
76 GNUPGHOME="$GNUPGHOME_CORE"
79 gpg --no-greeting --quiet --no-tty "$@"
82 # function to interact with the gpg sphere keyring
83 # FIXME: this function requires only a single argument because of
84 # problems with quote expansion. this needs to be fixed/improved.
86 GNUPGHOME="$GNUPGHOME_SPHERE"
89 su_monkeysphere_user "gpg --no-greeting --quiet --no-tty $@"
92 # output to stdout the core fingerprint from the gpg core secret
95 log debug "determining core key fingerprint..."
96 gpg_core --list-secret-key --with-colons \
97 --fixed-list-mode --with-fingerprint \
98 | grep ^fpr: | cut -d: -f10
101 # export signatures from core to sphere
102 gpg_core_sphere_sig_transfer() {
103 log debug "exporting core local sigs to sphere..."
104 gpg_core --export-options export-local-sigs --export | \
105 gpg_sphere "--import-options import-local-sigs --import"
108 ########################################################################
110 ########################################################################
112 # set unset default variables
113 AUTHORIZED_USER_IDS="%h/.monkeysphere/authorized_user_ids"
114 RAW_AUTHORIZED_KEYS="%h/.ssh/authorized_keys"
116 # load configuration file
117 [ -e ${MONKEYSPHERE_AUTHENTICATION_CONFIG:="${SYSCONFIGDIR}/monkeysphere-authentication.conf"} ] \
118 && . "$MONKEYSPHERE_AUTHENTICATION_CONFIG"
120 # set empty config variable with ones from the environment
121 LOG_LEVEL=${MONKEYSPHERE_LOG_LEVEL:=$LOG_LEVEL}
122 KEYSERVER=${MONKEYSPHERE_KEYSERVER:=$KEYSERVER}
123 CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=$CHECK_KEYSERVER}
124 MONKEYSPHERE_USER=${MONKEYSPHERE_MONKEYSPHERE_USER:=$MONKEYSPHERE_USER}
125 PROMPT=${MONKEYSPHERE_PROMPT:=$PROMPT}
126 AUTHORIZED_USER_IDS=${MONKEYSPHERE_AUTHORIZED_USER_IDS:=$AUTHORIZED_USER_IDS}
127 RAW_AUTHORIZED_KEYS=${MONKEYSPHERE_RAW_AUTHORIZED_KEYS:=$RAW_AUTHORIZED_KEYS}
130 REQUIRED_USER_KEY_CAPABILITY=${MONKEYSPHERE_REQUIRED_USER_KEY_CAPABILITY:="a"}
131 GNUPGHOME_CORE=${MONKEYSPHERE_GNUPGHOME_CORE:="${MADATADIR}/core"}
132 GNUPGHOME_SPHERE=${MONKEYSPHERE_GNUPGHOME_SPHERE:="${MADATADIR}/sphere"}
133 CORE_KEYLENGTH=${MONKEYSPHERE_CORE_KEYLENGTH:="2048"}
135 # export variables needed in su invocation
140 export MONKEYSPHERE_USER
142 export CHECK_KEYSERVER
143 export REQUIRED_USER_KEY_CAPABILITY
144 export GNUPGHOME_CORE
145 export GNUPGHOME_SPHERE
147 export CORE_KEYLENGTH
151 [ "$COMMAND" ] || failure "Type '$PGRM help' for usage."
156 source "${MASHAREDIR}/setup"
160 'update-users'|'update-user'|'u')
161 source "${MASHAREDIR}/setup"
163 source "${MASHAREDIR}/update_users"
167 'add-identity-certifier'|'add-id-certifier'|'add-certifier'|'c+')
168 source "${MASHAREDIR}/setup"
170 source "${MASHAREDIR}/add_certifier"
174 'remove-identity-certifier'|'remove-id-certifier'|'remove-certifier'|'c-')
175 source "${MASHAREDIR}/setup"
177 source "${MASHAREDIR}/remove_certifier"
178 remove_certifier "$@"
181 'list-identity-certifiers'|'list-id-certifiers'|'list-certifiers'|'list-certifier'|'c')
182 source "${MASHAREDIR}/setup"
184 source "${MASHAREDIR}/list_certifiers"
189 source "${MASHAREDIR}/setup"
191 source "${MASHAREDIR}/diagnostics"
196 source "${MASHAREDIR}/setup"
205 '--help'|'help'|'-h'|'h'|'?')
210 failure "Unknown command: '$COMMAND'
211 Type '$PGRM help' for usage."