s3-notify: Lift "/." handling up one level
[kai/samba-autobuild/.git] / source3 / smbd / notify.c
index 37d585b89602d07b1ceea8665b12f2b4f1404b7c..534ed8477bc2664c8310ac960fca44796bd11b5b 100644 (file)
@@ -178,6 +178,7 @@ NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
                              bool recursive)
 {
        char *fullpath;
+       size_t len;
        struct notify_entry e;
        NTSTATUS status;
 
@@ -202,6 +203,14 @@ NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
                return NT_STATUS_NO_MEMORY;
        }
 
+       /*
+        * Avoid /. at the end of the path name. notify can't deal with it.
+        */
+       len = strlen(fullpath);
+       if (len > 1 && fullpath[len-1] == '.' && fullpath[len-2] == '/') {
+               fullpath[len-2] = '\0';
+       }
+
        ZERO_STRUCT(e);
        e.path = fullpath;
        e.dir_fd = fsp->fh->fd;