summaryrefslogtreecommitdiff
path: root/lib/tdb2/open.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tdb2/open.c')
-rw-r--r--lib/tdb2/open.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/tdb2/open.c b/lib/tdb2/open.c
index 2dd474cc81..757cfd416c 100644
--- a/lib/tdb2/open.c
+++ b/lib/tdb2/open.c
@@ -402,7 +402,8 @@ struct tdb_context *tdb_open(const char *name, int tdb_flags,
}
if (tdb_flags & ~(TDB_INTERNAL | TDB_NOLOCK | TDB_NOMMAP | TDB_CONVERT
- | TDB_NOSYNC | TDB_SEQNUM | TDB_ALLOW_NESTING)) {
+ | TDB_NOSYNC | TDB_SEQNUM | TDB_ALLOW_NESTING
+ | TDB_RDONLY)) {
ecode = tdb_logerr(tdb, TDB_ERR_EINVAL, TDB_LOG_USE_ERROR,
"tdb_open: unknown flags %u", tdb_flags);
goto fail;
@@ -416,10 +417,16 @@ struct tdb_context *tdb_open(const char *name, int tdb_flags,
}
if ((open_flags & O_ACCMODE) == O_RDONLY) {
- tdb->read_only = true;
openlock = F_RDLCK;
+ tdb->flags |= TDB_RDONLY;
} else {
- tdb->read_only = false;
+ if (tdb_flags & TDB_RDONLY) {
+ ecode = tdb_logerr(tdb, TDB_ERR_EINVAL,
+ TDB_LOG_USE_ERROR,
+ "tdb_open: can't use TDB_RDONLY"
+ " without O_RDONLY");
+ goto fail;
+ }
openlock = F_WRLCK;
}