Samba 3.0.32 - internal change notify on share directory

Jeremy Allison jra at samba.org
Tue Nov 18 20:10:24 GMT 2008


On Tue, Nov 18, 2008 at 02:48:02PM +0200, Dina Fine wrote:
> 
> Hi
> 
> It seems that when using change notify (internal only with no inotify
> mechanism) the notification doesn't work on share directory path for
> create and rename operations (and works only for delete).
> 
> It appears that when working on share directory, the add change notify
> request receives the following path "/share_path/." and cuts off the
> "\." at the path end. The notification request is saved with
> "/share_path" path.
> 
> But on notify_trigger (fro example when creating file_name),
> notify_fname creates a full path: "/share_path/./file_name" and doesn't
> cut off the prefix "./" of the relative file path. Then notify_trigger
> searches for the relevant subscription "/share_path/." in the tdb file
> and of course fails.
> 
> The attached patch solves the problem.
>  <<change_notify_on_volume_root.patch>> 
> Thanks,
> Dina Fine
> Software Engineer - Core Technologies
> Exanet Ltd.
> 

Great catch - thanks !

I think we can do this without the strlen or tmp_path though, as
we know we have a string of at least one character, so
the statement :

if (path[0] == '.' && path[1] == '/')

will always be safe as the order of evauluation will be
path[0] first only followed by path[1] if path[0] == '.'.


So the patch could be as simple as the attached. I'll
apply (with git-author attribution of course).

Jeremy.
-------------- next part --------------
diff --git a/source/smbd/notify.c b/source/smbd/notify.c
index 6e24466..b017237 100644
--- a/source/smbd/notify.c
+++ b/source/smbd/notify.c
@@ -349,6 +349,9 @@ void notify_fname(connection_struct *conn, uint32 action, uint32 filter,
 {
 	char *fullpath;
 
+	if (path[0] == '.' && path[1] == '/') {
+		path += 2;
+	}
 	if (asprintf(&fullpath, "%s/%s", conn->connectpath, path) == -1) {
 		DEBUG(0, ("asprintf failed\n"));
 		return;


More information about the samba-technical mailing list