only proxy to a remote when remote.name.annex-proxy is set

Avoids someone writing to proxy.log and gaining access to remotes
of someone else's repository that they were not intended to be able
to proxy to.
This commit is contained in:
Joey Hess 2024-06-18 11:43:10 -04:00
parent fb0fd78485
commit ca08f3fcc2
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -20,6 +20,7 @@ import CmdLine.GitAnnexShell.Fields
import Remote.GCrypt (getGCryptUUID)
import P2P.Protocol (ServerMode(..))
import Git.Types
import qualified Types.Remote as R
import Logs.Proxy
import Logs.Cluster
import Logs.UUID
@ -204,8 +205,9 @@ checkProxy remoteuuid ouruuid = M.lookup ouruuid <$> getProxies >>= \case
proxyfor ps = do
rs <- concat . byCost <$> remoteList
let sameuuid r = uuid r == remoteuuid
let proxyconfigured = remoteAnnexProxy . R.gitconfig
let samename r p = name r == proxyRemoteName p
case headMaybe (filter (\r -> sameuuid r && any (samename r) ps) rs) of
case headMaybe (filter (\r -> sameuuid r && proxyconfigured r && any (samename r) ps) rs) of
Nothing -> notconfigured
Just r -> do
Annex.changeState $ \st ->