simplify base64 to only use ByteString
Note the use of fromString and toString from Data.ByteString.UTF8 dated back to commit9b93278e8a
. Back then it was using the dataenc package for base64, which operated on Word8 and String. But with the switch to sandi, it uses ByteString, and indeed fromB64' and toB64' were already using ByteString without that complication. So I think there is no risk of such an encoding related breakage. I also tested the case that9b93278e8a
fixed: git-annex metadata -s foo='a …' x git-annex metadata x metadata x foo=a … In Remote.Helper.Encryptable, it was avoiding using Utility.Base64 because of that UTF8 conversion. Since that's no longer done, it can just use it now.
This commit is contained in:
parent
985dd38847
commit
3742263c99
7 changed files with 27 additions and 71 deletions
14
Creds.hs
14
Creds.hs
|
@ -100,10 +100,10 @@ setRemoteCredPair' pc encsetup gc storage mcreds = case mcreds of
|
|||
cmd <- gpgCmd <$> Annex.getGitConfig
|
||||
s <- liftIO $ encrypt cmd (pc, gc) cipher
|
||||
(feedBytes $ L.pack $ encodeCredPair creds)
|
||||
(readBytesStrictly $ return . S.unpack)
|
||||
storeconfig' key (Accepted (toB64 s))
|
||||
(readBytesStrictly return)
|
||||
storeconfig' key (Accepted (decodeBS (toB64 s)))
|
||||
storeconfig creds key Nothing =
|
||||
storeconfig' key (Accepted (toB64 $ encodeCredPair creds))
|
||||
storeconfig' key (Accepted (decodeBS $ toB64 $ encodeBS $ encodeCredPair creds))
|
||||
|
||||
storeconfig' key val = return $ pc
|
||||
{ parsedRemoteConfigMap = M.insert key (RemoteConfigValue val) (parsedRemoteConfigMap pc)
|
||||
|
@ -129,13 +129,13 @@ getRemoteCredPair c gc storage = maybe fromcache (return . Just) =<< fromenv
|
|||
case (getval, mcipher) of
|
||||
(Nothing, _) -> return Nothing
|
||||
(Just enccreds, Just (cipher, storablecipher)) ->
|
||||
fromenccreds enccreds cipher storablecipher
|
||||
fromenccreds (encodeBS enccreds) cipher storablecipher
|
||||
(Just bcreds, Nothing) ->
|
||||
fromcreds $ fromB64 bcreds
|
||||
fromcreds $ decodeBS $ fromB64 $ encodeBS bcreds
|
||||
fromenccreds enccreds cipher storablecipher = do
|
||||
cmd <- gpgCmd <$> Annex.getGitConfig
|
||||
mcreds <- liftIO $ catchMaybeIO $ decrypt cmd (c, gc) cipher
|
||||
(feedBytes $ L.pack $ fromB64 enccreds)
|
||||
(feedBytes $ L.fromStrict $ fromB64 enccreds)
|
||||
(readBytesStrictly $ return . S.unpack)
|
||||
case mcreds of
|
||||
Just creds -> fromcreds creds
|
||||
|
@ -146,7 +146,7 @@ getRemoteCredPair c gc storage = maybe fromcache (return . Just) =<< fromenv
|
|||
case storablecipher of
|
||||
SharedCipher {} -> showLongNote "gpg error above was caused by an old git-annex bug in credentials storage. Working around it.."
|
||||
_ -> giveup "*** Insecure credentials storage detected for this remote! See https://git-annex.branchable.com/upgrades/insecure_embedded_creds/"
|
||||
fromcreds $ fromB64 enccreds
|
||||
fromcreds $ decodeBS $ fromB64 enccreds
|
||||
fromcreds creds = case decodeCredPair creds of
|
||||
Just credpair -> do
|
||||
writeCacheCredPair credpair storage
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue