r2786: - match on both long and short name for search posix backend
authorAndrew Tridgell <tridge@samba.org>
Sat, 2 Oct 2004 12:25:02 +0000 (12:25 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:33 +0000 (12:59 -0500)
- a final name component of . is illegal

source/ntvfs/posix/pvfs_dirlist.c
source/ntvfs/posix/pvfs_resolve.c
source/ntvfs/posix/pvfs_shortname.c

index 56afb4f33b3c16c00627b1f8fe70f4e225f8a338..79d9a9a3fa9b2b234b4307849eea3915fa3d18f8 100644 (file)
@@ -98,11 +98,20 @@ NTSTATUS pvfs_list(struct pvfs_state *pvfs, struct pvfs_filename *name, struct p
        while ((dent = readdir(odir))) {
                uint_t i = dir->count;
                const char *dname = dent->d_name;
+               char *short_name;
+
+               short_name = pvfs_short_name_component(pvfs, dname);
 
                /* check it matches the wildcard pattern */
-               if (ms_fnmatch(pattern, dname, PROTOCOL_NT1) != 0) {
+               if (ms_fnmatch(pattern, dname, 
+                              pvfs->tcon->smb_conn->negotiate.protocol) != 0 &&
+                   ms_fnmatch(pattern, short_name, 
+                              pvfs->tcon->smb_conn->negotiate.protocol) != 0) {
+                       talloc_free(short_name);
                        continue;
                }
+
+               talloc_free(short_name);
                
                if (dir->count >= allocated) {
                        allocated = (allocated + 100) * 1.2;
index dfd6744effc313b9449ed7c2146910e013254e5e..e846b7be77e3c9d6d885d964634d371b3d8236cd 100644 (file)
@@ -159,6 +159,7 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
                               uint_t flags, struct pvfs_filename *name)
 {
        char *ret, *p;
+       size_t len;
 
        name->original_name = talloc_strdup(name, cifs_name);
        name->stream_name = NULL;
@@ -183,8 +184,13 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
 
        p = ret + strlen(pvfs->base_directory) + 1;
 
-       if (p[strlen(cifs_name)-1] == '\\') {
-               p[strlen(cifs_name)-1] = 0;
+       len = strlen(cifs_name);
+       if (len>0 && p[len-1] == '\\') {
+               p[len-1] = 0;
+               len--;
+       }
+       if (len>1 && p[len-1] == '.' && p[len-2] == '\\') {
+               return NT_STATUS_OBJECT_NAME_INVALID;
        }
 
        /* now do an in-place conversion of '\' to '/', checking
index fe6fd8e03081654ced7124b9fae22edc52a920bc..33e601e429e13a1547a9f75e9873d670356e5b15 100644 (file)
 #include "vfs_posix.h"
 
 
+/*
+  return the short name for a component of a full name
+  TODO: this is obviously not very useful in its current form !
+*/
+char *pvfs_short_name_component(struct pvfs_state *pvfs, const char *name)
+{
+       return talloc_strndup(pvfs, name, 12);
+}
+
+
 /*
   return the short name for a given entry in a directory
   TODO: this is obviously not very useful in its current form !
@@ -31,5 +41,5 @@
 char *pvfs_short_name(struct pvfs_state *pvfs, struct pvfs_filename *name)
 {
        char *p = strrchr(name->full_name, '/');
-       return talloc_strndup(name, p+1, 12);
+       return pvfs_short_name_component(pvfs, p+1);
 }