From e6f5998b7699567ab6002afea82476fc08120bca Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sun, 5 Jul 2020 00:34:54 +0300 Subject: [PATCH] mdbx: refine mode bits while auto-creating LCK-file. Change-Id: Ideb603cf6a1709188b3c121a9d6bf2097b9c244d --- src/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index 33b39ecc..ecd34972 100644 --- a/src/core.c +++ b/src/core.c @@ -10179,7 +10179,13 @@ int __cold mdbx_env_open(MDBX_env *env, const char *pathname, unsigned flags, rc = errno; goto bailout; } - mode = st.st_mode; + mode = (/* inherit read permissions for group and others */ st.st_mode & + (S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) | + /* always add read/write/search for owner */ S_IRUSR | S_IWUSR | + ((st.st_mode & S_IRGRP) ? /* +write if readable by group */ S_IWGRP + : 0) | + ((st.st_mode & S_IROTH) ? /* +write if readable by others */ S_IWOTH + : 0); } #endif /* !Windows */ const int lck_rc = mdbx_setup_lck(env, lck_pathname, mode);