initremote: Avoid creating a remote that is not encrypted when gpg is broken
checksize was applied lazily, so the exception didn't happen until the remote was set up. Sponsored-by: k0ld on Patreon
This commit is contained in:
parent
23719bc91b
commit
57c1b4f5e5
3 changed files with 11 additions and 4 deletions
|
@ -35,6 +35,8 @@ git-annex (10.20230408) UNRELEASED; urgency=medium
|
||||||
.git/annex/journal/* with permissions configured by core.sharedRepository.
|
.git/annex/journal/* with permissions configured by core.sharedRepository.
|
||||||
* Bug fix: Lock files were created with wrong modes for some combinations
|
* Bug fix: Lock files were created with wrong modes for some combinations
|
||||||
of core.sharedRepository and umask.
|
of core.sharedRepository and umask.
|
||||||
|
* initremote: Avoid creating a remote that is not encrypted when gpg is
|
||||||
|
broken.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Sat, 08 Apr 2023 13:57:18 -0400
|
-- Joey Hess <id@joeyh.name> Sat, 08 Apr 2023 13:57:18 -0400
|
||||||
|
|
||||||
|
|
|
@ -302,7 +302,10 @@ genSecretKey (GpgCmd cmd) keytype passphrase userid keysize =
|
||||||
- It is armored, to avoid newlines, since gpg only reads ciphers up to the
|
- It is armored, to avoid newlines, since gpg only reads ciphers up to the
|
||||||
- first newline. -}
|
- first newline. -}
|
||||||
genRandom :: GpgCmd -> Bool -> Size -> IO String
|
genRandom :: GpgCmd -> Bool -> Size -> IO String
|
||||||
genRandom cmd highQuality size = checksize <$> readStrict cmd params
|
genRandom cmd highQuality size = do
|
||||||
|
s <- readStrict cmd params
|
||||||
|
checksize s
|
||||||
|
return s
|
||||||
where
|
where
|
||||||
params =
|
params =
|
||||||
[ Param "--gen-random"
|
[ Param "--gen-random"
|
||||||
|
@ -325,9 +328,8 @@ genRandom cmd highQuality size = checksize <$> readStrict cmd params
|
||||||
expectedlength = size * 8 `div` 6
|
expectedlength = size * 8 `div` 6
|
||||||
|
|
||||||
checksize s = let len = length s in
|
checksize s = let len = length s in
|
||||||
if len >= expectedlength
|
unless (len >= expectedlength) $
|
||||||
then s
|
shortread len
|
||||||
else shortread len
|
|
||||||
|
|
||||||
shortread got = giveup $ unwords
|
shortread got = giveup $ unwords
|
||||||
[ "Not enough bytes returned from gpg", show params
|
[ "Not enough bytes returned from gpg", show params
|
||||||
|
|
|
@ -22,3 +22,6 @@ tried with `10.20230329` and `10.20230408+gc70677e31` on Manjaro
|
||||||
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
|
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
|
||||||
|
|
||||||
It's awesome 👍
|
It's awesome 👍
|
||||||
|
|
||||||
|
> Indeed, there was a laziness bug that prevented it from exiting early
|
||||||
|
> enough. [[fixed|done]] --[[Joey]]
|
||||||
|
|
Loading…
Reference in a new issue