diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2012-06-22 09:44:41 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-06-22 07:35:17 +0200 |
commit | 01ec4a72de56ade54bbbc92e0a408771390c5c12 (patch) | |
tree | 1ee7082cac28cee704ebc0eb6e76d372baa31405 /lib/ntdb/lock.c | |
parent | bd5c061932d9aaf2e66cd56a39743c9ff34c3a88 (diff) | |
download | samba-01ec4a72de56ade54bbbc92e0a408771390c5c12.tar.gz samba-01ec4a72de56ade54bbbc92e0a408771390c5c12.tar.bz2 samba-01ec4a72de56ade54bbbc92e0a408771390c5c12.zip |
ntdb: make database read-only during ntdb_parse() callback.
Since we have a readlock, any write will grab a write lock: if it happens
to be on the same bucket, we'll fail.
For that reason, enforce read-only so every write operation fails
(even for NTDB_NOLOCK or NTDB_INTERNAL dbs), and document it!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/ntdb/lock.c')
-rw-r--r-- | lib/ntdb/lock.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/ntdb/lock.c b/lib/ntdb/lock.c index f6a811a3fa..4517e25568 100644 --- a/lib/ntdb/lock.c +++ b/lib/ntdb/lock.c @@ -188,15 +188,15 @@ static enum NTDB_ERROR ntdb_brlock(struct ntdb_context *ntdb, { int ret; - if (ntdb->flags & NTDB_NOLOCK) { - return NTDB_SUCCESS; - } - if (rw_type == F_WRLCK && (ntdb->flags & NTDB_RDONLY)) { return ntdb_logerr(ntdb, NTDB_ERR_RDONLY, NTDB_LOG_USE_ERROR, "Write lock attempted on read-only database"); } + if (ntdb->flags & NTDB_NOLOCK) { + return NTDB_SUCCESS; + } + /* A 32 bit system cannot open a 64-bit file, but it could have * expanded since then: check here. */ if ((size_t)(offset + len) != offset + len) { @@ -533,8 +533,9 @@ enum NTDB_ERROR ntdb_allrecord_lock(struct ntdb_context *ntdb, int ltype, enum NTDB_ERROR ecode; ntdb_bool_err berr; - if (ntdb->flags & NTDB_NOLOCK) + if (ntdb->flags & NTDB_NOLOCK) { return NTDB_SUCCESS; + } if (!check_lock_pid(ntdb, "ntdb_allrecord_lock", true)) { return NTDB_ERR_LOCK; |