Problems with map hidden (and possibly map system)

Glen Gibb grg at ridley.unimelb.edu.au
Tue Nov 5 23:35:32 GMT 2002


Hi all,

I encountered a problem with map hidden a week or two ago and posted a
patch to fix the problem. However, it appears that it slipped under radar
as I didn't receive any comments (either positive or negative). So I'm
reposting the information, hopefully with a clearer explanation.

Summary:
========
The problem arrises on shares with map hidden enabled when an NTCreate
message is sent and the file already exists, but the NTCreate specifies
the opposite value for hidden as the current file.

Detailed description:
=====================
I came across this problem when I enabled map hidden on a profiles share.
When copying hidden files to the profiles share, XP does the following:

1. An NTCreate message is sent to the server with the hidden bit NOT set,
with the file name set to a temporary file.
2. The NTCreate succeeds, and the appropriate message is returned to the
client.
3. The client sends a close message to the server, and the file is closed.
4. The client then sends another NTCreate message to the server, passing
in the same file name, but with the the hidden bit SET. (The server is
instructed to truncate the file if it already exists).

Step 4 fails on the samba server because the existing file has a different
set of attributes to that requested. In open_file_shared1 in smbd/open.c,
there is  a check performed when the file already exists to compare the
attributes, and this test is failing.

I've attached a patch that attempts to change the attributes on an
NTCreate when the TRUNCate flag is set, and only if the attribute change
fails does the NTCreate fail.

I'm using the patch in a 2.2.6 system without any problems. I haven't
tested this in 3, but the code is identical in smbd/open.c in the relevant
section.

Can someone have a look at the attached patch (against 2.2.6) to check if
it is the correct solution. If there are any problems please let me know.

BTW, if anyone would like a look, I can send a packet dump that shows XP
doing the above sequence of steps.

Looking forward to receiving feedback.

Thanks
Glen Gibb
Ridley College

PS. Is there an ideal format for sending in bug reports/patches?
-------------- next part --------------
--- open.c.orig	Sat Oct 26 21:14:11 2002
+++ open.c	Sat Oct 26 21:14:21 2002
@@ -822,11 +822,13 @@
 	/* We only care about matching attributes on file exists and truncate. */
 	if (file_existed && (GET_FILE_OPEN_DISPOSITION(ofun) == FILE_EXISTS_TRUNCATE)) {
 		if (!open_match_attributes(conn, fname, psbuf->st_mode, mode)) {
-			DEBUG(5,("open_file_shared: attributes missmatch for file %s (0%o, 0%o)\n",
-						fname, psbuf->st_mode, mode ));
-			file_free(fsp);
-			errno = EACCES;
-			return NULL;
+			if (vfs_chmod(conn,fname,mode) != 0) {
+				DEBUG(5,("open_file_shared: attributes missmatch for file %s (0%o, 0%o)\n",
+							fname, psbuf->st_mode, mode ));
+				file_free(fsp);
+				errno = EACCES;
+				return NULL;
+			}
 		}
 	}
 


More information about the samba-technical mailing list