MSG_SMB_TELL_NUM_CHILDREN = 0x0317,
MSG_SMB_NUM_CHILDREN = 0x0318,
+ /* Cancel a notify, directory got deleted */
+ MSG_SMB_NOTIFY_CANCEL_DELETED = 0x0319,
+
/* winbind messages */
MSG_WINBIND_FINISHED = 0x0401,
MSG_WINBIND_FORGET_STATE = 0x0402,
#include "messages.h"
#include "util_tdb.h"
#include "../librpc/gen_ndr/ndr_open_files.h"
+#include "librpc/gen_ndr/ndr_file_id.h"
#include "locking/leases_db.h"
#undef DBGC_CLASS
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;
- int i;
+ uint32_t i;
bool ret;
+ DATA_BLOB fid_blob = {};
+ enum ndr_err_code ndr_err;
SMB_ASSERT(nt_tok != NULL);
SMB_ASSERT(tok != NULL);
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);
+ 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)));
+ }
+ }
+
+ TALLOC_FREE(fid_blob.data);
}
bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../librpc/gen_ndr/ndr_notify.h"
+#include "librpc/gen_ndr/ndr_file_id.h"
struct notify_change_event {
struct timespec when;
change_notify_remove_request(sconn, map->req);
}
+static struct files_struct *smbd_notify_cancel_deleted_fn(
+ struct files_struct *fsp, void *private_data)
+{
+ struct file_id *fid = talloc_get_type_abort(
+ private_data, struct file_id);
+
+ if (file_id_equal(&fsp->file_id, fid)) {
+ remove_pending_change_notify_requests_by_fid(
+ fsp, NT_STATUS_DELETE_PENDING);
+ }
+ return NULL;
+}
+
+void smbd_notify_cancel_deleted(struct messaging_context *msg,
+ void *private_data, uint32_t msg_type,
+ struct server_id server_id, DATA_BLOB *data)
+{
+ struct smbd_server_connection *sconn = talloc_get_type_abort(
+ private_data, struct smbd_server_connection);
+ struct file_id *fid;
+ enum ndr_err_code ndr_err;
+
+ fid = talloc(talloc_tos(), struct file_id);
+ if (fid == NULL) {
+ DEBUG(1, ("talloc failed\n"));
+ return;
+ }
+
+ ndr_err = ndr_pull_struct_blob_all(
+ data, fid, fid, (ndr_pull_flags_fn_t)ndr_pull_file_id);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(10, ("%s: ndr_pull_file_id failed: %s\n", __func__,
+ ndr_errstr(ndr_err)));
+ goto done;
+ }
+
+ files_forall(sconn, smbd_notify_cancel_deleted_fn, fid);
+
+done:
+ TALLOC_FREE(fid);
+}
+
/****************************************************************************
Delete entries by fnum from the change notify pending queue.
*****************************************************************************/
void (*reply_fn)(struct smb_request *req,
NTSTATUS error_code,
uint8_t *buf, size_t len));
+void smbd_notify_cancel_deleted(struct messaging_context *msg,
+ void *private_data, uint32_t msg_type,
+ struct server_id server_id, DATA_BLOB *data);
void remove_pending_change_notify_requests_by_mid(
struct smbd_server_connection *sconn, uint64_t mid);
void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
if (sconn->notify_ctx == NULL) {
sconn->notify_ctx = notify_init(
sconn, sconn->msg_ctx, sconn->ev_ctx);
+ status = messaging_register(
+ sconn->msg_ctx, sconn,
+ MSG_SMB_NOTIFY_CANCEL_DELETED,
+ smbd_notify_cancel_deleted);
}
if (sconn->sys_notify_ctx == NULL) {
sconn->sys_notify_ctx = sys_notify_context_create(