fix embedcreds=yes reversion
Fix bug that made enableremote of S3 and webdav remotes, that have embedcreds=yes, fail to set up the embedded creds, so accessing the remotes failed. (Regression introduced in version 7.20200202.7 in when reworking all the remote configs to be parsed.) Root problem is that parseEncryptionConfig excludes all other config keys except encryption ones, so it is then unable to find the credPairRemoteField. And since that field is not required to be present, it proceeds as if it's not, rather than failing in any visible way. This causes it to not find any creds, and so it does not cache them. When when the S3 remote tries to make a S3 connection, it finds no creds, so assumes it's being used in no-creds mode, and tries to find a public url. With no public url available, it fails, but the failure doesn't say a lack of creds is the problem. Fix is to provide setRemoteCredPair with a ParsedRemoteConfig, so the full set of configs of the remote can be parsed. A bit annoying to need to parse the remote config before the full config (as returned by setRemoteCredPair) is available, but this avoids the problem. I assume webdav also had the problem by inspection, but didn't try to reproduce it with it. Also, getRemoteCredPair used getRemoteConfigValue to get a ProposedAccepted String, but that does not seem right. Now that it runs that code, it crashed saying it had just a String. Remotes that have already been enableremoted, and so lack the cached creds file will work after this fix, because getRemoteCredPair will extract the creds from the remote config, writing the missing file. This commit was sponsored by Ilya Shlyakhter on Patreon.
This commit is contained in:
parent
0ae63d5eec
commit
e63dcbf36c
8 changed files with 47 additions and 38 deletions
37
Remote/S3.hs
37
Remote/S3.hs
|
@ -243,7 +243,7 @@ s3Setup ss mu mcreds c gc = do
|
|||
s3Setup' ss u mcreds c gc
|
||||
|
||||
s3Setup' :: SetupStage -> UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID)
|
||||
s3Setup' ss u mcreds c gc
|
||||
s3Setup' ss u mcreds c gc
|
||||
| maybe False (isIAHost . fromProposedAccepted) (M.lookup hostField c) = archiveorg
|
||||
| otherwise = defaulthost
|
||||
where
|
||||
|
@ -263,21 +263,24 @@ s3Setup' ss u mcreds c gc
|
|||
return (fullconfig, u)
|
||||
|
||||
defaulthost = do
|
||||
(c', encsetup) <- encryptionSetup c gc
|
||||
c'' <- setRemoteCredPair encsetup c' gc (AWS.creds u) mcreds
|
||||
let fullconfig = c'' `M.union` defaults
|
||||
pc <- either giveup return . parseRemoteConfig fullconfig
|
||||
=<< configParser remote fullconfig
|
||||
info <- extractS3Info pc
|
||||
checkexportimportsafe pc info
|
||||
(c', encsetup) <- encryptionSetup (c `M.union` defaults) gc
|
||||
pc <- either giveup return . parseRemoteConfig c'
|
||||
=<< configParser remote c'
|
||||
c'' <- setRemoteCredPair encsetup pc gc (AWS.creds u) mcreds
|
||||
pc' <- either giveup return . parseRemoteConfig c''
|
||||
=<< configParser remote c''
|
||||
info <- extractS3Info pc'
|
||||
checkexportimportsafe pc' info
|
||||
case ss of
|
||||
Init -> genBucket pc gc u
|
||||
Init -> genBucket pc' gc u
|
||||
_ -> return ()
|
||||
use fullconfig pc info
|
||||
use c'' pc' info
|
||||
|
||||
archiveorg = do
|
||||
showNote "Internet Archive mode"
|
||||
c' <- setRemoteCredPair noEncryptionUsed c gc (AWS.creds u) mcreds
|
||||
pc <- either giveup return . parseRemoteConfig c
|
||||
=<< configParser remote c
|
||||
c' <- setRemoteCredPair noEncryptionUsed pc gc (AWS.creds u) mcreds
|
||||
-- Ensure user enters a valid bucket name, since
|
||||
-- this determines the name of the archive.org item.
|
||||
let validbucket = replace " " "-" $ map toLower $
|
||||
|
@ -292,14 +295,14 @@ s3Setup' ss u mcreds c gc
|
|||
M.union c' $
|
||||
-- special constraints on key names
|
||||
M.insert mungekeysField (Proposed "ia") defaults
|
||||
pc <- either giveup return . parseRemoteConfig archiveconfig
|
||||
pc' <- either giveup return . parseRemoteConfig archiveconfig
|
||||
=<< configParser remote archiveconfig
|
||||
info <- extractS3Info pc
|
||||
checkexportimportsafe pc info
|
||||
hdl <- mkS3HandleVar pc gc u
|
||||
info <- extractS3Info pc'
|
||||
checkexportimportsafe pc' info
|
||||
hdl <- mkS3HandleVar pc' gc u
|
||||
withS3HandleOrFail u hdl $
|
||||
writeUUIDFile pc u info
|
||||
use archiveconfig pc info
|
||||
writeUUIDFile pc' u info
|
||||
use archiveconfig pc' info
|
||||
|
||||
checkexportimportsafe c' info =
|
||||
unlessM (Annex.getState Annex.force) $
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue