Fix crash of enableremote when the special remote has embedcreds=yes
The crash occurred because writeCreds got called twice, and writeFileProtected neglected to close its file handle, so the file was open for write when written the second time. It seems unncessary and suboptimal that writeCreds gets called twice. One call is from getRemoteCredPair and the other from setRemoteCredPair'. What happens is that in the enableremote case, code that also runs at initremote does unncessary work. Might be possible to improve that, but I've gone for the simple fix. Sponsored-by: k0ld on Patreon
This commit is contained in:
parent
37c299ae6c
commit
6a61c7ff45
3 changed files with 10 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
git-annex (10.20230927) UNRELEASED; urgency=medium
|
||||
|
||||
* Ignore directories and other unusual files in .git/annex/journal/
|
||||
* Fix crash of enableremote when the special remote has embedcreds=yes.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Tue, 10 Oct 2023 13:17:31 -0400
|
||||
|
||||
|
|
|
@ -175,10 +175,13 @@ writeFileProtected file content = writeFileProtected' file
|
|||
(\h -> hPutStr h content)
|
||||
|
||||
writeFileProtected' :: RawFilePath -> (Handle -> IO ()) -> IO ()
|
||||
writeFileProtected' file writer = do
|
||||
h <- protectedOutput $ openFile (fromRawFilePath file) WriteMode
|
||||
void $ tryIO $ modifyFileMode file $ removeModes otherGroupModes
|
||||
writer h
|
||||
writeFileProtected' file writer = bracket setup cleanup writer
|
||||
where
|
||||
setup = do
|
||||
h <- protectedOutput $ openFile (fromRawFilePath file) WriteMode
|
||||
void $ tryIO $ modifyFileMode file $ removeModes otherGroupModes
|
||||
return h
|
||||
cleanup = hClose
|
||||
|
||||
protectedOutput :: IO a -> IO a
|
||||
protectedOutput = withUmask 0o0077
|
||||
|
|
|
@ -52,3 +52,5 @@ git-annex version: 10.20230926-g44a7b4c9734adfda5912dd82c1aa97c615689f57
|
|||
### 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)
|
||||
|
||||
A great deal, we use it daily in our research and I also use it on some personal files -- thanks for all your efforts Joey et al.!
|
||||
|
||||
> Reproduced and fixed. [[done]] --[[Joey]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue