S3: Fix irrefutable pattern failure when accessing encrypted S3 credentials.

This commit is contained in:
Joey Hess 2012-02-08 11:41:15 -04:00
parent 995bf51e10
commit 57a747d081
2 changed files with 8 additions and 3 deletions

View file

@ -289,12 +289,15 @@ s3GetCreds c = maybe fromconfig (return . Just) =<< liftIO getenv
liftIO $ decrypt s3creds cipher
_ -> return Nothing
decrypt s3creds cipher = do
[ak, sk, _rest] <- lines <$>
creds <- lines <$>
withDecryptedContent cipher
(return $ L.pack $ fromB64 s3creds)
(return . L.unpack)
setenv (ak, sk)
return $ Just (ak, sk)
case creds of
[ak, sk] -> do
setenv (ak, sk)
return $ Just (ak, sk)
_ -> do error "bad s3creds"
{- Stores S3 creds encrypted in the remote's config if possible. -}
s3SetCreds :: RemoteConfig -> Annex RemoteConfig