From: Volker Lendecke Date: Mon, 13 Jun 2016 16:06:08 +0000 (+0200) Subject: smbd: Add "path" to notify_remove X-Git-Tag: tdb-1.3.10~326 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=229c9108d91e353c60eb47d33b3c55e7689db605;p=thirdparty%2Fsamba.git smbd: Add "path" to notify_remove Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/files.c b/source3/smbd/files.c index f211c17f5e9..1ef1bc9ff9b 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -518,9 +518,21 @@ void file_free(struct smb_request *req, files_struct *fsp) uint64_t fnum = fsp->fnum; if (fsp->notify) { - struct notify_context *notify_ctx = - fsp->conn->sconn->notify_ctx; - notify_remove(notify_ctx, fsp); + size_t len = fsp_fullbasepath(fsp, NULL, 0); + char fullpath[len+1]; + + fsp_fullbasepath(fsp, fullpath, sizeof(fullpath)); + + /* + * Avoid /. at the end of the path name. notify can't + * deal with it. + */ + if (len > 1 && fullpath[len-1] == '.' && + fullpath[len-2] == '/') { + fullpath[len-2] = '\0'; + } + + notify_remove(fsp->conn->sconn->notify_ctx, fsp, fullpath); TALLOC_FREE(fsp->notify); } diff --git a/source3/smbd/notify_msg.c b/source3/smbd/notify_msg.c index ea067d0e80e..572ec3e3236 100644 --- a/source3/smbd/notify_msg.c +++ b/source3/smbd/notify_msg.c @@ -176,7 +176,8 @@ NTSTATUS notify_add(struct notify_context *ctx, return NT_STATUS_OK; } -NTSTATUS notify_remove(struct notify_context *ctx, void *private_data) +NTSTATUS notify_remove(struct notify_context *ctx, void *private_data, + char *path) { struct notify_list *listel; struct notify_rec_change_msg msg = {}; @@ -203,8 +204,8 @@ NTSTATUS notify_remove(struct notify_context *ctx, void *private_data) iov[0].iov_base = &msg; iov[0].iov_len = offsetof(struct notify_rec_change_msg, path); - iov[1].iov_base = discard_const_p(char, listel->path); - iov[1].iov_len = strlen(listel->path)+1; + iov[1].iov_base = path; + iov[1].iov_len = strlen(path)+1; status = messaging_send_iov( ctx->msg_ctx, ctx->notifyd, MSG_SMB_NOTIFY_REC_CHANGE, diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 764673cf7f2..9706fb0b709 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -589,7 +589,8 @@ NTSTATUS notify_add(struct notify_context *notify, void (*callback)(void *, struct timespec, const struct notify_event *), void *private_data); -NTSTATUS notify_remove(struct notify_context *notify, void *private_data); +NTSTATUS notify_remove(struct notify_context *ctx, void *private_data, + char *path); void notify_trigger(struct notify_context *notify, uint32_t action, uint32_t filter, const char *dir, const char *path);