Samba-Patch samba-3.0.20b

Jeremy Allison jra at samba.org
Tue Nov 22 02:20:16 GMT 2005


On Mon, Nov 21, 2005 at 06:10:01PM -0800, Jeremy Allison wrote:
> On Mon, Nov 21, 2005 at 07:01:18PM +0100, Thomas Neumann wrote:
> > Hello,
> > 
> > we discovered a bug in samba-3.0.20b (in fact 3.0.*) in combination with
> > the following settings (considered default-configuration):
> > 
> >         case sensitive = no
> >         preserve case = yes
> >         short preserve case = no
> >         default case = lower
> > 
> > Lower case is not used for files in subdirectories due to an erratic
> > 8.3-file checking in source/smbd/filename.c where the whole given path
> > is used to detect short filenames.
> > 
> > The diff containing the fixes for this source-file are attached to this
> > mail.
> 
> Thanks Thomas, this is a valid bug but not I think a correct patch.
> 
> The problem is that the variable &start output from stat_cache_lookup() may be 
> pointing at any valid component along the path - it may not be just pointing
> at the last component (as you're assuming here).
> 
> The correct fix for this is to move the string normalization into the
> part of this function containing the comment :
> 
> /*
>  * Just the last part of the name doesn't exist.
>  * We may need to strupper() or strlower() it in case
>  * this conversion is being used for file creation
>  * purposes. If the filename is of mixed case then
>  * don't normalise it.
>  */
> 
> The bug is that the "short preserve case" is not being looked
> at here for 8.3 filename. Remember that the "preserve case",
> "short preserve case" and "default case" parameters are only
> supposed to apply for new files.
> 
> I'll send you my patch for this for you to test if that's ok.

Ok, can you try this please. I think it's correct but will do lots
more checking....

Thanks,

	Jeremy.
-------------- next part --------------
Index: smbd/filename.c
===================================================================
--- smbd/filename.c	(revision 11837)
+++ smbd/filename.c	(working copy)
@@ -150,9 +150,6 @@
 			pstrcpy(saved_last_component, name);
 	}
 
-	if (!conn->case_preserve || (mangle_is_8_3(name, False, SNUM(conn)) && !conn->short_case_preserve))
-		strnorm(name, lp_defaultcase(SNUM(conn)));
-
 	start = name;
 	pstrcpy(orig_path, name);
 
@@ -301,16 +298,17 @@
 					return(False);
 				}
 
-				/* 
+				/*
 				 * Just the last part of the name doesn't exist.
-				 * We may need to strupper() or strlower() it in case
-				 * this conversion is being used for file creation 
-				 * purposes. If the filename is of mixed case then 
-				 * don't normalise it.
+				 * We need to strupper() or strlower() it as
+				 * this conversion may be used for file creation 
+				 * purposes. Fix inspired by Thomas Neumann <t.neumann at iku-ag.de>.
 				 */
-
-				if (!conn->case_preserve && (!strhasupper(start) || !strhaslower(start)))		
+				if (!conn->case_preserve ||
+						(mangle_is_8_3(start, False, SNUM(conn)) &&
+						 !conn->short_case_preserve)) {
 					strnorm(start, lp_defaultcase(SNUM(conn)));
+				}
 
 				/*
 				 * check on the mangled stack to see if we can recover the 


More information about the samba-technical mailing list