From 4ded5bf3d9cd878d00adc7b9a6063b44d528094c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 23 Sep 2015 14:26:26 -0400 Subject: remove git signing key when it's the key to be removed --- src/Propellor/Gpg.hs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Propellor/Gpg.hs b/src/Propellor/Gpg.hs index 46f2c7d9..84f67dc1 100644 --- a/src/Propellor/Gpg.hs +++ b/src/Propellor/Gpg.hs @@ -43,7 +43,7 @@ addKey keyid = exitBool =<< allM (uncurry actionMessage) [ ("adding key to propellor's keyring", addkeyring) , ("staging propellor's keyring", gitAdd keyring) , ("updating encryption of any privdata", reencryptPrivData) - , ("configuring git signing to use key", gitconfig) + , ("configuring git commit signing to use key", gitconfig) , ("committing changes", gitCommitKeyRing "add-key") ] where @@ -71,12 +71,25 @@ rmKey keyid = exitBool =<< allM (uncurry actionMessage) [ ("removing key from propellor's keyring", rmkeyring) , ("staging propellor's keyring", gitAdd keyring) , ("updating encryption of any privdata", reencryptPrivData) + , ("configuring git commit signing to not use key", gitconfig) , ("committing changes", gitCommitKeyRing "rm-key") ] where rmkeyring = boolSystem "gpg" $ (map Param useKeyringOpts) ++ - [Param "--delete-key", Param keyid] + [ Param "--batch" + , Param "--yes" + , Param "--delete-key", Param keyid + ] + + gitconfig = ifM ((==) (keyid++"\n", True) <$> processTranscript "git" ["config", "user.signingkey"] Nothing) + ( boolSystem "git" + [ Param "config" + , Param "--unset" + , Param "user.signingkey" + ] + , return True + ) reencryptPrivData :: IO Bool reencryptPrivData = ifM (doesFileExist privDataFile) -- cgit v1.3-2-g0d8e