From: Jameson Rollins Date: Sun, 10 Jan 2010 23:48:59 +0000 (-0500) Subject: Fix patch for gen_key to test gpg version. X-Git-Tag: monkeysphere_0.27~8 X-Git-Url: https://codewiz.org/gitweb?p=monkeysphere.git;a=commitdiff_plain;h=cf7d2f1e843e429a462d2dd11430fd48b0281cb2 Fix patch for gen_key to test gpg version. This patch checks the version of gpg (for v1 and v2) and sets the key type command for the gen_subkey gpg edit-key script appropriately. --- diff --git a/packaging/debian/changelog b/packaging/debian/changelog index df28da4..f7e6032 100644 --- a/packaging/debian/changelog +++ b/packaging/debian/changelog @@ -3,14 +3,14 @@ monkeysphere (0.27-1~pre1) UNRELEASED; urgency=low * New upstream release: - fixed monkeysphere gen-subkey subcommand that was erroneously creating DSA subkeys due to unannounced change in gpg edit-key UI. + Now tests for gpg version. - add new monkeysphere keys-from-userid subcommand to output all acceptable keys for a given user ID literal * updated debian/copyright to match the latest revision of DEP5. * updated standards version to 3.8.3 (no changes needed) - * updated Depends to require >=1.4.10 due to gpg UI change. * add cpio to Build-Depends (used in test suite) (Closes: #562444) - -- Jameson Graef Rollins Sun, 10 Jan 2010 16:52:54 -0500 + -- Jameson Rollins Sun, 10 Jan 2010 18:45:37 -0500 monkeysphere (0.26-1) unstable; urgency=low diff --git a/packaging/debian/control b/packaging/debian/control index df00ed0..f1341d4 100644 --- a/packaging/debian/control +++ b/packaging/debian/control @@ -3,7 +3,7 @@ Section: net Priority: extra Maintainer: Jameson Graef Rollins Uploaders: Daniel Kahn Gillmor -Build-Depends: debhelper (>= 7.0), cpio, socat, openssh-server, gnupg (>=1.4.10), libcrypt-openssl-rsa-perl, libdigest-sha-perl, lockfile-progs | procmail +Build-Depends: debhelper (>= 7.0), cpio, socat, openssh-server, gnupg, libcrypt-openssl-rsa-perl, libdigest-sha-perl, lockfile-progs | procmail Standards-Version: 3.8.3 Homepage: http://web.monkeysphere.info/ Vcs-Git: git://git.monkeysphere.info/monkeysphere @@ -11,7 +11,7 @@ Dm-Upload-Allowed: yes Package: monkeysphere Architecture: all -Depends: openssh-client, gnupg (>=1.4.10), libcrypt-openssl-rsa-perl, libdigest-sha-perl, lockfile-progs | procmail, adduser, ${misc:Depends} +Depends: openssh-client, gnupg, libcrypt-openssl-rsa-perl, libdigest-sha-perl, lockfile-progs | procmail, adduser, ${misc:Depends} Recommends: netcat | socat, ssh-askpass, cron Enhances: openssh-client, openssh-server Description: use the OpenPGP web of trust to verify ssh connections 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