]> git.saurik.com Git - apt.git/commitdiff
allow spaces in fingerprints for 'apt-key del'
authorDavid Kalnischkies <david@kalnischkies.de>
Wed, 17 Aug 2016 06:10:29 +0000 (08:10 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Wed, 17 Aug 2016 12:12:24 +0000 (14:12 +0200)
Fingerprints tend to be displayed in space-separated octet pairs so be
nice and allow delete to remove a key based on such a string rather than
requiring that the user is deleting all the spaces manually.

cmdline/apt-key.in
test/integration/test-apt-key

index aff75c300bab3abca166b86da0a72433e3f6783a..81314c7f5fab1a4d94fb67afae5ed804bffae12c 100644 (file)
@@ -200,8 +200,8 @@ remove_key_from_keyring() {
        local FINGERPRINTS="${GPGHOMEDIR}/keyringfile.keylst"
        get_fingerprints_of_keyring "$KEYRINGFILE" > "$FINGERPRINTS"
 
-        # strip leading 0x, if present:
-        KEY="${KEY#0x}"
+       # strip leading 0x, if present:
+       KEY="$(echo "${KEY#0x}" | tr -d ' ')"
 
        # check if the key is in this keyring
        if ! grep -iq "^[0-9A-F]*${KEY}$" "$FINGERPRINTS"; then
index eb5f998cf55386ddc28413e077209b0b970b4c2c..759ce148767af1aa1be0f9061f5aa3dccf3105ef 100755 (executable)
@@ -116,6 +116,14 @@ gpg:              unchanged: 1' aptkey --fakeroot update
        testfailure test -e "${ROOTDIR}/etc/apt/trusted.gpg.d/joesixpack.gpg"
        testsuccess cmp "${KEYDIR}/joesixpack.pub" "${ROOTDIR}/etc/apt/trusted.gpg.d/joesixpack.gpg~"
 
+       msgtest 'Test key removal with' 'spaced fingerprint'
+       cleanplate
+       cp -a "${KEYDIR}/joesixpack.pub" "${ROOTDIR}/etc/apt/trusted.gpg.d/joesixpack.gpg"
+       testsuccess --nomsg aptkey --fakeroot del '34A8 E9D1 8DB3 20F3 67E8 EAA0 5A90 D141 DBAC 8DAE'
+       testempty aptkey list
+       testfailure test -e "${ROOTDIR}/etc/apt/trusted.gpg.d/joesixpack.gpg"
+       testsuccess cmp "${KEYDIR}/joesixpack.pub" "${ROOTDIR}/etc/apt/trusted.gpg.d/joesixpack.gpg~"
+
        msgtest 'Test key removal with' 'single key in softlink'
        cleanplate
        ln -s "$(readlink -f "${KEYDIR}/joesixpack.pub")" "${ROOTDIR}/etc/apt/trusted.gpg.d/joesixpack.gpg"