| |
@@ -12,6 +12,7 @@
|
| |
# modified is included with the above copyright notice.
|
| |
|
| |
|
| |
+
|
| |
function print_help {
|
| |
cat <<'EOF'
|
| |
Usage: gpgverify --keyring=<pathname> --signature=<pathname> --data=<pathname>
|
| |
@@ -35,16 +36,16 @@
|
| |
|
| |
fatal_error() {
|
| |
message="$1" # an error message
|
| |
- status=$2 # a number to use as the exit code
|
| |
+ status="$2" # a number to use as the exit code
|
| |
echo "gpgverify: $message" >&2
|
| |
- exit $status
|
| |
+ exit "$status"
|
| |
}
|
| |
|
| |
|
| |
require_parameter() {
|
| |
term="$1" # a term for a required parameter
|
| |
value="$2" # Complain and terminate if this value is empty.
|
| |
- if test -z "${value}" ; then
|
| |
+ if [[ -z "$value" ]] ; then
|
| |
fatal_error "No ${term} was provided." 2
|
| |
fi
|
| |
}
|
| |
@@ -52,9 +53,9 @@
|
| |
|
| |
check_status() {
|
| |
action="$1" # a string that describes the action that was attempted
|
| |
- status=$2 # the exit code of the command
|
| |
- if test $status -ne 0 ; then
|
| |
- fatal_error "$action failed." $status
|
| |
+ status="$2" # the exit code of the command
|
| |
+ if [[ $status -ne 0 ]] ; then
|
| |
+ fatal_error "$action failed." "$status"
|
| |
fi
|
| |
}
|
| |
|
| |
@@ -65,21 +66,21 @@
|
| |
data=
|
| |
for parameter in "$@" ; do
|
| |
case "${parameter}" in
|
| |
- (--help)
|
| |
+ --help)
|
| |
print_help
|
| |
exit
|
| |
;;
|
| |
- (--keyring=*)
|
| |
+ --keyring=*)
|
| |
keyring="${parameter#*=}"
|
| |
;;
|
| |
- (--signature=*)
|
| |
+ --signature=*)
|
| |
signature="${parameter#*=}"
|
| |
;;
|
| |
- (--data=*)
|
| |
+ --data=*)
|
| |
data="${parameter#*=}"
|
| |
;;
|
| |
- (*)
|
| |
- fatal_error "Unknown parameter: \"${parameter}\"" 2
|
| |
+ *)
|
| |
+ fatal_error 'Unknown parameter:' "$parameter" 2
|
| |
;;
|
| |
esac
|
| |
done
|
| |
@@ -89,17 +90,17 @@
|
| |
|
| |
# Make a temporary working directory.
|
| |
workdir="$(mktemp --directory)"
|
| |
- check_status 'Making a temporary directory' $?
|
| |
+ check_status 'Making a temporary directory' "$?"
|
| |
workring="${workdir}/keyring.gpg"
|
| |
|
| |
# Decode any ASCII armor on the keyring. This is harmless if the keyring isn't
|
| |
# ASCII-armored.
|
| |
gpg2 --homedir="${workdir}" --yes --output="${workring}" --dearmor "${keyring}"
|
| |
- check_status 'Decoding the keyring' $?
|
| |
+ check_status 'Decoding the keyring' "$?"
|
| |
|
| |
# Verify the signature using the decoded keyring.
|
| |
gpgv2 --homedir="${workdir}" --keyring="${workring}" "${signature}" "${data}"
|
| |
- check_status 'Signature verification' $?
|
| |
+ check_status 'Signature verification' "$?"
|
| |
|
| |
# (--homedir isn't actually necessary. --dearmor processes only the input file,
|
| |
# and if --keyring is used and contains a slash, then gpgv2 uses only that
|
| |
This drops the quoted in output. Please skip this chunk.