pkg/lockfile: fix openLock file permissions
Since commit 162a0bf730, openLock creates a file in case ro
argument is set, but the file is created with 0 permission bits.
Fix this, and unify the file creation logic while at it.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
2076605830
commit
463d50fabc
|
|
@ -71,15 +71,11 @@ func newLastWriterID() []byte {
|
|||
// openLock will create the file and its parent directories,
|
||||
// if necessary.
|
||||
func openLock(path string, ro bool) (fd int, err error) {
|
||||
if ro {
|
||||
fd, err = unix.Open(path, os.O_RDONLY|unix.O_CLOEXEC|os.O_CREATE, 0)
|
||||
} else {
|
||||
fd, err = unix.Open(path,
|
||||
os.O_RDWR|unix.O_CLOEXEC|os.O_CREATE,
|
||||
unix.S_IRUSR|unix.S_IWUSR|unix.S_IRGRP|unix.S_IROTH,
|
||||
)
|
||||
flags := os.O_RDONLY | unix.O_CLOEXEC | os.O_CREATE
|
||||
if !ro {
|
||||
flags |= os.O_RDWR
|
||||
}
|
||||
|
||||
fd, err = unix.Open(path, flags, 0o644)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue