svn commit: samba r7841 - in trunk/source: lib param smbd

jra at samba.org jra at samba.org
Wed Jun 22 21:20:41 GMT 2005


Author: jra
Date: 2005-06-22 21:20:38 +0000 (Wed, 22 Jun 2005)
New Revision: 7841

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7841

Log:
With the patch I sent Steve yesterday this gives us complete POSIX pathnames.
ie. files containing : and \ can be accessed from Linux.
Jeremy.

Modified:
   trunk/source/lib/util.c
   trunk/source/param/loadparm.c
   trunk/source/smbd/dir.c
   trunk/source/smbd/mangle.c
   trunk/source/smbd/mangle_hash2.c
   trunk/source/smbd/nttrans.c
   trunk/source/smbd/reply.c
   trunk/source/smbd/trans2.c


Changeset:
Modified: trunk/source/lib/util.c
===================================================================
--- trunk/source/lib/util.c	2005-06-22 20:33:49 UTC (rev 7840)
+++ trunk/source/lib/util.c	2005-06-22 21:20:38 UTC (rev 7841)
@@ -2451,6 +2451,12 @@
 BOOL ms_has_wild(const char *s)
 {
 	char c;
+
+	if (lp_posix_pathnames()) {
+		/* With posix pathnames no characters are wild. */
+		return False;
+	}
+
 	while ((c = *s++)) {
 		switch (c) {
 		case '*':

Modified: trunk/source/param/loadparm.c
===================================================================
--- trunk/source/param/loadparm.c	2005-06-22 20:33:49 UTC (rev 7840)
+++ trunk/source/param/loadparm.c	2005-06-22 21:20:38 UTC (rev 7841)
@@ -4548,3 +4548,29 @@
 		return;
 	ServicePtrs[(snum)]->bStoreDosAttributes = val;
 }
+
+void lp_set_mangling_method(const char *new_method)
+{
+	string_set(&Globals.szManglingMethod, new_method);
+}
+
+/*******************************************************************
+ Global state for POSIX pathname processing.
+********************************************************************/
+
+static BOOL posix_pathnames;
+
+BOOL lp_posix_pathnames(void)
+{
+	return posix_pathnames;
+}
+
+/*******************************************************************
+ Change everything needed to ensure POSIX pathname processing (currently
+ not much).
+********************************************************************/
+
+void lp_set_posix_pathnames(void)
+{
+	posix_pathnames = True;
+}

Modified: trunk/source/smbd/dir.c
===================================================================
--- trunk/source/smbd/dir.c	2005-06-22 20:33:49 UTC (rev 7840)
+++ trunk/source/smbd/dir.c	2005-06-22 21:20:38 UTC (rev 7841)
@@ -238,7 +238,7 @@
 		dptr->wcard = SMB_STRDUP(wcard);
 		if (!dptr->wcard)
 			return False;
-		if (wcard[0] == '.' && wcard[1] == 0) {
+		if (lp_posix_pathnames() || (wcard[0] == '.' && wcard[1] == 0)) {
 			dptr->has_wild = True;
 		} else {
 			dptr->has_wild = ms_has_wild(wcard);

Modified: trunk/source/smbd/mangle.c
===================================================================
--- trunk/source/smbd/mangle.c	2005-06-22 20:33:49 UTC (rev 7840)
+++ trunk/source/smbd/mangle.c	2005-06-22 21:20:38 UTC (rev 7841)
@@ -29,6 +29,7 @@
 } mangle_backends[] = {
 	{ "hash", mangle_hash_init },
 	{ "hash2", mangle_hash2_init },
+	{ "posix", posix_mangle_init },
 	/*{ "tdb", mangle_tdb_init }, */
 	{ NULL, NULL }
 };
@@ -39,7 +40,7 @@
 static void mangle_init(void)
 {
 	int i;
-	char *method;
+	const char *method;
 
 	if (mangle_fns)
 		return;
@@ -70,6 +71,13 @@
 	mangle_fns->reset();
 }
 
+void mangle_change_to_posix(void)
+{
+	mangle_fns = NULL;
+	lp_set_mangling_method("posix");
+	mangle_reset_cache();
+}
+
 /*
   see if a filename has come out of our mangling code
 */

Modified: trunk/source/smbd/mangle_hash2.c
===================================================================
--- trunk/source/smbd/mangle_hash2.c	2005-06-22 20:33:49 UTC (rev 7840)
+++ trunk/source/smbd/mangle_hash2.c	2005-06-22 21:20:38 UTC (rev 7841)
@@ -716,3 +716,42 @@
 
 	return &mangle_fns;
 }
+
+static void posix_mangle_reset(void)
+{;}
+
+static BOOL posix_is_mangled(const char *s, int snum)
+{
+	return False;
+}
+
+static BOOL posix_is_8_3(const char *fname, BOOL check_case, BOOL allow_wildcards, int snum)
+{
+	return False;
+}
+
+static BOOL posix_check_cache( char *s, size_t maxlen, int snum )
+{
+	return False;
+}
+
+static void posix_name_map(char *OutName, BOOL need83, BOOL cache83, int default_case, int snum)
+{
+	if (need83) {
+		memset(OutName, '\0', 13);
+	}
+}
+
+/* POSIX paths backend - no mangle. */
+static struct mangle_fns posix_mangle_fns = {
+        posix_mangle_reset,
+        posix_is_mangled,
+        posix_is_8_3,
+        posix_check_cache,
+        posix_name_map
+};
+
+struct mangle_fns *posix_mangle_init(void)
+{
+	return &posix_mangle_fns;
+}

Modified: trunk/source/smbd/nttrans.c
===================================================================
--- trunk/source/smbd/nttrans.c	2005-06-22 20:33:49 UTC (rev 7840)
+++ trunk/source/smbd/nttrans.c	2005-06-22 21:20:38 UTC (rev 7841)
@@ -268,6 +268,9 @@
 
 BOOL is_ntfs_stream_name(const char *fname)
 {
+	if (lp_posix_pathnames()) {
+		return False;
+	}
 	return (strchr_m(fname, ':') != NULL) ? True : False;
 }
 

Modified: trunk/source/smbd/reply.c
===================================================================
--- trunk/source/smbd/reply.c	2005-06-22 20:33:49 UTC (rev 7840)
+++ trunk/source/smbd/reply.c	2005-06-22 21:20:38 UTC (rev 7841)
@@ -398,7 +398,9 @@
 	} else {
 		ret = srvstr_pull( inbuf, tmppath_ptr, src, dest_len, src_len, flags);
 	}
-	if (allow_wcard_names) {
+	if (lp_posix_pathnames()) {
+		*err = check_path_syntax_posix(dest, tmppath);
+	} else if (allow_wcard_names) {
 		*err = check_path_syntax_wcard(dest, tmppath);
 	} else {
 		*err = check_path_syntax(dest, tmppath);
@@ -1032,6 +1034,10 @@
 	NTSTATUS nt_status;
 	BOOL allow_long_path_components = (SVAL(inbuf,smb_flg2) & FLAGS2_LONG_PATH_COMPONENTS) ? True : False;
 
+	if (lp_posix_pathnames()) {
+		return reply_unknown(inbuf, outbuf);
+	}
+
 	START_PROFILE(SMBsearch);
 
 	*mask = *directory = *fname = 0;
@@ -1228,6 +1234,10 @@
 	char *p;
 	NTSTATUS err;
 
+	if (lp_posix_pathnames()) {
+		return reply_unknown(inbuf, outbuf);
+	}
+
 	START_PROFILE(SMBfclose);
 
 	outsize = set_message(outbuf,1,0,True);

Modified: trunk/source/smbd/trans2.c
===================================================================
--- trunk/source/smbd/trans2.c	2005-06-22 20:33:49 UTC (rev 7840)
+++ trunk/source/smbd/trans2.c	2005-06-22 21:20:38 UTC (rev 7841)
@@ -2392,7 +2392,8 @@
 			data_len = 12;
 			SSVAL(pdata,0,CIFS_UNIX_MAJOR_VERSION);
 			SSVAL(pdata,2,CIFS_UNIX_MINOR_VERSION);
-			SBIG_UINT(pdata,4,((SMB_BIG_UINT)CIFS_UNIX_POSIX_ACLS_CAP)); /* We have POSIX ACLs. */
+			SBIG_UINT(pdata,4,((SMB_BIG_UINT)(CIFS_UNIX_POSIX_ACLS_CAP|
+					CIFS_UNIX_POSIX_PATHNAMES_CAP))); /* We have POSIX ACLs and pathname capability. */
 			break;
 
 		case SMB_MAC_QUERY_FS_INFO:
@@ -2463,13 +2464,16 @@
 				client_unix_cap_low = IVAL(pdata,4);
 				client_unix_cap_high = IVAL(pdata,8);
 				/* Just print these values for now. */
-				DEBUG(10,("call_trans2setfsinfo: set unix info. major = %u, minor = %u\
+				DEBUG(10,("call_trans2setfsinfo: set unix info. major = %u, minor = %u \
 cap_low = 0x%x, cap_high = 0x%x\n",
 					(unsigned int)client_unix_major,
 					(unsigned int)client_unix_minor,
 					(unsigned int)client_unix_cap_low,
 					(unsigned int)client_unix_cap_high ));
 
+				/* Here is where we must switch to posix pathname processing... */
+				lp_set_posix_pathnames();
+				mangle_change_to_posix();
 				break;
 			}
 		case SMB_FS_QUOTA_INFORMATION:



More information about the samba-cvs mailing list