diff options
-rw-r--r-- | cmdline/apt-key.in | 2 | ||||
-rwxr-xr-x | test/integration/test-apt-key | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/cmdline/apt-key.in b/cmdline/apt-key.in index cfd4be35d..3ed2a70ce 100644 --- a/cmdline/apt-key.in +++ b/cmdline/apt-key.in @@ -193,7 +193,7 @@ remove_key_from_keyring() { get_fingerprints_of_keyring "$KEYRINGFILE" > "$FINGERPRINTS" # strip leading 0x, if present: - KEY="$(printf %s "$KEY" | sed s/^0x//)" + KEY="${KEY#0x}" # check if the key is in this keyring if ! grep -iq "^[0-9A-F]*${KEY}$" "$FINGERPRINTS"; then diff --git a/test/integration/test-apt-key b/test/integration/test-apt-key index 907824db1..82b64963c 100755 --- a/test/integration/test-apt-key +++ b/test/integration/test-apt-key @@ -85,6 +85,17 @@ gpg: unchanged: 1' aptkey --fakeroot update testfailure test -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~ + msgtest 'Test key removal with' 'different key specs' + cleanplate + cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg + cp -a keys/marvinparanoid.pub rootdir/etc/apt/trusted.gpg.d/marvinparanoid.gpg + testsuccess --nomsg aptkey --fakeroot del 0xDBAC8DAE 528144E2 + testempty aptkey list + testfailure test -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg + testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~ + testfailure test -e rootdir/etc/apt/trusted.gpg.d/marvinparanoid.gpg + testsuccess cmp keys/marvinparanoid.pub rootdir/etc/apt/trusted.gpg.d/marvinparanoid.gpg~ + msgtest 'Test key removal with' 'long key ID' cleanplate cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg |