summaryrefslogtreecommitdiff
path: root/source3/lib/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r--source3/lib/util.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 0ee6947d09..f31ae390aa 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -3432,32 +3432,33 @@ char *readdirname(void *p)
return(dname);
}
+/*
+ * Utility function used by is_hidden_path() and is_vetoed_name()
+ * to decide if the last component of a path matches a (possibly
+ * wildcarded) entry in a namelist.
+ */
-BOOL is_hidden_path(int snum, char *name)
-{
- return is_in_path(name, lp_hide_files(snum));
-}
-
-BOOL is_vetoed_name(int snum, char *name)
-{
- return is_in_path(name, lp_veto_files(snum));
-}
-
-BOOL is_in_path(char *name, char *namelist)
+static BOOL is_in_path(char *name, char *namelist)
{
-
+ pstring last_component;
+ char *p;
char *nameptr = namelist;
char *name_end;
DEBUG(5, ("is_in_path: %s list: %s\n", name, namelist));
/* if we have no list it's obviously not in the path */
- if((nameptr == NULL ) || (*nameptr == '\0'))
+ if((nameptr == NULL ) || ((nameptr != NULL) && (*nameptr == '\0')))
{
DEBUG(5,("is_in_path: no name list. return False\n"));
return False;
}
+ /* Get the last component of the unix name. */
+ p = strrchr(name, '/');
+ strncpy(last_component, p ? p : name, sizeof(last_component)-1);
+ last_component[sizeof(last_component)-1] = '\0';
+
/* now, we need to find the names one by one and check them
they can contain spaces and all sorts of stuff so we
separate them with of all things '\' which can never be in a filename
@@ -3470,9 +3471,6 @@ BOOL is_in_path(char *name, char *namelist)
that unix_convert is called before check_path and dos_mode.
unix_convert changes, in the path, all dos '\'s to unix '/'s.
- therefore, users might want to match against '/'s in the path,
- and therefore '\' must be used as the separator.
-
the alternatives are:
1) move all check_path and dos_mode calls to before the
@@ -3502,7 +3500,7 @@ BOOL is_in_path(char *name, char *namelist)
}
/* look for a match. */
- if (mask_match(name, nameptr, case_sensitive, False))
+ if (mask_match(last_component, nameptr, case_sensitive, False))
{
DEBUG(5,("is_in_path: mask match succeeded\n"));
return True;
@@ -3524,6 +3522,16 @@ BOOL is_in_path(char *name, char *namelist)
return False;
}
+BOOL is_hidden_path(int snum, char *name)
+{
+ return is_in_path(name, lp_hide_files(snum));
+}
+
+BOOL is_vetoed_name(int snum, char *name)
+{
+ return is_in_path(name, lp_veto_files(snum));
+}
+
/****************************************************************************
routine to do file locking
****************************************************************************/