summaryrefslogtreecommitdiff
path: root/source3/smbd/trans2.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-03-31 02:12:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:24 -0500
commitb76112f2116c3c08c7656387a4a49ea64915f470 (patch)
treed14c063580b71001458714b62f8554a4dea41c2a /source3/smbd/trans2.c
parentb7c6e71b26b913fda0a4ba4a99eb7ea35657a104 (diff)
downloadsamba-b76112f2116c3c08c7656387a4a49ea64915f470.tar.gz
samba-b76112f2116c3c08c7656387a4a49ea64915f470.tar.bz2
samba-b76112f2116c3c08c7656387a4a49ea64915f470.zip
r6146: Added OS/2 EA support in trans2_open and trans2_mkdir. Fixed in nttrans_create.
Jeremy. (This used to be commit 989fcb4c084c63f1e3b114af68ef5bc0a2fbc09e)
Diffstat (limited to 'source3/smbd/trans2.c')
-rw-r--r--source3/smbd/trans2.c95
1 files changed, 90 insertions, 5 deletions
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 1ae013d23a..a68b165cb0 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -710,6 +710,7 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
unsigned int max_data_bytes)
{
char *params = *pparams;
+ char *pdata = *ppdata;
int16 open_mode;
int16 open_attr;
BOOL oplock_request;
@@ -729,6 +730,8 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
int smb_action = 0;
BOOL bad_path = False;
files_struct *fsp;
+ TALLOC_CTX *ctx = NULL;
+ struct ea_list *ea_list = NULL;
NTSTATUS status;
/*
@@ -759,7 +762,7 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
return ERROR_NT(status);
}
- DEBUG(3,("trans2open %s mode=%d attr=%d ofun=%d size=%d\n",
+ DEBUG(3,("call_trans2open %s mode=%d attr=%d ofun=%d size=%d\n",
fname,open_mode, open_attr, open_ofun, open_size));
/* XXXX we need to handle passed times, sattr and flags */
@@ -773,10 +776,38 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRnoaccess);
}
+ /* Any data in this call is an EA list. */
+ if (total_data && !lp_ea_support(SNUM(conn))) {
+ return ERROR_NT(NT_STATUS_EAS_NOT_SUPPORTED);
+ }
+
+ if (total_data) {
+ if (total_data < 10) {
+ return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (IVAL(pdata,0) > total_data) {
+ DEBUG(10,("call_trans2open: bad total data size (%u) > %u\n",
+ IVAL(pdata,0), (unsigned int)total_data));
+ return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
+ }
+
+ ctx = talloc_init("TRANS2_OPEN_SET_EA");
+ if (!ctx) {
+ return ERROR_NT(NT_STATUS_NO_MEMORY);
+ }
+ ea_list = read_ea_list(ctx, pdata + 4, total_data - 4);
+ if (!ea_list) {
+ talloc_destroy(ctx);
+ return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
+ }
+ }
+
fsp = open_file_shared(conn,fname,&sbuf,open_mode,open_ofun,(uint32)open_attr,
oplock_request, &rmode,&smb_action);
if (!fsp) {
+ talloc_destroy(ctx);
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
/* We have re-scheduled this call. */
clear_cached_errors();
@@ -790,10 +821,20 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
mtime = sbuf.st_mtime;
inode = sbuf.st_ino;
if (fmode & aDIR) {
+ talloc_destroy(ctx);
close_file(fsp,False);
return(ERROR_DOS(ERRDOS,ERRnoaccess));
}
+ if (total_data && smb_action == FILE_WAS_CREATED) {
+ status = set_ea(conn, fsp, fname, ea_list);
+ talloc_destroy(ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ close_file(fsp,False);
+ return ERROR_NT(status);
+ }
+ }
+
/* Realloc the size of parameters and data we will return */
params = SMB_REALLOC(*pparams, 28);
if( params == NULL ) {
@@ -3670,7 +3711,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
status = set_ea(conn, fsp, fname, ea_list);
talloc_destroy(ctx);
- if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_OK)) {
+ if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}
break;
@@ -3853,13 +3894,15 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
status = set_delete_on_close_internal(fsp, delete_on_close, dosmode);
- if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_OK))
+ if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
+ }
/* The set is across all open files on this dev/inode pair. */
status =set_delete_on_close_over_all(fsp, delete_on_close);
- if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_OK))
+ if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
+ }
break;
}
@@ -4371,11 +4414,14 @@ static int call_trans2mkdir(connection_struct *conn, char *inbuf, char *outbuf,
unsigned int max_data_bytes)
{
char *params = *pparams;
+ char *pdata = *ppdata;
pstring directory;
int ret = -1;
SMB_STRUCT_STAT sbuf;
BOOL bad_path = False;
NTSTATUS status = NT_STATUS_OK;
+ TALLOC_CTX *ctx = NULL;
+ struct ea_list *ea_list = NULL;
if (!CAN_WRITE(conn))
return ERROR_DOS(ERRSRV,ERRaccess);
@@ -4395,14 +4441,53 @@ static int call_trans2mkdir(connection_struct *conn, char *inbuf, char *outbuf,
if (bad_path) {
return ERROR_NT(NT_STATUS_OBJECT_PATH_NOT_FOUND);
}
- if (check_name(directory,conn))
+
+ /* Any data in this call is an EA list. */
+ if (total_data && !lp_ea_support(SNUM(conn))) {
+ return ERROR_NT(NT_STATUS_EAS_NOT_SUPPORTED);
+ }
+
+ if (total_data) {
+ if (total_data < 10) {
+ return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (IVAL(pdata,0) > total_data) {
+ DEBUG(10,("call_trans2mkdir: bad total data size (%u) > %u\n",
+ IVAL(pdata,0), (unsigned int)total_data));
+ return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
+ }
+
+ ctx = talloc_init("TRANS2_MKDIR_SET_EA");
+ if (!ctx) {
+ return ERROR_NT(NT_STATUS_NO_MEMORY);
+ }
+ ea_list = read_ea_list(ctx, pdata + 4, total_data - 4);
+ if (!ea_list) {
+ talloc_destroy(ctx);
+ return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
+ }
+ }
+
+ if (check_name(directory,conn)) {
ret = vfs_MkDir(conn,directory,unix_mode(conn,aDIR,directory,True));
+ }
if(ret < 0) {
+ talloc_destroy(ctx);
DEBUG(5,("call_trans2mkdir error (%s)\n", strerror(errno)));
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRnoaccess);
}
+ /* Try and set any given EA. */
+ if (total_data) {
+ status = set_ea(conn, NULL, directory, ea_list);
+ talloc_destroy(ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ERROR_NT(status);
+ }
+ }
+
/* Realloc the parameter and data sizes */
params = SMB_REALLOC(*pparams,2);
if(params == NULL) {