diff options
author | Joey Hess <joey@kitenet.net> | 2014-08-15 17:30:16 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-08-15 17:30:40 -0400 |
commit | 022e81407e7d806100a0882c0f23067a88b4900a (patch) | |
tree | b8035dc47239d6b687aa83adef0d45e11ac65969 /Creds.hs | |
parent | 52089bbe73d95c5a2c06a3c58c507129335e5580 (diff) | |
parent | e9128138ef1e19a341d7edfda4db2d6b1f8f6b0a (diff) |
Merge branch 'master' into s3-aws
Conflicts:
git-annex.cabal
Diffstat (limited to 'Creds.hs')
-rw-r--r-- | Creds.hs | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -23,7 +23,7 @@ import Annex.Perms import Utility.FileMode import Crypto import Types.Remote (RemoteConfig, RemoteConfigKey) -import Remote.Helper.Encryptable (remoteCipher, embedCreds) +import Remote.Helper.Encryptable (remoteCipher, remoteCipher', embedCreds) import Utility.Env (getEnv) import qualified Data.ByteString.Lazy.Char8 as L @@ -85,15 +85,19 @@ getRemoteCredPair c storage = maybe fromcache (return . Just) =<< fromenv fromcache = maybe fromconfig (return . Just) =<< readCacheCredPair storage fromconfig = case credPairRemoteKey storage of Just key -> do - mcipher <- remoteCipher c - case (M.lookup key c, mcipher) of - (Nothing, _) -> return Nothing - (Just enccreds, Just cipher) -> do + mcipher <- remoteCipher' c + case (mcipher, M.lookup key c) of + (_, Nothing) -> return Nothing + (Just (_cipher, SharedCipher {}), Just bcreds) -> + -- When using a shared cipher, the + -- creds are not stored encrypted. + fromcreds $ fromB64 bcreds + (Just (cipher, _), Just enccreds) -> do creds <- liftIO $ decrypt cipher (feedBytes $ L.pack $ fromB64 enccreds) (readBytes $ return . L.unpack) fromcreds creds - (Just bcreds, Nothing) -> + (Nothing, Just bcreds) -> fromcreds $ fromB64 bcreds Nothing -> return Nothing fromcreds creds = case decodeCredPair creds of |