{- common functions for encryptable remotes
-
- - Copyright 2011-2021 Joey Hess <id@joeyh.name>
+ - Copyright 2011-2025 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
- could opt to use a shared cipher, which is stored unencrypted. -}
encryptionSetup :: SetupStage -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, EncryptionIsSetup)
encryptionSetup setupstage c gc = do
- checkallowedchange
pc <- either giveup return $ parseEncryptionConfig c
+ checkallowedchange pc
gpgcmd <- gpgCmd <$> Annex.getGitConfig
maybe (genCipher pc gpgcmd) (updateCipher pc gpgcmd) (extractCipher pc)
where
-- public-key encryption, hence we leave it on newer
-- remotes (while being backward-compatible).
(map Accepted ["keyid", "keyid+", "keyid-", "highRandomQuality"])
- oldpc = either (const Nothing) Just $ parseEncryptionConfig $
+ moldpc = either (const Nothing) Just $ parseEncryptionConfig $
case setupstage of
Init -> mempty
Enable oldc -> oldc
AutoEnable oldc -> oldc
- checkallowedchange = case oldpc of
+ checkallowedchange pc = case moldpc of
Nothing -> return ()
- Just oldpc' -> case extractCipher oldpc' of
- Nothing -> req NoneEncryption
- Just (EncryptedCipher _ Hybrid _) -> req HybridEncryption
- Just (EncryptedCipher _ PubKey _) -> req PubKeyEncryption
- Just (SharedCipher _) -> req SharedEncryption
- Just (SharedPubKeyCipher _ _) -> req SharedPubKeyEncryption
+ Just oldpc -> do
+ case extractCipher oldpc of
+ Nothing -> req NoneEncryption
+ Just (EncryptedCipher _ Hybrid _) -> req HybridEncryption
+ Just (EncryptedCipher _ PubKey _) -> req PubKeyEncryption
+ Just (SharedCipher _) -> req SharedEncryption
+ Just (SharedPubKeyCipher _ _) -> req SharedPubKeyEncryption
+ when (onlyEncryptCreds oldpc /= onlyEncryptCreds pc) $
+ giveup "Cannot change onlyencryptcreds of existing remotes."
where
- req v
- | encryption /= Right v = cannotchange
- | otherwise = return ()
+ req v = when (encryption /= Right v) cannotchange
data CipherPurpose t = CipherAllPurpose t | CipherOnlyCreds t
enableremote d (encryption setup) (encryption key stored in git repository) ok
(recording state in git...)
-This config change should not be allowed. This is a reversion,
-probably introduced around [[!commit 71f78fe45dc91dbef0bedd79b33d6a9fed85704d]]
+This config change should not be allowed.
+
+Indeed, changing encryption type of an existing special remote should never
+be allowed, whether or not it uses exporttree. This is a reversion,
+probably introduced around
+[[!commit 71f78fe45dc91dbef0bedd79b33d6a9fed85704d]]
Also, the new onlyencryptcreds=yes setting can passed to enableremote,
which changes a previously encrypted remote to not use encryption for the
data stored on it. That should also not be allowed. --[[Joey]]
+
+> [[fixed|done]] --[[Joey]]