diff options
author | Volker Lendecke <vl@samba.org> | 2019-08-14 17:29:19 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-09-17 22:49:37 +0000 |
commit | f5a6fa40928f9e8c9b91f38f287fd9264de9d826 (patch) | |
tree | d4fe94ec8fe6038d57ddadde6d0b8b4adbcfa884 /source3/locking | |
parent | 5cbd3e46714f5bfdbfa54c8cef0f8145bee08094 (diff) | |
download | samba-f5a6fa40928f9e8c9b91f38f287fd9264de9d826.tar.gz |
smbd: Use share_mode_forall_entries() in set_delete_on_close_lck()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/locking')
-rw-r--r-- | source3/locking/locking.c | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c index e8820ee0356..d3d954c2d83 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -1021,6 +1021,35 @@ void reset_delete_on_close_lck(files_struct *fsp, } } +struct set_delete_on_close_state { + struct messaging_context *msg_ctx; + DATA_BLOB blob; +}; + +static bool set_delete_on_close_fn( + struct share_mode_entry *e, + bool *modified, + void *private_data) +{ + struct set_delete_on_close_state *state = private_data; + NTSTATUS status; + + status = messaging_send( + state->msg_ctx, + e->pid, + MSG_SMB_NOTIFY_CANCEL_DELETED, + &state->blob); + + if (!NT_STATUS_IS_OK(status)) { + struct server_id_buf tmp; + DBG_DEBUG("messaging_send to %s returned %s\n", + server_id_str_buf(e->pid, &tmp), + nt_errstr(status)); + } + + return false; +} + /**************************************************************************** Sets the delete on close flag over all share modes on this file. Modify the share mode entry for all files open @@ -1037,11 +1066,12 @@ void set_delete_on_close_lck(files_struct *fsp, const struct security_token *nt_tok, const struct security_unix_token *tok) { - struct messaging_context *msg_ctx = fsp->conn->sconn->msg_ctx; struct share_mode_data *d = lck->data; + struct set_delete_on_close_state state = { + .msg_ctx = fsp->conn->sconn->msg_ctx + }; uint32_t i; bool ret; - DATA_BLOB fid_blob = {}; enum ndr_err_code ndr_err; SMB_ASSERT(nt_tok != NULL); @@ -1067,30 +1097,23 @@ void set_delete_on_close_lck(files_struct *fsp, ret = add_delete_on_close_token(lck->data, fsp->name_hash, nt_tok, tok); SMB_ASSERT(ret); - ndr_err = ndr_push_struct_blob(&fid_blob, talloc_tos(), &fsp->file_id, - (ndr_push_flags_fn_t)ndr_push_file_id); + ndr_err = ndr_push_struct_blob( + &state.blob, + talloc_tos(), + &fsp->file_id, + (ndr_push_flags_fn_t)ndr_push_file_id); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(10, ("ndr_push_file_id failed: %s\n", ndr_errstr(ndr_err))); } - for (i=0; i<d->num_share_modes; i++) { - struct share_mode_entry *e = &d->share_modes[i]; - NTSTATUS status; - - status = messaging_send( - msg_ctx, e->pid, MSG_SMB_NOTIFY_CANCEL_DELETED, - &fid_blob); - - if (!NT_STATUS_IS_OK(status)) { - struct server_id_buf tmp; - DEBUG(10, ("%s: messaging_send to %s returned %s\n", - __func__, server_id_str_buf(e->pid, &tmp), - nt_errstr(status))); - } + ret = share_mode_forall_entries( + lck, set_delete_on_close_fn, &state); + if (!ret) { + DBG_DEBUG("share_mode_forall_entries failed\n"); } - TALLOC_FREE(fid_blob.data); + TALLOC_FREE(state.blob.data); } bool set_delete_on_close(files_struct *fsp, bool delete_on_close, |