smbd: Add "path" to notify_remove
authorVolker Lendecke <vl@samba.org>
Mon, 13 Jun 2016 16:06:08 +0000 (18:06 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 20 Jul 2016 03:21:06 +0000 (05:21 +0200)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/files.c
source3/smbd/notify_msg.c
source3/smbd/proto.h

index f211c17f5e9e63ab9142f9cd0bf1faf4d578d547..1ef1bc9ff9b297321d63928f5759e7a7a97ef41f 100644 (file)
@@ -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);
        }
 
index ea067d0e80e9b5aad18d3711f71b1b5499fe8238..572ec3e3236168be290fc204a42c070ef62e8b76 100644 (file)
@@ -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,
index 764673cf7f2a6076e83ad332153af15ef5dd6cb3..9706fb0b709c6e3035c4a59bb9aae8befa42f4c4 100644 (file)
@@ -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);