From aa0bb2e43b6de5301939ca4dad2f5e264e469227 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 17 Aug 2016 15:38:35 -0400 Subject: simplify Don't need to check key server for --gpgkeyid backup, because the same switch has to be provided at restore time. --- Gpg.hs | 9 +-------- keysafe.hs | 11 +++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Gpg.hs b/Gpg.hs index 4a0633a..cbb7991 100644 --- a/Gpg.hs +++ b/Gpg.hs @@ -3,7 +3,7 @@ - Licensed under the GNU AGPL version 3 or higher. -} -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE OverloadedStrings, BangPatterns #-} module Gpg where @@ -55,10 +55,3 @@ getSecretKey (KeyId kid) = do _ -> error "gpg --export-secret-key failed" where ps = ["--batch", "--export-secret-key", BU8.toString kid] - --- | Check if a given gpg key is present on the keyserver. --- (Without downloading the key.) -knownByKeyServer :: KeyId -> IO Bool -knownByKeyServer kid = undefined --- gpg --batch --with-colons --search-keys 2>/dev/null --- check if output includes pub: line diff --git a/keysafe.hs b/keysafe.hs index 7756b26..4666dd3 100644 --- a/keysafe.hs +++ b/keysafe.hs @@ -48,19 +48,14 @@ dispatch cmdline ui tunables = do go mode (CmdLine.secretkeysource cmdline) where storage = CmdLine.storage cmdline - go CmdLine.Backup (Just secretkeysource@(GpgKey kid)) = do - ok <- Gpg.knownByKeyServer kid - unless ok $ - showError ui "Your gpg public key has to be stored on the keyservers before you can back it up by keyid. Either use gpg --send-key to store the public key on the keyservers, or omit the --gpgkeyid option" - backup storage ui tunables secretkeysource - =<< getSecretKey secretkeysource go CmdLine.Backup (Just secretkeysource) = backup storage ui tunables secretkeysource =<< getSecretKey secretkeysource - go CmdLine.Backup Nothing = - backup storage ui tunables Gpg.anyKey =<< Gpg.getKeyToBackup ui go CmdLine.Restore (Just secretkeydest) = restore storage ui secretkeydest + go CmdLine.Backup Nothing = + backup storage ui tunables Gpg.anyKey + =<< Gpg.getKeyToBackup ui go CmdLine.Restore Nothing = restore storage ui Gpg.anyKey go CmdLine.Benchmark _ = -- cgit v1.2.3