summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/share/common9
-rw-r--r--src/share/m/gen_subkey23
2 files changed, 27 insertions, 5 deletions
diff --git a/src/share/common b/src/share/common
index 28da3c0..de97ef7 100644
--- a/src/share/common
+++ b/src/share/common
@@ -530,6 +530,15 @@ gpg2authorized_keys() {
### GPG UTILITIES
+# script to determine if gpg version is equal to or greater than specified version
+is_gpg_version_greater_equal() {
+ local gpgVersion=$(gpg --version | head -1 | awk '{ print $3 }')
+ local latest=$(printf '%s\n%s\n' "$1" "$gpgVersion" \
+ | tr '.' ' ' | sort -g -k1 -k2 -k3 \
+ | tail -1 | tr ' ' '.')
+ [[ "$gpgVersion" == "$latest" ]]
+}
+
# retrieve all keys with given user id from keyserver
# FIXME: need to figure out how to retrieve all matching keys
# (not just first N (5 in this case))
diff --git a/src/share/m/gen_subkey b/src/share/m/gen_subkey
index 9cc6028..cf1ed0c 100644
--- a/src/share/m/gen_subkey
+++ b/src/share/m/gen_subkey
@@ -44,12 +44,25 @@ Type '$PGRM help' for usage."
# check that an authentication subkey does not already exist
check_gpg_authentication_subkey "$keyID"
+ # determine which keyType to use from gpg version
+ keyType=7
+ case $(gpg --version | head -1 | awk '{ print $3 }' | cut -d. -f1) in
+ 1)
+ if is_gpg_version_greater_equal 1.4.10 ; then
+ keyType=8
+ fi
+ ;;
+ 2)
+ if is_gpg_version_greater_equal 2.0.13 ; then
+ keyType=8
+ fi
+ ;;
+ *)
+ keyType=8
+ ;;
+ esac
+
# generate the list of commands that will be passed to edit-key
- # 7 for < 1.4.10
- # 8 for >= 1.4.10
- # 7 for < 2.0.13
- # 8 for >= 2.0.13
- keyType=8
editCommands="addkey
$keyType
S