diff options
Diffstat (limited to 'libexec/container/key')
-rwxr-xr-x | libexec/container/key | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/libexec/container/key b/libexec/container/key index 5f76fb2..19b7fa9 100755 --- a/libexec/container/key +++ b/libexec/container/key @@ -76,7 +76,7 @@ Parameters () Usage () { - echo "Usage: ${PROGRAM} ${COMMAND} [-a|--add KEY] [-l|--list] [-r|--remove KEY]" >&2 + echo "Usage: ${PROGRAM} ${COMMAND} [-a|--add KEY_FILE|KEY_ID] [-l|--list] [-r|--remove KEY|KEY_ID]" >&2 exit 1 } @@ -87,6 +87,15 @@ then Usage fi +if [ ! -w "${KEYS}" ] +then + if [ "$(id -u)" -ne 0 ] + then + echo "'${COMMAND}': need root privileges (or write permissions to '${KEYS}')" >&2 + exit 1 + fi +fi + # Pre hooks for FILE in "${HOOKS}/pre-${COMMAND}".* "${HOOKS}/${NAME}.pre-${COMMAND}" do @@ -105,7 +114,7 @@ then chmod 0700 "${KEYS}" cat > "${KEYS}/gnupg.conf" << EOF -keyserver hkps://hkps.pool.sks-keyservers.net +keyserver hkps://keys.openpgp.org keyserver-options include-revoked keyserver-options no-honor-keyserver-url @@ -131,7 +140,18 @@ fi case "${ACTION}" in add) - gpg --homedir "${KEYS}" --import "${ADD}" + if [ -e "${ADD}" ] + then + gpg --homedir "${KEYS}" --import "${ADD}" + elif [ -e "/usr/share/compute-tools/keys/${ADD}" ] + then + gpg --homedir "${KEYS}" --import "/usr/share/compute-tools/keys/${ADD}" + elif [ -e "/usr/share/compute-tools/keys/${ADD}.pub" ] + then + gpg --homedir "${KEYS}" --import "/usr/share/compute-tools/keys/${ADD}.pub" + else + gpg --homedir "${KEYS}" --recv "${ADD}" + fi ;; list) |