]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/cache: fix cache lock based on fcntl()
authorPetr Špaček <petr.spacek@nic.cz>
Fri, 9 Oct 2020 09:29:23 +0000 (11:29 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Fri, 9 Oct 2020 10:39:15 +0000 (12:39 +0200)
Fixes bug introduced in b65e8977566be831c0308390b70fc2151f40e4e7.
open() was creating a file which could not be open again because of
insufficient permissions. This somehow worked because lockfile_release()
unlinks the file, but it broke terribly if lockfile_release() was not
called because of crash or something like that.

Fixes: merge request knot/knot-resolver!1042
NEWS
lib/cache/cdb_lmdb.c

diff --git a/NEWS b/NEWS
index 02680d5999ffab0e1ab184cc18dbea1f4c1f95b1..bd0ffa2936264559953ee0f0d13fe7b7ccc73c2c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Improvements
 Bugfixes
 --------
 - avoid an assert() error in stash_rrset() (!1072)
+- fix emergency cache locking bug introduced in 5.1.3 (!1078)
 
 
 Knot Resolver 5.1.3 (2020-09-08)
index 68346480a360b86d98999ce49071959504107e60..f7a4557d3a09c1f8922447b1b7c11dcfa7992b6c 100644 (file)
@@ -495,7 +495,7 @@ static int cdb_check_health(kr_cdb_pt db, struct kr_cdb_stats *stats)
 static int lockfile_get(const char *path)
 {
        assert(path);
-       const int fd = open(path, O_CREAT|O_RDWR, S_IRUSR);
+       const int fd = open(path, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
        if (fd < 0)
                return kr_error(errno);