summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/smb.h4
-rw-r--r--source3/locking/locking.c63
-rw-r--r--source3/locking/proto.h1
-rw-r--r--source3/smbd/open.c3
4 files changed, 22 insertions, 49 deletions
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 3451123dee..0724b7ce82 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -1070,11 +1070,11 @@ enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
* inform potential level2 holders on
* write. */
#define DEFERRED_OPEN_ENTRY 0x20
-#define UNUSED_SHARE_MODE_ENTRY 0x40
+/* #define UNUSED_SHARE_MODE_ENTRY 0x40 */ /* Not used anymore */
#define FORCE_OPLOCK_BREAK_TO_NONE 0x80
/* None of the following should ever appear in fsp->oplock_request. */
-#define SAMBA_PRIVATE_OPLOCK_MASK (INTERNAL_OPEN_ONLY|DEFERRED_OPEN_ENTRY|UNUSED_SHARE_MODE_ENTRY|FORCE_OPLOCK_BREAK_TO_NONE)
+#define SAMBA_PRIVATE_OPLOCK_MASK (INTERNAL_OPEN_ONLY|DEFERRED_OPEN_ENTRY|FORCE_OPLOCK_BREAK_TO_NONE)
#define EXCLUSIVE_OPLOCK_TYPE(lck) ((lck) & ((unsigned int)EXCLUSIVE_OPLOCK|(unsigned int)BATCH_OPLOCK))
#define BATCH_OPLOCK_TYPE(lck) ((lck) & (unsigned int)BATCH_OPLOCK)
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index b0f719bb48..39d3f28e26 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -495,12 +495,11 @@ static TDB_DATA locking_key(const struct file_id *id, struct file_id *tmp)
char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e)
{
- return talloc_asprintf(ctx, "share_mode_entry[%d]: %s "
+ return talloc_asprintf(ctx, "share_mode_entry[%d]: "
"pid = %s, share_access = 0x%x, private_options = 0x%x, "
"access_mask = 0x%x, mid = 0x%llx, type= 0x%x, gen_id = %lu, "
"uid = %u, flags = %u, file_id %s, name_hash = 0x%x",
num,
- e->op_type == UNUSED_SHARE_MODE_ENTRY ? "UNUSED" : "",
procid_str_static(&e->pid),
e->share_access, e->private_options,
e->access_mask, (unsigned long long)e->op_mid,
@@ -562,12 +561,16 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
smb_panic("parse_share_modes: serverids_exist failed");
}
- for (i = 0; i < lck->num_share_modes; i++) {
- struct share_mode_entry *entry_p = &lck->share_modes[i];
+ i = 0;
+ while (i < lck->num_share_modes) {
+ struct share_mode_entry *e = &lck->share_modes[i];
if (!pid_exists[i]) {
- entry_p->op_type = UNUSED_SHARE_MODE_ENTRY;
+ *e = lck->share_modes[lck->num_share_modes-1];
+ lck->num_share_modes -= 1;
lck->modified = True;
+ continue;
}
+ i += 1;
}
TALLOC_FREE(pid_exists);
TALLOC_FREE(pids);
@@ -579,19 +582,13 @@ static TDB_DATA unparse_share_modes(struct share_mode_lock *lck)
{
DATA_BLOB blob;
enum ndr_err_code ndr_err;
- uint32_t i;
if (DEBUGLEVEL >= 10) {
DEBUG(10, ("unparse_share_modes:\n"));
NDR_PRINT_DEBUG(share_mode_lock, lck);
}
- for (i=0; i<lck->num_share_modes; i++) {
- if (!is_unused_share_mode_entry(&lck->share_modes[i])) {
- break;
- }
- }
- if (i == lck->num_share_modes) {
+ if (lck->num_share_modes == 0) {
DEBUG(10, ("No used share mode found\n"));
return make_tdb_data(NULL, 0);
}
@@ -773,6 +770,10 @@ struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
TALLOC_FREE(lck);
return NULL;
}
+ if (data.dptr == NULL) {
+ TALLOC_FREE(lck);
+ return NULL;
+ }
if (!fill_share_mode_lock(lck, id, NULL, NULL, data, NULL)) {
DEBUG(10, ("fetch_share_mode_unlocked: no share_mode record "
@@ -936,14 +937,6 @@ bool is_valid_share_mode_entry(const struct share_mode_entry *e)
{
int num_props = 0;
- if (e->op_type == UNUSED_SHARE_MODE_ENTRY) {
- /* cope with dead entries from the process not
- existing. These should not be considered valid,
- otherwise we end up doing zero timeout sharing
- violation */
- return False;
- }
-
num_props += ((e->op_type == NO_OPLOCK) ? 1 : 0);
num_props += (EXCLUSIVE_OPLOCK_TYPE(e->op_type) ? 1 : 0);
num_props += (LEVEL_II_OPLOCK_TYPE(e->op_type) ? 1 : 0);
@@ -957,11 +950,6 @@ bool is_deferred_open_entry(const struct share_mode_entry *e)
return (e->op_type == DEFERRED_OPEN_ENTRY);
}
-bool is_unused_share_mode_entry(const struct share_mode_entry *e)
-{
- return (e->op_type == UNUSED_SHARE_MODE_ENTRY);
-}
-
/*******************************************************************
Fill a share mode entry.
********************************************************************/
@@ -1006,21 +994,8 @@ static void fill_deferred_open_entry(struct share_mode_entry *e,
static void add_share_mode_entry(struct share_mode_lock *lck,
const struct share_mode_entry *entry)
{
- int i;
-
- for (i=0; i<lck->num_share_modes; i++) {
- struct share_mode_entry *e = &lck->share_modes[i];
- if (is_unused_share_mode_entry(e)) {
- *e = *entry;
- break;
- }
- }
-
- if (i == lck->num_share_modes) {
- /* No unused entry found */
- ADD_TO_ARRAY(lck, struct share_mode_entry, *entry,
- &lck->share_modes, &lck->num_share_modes);
- }
+ ADD_TO_ARRAY(lck, struct share_mode_entry, *entry,
+ &lck->share_modes, &lck->num_share_modes);
lck->modified = True;
}
@@ -1105,8 +1080,8 @@ bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp)
if (e == NULL) {
return False;
}
-
- e->op_type = UNUSED_SHARE_MODE_ENTRY;
+ *e = lck->share_modes[lck->num_share_modes-1];
+ lck->num_share_modes -= 1;
lck->modified = True;
return True;
}
@@ -1123,8 +1098,8 @@ void del_deferred_open_entry(struct share_mode_lock *lck, uint64_t mid,
if (e == NULL) {
return;
}
-
- e->op_type = UNUSED_SHARE_MODE_ENTRY;
+ *e = lck->share_modes[lck->num_share_modes-1];
+ lck->num_share_modes -= 1;
lck->modified = True;
}
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index 2c01634d31..d6f1c1bf4a 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -165,7 +165,6 @@ void get_file_infos(struct file_id id,
struct timespec *write_time);
bool is_valid_share_mode_entry(const struct share_mode_entry *e);
bool is_deferred_open_entry(const struct share_mode_entry *e);
-bool is_unused_share_mode_entry(const struct share_mode_entry *e);
void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
uid_t uid, uint64_t mid, uint16 op_type);
void add_deferred_open(struct share_mode_lock *lck, uint64_t mid,
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 265de27184..461206893b 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -911,8 +911,7 @@ static void validate_my_share_entries(struct smbd_server_connection *sconn,
"share entry with an open file\n");
}
- if (is_deferred_open_entry(share_entry) ||
- is_unused_share_mode_entry(share_entry)) {
+ if (is_deferred_open_entry(share_entry)) {
goto panic;
}