diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/printing/nt_printing.c | 2 | ||||
-rw-r--r-- | source3/smbd/open.c | 50 | ||||
-rw-r--r-- | source3/smbd/reply.c | 50 |
3 files changed, 50 insertions, 52 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 1ff29a67ee..d1d7745d44 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -1800,7 +1800,7 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract DEBUG(5,("Creating first directory\n")); slprintf(new_dir, sizeof(new_dir)-1, "%s/%d", architecture, driver->cversion); driver_unix_convert(new_dir, conn, NULL, &bad_path, &st); - mkdir_internal(conn, new_dir, bad_path); + create_directory(conn, new_dir); /* For each driver file, archi\filexxx.yyy, if there is a duplicate file * listed for this driver which has already been moved, skip it (note: diff --git a/source3/smbd/open.c b/source3/smbd/open.c index dcd1a7a36f..e8536e3335 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1851,6 +1851,30 @@ int close_file_fchmod(files_struct *fsp) return ret; } +static NTSTATUS mkdir_internal(connection_struct *conn, + const pstring directory) +{ + int ret= -1; + + if(!CAN_WRITE(conn)) { + DEBUG(5,("mkdir_internal: failing create on read-only share " + "%s\n", lp_servicename(SNUM(conn)))); + return NT_STATUS_ACCESS_DENIED; + } + + if (!check_name(directory, conn)) { + return map_nt_error_from_unix(errno); + } + + ret = vfs_MkDir(conn,directory,unix_mode(conn,aDIR,directory,True)); + + if (ret == -1) { + return map_nt_error_from_unix(errno); + } + + return NT_STATUS_OK; +} + /**************************************************************************** Open a directory from an NT SMB call. ****************************************************************************/ @@ -1899,7 +1923,7 @@ NTSTATUS open_directory(connection_struct *conn, /* If directory exists error. If directory doesn't * exist create. */ - status = mkdir_internal(conn, fname, False); + status = mkdir_internal(conn, fname); if (!NT_STATUS_IS_OK(status)) { DEBUG(2, ("open_directory: unable to create " "%s. Error was %s\n", fname, @@ -1916,7 +1940,7 @@ NTSTATUS open_directory(connection_struct *conn, * exist create. */ - status = mkdir_internal(conn, fname, False); + status = mkdir_internal(conn, fname); if (NT_STATUS_IS_OK(status)) { info = FILE_WAS_CREATED; @@ -1948,7 +1972,7 @@ NTSTATUS open_directory(connection_struct *conn, } if(!S_ISDIR(psbuf->st_mode)) { - DEBUG(0,("open_directory: %s is not a directory !\n", + DEBUG(5,("open_directory: %s is not a directory !\n", fname )); return NT_STATUS_NOT_A_DIRECTORY; } @@ -2037,6 +2061,26 @@ NTSTATUS open_directory(connection_struct *conn, return NT_STATUS_OK; } +NTSTATUS create_directory(connection_struct *conn, const char *directory) +{ + NTSTATUS status; + SMB_STRUCT_STAT sbuf; + files_struct *fsp; + + SET_STAT_INVALID(sbuf); + + 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); + + if (NT_STATUS_IS_OK(status)) { + close_file(fsp, NORMAL_CLOSE); + } + + return status; +} + /**************************************************************************** Open a pseudo-file (no locking checks - a 'stat' open). ****************************************************************************/ diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 282779fcd3..a156409942 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3745,46 +3745,6 @@ int reply_printwrite(connection_struct *conn, char *inbuf,char *outbuf, int dum_ } /**************************************************************************** - The guts of the mkdir command, split out so it may be called by the NT SMB - code. -****************************************************************************/ - -NTSTATUS mkdir_internal(connection_struct *conn, const pstring directory, BOOL bad_path) -{ - int ret= -1; - - if(!CAN_WRITE(conn)) { - DEBUG(5,("mkdir_internal: failing create on read-only share %s\n", lp_servicename(SNUM(conn)))); - return NT_STATUS_ACCESS_DENIED; - } - - if (bad_path) { - return NT_STATUS_OBJECT_PATH_NOT_FOUND; - } - - if (!check_name(directory, conn)) { - if(errno == ENOENT) { - if (bad_path) { - return NT_STATUS_OBJECT_PATH_NOT_FOUND; - } else { - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - } - return map_nt_error_from_unix(errno); - } - - ret = vfs_MkDir(conn,directory,unix_mode(conn,aDIR,directory,True)); - if (ret == -1) { - if(errno == ENOENT) { - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - return map_nt_error_from_unix(errno); - } - - return NT_STATUS_OK; -} - -/**************************************************************************** Reply to a mkdir. ****************************************************************************/ @@ -3795,7 +3755,6 @@ 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); @@ -3809,12 +3768,9 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, unix_convert(directory,conn,0,&bad_path,&sbuf); - 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); + status = create_directory(conn, directory); - DEBUG(1, ("open_directory returned %s\n", nt_errstr(status))); + DEBUG(1, ("create_directory returned %s\n", nt_errstr(status))); if (!NT_STATUS_IS_OK(status)) { @@ -3833,8 +3789,6 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, return ERROR_NT(status); } - close_file(fsp, NORMAL_CLOSE); - outsize = set_message(outbuf,0,0,False); DEBUG( 3, ( "mkdir %s ret=%d\n", directory, outsize ) ); |