Index: vfs_recycle.c =================================================================== --- vfs_recycle.c (revision 22072) +++ vfs_recycle.c (working copy) @@ -311,6 +311,33 @@ } /** + * Check if needle is contained in haystack starting at first positon + * @param haystack list of parameters separated by delimimiter character + * @param needle string to be matched exactly to haystack + * @return True if found + **/ +static BOOL checkdirparam(const char **haystack_list, const char *needle) +{ + int i; + + if (haystack_list == NULL || haystack_list[0] == NULL || + *haystack_list[0] == '\0' || needle == NULL || *needle == '\0') { + return False; + } + + for(i=0; haystack_list[i] ; i++) { + char *phaystack; + + phaystack = haystack_list[i] + strlen(haystack_list[i]) - 1; + if (phaystack[0] != '/') return False; + if (strncmp(haystack_list[i], needle, strlen(haystack_list[i])) == 0) + return True; + } + + return False; +} + +/** * Check if needle is contained exactly in haystack * @param haystack list of parameters separated by delimimiter character * @param needle string to be matched exactly to haystack @@ -488,8 +515,12 @@ /* FIXME: this check will fail if we have more than one level of directories, * we shoud check for every level 1, 1/2, 1/2/3, 1/2/3/4 .... * ---simo + * This is an attempt to fix the problem. Directories in the list must end with + * a '/', then this is used in the comparison. If a directory is excluded, all + * child directories are also excluded. + * --- jon gough */ - if (checkparam(recycle_exclude_dir(handle), path_name)) { + if (checkdirparam(recycle_exclude_dir(handle), path_name)) { DEBUG(3, ("recycle: directory %s is excluded \n", path_name)); rc = SMB_VFS_NEXT_UNLINK(handle, file_name); goto done;