diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-26 12:45:55 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-27 12:50:53 +0100 |
commit | 5a094287defcf440f2058c728bd862e2275e7dc9 (patch) | |
tree | effbe8a4805d9a9cfc9c125027e0aff4ab65864b /conf/filewriter_windows.go | |
parent | conf: do exponential back off for sharing violation in hotfolder (diff) | |
download | wireguard-windows-5a094287defcf440f2058c728bd862e2275e7dc9.tar.xz wireguard-windows-5a094287defcf440f2058c728bd862e2275e7dc9.zip |
conf: open temporary file with read sharing
The reason we do the rename-in-place temporary file situation is to
allow reads to be complete once renamed. But the rename takes place
before the filehandle is closed, so make sure that the handle is opened
with read sharing, in case this races.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | conf/filewriter_windows.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/conf/filewriter_windows.go b/conf/filewriter_windows.go index ca45bf42..f42603b3 100644 --- a/conf/filewriter_windows.go +++ b/conf/filewriter_windows.go @@ -45,7 +45,7 @@ func writeEncryptedFile(destination string, overwrite bool, contents []byte) err if err != nil { return err } - handle, err := windows.CreateFile(tmpDestination16, windows.GENERIC_WRITE|windows.DELETE, 0, sa, windows.CREATE_ALWAYS, windows.FILE_ATTRIBUTE_NORMAL, 0) + handle, err := windows.CreateFile(tmpDestination16, windows.GENERIC_WRITE|windows.DELETE, windows.FILE_SHARE_READ, sa, windows.CREATE_ALWAYS, windows.FILE_ATTRIBUTE_NORMAL, 0) if err != nil { return err } |