summaryrefslogtreecommitdiff
path: root/src/monkeysphere-server
blob: 1e5f2096677cb8dfa9522babeeec5877817b28e0 (plain)
  1. #!/bin/bash
  2. # monkeysphere-server: MonkeySphere server admin tool
  3. #
  4. # The monkeysphere scripts are written by:
  5. # Jameson Rollins <jrollins@fifthhorseman.net>
  6. #
  7. # They are Copyright 2008, and are all released under the GPL, version 3
  8. # or later.
  9. ########################################################################
  10. PGRM=$(basename $0)
  11. SHARE=${MONKEYSPHERE_SHARE:="/usr/share/monkeysphere"}
  12. export SHARE
  13. . "${SHARE}/common" || exit 1
  14. VARLIB="/var/lib/monkeysphere"
  15. export VARLIB
  16. # date in UTF format if needed
  17. DATE=$(date -u '+%FT%T')
  18. # unset some environment variables that could screw things up
  19. unset GREP_OPTIONS
  20. # default return code
  21. RETURN=0
  22. ########################################################################
  23. # FUNCTIONS
  24. ########################################################################
  25. usage() {
  26. cat <<EOF
  27. usage: $PGRM <subcommand> [options] [args]
  28. MonkeySphere server admin tool.
  29. subcommands:
  30. update-users (u) [USER]... update user authorized_keys files
  31. gen-key (g) [HOSTNAME] generate gpg key for the server
  32. -l|--length BITS key length in bits (2048)
  33. -e|--expire EXPIRE date to expire
  34. -r|--revoker FINGERPRINT add a revoker
  35. show-fingerprint (f) show server's host key fingerprint
  36. publish-key (p) publish server's host key to keyserver
  37. diagnostics (d) report on the server's monkeysphere status
  38. add-identity-certifier (a) KEYID import and tsign a certification key
  39. -n|--domain DOMAIN limit ID certifications to IDs in DOMAIN
  40. -t|--trust TRUST trust level of certifier (full)
  41. -d|--depth DEPTH trust depth for certifier (1)
  42. remove-identity-certifier (r) KEYID remove a certification key
  43. list-identity-certifiers (l) list certification keys
  44. gpg-authentication-cmd CMD gnupg-authentication command
  45. -h|--help|help (h,?) this help
  46. EOF
  47. }
  48. su_monkeysphere_user() {
  49. su --preserve-environment "$MONKEYSPHERE_USER" -- -c "$@"
  50. }
  51. # function to interact with the host gnupg keyring
  52. gpg_host() {
  53. local returnCode
  54. GNUPGHOME="$GNUPGHOME_HOST"
  55. export GNUPGHOME
  56. # NOTE: we supress this warning because we need the monkeysphere
  57. # user to be able to read the host pubring. we realize this might
  58. # be problematic, but it's the simplest solution, without too much
  59. # loss of security.
  60. gpg --no-permission-warning "$@"
  61. returnCode="$?"
  62. # always reset the permissions on the host pubring so that the
  63. # monkeysphere user can read the trust signatures
  64. chgrp "$MONKEYSPHERE_USER" "${GNUPGHOME_HOST}/pubring.gpg"
  65. chmod g+r "${GNUPGHOME_HOST}/pubring.gpg"
  66. return "$returnCode"
  67. }
  68. # function to interact with the authentication gnupg keyring
  69. # FIXME: this function requires basically accepts only a single
  70. # argument because of problems with quote expansion. this needs to be
  71. # fixed/improved.
  72. gpg_authentication() {
  73. GNUPGHOME="$GNUPGHOME_AUTHENTICATION"
  74. export GNUPGHOME
  75. su_monkeysphere_user "gpg $@"
  76. }
  77. # update authorized_keys for users
  78. update_users() {
  79. if [ "$1" ] ; then
  80. # get users from command line
  81. unames="$@"
  82. else
  83. # or just look at all users if none specified
  84. unames=$(getent passwd | cut -d: -f1)
  85. fi
  86. # set mode
  87. MODE="authorized_keys"
  88. # set gnupg home
  89. GNUPGHOME="$GNUPGHOME_AUTHENTICATION"
  90. # check to see if the gpg trust database has been initialized
  91. if [ ! -s "${GNUPGHOME}/trustdb.gpg" ] ; then
  92. failure "GNUPG trust database uninitialized. Please see MONKEYSPHERE-SERVER(8)."
  93. fi
  94. # make sure the authorized_keys directory exists
  95. mkdir -p "${VARLIB}/authorized_keys"
  96. # loop over users
  97. for uname in $unames ; do
  98. # check all specified users exist
  99. if ! getent passwd "$uname" >/dev/null ; then
  100. log "----- unknown user '$uname' -----"
  101. continue
  102. fi
  103. # set authorized_user_ids and raw authorized_keys variables,
  104. # translating ssh-style path variables
  105. authorizedUserIDs=$(translate_ssh_variables "$uname" "$AUTHORIZED_USER_IDS")
  106. rawAuthorizedKeys=$(translate_ssh_variables "$uname" "$RAW_AUTHORIZED_KEYS")
  107. # if neither is found, skip user
  108. if [ ! -s "$authorizedUserIDs" ] ; then
  109. if [ "$rawAuthorizedKeys" = '-' -o ! -s "$rawAuthorizedKeys" ] ; then
  110. continue
  111. fi
  112. fi
  113. log "----- user: $uname -----"
  114. # exit if the authorized_user_ids file is empty
  115. if ! check_key_file_permissions "$uname" "$AUTHORIZED_USER_IDS" ; then
  116. log "Improper permissions on authorized_user_ids file path."
  117. continue
  118. fi
  119. # check permissions on the authorized_keys file path
  120. if ! check_key_file_permissions "$uname" "$RAW_AUTHORIZED_KEYS" ; then
  121. log "Improper permissions on authorized_keys file path path."
  122. continue
  123. fi
  124. # make temporary directory
  125. TMPDIR=$(mktemp -d)
  126. # trap to delete temporary directory on exit
  127. trap "rm -rf $TMPDIR" EXIT
  128. # create temporary authorized_user_ids file
  129. TMP_AUTHORIZED_USER_IDS="${TMPDIR}/authorized_user_ids"
  130. touch "$TMP_AUTHORIZED_USER_IDS"
  131. # create temporary authorized_keys file
  132. AUTHORIZED_KEYS="${TMPDIR}/authorized_keys"
  133. touch "$AUTHORIZED_KEYS"
  134. # set restrictive permissions on the temporary files
  135. # FIXME: is there a better way to do this?
  136. chmod 0700 "$TMPDIR"
  137. chmod 0600 "$AUTHORIZED_KEYS"
  138. chmod 0600 "$TMP_AUTHORIZED_USER_IDS"
  139. chown -R "$MONKEYSPHERE_USER" "$TMPDIR"
  140. # if the authorized_user_ids file exists...
  141. if [ -s "$authorizedUserIDs" ] ; then
  142. # copy user authorized_user_ids file to temporary
  143. # location
  144. cat "$authorizedUserIDs" > "$TMP_AUTHORIZED_USER_IDS"
  145. # export needed variables
  146. export AUTHORIZED_KEYS
  147. export TMP_AUTHORIZED_USER_IDS
  148. # process authorized_user_ids file, as monkeysphere
  149. # user
  150. su_monkeysphere_user \
  151. ". ${SHARE}/common; process_authorized_user_ids $TMP_AUTHORIZED_USER_IDS"
  152. RETURN="$?"
  153. fi
  154. # add user-controlled authorized_keys file path if specified
  155. if [ "$rawAuthorizedKeys" != '-' -a -s "$rawAuthorizedKeys" ] ; then
  156. log -n "adding raw authorized_keys file... "
  157. cat "$rawAuthorizedKeys" >> "$AUTHORIZED_KEYS"
  158. loge "done."
  159. fi
  160. # openssh appears to check the contents of the
  161. # authorized_keys file as the user in question, so the
  162. # file must be readable by that user at least.
  163. # FIXME: is there a better way to do this?
  164. chown root "$AUTHORIZED_KEYS"
  165. chgrp $(getent passwd "$uname" | cut -f4 -d:) "$AUTHORIZED_KEYS"
  166. chmod g+r "$AUTHORIZED_KEYS"
  167. # move the resulting authorized_keys file into place
  168. mv -f "$AUTHORIZED_KEYS" "${VARLIB}/authorized_keys/${uname}"
  169. # destroy temporary directory
  170. rm -rf "$TMPDIR"
  171. done
  172. }
  173. # generate server gpg key
  174. gen_key() {
  175. local keyType
  176. local keyLength
  177. local keyUsage
  178. local keyExpire
  179. local revoker
  180. local hostName
  181. local userID
  182. local keyParameters
  183. local fingerprint
  184. # set default key parameter values
  185. keyType="RSA"
  186. keyLength="2048"
  187. keyUsage="auth"
  188. keyExpire=
  189. revoker=
  190. # get options
  191. TEMP=$(getopt -o e:l:r -l expire:,length:,revoker: -n "$PGRM" -- "$@")
  192. if [ $? != 0 ] ; then
  193. exit 1
  194. fi
  195. # Note the quotes around `$TEMP': they are essential!
  196. eval set -- "$TEMP"
  197. while true ; do
  198. case "$1" in
  199. -l|--length)
  200. keyLength="$2"
  201. shift 2
  202. ;;
  203. -e|--expire)
  204. keyExpire="$2"
  205. shift 2
  206. ;;
  207. -r|--revoker)
  208. revoker="$2"
  209. shift 2
  210. ;;
  211. --)
  212. shift
  213. ;;
  214. *)
  215. break
  216. ;;
  217. esac
  218. done
  219. hostName=${1:-$(hostname --fqdn)}
  220. userID="ssh://${hostName}"
  221. # check for presense of key with user ID
  222. if gpg_host --list-key ="$userID" > /dev/null 2>&1 ; then
  223. failure "Key for '$userID' already exists"
  224. fi
  225. # prompt about key expiration if not specified
  226. if [ -z "$keyExpire" ] ; then
  227. cat <<EOF
  228. Please specify how long the key should be valid.
  229. 0 = key does not expire
  230. <n> = key expires in n days
  231. <n>w = key expires in n weeks
  232. <n>m = key expires in n months
  233. <n>y = key expires in n years
  234. EOF
  235. while [ -z "$keyExpire" ] ; do
  236. read -p "Key is valid for? (0) " keyExpire
  237. if ! test_gpg_expire ${keyExpire:=0} ; then
  238. echo "invalid value"
  239. unset keyExpire
  240. fi
  241. done
  242. elif ! test_gpg_expire "$keyExpire" ; then
  243. failure "invalid key expiration value '$keyExpire'."
  244. fi
  245. # set key parameters
  246. keyParameters=$(cat <<EOF
  247. Key-Type: $keyType
  248. Key-Length: $keyLength
  249. Key-Usage: $keyUsage
  250. Name-Real: $userID
  251. Expire-Date: $keyExpire
  252. EOF
  253. )
  254. # add the revoker field if specified
  255. # FIXME: the "1:" below assumes that $REVOKER's key is an RSA key.
  256. # FIXME: key is marked "sensitive"? is this appropriate?
  257. if [ "$revoker" ] ; then
  258. keyParameters="${keyParameters}"$(cat <<EOF
  259. Revoker: 1:$revoker sensitive
  260. EOF
  261. )
  262. fi
  263. echo "The following key parameters will be used for the host private key:"
  264. echo "$keyParameters"
  265. read -p "Generate key? (Y/n) " OK; OK=${OK:=Y}
  266. if [ ${OK/y/Y} != 'Y' ] ; then
  267. failure "aborting."
  268. fi
  269. # add commit command
  270. keyParameters="${keyParameters}"$(cat <<EOF
  271. %commit
  272. %echo done
  273. EOF
  274. )
  275. log "generating server key..."
  276. echo "$keyParameters" | gpg_host --batch --gen-key
  277. # output the server fingerprint
  278. fingerprint_server_key "=${userID}"
  279. # find the key fingerprint of the server primary key
  280. fingerprint=$(gpg_host --list-key --with-colons --with-fingerprint "=${userID}" | \
  281. grep '^fpr:' | head -1 | cut -d: -f10)
  282. # export host ownertrust to authentication keyring
  283. log "setting ultimate owner trust for server key..."
  284. echo "${fingerprint}:6:" | gpg_authentication "--import-ownertrust"
  285. # translate the private key to ssh format, and export to a file
  286. # for sshs usage.
  287. # NOTE: assumes that the primary key is the proper key to use
  288. (umask 077 && \
  289. gpg_host --export-secret-key "$fingerprint" | \
  290. openpgp2ssh "$fingerprint" > "${VARLIB}/ssh_host_rsa_key")
  291. log "Private SSH host key output to file: ${VARLIB}/ssh_host_rsa_key"
  292. }
  293. # gpg output key fingerprint
  294. fingerprint_server_key() {
  295. gpg_host --fingerprint --list-secret-keys
  296. }
  297. # publish server key to keyserver
  298. publish_server_key() {
  299. read -p "Really publish key to $KEYSERVER? (y/N) " OK; OK=${OK:=N}
  300. if [ ${OK/y/Y} != 'Y' ] ; then
  301. failure "aborting."
  302. fi
  303. # publish host key
  304. # FIXME: need to figure out better way to identify host key
  305. # dummy command so as not to publish fakes keys during testing
  306. # eventually:
  307. #gpg_authentication "--keyserver $KEYSERVER --send-keys $(hostname -f)"
  308. echo "NOT PUBLISHED (to avoid permanent publication errors during monkeysphere development)."
  309. echo "The following command should publish the key:"
  310. echo "monkeysphere-server gpg-authentication-cmd '--keyserver $KEYSERVER --send-keys $(hostname -f)'"
  311. exit 255
  312. }
  313. diagnostics() {
  314. # * check on the status and validity of the key and public certificates
  315. local seckey
  316. local keysfound
  317. local curdate
  318. local warnwindow
  319. local warndate
  320. local create
  321. local expire
  322. local uid
  323. local fingerprint
  324. local badhostkeys
  325. seckey=$(gpg_host --list-secret-keys --fingerprint --with-colons --fixed-list-mode)
  326. keysfound=$(echo "$seckey" | grep -c ^sec:)
  327. curdate=$(date +%s)
  328. # warn when anything is 2 months away from expiration
  329. warnwindow='2 months'
  330. warndate=$(date +%s -d "$warnwindow")
  331. echo "Checking host GPG key..."
  332. if (( "$keysfound" < 1 )); then
  333. echo "! No host key found."
  334. echo " - Recommendation: run 'monkeysphere-server gen-key'"
  335. elif (( "$keysfound" > 1 )); then
  336. echo "! More than one host key found?"
  337. # FIXME: recommend a way to resolve this
  338. else
  339. create=$(echo "$seckey" | grep ^sec: | cut -f6 -d:)
  340. expire=$(echo "$seckey" | grep ^sec: | cut -f7 -d:)
  341. fingerprint=$(echo "$seckey" | grep ^fpr: | head -n1 | cut -f10 -d:)
  342. # check for key expiration:
  343. if [ "$expire" ]; then
  344. if (( "$expire" < "$curdate" )); then
  345. echo "! Host key is expired."
  346. # FIXME: recommend a way to resolve this other than re-keying?
  347. elif (( "$expire" < "$warndate" )); then
  348. echo "! Host key expires in less than $warnwindow:" $(date -d "$(( $expire - $curdate )) seconds" +%F)
  349. # FIXME: recommend a way to resolve this?
  350. fi
  351. fi
  352. # and weirdnesses:
  353. if [ "$create" ] && (( "$create" > "$curdate" )); then
  354. echo "! Host key was created in the future(?!). Is your clock correct?"
  355. echo " - Recommendation: Check clock ($(date +%F_%T)); use NTP?"
  356. fi
  357. # check for UserID expiration:
  358. echo "$seckey" | grep ^uid: | cut -d: -f6,7,10 | \
  359. while IFS=: read create expire uid ; do
  360. # FIXME: should we be doing any checking on the form
  361. # of the User ID? Should we be unmangling it somehow?
  362. if [ "$create" ] && (( "$create" > "$curdate" )); then
  363. echo "! User ID '$uid' was created in the future(?!). Is your clock correct?"
  364. echo " - Recommendation: Check clock ($(date +%F_%T)); use NTP?"
  365. fi
  366. if [ "$expire" ] ; then
  367. if (( "$expire" < "$curdate" )); then
  368. echo "! User ID '$uid' is expired."
  369. # FIXME: recommend a way to resolve this
  370. elif (( "$expire" < "$warndate" )); then
  371. echo "! User ID '$uid' expires in less than $warnwindow:" $(date -d "$(( $expire - $curdate )) seconds" +%F)
  372. # FIXME: recommend a way to resolve this
  373. fi
  374. fi
  375. done
  376. # FIXME: verify that the host key is properly published to the
  377. # keyservers (do this with the non-privileged user)
  378. # FIXME: check that there are valid, non-expired certifying signatures
  379. # attached to the host key after fetching from the public keyserver
  380. # (do this with the non-privileged user as well)
  381. # FIXME: propose adding a revoker to the host key if none exist (do we
  382. # have a way to do that after key generation?)
  383. # Ensure that the ssh_host_rsa_key file is present and non-empty:
  384. echo "Checking host SSH key..."
  385. if [ ! -s "${VARLIB}/ssh_host_rsa_key" ] ; then
  386. echo "! The host key as prepared for SSH (${VARLIB}/ssh_host_rsa_key) is missing or empty."
  387. else
  388. if [ $(stat -c '%a' "${VARLIB}/ssh_host_rsa_key") != 600 ] ; then
  389. echo "! Permissions seem wrong for ${VARLIB}/ssh_host_rsa_key -- should be 0600."
  390. fi
  391. # propose changes needed for sshd_config (if any)
  392. if ! grep -q "^HostKey ${VARLIB}/ssh_host_rsa_key$" /etc/ssh/sshd_config; then
  393. echo "! /etc/ssh/sshd_config does not point to the monkeysphere host key (${VARLIB}/ssh_host_rsa_key)."
  394. echo " - Recommendation: add a line to /etc/ssh/sshd_config: 'HostKey ${VARLIB}/ssh_host_rsa_key'"
  395. fi
  396. if badhostkeys=$(grep '^HostKey' | grep -q -v "^HostKey ${VARLIB}/ssh_host_rsa_key$") ; then
  397. echo "! /etc/sshd_config refers to some non-monkeysphere host keys:"
  398. echo "$badhostkeys"
  399. echo "- Recommendation: remove the above HostKey lines from /etc/ssh/sshd_config"
  400. fi
  401. fi
  402. fi
  403. # FIXME: look at the ownership/privileges of the various keyrings,
  404. # directories housing them, etc (what should those values be? can
  405. # we make them as minimal as possible?)
  406. # FIXME: look to see that the ownertrust rules are set properly on the
  407. # authentication keyring
  408. # FIXME: make sure that at least one identity certifier exists
  409. }
  410. # retrieve key from web of trust, import it into the host keyring, and
  411. # ltsign the key in the host keyring so that it may certify other keys
  412. add_certifier() {
  413. local domain
  414. local trust
  415. local depth
  416. local keyID
  417. local fingerprint
  418. local ltsignCommand
  419. local trustval
  420. # set default values for trust depth and domain
  421. domain=
  422. trust=full
  423. depth=1
  424. # get options
  425. TEMP=$(getopt -o n:t:d: -l domain:,trust:,depth: -n "$PGRM" -- "$@")
  426. if [ $? != 0 ] ; then
  427. exit 1
  428. fi
  429. # Note the quotes around `$TEMP': they are essential!
  430. eval set -- "$TEMP"
  431. while true ; do
  432. case "$1" in
  433. -n|--domain)
  434. domain="$2"
  435. shift 2
  436. ;;
  437. -t|--trust)
  438. trust="$2"
  439. shift 2
  440. ;;
  441. -d|--depth)
  442. depth="$2"
  443. shift 2
  444. ;;
  445. --)
  446. shift
  447. ;;
  448. *)
  449. break
  450. ;;
  451. esac
  452. done
  453. keyID="$1"
  454. if [ -z "$keyID" ] ; then
  455. failure "You must specify the key ID of a key to add."
  456. fi
  457. export keyID
  458. # get the key from the key server
  459. gpg_authentication "--keyserver $KEYSERVER --recv-key '$keyID'"
  460. # get the full fingerprint of a key ID
  461. fingerprint=$(gpg_authentication "--list-key --with-colons --with-fingerprint $keyID" | \
  462. grep '^fpr:' | grep "$keyID" | cut -d: -f10)
  463. echo "key found:"
  464. gpg_authentication "--fingerprint $fingerprint"
  465. echo "Are you sure you want to add this key as a certifier of"
  466. read -p "users on this system? (y/N) " OK; OK=${OK:-N}
  467. if [ "${OK/y/Y}" != 'Y' ] ; then
  468. failure "aborting."
  469. fi
  470. # export the key to the host keyring
  471. gpg_authentication "--export $keyID" | gpg_host --import
  472. if [ "$trust" == marginal ]; then
  473. trustval=1
  474. elif [ "$trust" == full ]; then
  475. trustval=2
  476. else
  477. failure "trust value requested ('$trust') was unclear (only 'marginal' or 'full' are supported)"
  478. fi
  479. # ltsign command
  480. # NOTE: *all* user IDs will be ltsigned
  481. ltsignCommand=$(cat <<EOF
  482. ltsign
  483. y
  484. $trustval
  485. $depth
  486. $domain
  487. y
  488. save
  489. EOF
  490. )
  491. # ltsign the key
  492. echo "$ltsignCommand" | gpg_host --quiet --command-fd 0 --edit-key "$fingerprint"
  493. # update the trustdb for the authentication keyring
  494. gpg_authentication "--check-trustdb"
  495. }
  496. # delete a certifiers key from the host keyring
  497. remove_certifier() {
  498. local keyID
  499. local fingerprint
  500. keyID="$1"
  501. if [ -z "$keyID" ] ; then
  502. failure "You must specify the key ID of a key to remove."
  503. fi
  504. # delete the requested key (with prompting)
  505. gpg_host --delete-key "$keyID"
  506. # update the trustdb for the authentication keyring
  507. gpg_authentication "--check-trustdb"
  508. }
  509. # list the host certifiers
  510. list_certifiers() {
  511. gpg_host --list-keys
  512. }
  513. # issue command to gpg-authentication keyring
  514. gpg_authentication_cmd() {
  515. gpg_authentication "$@"
  516. }
  517. ########################################################################
  518. # MAIN
  519. ########################################################################
  520. # unset variables that should be defined only in config file
  521. unset KEYSERVER
  522. unset AUTHORIZED_USER_IDS
  523. unset RAW_AUTHORIZED_KEYS
  524. unset MONKEYSPHERE_USER
  525. # load configuration file
  526. [ -e ${MONKEYSPHERE_SERVER_CONFIG:="${ETC}/monkeysphere-server.conf"} ] && . "$MONKEYSPHERE_SERVER_CONFIG"
  527. # set empty config variable with ones from the environment, or with
  528. # defaults
  529. KEYSERVER=${MONKEYSPHERE_KEYSERVER:=${KEYSERVER:="subkeys.pgp.net"}}
  530. AUTHORIZED_USER_IDS=${MONKEYSPHERE_AUTHORIZED_USER_IDS:=${AUTHORIZED_USER_IDS:="%h/.config/monkeysphere/authorized_user_ids"}}
  531. RAW_AUTHORIZED_KEYS=${MONKEYSPHERE_RAW_AUTHORIZED_KEYS:=${RAW_AUTHORIZED_KEYS:="%h/.ssh/authorized_keys"}}
  532. MONKEYSPHERE_USER=${MONKEYSPHERE_MONKEYSPHERE_USER:=${MONKEYSPHERE_USER:="monkeysphere"}}
  533. # other variables
  534. CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:="true"}
  535. REQUIRED_USER_KEY_CAPABILITY=${MONKEYSPHERE_REQUIRED_USER_KEY_CAPABILITY:="a"}
  536. GNUPGHOME_HOST=${MONKEYSPHERE_GNUPGHOME_HOST:="${VARLIB}/gnupg-host"}
  537. GNUPGHOME_AUTHENTICATION=${MONKEYSPHERE_GNUPGHOME_AUTHENTICATION:="${VARLIB}/gnupg-authentication"}
  538. # export variables needed in su invocation
  539. export DATE
  540. export MODE
  541. export MONKEYSPHERE_USER
  542. export KEYSERVER
  543. export CHECK_KEYSERVER
  544. export REQUIRED_USER_KEY_CAPABILITY
  545. export GNUPGHOME_HOST
  546. export GNUPGHOME_AUTHENTICATION
  547. export GNUPGHOME
  548. # get subcommand
  549. COMMAND="$1"
  550. [ "$COMMAND" ] || failure "Type '$PGRM help' for usage."
  551. shift
  552. case $COMMAND in
  553. 'update-users'|'update-user'|'u')
  554. update_users "$@"
  555. ;;
  556. 'gen-key'|'g')
  557. gen_key "$@"
  558. ;;
  559. 'show-fingerprint'|'f')
  560. fingerprint_server_key
  561. ;;
  562. 'publish-key'|'p')
  563. publish_server_key
  564. ;;
  565. 'diagnostics'|'d')
  566. diagnostics
  567. ;;
  568. 'add-identity-certifier'|'add-certifier'|'a')
  569. add_certifier "$1"
  570. ;;
  571. 'remove-identity-certifier'|'remove-certifier'|'r')
  572. remove_certifier "$1"
  573. ;;
  574. 'list-identity-certifiers'|'list-certifiers'|'list-certifier'|'l')
  575. list_certifiers "$@"
  576. ;;
  577. 'gpg-authentication-cmd')
  578. gpg_authentication_cmd "$@"
  579. ;;
  580. '--help'|'help'|'-h'|'h'|'?')
  581. usage
  582. ;;
  583. *)
  584. failure "Unknown command: '$COMMAND'
  585. Type '$PGRM help' for usage."
  586. ;;
  587. esac
  588. exit "$RETURN"