diff options
author | Jeremy Allison <jra@samba.org> | 2004-02-28 01:53:19 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2004-02-28 01:53:19 +0000 |
commit | a51129c4740cc4795440c193a99cedf844531462 (patch) | |
tree | 39ea8e843b85c915e29cd2e9600c53863b3c2a1d | |
parent | cff0114f2b5965cfc49f39061305ff23fa4f3931 (diff) | |
download | samba-a51129c4740cc4795440c193a99cedf844531462.tar.gz samba-a51129c4740cc4795440c193a99cedf844531462.tar.bz2 samba-a51129c4740cc4795440c193a99cedf844531462.zip |
Can't set allocation size on directories, return correct error code on
fail if file exists and target is a directory. gentest.
Jeremy.
(This used to be commit 4b1262322995c8794cd73d84712f82d8c91abdc6)
-rw-r--r-- | source3/libsmb/errormap.c | 1 | ||||
-rw-r--r-- | source3/smbd/nttrans.c | 12 | ||||
-rw-r--r-- | source3/smbd/open.c | 6 |
3 files changed, 18 insertions, 1 deletions
diff --git a/source3/libsmb/errormap.c b/source3/libsmb/errormap.c index 116d2cefe1..aeb68b6596 100644 --- a/source3/libsmb/errormap.c +++ b/source3/libsmb/errormap.c @@ -1503,6 +1503,7 @@ const struct unix_error_map unix_dos_nt_errmap[] = { { EMFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES }, { ENOSPC, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, { ENOMEM, ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY }, + { EISDIR, ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY}, #ifdef EDQUOT { EDQUOT, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, #endif diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index a8a314c876..1afcf0af63 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -896,6 +896,12 @@ create_options = 0x%x root_dir_fid = 0x%x\n", flags, desired_access, file_attrib #endif if (allocation_size && (allocation_size > (SMB_BIG_UINT)file_len)) { fsp->initial_allocation_size = SMB_ROUNDUP(allocation_size,SMB_ROUNDUP_ALLOCATION_SIZE); + if (fsp->is_directory) { + close_file(fsp,False); + END_PROFILE(SMBntcreateX); + /* Can't set allocation size on a directory. */ + return ERROR_NT(NT_STATUS_ACCESS_DENIED); + } if (vfs_allocate_file_space(fsp, fsp->initial_allocation_size) == -1) { close_file(fsp,False); END_PROFILE(SMBntcreateX); @@ -1405,6 +1411,12 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o #endif if (allocation_size && (allocation_size > file_len)) { fsp->initial_allocation_size = SMB_ROUNDUP(allocation_size,SMB_ROUNDUP_ALLOCATION_SIZE); + if (fsp->is_directory) { + close_file(fsp,False); + END_PROFILE(SMBntcreateX); + /* Can't set allocation size on a directory. */ + return ERROR_NT(NT_STATUS_ACCESS_DENIED); + } if (vfs_allocate_file_space(fsp, fsp->initial_allocation_size) == -1) { close_file(fsp,False); return ERROR_NT(NT_STATUS_DISK_FULL); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index dd10a87055..e688f8de48 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -866,7 +866,11 @@ files_struct *open_file_shared1(connection_struct *conn,char *fname, SMB_STRUCT_ DEBUG(5,("open_file_shared: create new requested for file %s and file already exists.\n", fname )); file_free(fsp); - errno = EEXIST; + if (S_ISDIR(psbuf->st_mode)) { + errno = EISDIR; + } else { + errno = EEXIST; + } return NULL; } |