summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-12-19 16:36:54 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:16:37 -0500
commitf4f1814f8c7135577c8b774aacb8eed042380788 (patch)
tree7d281d564763f6afc852492cd046a8c1f611550d
parent03b14454501633feae1f713f23e67682aef31c18 (diff)
downloadsamba-f4f1814f8c7135577c8b774aacb8eed042380788.tar.gz
samba-f4f1814f8c7135577c8b774aacb8eed042380788.tar.bz2
samba-f4f1814f8c7135577c8b774aacb8eed042380788.zip
r20253: Reduce some code duplication, make reply_mkdir go through the same code paths
ncreate does. This is a bit slower (about 10-20%), because it goes touches the share mode db, but I think not having to call change_owner_to_parent and friends in fewer places outweighs this. And, mkdir is not the way current Windows boxes create directories, they do it via the ncreate call. Volker (This used to be commit ddae494fbe36e4a74776f71c212b00cce61fbf81)
-rw-r--r--source3/smbd/reply.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index c069bd28b9..a7804d3f43 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3795,6 +3795,7 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
NTSTATUS status;
BOOL bad_path = False;
SMB_STRUCT_STAT sbuf;
+ files_struct *fsp;
START_PROFILE(SMBmkdir);
@@ -3808,17 +3809,17 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
unix_convert(directory,conn,0,&bad_path,&sbuf);
- if( is_ntfs_stream_name(directory)) {
- DEBUG(5,("reply_mkdir: failing create on filename %s with colon in name\n", directory));
- END_PROFILE(SMBmkdir);
- return ERROR_NT(NT_STATUS_NOT_A_DIRECTORY);
- }
+ status = open_directory(conn, directory, &sbuf,
+ FILE_READ_ATTRIBUTES, /* Just a stat open */
+ FILE_SHARE_NONE, /* Ignored for stat opens */
+ FILE_CREATE, 0, NULL, &fsp);
+
+ DEBUG(1, ("open_directory returned %s\n", nt_errstr(status)));
- status = mkdir_internal(conn, directory,bad_path);
if (!NT_STATUS_IS_OK(status)) {
- if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION) &&
- !use_nt_status()) {
+ if (NT_STATUS_EQUAL(
+ status, NT_STATUS_DOS(ERRDOS, ERRfilexists))) {
/*
* Yes, in the DOS error code case we get a
* ERRDOS:ERRnoaccess here. See BASE-SAMBA3ERROR
@@ -3831,23 +3832,7 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
return ERROR_NT(status);
}
- if (lp_inherit_owner(SNUM(conn))) {
- /* Ensure we're checking for a symlink here.... */
- /* We don't want to get caught by a symlink racer. */
-
- if(SMB_VFS_LSTAT(conn,directory, &sbuf) != 0) {
- END_PROFILE(SMBmkdir);
- return(UNIXERROR(ERRDOS,ERRnoaccess));
- }
-
- if(!S_ISDIR(sbuf.st_mode)) {
- DEBUG(0,("reply_mkdir: %s is not a directory !\n", directory ));
- END_PROFILE(SMBmkdir);
- return(UNIXERROR(ERRDOS,ERRnoaccess));
- }
-
- change_owner_to_parent(conn, NULL, directory, &sbuf);
- }
+ close_file(fsp, NORMAL_CLOSE);
outsize = set_message(outbuf,0,0,False);