summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2015-04-21 11:36:30 +0200
committerKarolin Seeger <kseeger@samba.org>2015-05-21 17:44:34 +0200
commitd7540992f2156392033046b33c21df5b3ec8a9a5 (patch)
tree0b0a35b40f33dba92852009c2bf6f3c07179a4b9
parentfa55c75bf4e4cdee327f80f203a9b2cd3e6ca339 (diff)
downloadsamba-d7540992f2156392033046b33c21df5b3ec8a9a5.tar.gz
smbd: Introduce reset_delete_on_close_lck
Boolean flags passed down make things more complex than necessary... BUG: https://bugzilla.samba.org/show_bug.cgi?id=11257 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit d75a0a589f477e4541badfc1a6ba939e281a5582)
-rw-r--r--source3/locking/locking.c61
-rw-r--r--source3/locking/proto.h2
2 files changed, 37 insertions, 26 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 221d6ee8d6e..cff9025e22d 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -1081,6 +1081,27 @@ static bool add_delete_on_close_token(struct share_mode_data *d,
return true;
}
+void reset_delete_on_close_lck(files_struct *fsp,
+ struct share_mode_lock *lck)
+{
+ struct share_mode_data *d = lck->data;
+ uint32_t i;
+
+ for (i=0; i<d->num_delete_tokens; i++) {
+ struct delete_token *dt = &d->delete_tokens[i];
+
+ if (dt->name_hash == fsp->name_hash) {
+ d->modified = true;
+
+ /* Delete this entry. */
+ TALLOC_FREE(dt->delete_nt_token);
+ TALLOC_FREE(dt->delete_token);
+ *dt = d->delete_tokens[d->num_delete_tokens-1];
+ d->num_delete_tokens -= 1;
+ }
+ }
+}
+
/****************************************************************************
Sets the delete on close flag over all share modes on this file.
Modify the share mode entry for all files open
@@ -1102,44 +1123,32 @@ void set_delete_on_close_lck(files_struct *fsp,
int i;
bool ret;
- if (delete_on_close) {
- SMB_ASSERT(nt_tok != NULL);
- SMB_ASSERT(tok != NULL);
- } else {
+ if (!delete_on_close) {
SMB_ASSERT(nt_tok == NULL);
SMB_ASSERT(tok == NULL);
+ return reset_delete_on_close_lck(fsp, lck);
}
+ SMB_ASSERT(nt_tok != NULL);
+ SMB_ASSERT(tok != NULL);
+
for (i=0; i<d->num_delete_tokens; i++) {
struct delete_token *dt = &d->delete_tokens[i];
if (dt->name_hash == fsp->name_hash) {
d->modified = true;
- if (delete_on_close == false) {
- /* Delete this entry. */
- TALLOC_FREE(dt->delete_nt_token);
- TALLOC_FREE(dt->delete_token);
- *dt = d->delete_tokens[
- d->num_delete_tokens-1];
- d->num_delete_tokens -= 1;
- } else {
- /* Replace this token with the
- given tok. */
- TALLOC_FREE(dt->delete_nt_token);
- dt->delete_nt_token = dup_nt_token(dt, nt_tok);
- SMB_ASSERT(dt->delete_nt_token != NULL);
- TALLOC_FREE(dt->delete_token);
- dt->delete_token = copy_unix_token(dt, tok);
- SMB_ASSERT(dt->delete_token != NULL);
- }
+
+ /* Replace this token with the given tok. */
+ TALLOC_FREE(dt->delete_nt_token);
+ dt->delete_nt_token = dup_nt_token(dt, nt_tok);
+ SMB_ASSERT(dt->delete_nt_token != NULL);
+ TALLOC_FREE(dt->delete_token);
+ dt->delete_token = copy_unix_token(dt, tok);
+ SMB_ASSERT(dt->delete_token != NULL);
+
return;
}
}
- if (!delete_on_close) {
- /* Nothing to delete - not found. */
- return;
- }
-
ret = add_delete_on_close_token(lck->data, fsp->name_hash, nt_tok, tok);
SMB_ASSERT(ret);
}
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index c4ea198d20c..8a0e0234fc5 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -185,6 +185,8 @@ bool get_delete_on_close_token(struct share_mode_lock *lck,
uint32_t name_hash,
const struct security_token **pp_nt_tok,
const struct security_unix_token **pp_tok);
+void reset_delete_on_close_lck(files_struct *fsp,
+ struct share_mode_lock *lck);
void set_delete_on_close_lck(files_struct *fsp,
struct share_mode_lock *lck,
bool delete_on_close,