summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/getsmbpass.c2
-rw-r--r--source3/lib/ufc.c2
-rw-r--r--source3/lib/util.c42
3 files changed, 27 insertions, 19 deletions
diff --git a/source3/lib/getsmbpass.c b/source3/lib/getsmbpass.c
index 7ee8c18788..9008d40f91 100644
--- a/source3/lib/getsmbpass.c
+++ b/source3/lib/getsmbpass.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1992-1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/source3/lib/ufc.c b/source3/lib/ufc.c
index 67b0c6920a..0fa5cfd3a0 100644
--- a/source3/lib/ufc.c
+++ b/source3/lib/ufc.c
@@ -21,7 +21,7 @@
/*
* UFC-crypt: ultra fast crypt(3) implementation
*
- * Copyright (C) 1991, 1992, Free Software Foundation, Inc.
+ * Copyright (C) 1991-1997, Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
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
****************************************************************************/