summaryrefslogtreecommitdiffstats
path: root/source/smbd/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/smbd/dir.c')
-rw-r--r--source/smbd/dir.c154
1 files changed, 83 insertions, 71 deletions
diff --git a/source/smbd/dir.c b/source/smbd/dir.c
index 12e0758596f..cce62870715 100644
--- a/source/smbd/dir.c
+++ b/source/smbd/dir.c
@@ -559,6 +559,12 @@ BOOL dir_check_ftype(connection_struct *conn,int mode,SMB_STRUCT_STAT *st,int di
return True;
}
+static BOOL mangle_mask_match(connection_struct *conn, char *filename, char *mask)
+{
+ mangle_map(filename,True,False,SNUM(conn));
+ return mask_match(filename,mask,False);
+}
+
/****************************************************************************
Get an 8.3 directory entry.
****************************************************************************/
@@ -604,14 +610,13 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname,
*/
if ((strcmp(mask,"*.*") == 0) ||
mask_match(filename,mask,False) ||
- (name_map_mangle(filename,True,False,SNUM(conn)) &&
- mask_match(filename,mask,False)))
+ mangle_mask_match(conn,filename,mask))
{
if (isrootdir && (strequal(filename,"..") || strequal(filename,".")))
continue;
- if (!is_8_3(filename, False)) {
- name_map_mangle(filename,True,False,SNUM(conn));
+ if (!mangle_is_8_3(filename, False)) {
+ mangle_map(filename,True,False,SNUM(conn));
}
pstrcpy(fname,filename);
@@ -723,76 +728,83 @@ static BOOL user_can_read_file(connection_struct *conn, char *name)
void *OpenDir(connection_struct *conn, char *name, BOOL use_veto)
{
- Dir *dirp;
- char *n;
- DIR *p = conn->vfs_ops.opendir(conn,dos_to_unix_static(name));
- int used=0;
-
- if (!p) return(NULL);
- dirp = (Dir *)malloc(sizeof(Dir));
- if (!dirp) {
- DEBUG(0,("Out of memory in OpenDir\n"));
- conn->vfs_ops.closedir(conn,p);
- return(NULL);
- }
- dirp->pos = dirp->numentries = dirp->mallocsize = 0;
- dirp->data = dirp->current = NULL;
-
- while (True)
- {
- int l;
-
- if (used == 0) {
- n = ".";
- } else if (used == 2) {
- n = "..";
- } else {
- n = vfs_readdirname(conn, p);
- if (n == NULL)
- break;
- if ((strcmp(".",n) == 0) ||(strcmp("..",n) == 0))
- continue;
- }
-
- l = strlen(n)+1;
-
- /* Return value of vfs_readdirname has already gone through
- unix_to_dos() */
-
- /* If it's a vetoed file, pretend it doesn't even exist */
- if (use_veto && conn && IS_VETO_PATH(conn, n)) continue;
+ Dir *dirp;
+ char *n;
+ DIR *p = conn->vfs_ops.opendir(conn,dos_to_unix_static(name));
+ int used=0;
+
+ if (!p)
+ return(NULL);
+ dirp = (Dir *)malloc(sizeof(Dir));
+ if (!dirp) {
+ DEBUG(0,("Out of memory in OpenDir\n"));
+ conn->vfs_ops.closedir(conn,p);
+ return(NULL);
+ }
- /* Honour _hide unreadable_ option */
- if (conn && lp_hideunreadable(SNUM(conn))) {
- char *entry;
- int ret=0;
+ dirp->pos = dirp->numentries = dirp->mallocsize = 0;
+ dirp->data = dirp->current = NULL;
+
+ while (True) {
+ int l;
+ BOOL normal_entry = True;
+
+ if (used == 0) {
+ n = ".";
+ normal_entry = False;
+ } else if (used == 2) {
+ n = "..";
+ normal_entry = False;
+ } else {
+ n = vfs_readdirname(conn, p);
+ if (n == NULL)
+ break;
+ if ((strcmp(".",n) == 0) ||(strcmp("..",n) == 0))
+ continue;
+ normal_entry = True;
+ }
+
+ l = strlen(n)+1;
+
+ /* Return value of vfs_readdirname has already gone through
+ unix_to_dos() */
+
+ /* If it's a vetoed file, pretend it doesn't even exist */
+ if (normal_entry && use_veto && conn && IS_VETO_PATH(conn, n))
+ continue;
+
+ /* Honour _hide unreadable_ option */
+ if (normal_entry && conn && lp_hideunreadable(SNUM(conn))) {
+ char *entry;
+ int ret=0;
- if (asprintf(&entry, "%s/%s/%s", conn->origpath, name, n) > 0) {
- ret = user_can_read_file(conn, entry);
- SAFE_FREE(entry);
- }
- if (!ret) continue;
- }
-
- if (used + l > dirp->mallocsize) {
- int s = MAX(used+l,used+2000);
- char *r;
- r = (char *)Realloc(dirp->data,s);
- if (!r) {
- DEBUG(0,("Out of memory in OpenDir\n"));
- break;
- }
- dirp->data = r;
- dirp->mallocsize = s;
- dirp->current = dirp->data;
- }
- pstrcpy(dirp->data+used,n);
- used += l;
- dirp->numentries++;
- }
+ if (asprintf(&entry, "%s/%s/%s", conn->origpath, name, n) > 0) {
+ ret = user_can_read_file(conn, entry);
+ SAFE_FREE(entry);
+ }
+ if (!ret)
+ continue;
+ }
+
+ if (used + l > dirp->mallocsize) {
+ int s = MAX(used+l,used+2000);
+ char *r;
+ r = (char *)Realloc(dirp->data,s);
+ if (!r) {
+ DEBUG(0,("Out of memory in OpenDir\n"));
+ break;
+ }
+ dirp->data = r;
+ dirp->mallocsize = s;
+ dirp->current = dirp->data;
+ }
+ pstrcpy(dirp->data+used,n);
+ used += l;
+ dirp->numentries++;
+ }
- conn->vfs_ops.closedir(conn,p);
- return((void *)dirp);
+ conn->vfs_ops.closedir(conn,p);
+ return((void *)dirp);
}