From c3effa8b599a6a0a2fe05487edc3a0d13e83d427 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Aug 1998 13:11:34 +0000 Subject: this completes the splitup of server.c. the splitup was done with an axe, not a scalpel, so there are some rough edges. I mostly wanted to get the general form right with fine tuning of what goes where to come later. Still, this is better than what we had before where server.c was a general repository for anything that didn't fit elsewhere. (This used to be commit a6d194886a4a5f7507fa37289ff96c1be56f14a6) --- source3/smbd/error.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 source3/smbd/error.c (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c new file mode 100644 index 0000000000..ea23d8b28d --- /dev/null +++ b/source3/smbd/error.c @@ -0,0 +1,142 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + error packet handling + Copyright (C) Andrew Tridgell 1992-1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +extern int DEBUGLEVEL; + + +/**************************************************************************** + create an error packet from a cached error. +****************************************************************************/ +int cached_error_packet(char *inbuf,char *outbuf,files_struct *fsp,int line) +{ + write_bmpx_struct *wbmpx = fsp->wbmpx_ptr; + + int32 eclass = wbmpx->wr_errclass; + int32 err = wbmpx->wr_error; + + /* We can now delete the auxiliary struct */ + free((char *)wbmpx); + fsp->wbmpx_ptr = NULL; + return error_packet(inbuf,outbuf,eclass,err,line); +} + + +struct +{ + int unixerror; + int smbclass; + int smbcode; +} unix_smb_errmap[] = +{ + {EPERM,ERRDOS,ERRnoaccess}, + {EACCES,ERRDOS,ERRnoaccess}, + {ENOENT,ERRDOS,ERRbadfile}, + {ENOTDIR,ERRDOS,ERRbadpath}, + {EIO,ERRHRD,ERRgeneral}, + {EBADF,ERRSRV,ERRsrverror}, + {EINVAL,ERRSRV,ERRsrverror}, + {EEXIST,ERRDOS,ERRfilexists}, + {ENFILE,ERRDOS,ERRnofids}, + {EMFILE,ERRDOS,ERRnofids}, + {ENOSPC,ERRHRD,ERRdiskfull}, +#ifdef EDQUOT + {EDQUOT,ERRHRD,ERRdiskfull}, +#endif +#ifdef ENOTEMPTY + {ENOTEMPTY,ERRDOS,ERRnoaccess}, +#endif +#ifdef EXDEV + {EXDEV,ERRDOS,ERRdiffdevice}, +#endif + {EROFS,ERRHRD,ERRnowrite}, + {0,0,0} +}; + +/**************************************************************************** + create an error packet from errno +****************************************************************************/ +int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line) +{ + int eclass=def_class; + int ecode=def_code; + int i=0; + + if (unix_ERR_class != SMB_SUCCESS) + { + eclass = unix_ERR_class; + ecode = unix_ERR_code; + unix_ERR_class = SMB_SUCCESS; + unix_ERR_code = 0; + } + else + { + while (unix_smb_errmap[i].smbclass != 0) + { + if (unix_smb_errmap[i].unixerror == errno) + { + eclass = unix_smb_errmap[i].smbclass; + ecode = unix_smb_errmap[i].smbcode; + break; + } + i++; + } + } + + return(error_packet(inbuf,outbuf,eclass,ecode,line)); +} + + +/**************************************************************************** + create an error packet. Normally called using the ERROR() macro +****************************************************************************/ +int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int line) +{ + int outsize = set_message(outbuf,0,0,True); + int cmd = CVAL(inbuf,smb_com); + int flgs2 = SVAL(outbuf,smb_flg2); + + if ((flgs2 & FLAGS2_32_BIT_ERROR_CODES) == FLAGS2_32_BIT_ERROR_CODES) + { + SIVAL(outbuf,smb_rcls,error_code); + + DEBUG( 3, ( "32 bit error packet at line %d cmd=%d (%s) eclass=%08x [%s]\n", + line, cmd, smb_fn_name(cmd), error_code, smb_errstr(outbuf) ) ); + } + else + { + CVAL(outbuf,smb_rcls) = error_class; + SSVAL(outbuf,smb_err,error_code); + DEBUG( 3, ( "error packet at line %d cmd=%d (%s) eclass=%d ecode=%d\n", + line, + (int)CVAL(inbuf,smb_com), + smb_fn_name(CVAL(inbuf,smb_com)), + error_class, + error_code ) ); + + } + + if (errno != 0) + DEBUG(3,("error string = %s\n",strerror(errno))); + + return(outsize); +} -- cgit From dd2e202e5c8d6220e29becb48fde333fa5258794 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Aug 1998 13:44:05 +0000 Subject: move soem variables from server.c that don't belong there. (This used to be commit f92475aa3cb3ade576c39c02c7996c949c42082a) --- source3/smbd/error.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index ea23d8b28d..d879f9a93c 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -23,6 +23,10 @@ extern int DEBUGLEVEL; +/* these can be set by some functions to override the error codes */ +int unix_ERR_class=SMB_SUCCESS; +int unix_ERR_code=0; + /**************************************************************************** create an error packet from a cached error. -- cgit From 49a0e6d5989656c1b3c9c063a20308ca4ee5d73b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 10 May 2000 10:41:59 +0000 Subject: more merging voodoo this adds "#define OLD_NTDOMAIN 1" in lots of places. Don't panic - this isn't permanent, it should go after another few merge steps have been done (This used to be commit 92109d7b3c06f240452d39f669ecb8c9c86ab610) --- source3/smbd/error.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index d879f9a93c..49da44d68e 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -1,3 +1,5 @@ +#define OLD_NTDOMAIN 1 + /* Unix SMB/Netbios implementation. Version 1.9. @@ -144,3 +146,5 @@ int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int return(outsize); } + +#undef OLD_NTDOMAIN -- cgit From da3053048c3d224a20d6383ac6682d31059cd46c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 11 Mar 2001 00:32:10 +0000 Subject: Merge of new 2.2 code into HEAD (Gerald I hate you :-) :-). Allows new SAMR RPC code to merge with new passdb code. Currently rpcclient doesn't compile. I'm working on it... Jeremy. (This used to be commit 0be41d5158ea4e645e93e8cd30617c038416e549) --- source3/smbd/error.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 49da44d68e..d879f9a93c 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -1,5 +1,3 @@ -#define OLD_NTDOMAIN 1 - /* Unix SMB/Netbios implementation. Version 1.9. @@ -146,5 +144,3 @@ int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int return(outsize); } - -#undef OLD_NTDOMAIN -- cgit From fab898f9cd06d136efbd2f1de047c744bdd1fd07 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 26 Mar 2001 22:20:43 +0000 Subject: Patch from Sean.Batt@anu.edu.au to ensure error reporting is done before any code that could modify errno is called. Jeremy. (This used to be commit 109a174de9e23ccc89ae17d6b5b425b5947c8565) --- source3/smbd/error.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index d879f9a93c..472a8d8fd1 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -119,6 +119,9 @@ int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int int cmd = CVAL(inbuf,smb_com); int flgs2 = SVAL(outbuf,smb_flg2); + if (errno != 0) + DEBUG(3,("error string = %s\n",strerror(errno))); + if ((flgs2 & FLAGS2_32_BIT_ERROR_CODES) == FLAGS2_32_BIT_ERROR_CODES) { SIVAL(outbuf,smb_rcls,error_code); @@ -139,8 +142,5 @@ int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int } - if (errno != 0) - DEBUG(3,("error string = %s\n",strerror(errno))); - return(outsize); } -- cgit From e8e98c9ea0690e3acf1126b50882e59e1056c7b3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Aug 2001 08:19:43 +0000 Subject: converted smbd to use NTSTATUS by default major changes include: - added NSTATUS type - added automatic mapping between dos and nt error codes - changed all ERROR() calls to ERROR_DOS() and many to ERROR_NT() these calls auto-translate to the client error code system - got rid of the cached error code and the writebmpx code We eventually will need to also: - get rid of BOOL, so we don't lose error info - replace all ERROR_DOS() calls with ERROR_NT() calls but that is too much for one night (This used to be commit 83d9896c1ea8be796192b51a4678c2a3b87f7518) --- source3/smbd/error.c | 129 +++++++++++++++++++++++---------------------------- 1 file changed, 58 insertions(+), 71 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 472a8d8fd1..27dacda377 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -28,23 +28,6 @@ int unix_ERR_class=SMB_SUCCESS; int unix_ERR_code=0; -/**************************************************************************** - create an error packet from a cached error. -****************************************************************************/ -int cached_error_packet(char *inbuf,char *outbuf,files_struct *fsp,int line) -{ - write_bmpx_struct *wbmpx = fsp->wbmpx_ptr; - - int32 eclass = wbmpx->wr_errclass; - int32 err = wbmpx->wr_error; - - /* We can now delete the auxiliary struct */ - free((char *)wbmpx); - fsp->wbmpx_ptr = NULL; - return error_packet(inbuf,outbuf,eclass,err,line); -} - - struct { int unixerror; @@ -79,68 +62,72 @@ struct /**************************************************************************** create an error packet from errno ****************************************************************************/ -int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line) +int unix_error_packet(char *outbuf,int def_class,uint32 def_code,int line) { - int eclass=def_class; - int ecode=def_code; - int i=0; - - if (unix_ERR_class != SMB_SUCCESS) - { - eclass = unix_ERR_class; - ecode = unix_ERR_code; - unix_ERR_class = SMB_SUCCESS; - unix_ERR_code = 0; - } - else - { - while (unix_smb_errmap[i].smbclass != 0) - { - if (unix_smb_errmap[i].unixerror == errno) - { - eclass = unix_smb_errmap[i].smbclass; - ecode = unix_smb_errmap[i].smbcode; - break; - } - i++; - } - } - - return(error_packet(inbuf,outbuf,eclass,ecode,line)); + int eclass=def_class; + int ecode=def_code; + int i=0; + + if (unix_ERR_class != SMB_SUCCESS) { + eclass = unix_ERR_class; + ecode = unix_ERR_code; + unix_ERR_class = SMB_SUCCESS; + unix_ERR_code = 0; + } else { + while (unix_smb_errmap[i].smbclass != 0) { + if (unix_smb_errmap[i].unixerror == errno) { + eclass = unix_smb_errmap[i].smbclass; + ecode = unix_smb_errmap[i].smbcode; + break; + } + i++; + } + } + + return error_packet(outbuf,0,eclass,ecode,line); } /**************************************************************************** create an error packet. Normally called using the ERROR() macro ****************************************************************************/ -int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int line) +int error_packet(char *outbuf,uint32 ntstatus, + uint8 eclass,uint32 ecode,int line) { - int outsize = set_message(outbuf,0,0,True); - int cmd = CVAL(inbuf,smb_com); - int flgs2 = SVAL(outbuf,smb_flg2); - - if (errno != 0) - DEBUG(3,("error string = %s\n",strerror(errno))); - - if ((flgs2 & FLAGS2_32_BIT_ERROR_CODES) == FLAGS2_32_BIT_ERROR_CODES) - { - SIVAL(outbuf,smb_rcls,error_code); - - DEBUG( 3, ( "32 bit error packet at line %d cmd=%d (%s) eclass=%08x [%s]\n", - line, cmd, smb_fn_name(cmd), error_code, smb_errstr(outbuf) ) ); - } - else - { - CVAL(outbuf,smb_rcls) = error_class; - SSVAL(outbuf,smb_err,error_code); - DEBUG( 3, ( "error packet at line %d cmd=%d (%s) eclass=%d ecode=%d\n", - line, - (int)CVAL(inbuf,smb_com), - smb_fn_name(CVAL(inbuf,smb_com)), - error_class, - error_code ) ); + int outsize = set_message(outbuf,0,0,True); + extern uint32 global_client_caps; - } + if (errno != 0) + DEBUG(3,("error string = %s\n",strerror(errno))); - return(outsize); + if (global_client_caps & CAP_STATUS32) { + if (ntstatus == 0 && eclass) { + ntstatus = dos_to_ntstatus(eclass, ecode); + } + SIVAL(outbuf,smb_rcls,ntstatus); + SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES); + DEBUG(3,("error packet at line %d cmd=%d (%s) %s\n", + line, + (int)CVAL(outbuf,smb_com), + smb_fn_name(CVAL(outbuf,smb_com)), + get_nt_error_msg(ntstatus))); + return outsize; + } + + if (eclass == 0 && ntstatus) { + ntstatus_to_dos(ntstatus, &eclass, &ecode); + } + + SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)&~FLAGS2_32_BIT_ERROR_CODES); + SVAL(outbuf,smb_rcls) = eclass; + SSVAL(outbuf,smb_err,ecode); + + DEBUG(3,("error packet at line %d cmd=%d (%s) eclass=%d ecode=%d\n", + line, + (int)CVAL(outbuf,smb_com), + smb_fn_name(CVAL(outbuf,smb_com)), + eclass, + ecode)); + + return outsize; } -- cgit From ee5f7237decfe446f4fdb08422beb2e6cb43af7f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Aug 2001 17:52:23 +0000 Subject: started converting NTSTATUS to be a structure on systems with gcc in order to make it type incompatible with BOOL so we catch errors sooner. This has already found a number of bugs (This used to be commit 1b778bc7d22efff3f90dc450eb12baa1241cf68f) --- source3/smbd/error.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 27dacda377..f2613dc3a8 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -84,14 +84,14 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code,int line) } } - return error_packet(outbuf,0,eclass,ecode,line); + return error_packet(outbuf,NT_STATUS_OK,eclass,ecode,line); } /**************************************************************************** create an error packet. Normally called using the ERROR() macro ****************************************************************************/ -int error_packet(char *outbuf,uint32 ntstatus, +int error_packet(char *outbuf,NTSTATUS ntstatus, uint8 eclass,uint32 ecode,int line) { int outsize = set_message(outbuf,0,0,True); @@ -101,10 +101,10 @@ int error_packet(char *outbuf,uint32 ntstatus, DEBUG(3,("error string = %s\n",strerror(errno))); if (global_client_caps & CAP_STATUS32) { - if (ntstatus == 0 && eclass) { + if (NT_STATUS_V(ntstatus) == 0 && eclass) { ntstatus = dos_to_ntstatus(eclass, ecode); } - SIVAL(outbuf,smb_rcls,ntstatus); + SIVAL(outbuf,smb_rcls,NT_STATUS_V(ntstatus)); SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES); DEBUG(3,("error packet at line %d cmd=%d (%s) %s\n", line, @@ -114,7 +114,7 @@ int error_packet(char *outbuf,uint32 ntstatus, return outsize; } - if (eclass == 0 && ntstatus) { + if (eclass == 0 && NT_STATUS_V(ntstatus)) { ntstatus_to_dos(ntstatus, &eclass, &ecode); } -- cgit From b031af348c7dcc8c74bf49945211c466b8eca079 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Aug 2001 19:46:22 +0000 Subject: converted another bunch of stuff to NTSTATUS (This used to be commit 1d36250e338ae0ff9fbbf86019809205dd97d05e) --- source3/smbd/error.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index f2613dc3a8..a74b62de01 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -84,7 +84,7 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code,int line) } } - return error_packet(outbuf,NT_STATUS_OK,eclass,ecode,line); + return error_packet(outbuf,NT_STATUS(0),eclass,ecode,line); } @@ -119,7 +119,7 @@ int error_packet(char *outbuf,NTSTATUS ntstatus, } SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)&~FLAGS2_32_BIT_ERROR_CODES); - SVAL(outbuf,smb_rcls) = eclass; + SSVAL(outbuf,smb_rcls,eclass); SSVAL(outbuf,smb_err,ecode); DEBUG(3,("error packet at line %d cmd=%d (%s) eclass=%d ecode=%d\n", -- cgit From 19fea3242cf6234786b6cbb60631e0071f31ff9f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 4 Sep 2001 07:13:01 +0000 Subject: the next stage in the NTSTATUS/WERROR change. smbd and nmbd now compile, but the client code still needs some work (This used to be commit dcd6e735f709a9231860ceb9682db40ff26c9a66) --- source3/smbd/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index a74b62de01..6b5a4b27b1 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -84,7 +84,7 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code,int line) } } - return error_packet(outbuf,NT_STATUS(0),eclass,ecode,line); + return error_packet(outbuf,NT_STATUS_OK,eclass,ecode,line); } -- cgit From 851a06e1fd6ac0d921f96fe9e9529129b4b4c01d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 5 Sep 2001 10:18:58 +0000 Subject: added filename to error_packet() (This used to be commit 2c424788dec2fd6e44c243ea115d66689dfae6c0) --- source3/smbd/error.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 6b5a4b27b1..17606c62be 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -62,7 +62,8 @@ struct /**************************************************************************** create an error packet from errno ****************************************************************************/ -int unix_error_packet(char *outbuf,int def_class,uint32 def_code,int line) +int unix_error_packet(char *outbuf,int def_class,uint32 def_code, + int line, const char *file) { int eclass=def_class; int ecode=def_code; @@ -84,7 +85,7 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code,int line) } } - return error_packet(outbuf,NT_STATUS_OK,eclass,ecode,line); + return error_packet(outbuf,NT_STATUS_OK,eclass,ecode,line,file); } @@ -92,7 +93,7 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code,int line) create an error packet. Normally called using the ERROR() macro ****************************************************************************/ int error_packet(char *outbuf,NTSTATUS ntstatus, - uint8 eclass,uint32 ecode,int line) + uint8 eclass,uint32 ecode,int line, const char *file) { int outsize = set_message(outbuf,0,0,True); extern uint32 global_client_caps; @@ -106,8 +107,8 @@ int error_packet(char *outbuf,NTSTATUS ntstatus, } SIVAL(outbuf,smb_rcls,NT_STATUS_V(ntstatus)); SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES); - DEBUG(3,("error packet at line %d cmd=%d (%s) %s\n", - line, + DEBUG(3,("error packet at %s(%d) cmd=%d (%s) %s\n", + file, line, (int)CVAL(outbuf,smb_com), smb_fn_name(CVAL(outbuf,smb_com)), get_nt_error_msg(ntstatus))); @@ -122,8 +123,8 @@ int error_packet(char *outbuf,NTSTATUS ntstatus, SSVAL(outbuf,smb_rcls,eclass); SSVAL(outbuf,smb_err,ecode); - DEBUG(3,("error packet at line %d cmd=%d (%s) eclass=%d ecode=%d\n", - line, + DEBUG(3,("error packet at %s(%d) cmd=%d (%s) eclass=%d ecode=%d\n", + file, line, (int)CVAL(outbuf,smb_com), smb_fn_name(CVAL(outbuf,smb_com)), eclass, -- cgit From dc1fc3ee8ec2199bc73bb5d7ec711c6800f61d65 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Oct 2001 04:29:50 +0000 Subject: Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header. (This used to be commit 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e) --- source3/smbd/error.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 17606c62be..913f2ac266 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -21,8 +21,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /* these can be set by some functions to override the error codes */ int unix_ERR_class=SMB_SUCCESS; int unix_ERR_code=0; -- cgit From 6cc3953196e3feb340f7b9b7bb823575414c5683 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 19 Oct 2001 00:56:03 +0000 Subject: Restored old Bmpx code - actually used by OS/2. Jeremy. (This used to be commit 7c1688fd67c1bda1477aaf870371c825280db870) --- source3/smbd/error.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 913f2ac266..3c829deb09 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -25,6 +25,22 @@ int unix_ERR_class=SMB_SUCCESS; int unix_ERR_code=0; +/**************************************************************************** + Create an error packet from a cached error. +****************************************************************************/ + +int cached_error_packet(char *outbuf,files_struct *fsp,int line,const char *file) +{ + write_bmpx_struct *wbmpx = fsp->wbmpx_ptr; + + int32 eclass = wbmpx->wr_errclass; + int32 err = wbmpx->wr_error; + + /* We can now delete the auxiliary struct */ + free((char *)wbmpx); + fsp->wbmpx_ptr = NULL; + return error_packet(outbuf,NT_STATUS_OK,eclass,err,line,file); +} struct { -- cgit From 04ec469c72c6a220108312cdec3d30081cfe938a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 16 Jan 2002 21:27:57 +0000 Subject: Fixup error mapping so we have only one table containing errno -> dos error -> NT STATUS maps. Fixes problem with disk full returning incorrect error. Jeremy. (This used to be commit 16fcbf3c1ccf1d704765653f68395dd596c0d841) --- source3/smbd/error.c | 52 ++++++++++++++-------------------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 3c829deb09..fc26aa4ded 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -25,6 +25,9 @@ int unix_ERR_class=SMB_SUCCESS; int unix_ERR_code=0; +/* From lib/error.c */ +extern struct unix_error_map unix_dos_nt_errmap[]; + /**************************************************************************** Create an error packet from a cached error. ****************************************************************************/ @@ -42,45 +45,16 @@ int cached_error_packet(char *outbuf,files_struct *fsp,int line,const char *file return error_packet(outbuf,NT_STATUS_OK,eclass,err,line,file); } -struct -{ - int unixerror; - int smbclass; - int smbcode; -} unix_smb_errmap[] = -{ - {EPERM,ERRDOS,ERRnoaccess}, - {EACCES,ERRDOS,ERRnoaccess}, - {ENOENT,ERRDOS,ERRbadfile}, - {ENOTDIR,ERRDOS,ERRbadpath}, - {EIO,ERRHRD,ERRgeneral}, - {EBADF,ERRSRV,ERRsrverror}, - {EINVAL,ERRSRV,ERRsrverror}, - {EEXIST,ERRDOS,ERRfilexists}, - {ENFILE,ERRDOS,ERRnofids}, - {EMFILE,ERRDOS,ERRnofids}, - {ENOSPC,ERRHRD,ERRdiskfull}, -#ifdef EDQUOT - {EDQUOT,ERRHRD,ERRdiskfull}, -#endif -#ifdef ENOTEMPTY - {ENOTEMPTY,ERRDOS,ERRnoaccess}, -#endif -#ifdef EXDEV - {EXDEV,ERRDOS,ERRdiffdevice}, -#endif - {EROFS,ERRHRD,ERRnowrite}, - {0,0,0} -}; - /**************************************************************************** - create an error packet from errno + Create an error packet from errno. ****************************************************************************/ + int unix_error_packet(char *outbuf,int def_class,uint32 def_code, int line, const char *file) { int eclass=def_class; int ecode=def_code; + NTSTATUS ntstatus = NT_STATUS_OK; int i=0; if (unix_ERR_class != SMB_SUCCESS) { @@ -89,23 +63,25 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code, unix_ERR_class = SMB_SUCCESS; unix_ERR_code = 0; } else { - while (unix_smb_errmap[i].smbclass != 0) { - if (unix_smb_errmap[i].unixerror == errno) { - eclass = unix_smb_errmap[i].smbclass; - ecode = unix_smb_errmap[i].smbcode; + while (unix_dos_nt_errmap[i].dos_class != 0) { + if (unix_dos_nt_errmap[i].unix_error == errno) { + eclass = unix_dos_nt_errmap[i].dos_class; + ecode = unix_dos_nt_errmap[i].dos_code; + ntstatus = unix_dos_nt_errmap[i].nt_error; break; } i++; } } - return error_packet(outbuf,NT_STATUS_OK,eclass,ecode,line,file); + return error_packet(outbuf,ntstatus,eclass,ecode,line,file); } /**************************************************************************** - create an error packet. Normally called using the ERROR() macro + Create an error packet. Normally called using the ERROR() macro. ****************************************************************************/ + int error_packet(char *outbuf,NTSTATUS ntstatus, uint8 eclass,uint32 ecode,int line, const char *file) { -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/smbd/error.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index fc26aa4ded..6b3b73aa87 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 1.9. + Unix SMB/CIFS implementation. error packet handling Copyright (C) Andrew Tridgell 1992-1998 -- cgit From 2da4d64cfcf289d18d622c67d3250c51e6b88466 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 Feb 2002 21:46:53 +0000 Subject: Added "nt status support" parameter. Fix offline synchronisation. Jeremy. (This used to be commit 9243a9778e52999d5c62cba484640637b24994d8) --- source3/smbd/error.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 6b3b73aa87..92a7c11b15 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -90,10 +90,17 @@ int error_packet(char *outbuf,NTSTATUS ntstatus, if (errno != 0) DEBUG(3,("error string = %s\n",strerror(errno))); - if (global_client_caps & CAP_STATUS32) { - if (NT_STATUS_V(ntstatus) == 0 && eclass) { + /* + * We can explicitly force 32 bit error codes even when the + * parameter "nt status" is set to no by pre-setting the + * FLAGS2_32_BIT_ERROR_CODES bit in the smb_flg2 outbuf. + * This is to allow work arounds for client bugs that are needed + * when talking with clients that normally expect nt status codes. JRA. + */ + + if ((lp_nt_status_support() || (SVAL(outbuf,smb_flg2) & FLAGS2_32_BIT_ERROR_CODES)) && (global_client_caps & CAP_STATUS32)) { + if (NT_STATUS_V(ntstatus) == 0 && eclass) ntstatus = dos_to_ntstatus(eclass, ecode); - } SIVAL(outbuf,smb_rcls,NT_STATUS_V(ntstatus)); SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES); DEBUG(3,("error packet at %s(%d) cmd=%d (%s) %s\n", @@ -104,9 +111,8 @@ int error_packet(char *outbuf,NTSTATUS ntstatus, return outsize; } - if (eclass == 0 && NT_STATUS_V(ntstatus)) { + if (eclass == 0 && NT_STATUS_V(ntstatus)) ntstatus_to_dos(ntstatus, &eclass, &ecode); - } SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)&~FLAGS2_32_BIT_ERROR_CODES); SSVAL(outbuf,smb_rcls,eclass); -- cgit From ab13654dc9ac23872e4d1384e1c54e336f113009 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 17 Mar 2002 04:36:35 +0000 Subject: Renamed get_nt_error_msg() to nt_errstr(). (This used to be commit 1f007d3ed41c1b71a89fa6be7d173e67e927c302) --- source3/smbd/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 92a7c11b15..2f993fb41e 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -107,7 +107,7 @@ int error_packet(char *outbuf,NTSTATUS ntstatus, file, line, (int)CVAL(outbuf,smb_com), smb_fn_name(CVAL(outbuf,smb_com)), - get_nt_error_msg(ntstatus))); + nt_errstr(ntstatus))); return outsize; } -- cgit From b51160452eb992fd15bf45b9616a56bae9d16e37 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 5 Nov 2002 21:47:03 +0000 Subject: Fix to correctly return NT_STATUS_DELETE_PENDING. Jeremy. (This used to be commit 4ec381d64249203e0924b86600fe8e67ada1cb5b) --- source3/smbd/error.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 2f993fb41e..9d0e34bf52 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -23,6 +23,7 @@ /* these can be set by some functions to override the error codes */ int unix_ERR_class=SMB_SUCCESS; int unix_ERR_code=0; +NTSTATUS unix_ERR_ntstatus = NT_STATUS_OK; /* From lib/error.c */ extern struct unix_error_map unix_dos_nt_errmap[]; @@ -59,8 +60,10 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code, if (unix_ERR_class != SMB_SUCCESS) { eclass = unix_ERR_class; ecode = unix_ERR_code; + ntstatus = unix_ERR_ntstatus; unix_ERR_class = SMB_SUCCESS; unix_ERR_code = 0; + unix_ERR_ntstatus = NT_STATUS_OK; } else { while (unix_dos_nt_errmap[i].dos_class != 0) { if (unix_dos_nt_errmap[i].unix_error == errno) { -- cgit From c5b34aa7e6fb81068a303fb1b1d2d2b789eeda06 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 2 Oct 2003 00:55:22 +0000 Subject: Fix for not opening Excel 2000 files that are read-only. Needs tidying up but works for now. Jeremy. (This used to be commit 9ad9e0dfafed4558e5ab215991d9912cd44f1127) --- source3/smbd/error.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 9d0e34bf52..7eec5e25df 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -61,9 +61,6 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code, eclass = unix_ERR_class; ecode = unix_ERR_code; ntstatus = unix_ERR_ntstatus; - unix_ERR_class = SMB_SUCCESS; - unix_ERR_code = 0; - unix_ERR_ntstatus = NT_STATUS_OK; } else { while (unix_dos_nt_errmap[i].dos_class != 0) { if (unix_dos_nt_errmap[i].unix_error == errno) { @@ -93,6 +90,10 @@ int error_packet(char *outbuf,NTSTATUS ntstatus, if (errno != 0) DEBUG(3,("error string = %s\n",strerror(errno))); + unix_ERR_class = SMB_SUCCESS; + unix_ERR_code = 0; + unix_ERR_ntstatus = NT_STATUS_OK; + /* * We can explicitly force 32 bit error codes even when the * parameter "nt status" is set to no by pre-setting the -- cgit From b1ca1d9134a159c4d5d15eee3012cdc49f71bdb2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 2 Oct 2003 17:26:42 +0000 Subject: Correct fix for excel read-only bug. Add panic for logic error in developer mode. Jeremy. (This used to be commit f00af98f379463829b1ef62d78dda0365c1d7997) --- source3/smbd/error.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 7eec5e25df..795bf0949c 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -61,6 +61,9 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code, eclass = unix_ERR_class; ecode = unix_ERR_code; ntstatus = unix_ERR_ntstatus; + unix_ERR_class = SMB_SUCCESS; + unix_ERR_code = 0; + unix_ERR_ntstatus = NT_STATUS_OK; } else { while (unix_dos_nt_errmap[i].dos_class != 0) { if (unix_dos_nt_errmap[i].unix_error == errno) { @@ -90,9 +93,10 @@ int error_packet(char *outbuf,NTSTATUS ntstatus, if (errno != 0) DEBUG(3,("error string = %s\n",strerror(errno))); - unix_ERR_class = SMB_SUCCESS; - unix_ERR_code = 0; - unix_ERR_ntstatus = NT_STATUS_OK; +#if defined(DEVELOPER) + if (unix_ERR_class != SMB_SUCCESS || unix_ERR_code != 0 || !NT_STATUS_IS_OK(unix_ERR_ntstatus)) + smb_panic("logic error in error processing"); +#endif /* * We can explicitly force 32 bit error codes even when the -- cgit From 1843f6905caf30de6493de07316a416696394d3e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 4 May 2004 23:01:00 +0000 Subject: r478: Added Volkers fix to be able to force DOS errors when needed. Jeremy. (This used to be commit a9d1738ebab42ab9bab73f18341d79e086e290b3) --- source3/smbd/error.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 795bf0949c..9c81d465e7 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -42,7 +42,7 @@ int cached_error_packet(char *outbuf,files_struct *fsp,int line,const char *file /* We can now delete the auxiliary struct */ free((char *)wbmpx); fsp->wbmpx_ptr = NULL; - return error_packet(outbuf,NT_STATUS_OK,eclass,err,line,file); + return error_packet(outbuf,NT_STATUS_OK,eclass,err,False,line,file); } /**************************************************************************** @@ -76,7 +76,7 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code, } } - return error_packet(outbuf,ntstatus,eclass,ecode,line,file); + return error_packet(outbuf,ntstatus,eclass,ecode,False,line,file); } @@ -85,7 +85,7 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code, ****************************************************************************/ int error_packet(char *outbuf,NTSTATUS ntstatus, - uint8 eclass,uint32 ecode,int line, const char *file) + uint8 eclass,uint32 ecode,BOOL force_dos, int line, const char *file) { int outsize = set_message(outbuf,0,0,True); extern uint32 global_client_caps; @@ -106,7 +106,7 @@ int error_packet(char *outbuf,NTSTATUS ntstatus, * when talking with clients that normally expect nt status codes. JRA. */ - if ((lp_nt_status_support() || (SVAL(outbuf,smb_flg2) & FLAGS2_32_BIT_ERROR_CODES)) && (global_client_caps & CAP_STATUS32)) { + if ((lp_nt_status_support() || (SVAL(outbuf,smb_flg2) & FLAGS2_32_BIT_ERROR_CODES)) && (global_client_caps & CAP_STATUS32) && (!force_dos)) { if (NT_STATUS_V(ntstatus) == 0 && eclass) ntstatus = dos_to_ntstatus(eclass, ecode); SIVAL(outbuf,smb_rcls,NT_STATUS_V(ntstatus)); -- cgit From b28d08cc14bd37c6263ed029a57f390687746bb9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 9 Jun 2004 00:43:43 +0000 Subject: r1093: Ensure we clear any cached errors on a deferred open call so we don't return the wrong error code on the next packet. Jeremy. (This used to be commit c1b06deb574d7b8e746bdf0d6f0eab16848a6cc1) --- source3/smbd/error.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 9c81d465e7..d611e0ef87 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -28,6 +28,17 @@ NTSTATUS unix_ERR_ntstatus = NT_STATUS_OK; /* From lib/error.c */ extern struct unix_error_map unix_dos_nt_errmap[]; +/**************************************************************************** + Ensure we don't have any errors cached. +****************************************************************************/ + +void clear_cached_errors(void) +{ + unix_ERR_class = SMB_SUCCESS; + unix_ERR_code = 0; + unix_ERR_ntstatus = NT_STATUS_OK; +} + /**************************************************************************** Create an error packet from a cached error. ****************************************************************************/ -- cgit From 0557c6cba2a21c9df547fbc8ff4db2899bc1c171 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 1 Apr 2005 23:11:28 +0000 Subject: r6172: Tidy up error processing significantly. Remove unix_ERR_XXX global nastyness. Jeremy. (This used to be commit d3379fe61bb934082b51a37adac232a96bafcf46) --- source3/smbd/error.c | 143 +++++++++++++++++++++++++++++---------------------- 1 file changed, 81 insertions(+), 62 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index d611e0ef87..6988d74f91 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -20,23 +20,43 @@ #include "includes.h" -/* these can be set by some functions to override the error codes */ -int unix_ERR_class=SMB_SUCCESS; -int unix_ERR_code=0; -NTSTATUS unix_ERR_ntstatus = NT_STATUS_OK; - /* From lib/error.c */ extern struct unix_error_map unix_dos_nt_errmap[]; +/* these can be set by some functions to override the error codes */ +static int override_ERR_class; +static int override_ERR_code; +static NTSTATUS override_ERR_ntstatus; + /**************************************************************************** - Ensure we don't have any errors cached. + Setting eclass and ecode only and status to NT_STATUS_INVALID forces DOS errors. + Setting status only and eclass and ecode to -1 forces NT errors. ****************************************************************************/ -void clear_cached_errors(void) +void set_saved_error_triple(int eclass, int ecode, NTSTATUS status) +{ + override_ERR_class = eclass; + override_ERR_code = ecode; + override_ERR_ntstatus = status; +} + +/**************************************************************************** + Return the current settings of the error triple. Return True if any are set. +****************************************************************************/ + +BOOL get_saved_error_triple(int *peclass, int *pecode, NTSTATUS *pstatus) { - unix_ERR_class = SMB_SUCCESS; - unix_ERR_code = 0; - unix_ERR_ntstatus = NT_STATUS_OK; + if (peclass) { + *peclass = override_ERR_class; + } + if (pecode) { + *pecode = override_ERR_code; + } + if (pstatus) { + *pstatus = override_ERR_ntstatus; + } + + return (override_ERR_class || !NT_STATUS_IS_OK(override_ERR_ntstatus)); } /**************************************************************************** @@ -46,36 +66,29 @@ void clear_cached_errors(void) int cached_error_packet(char *outbuf,files_struct *fsp,int line,const char *file) { write_bmpx_struct *wbmpx = fsp->wbmpx_ptr; - int32 eclass = wbmpx->wr_errclass; int32 err = wbmpx->wr_error; + NTSTATUS ntstatus = wbmpx->wr_status; /* We can now delete the auxiliary struct */ - free((char *)wbmpx); - fsp->wbmpx_ptr = NULL; - return error_packet(outbuf,NT_STATUS_OK,eclass,err,False,line,file); + SAFE_FREE(fsp->wbmpx_ptr); + return error_packet(outbuf,eclass,err,ntstatus,line,file); } /**************************************************************************** Create an error packet from errno. ****************************************************************************/ -int unix_error_packet(char *outbuf,int def_class,uint32 def_code, - int line, const char *file) +int unix_error_packet(char *outbuf,int def_class,uint32 def_code, NTSTATUS def_status, int line, const char *file) { int eclass=def_class; int ecode=def_code; - NTSTATUS ntstatus = NT_STATUS_OK; + NTSTATUS ntstatus = def_status; int i=0; - if (unix_ERR_class != SMB_SUCCESS) { - eclass = unix_ERR_class; - ecode = unix_ERR_code; - ntstatus = unix_ERR_ntstatus; - unix_ERR_class = SMB_SUCCESS; - unix_ERR_code = 0; - unix_ERR_ntstatus = NT_STATUS_OK; - } else { + if (errno != 0) { + DEBUG(3,("unix_error_packet: error string = %s\n",strerror(errno))); + while (unix_dos_nt_errmap[i].dos_class != 0) { if (unix_dos_nt_errmap[i].unix_error == errno) { eclass = unix_dos_nt_errmap[i].dos_class; @@ -87,39 +100,44 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code, } } - return error_packet(outbuf,ntstatus,eclass,ecode,False,line,file); + return error_packet(outbuf,eclass,ecode,ntstatus,line,file); } /**************************************************************************** Create an error packet. Normally called using the ERROR() macro. + Setting eclass and ecode only and status to NT_STATUS_OK forces DOS errors. + Setting status only and eclass and ecode to zero forces NT errors. + If the override errors are set they take precedence over any passed in values. ****************************************************************************/ -int error_packet(char *outbuf,NTSTATUS ntstatus, - uint8 eclass,uint32 ecode,BOOL force_dos, int line, const char *file) +int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) { int outsize = set_message(outbuf,0,0,True); extern uint32 global_client_caps; + BOOL force_nt_status = False; + BOOL force_dos_status = False; + + if (override_ERR_class != SMB_SUCCESS || !NT_STATUS_IS_OK(override_ERR_ntstatus)) { + eclass = override_ERR_class; + ecode = override_ERR_code; + ntstatus = override_ERR_ntstatus; + override_ERR_class = SMB_SUCCESS; + override_ERR_code = 0; + override_ERR_ntstatus = NT_STATUS_OK; + } - if (errno != 0) - DEBUG(3,("error string = %s\n",strerror(errno))); - -#if defined(DEVELOPER) - if (unix_ERR_class != SMB_SUCCESS || unix_ERR_code != 0 || !NT_STATUS_IS_OK(unix_ERR_ntstatus)) - smb_panic("logic error in error processing"); -#endif - - /* - * We can explicitly force 32 bit error codes even when the - * parameter "nt status" is set to no by pre-setting the - * FLAGS2_32_BIT_ERROR_CODES bit in the smb_flg2 outbuf. - * This is to allow work arounds for client bugs that are needed - * when talking with clients that normally expect nt status codes. JRA. - */ - - if ((lp_nt_status_support() || (SVAL(outbuf,smb_flg2) & FLAGS2_32_BIT_ERROR_CODES)) && (global_client_caps & CAP_STATUS32) && (!force_dos)) { - if (NT_STATUS_V(ntstatus) == 0 && eclass) + if (eclass == (uint8)-1) { + force_nt_status = True; + } else if (NT_STATUS_IS_INVALID(ntstatus)) { + force_dos_status = True; + } + + if (force_nt_status || (!force_dos_status && lp_nt_status_support() && (global_client_caps & CAP_STATUS32))) { + /* We're returning an NT error. */ + if (NT_STATUS_V(ntstatus) == 0 && eclass) { ntstatus = dos_to_ntstatus(eclass, ecode); + } SIVAL(outbuf,smb_rcls,NT_STATUS_V(ntstatus)); SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES); DEBUG(3,("error packet at %s(%d) cmd=%d (%s) %s\n", @@ -127,22 +145,23 @@ int error_packet(char *outbuf,NTSTATUS ntstatus, (int)CVAL(outbuf,smb_com), smb_fn_name(CVAL(outbuf,smb_com)), nt_errstr(ntstatus))); - return outsize; - } - - if (eclass == 0 && NT_STATUS_V(ntstatus)) - ntstatus_to_dos(ntstatus, &eclass, &ecode); - - SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)&~FLAGS2_32_BIT_ERROR_CODES); - SSVAL(outbuf,smb_rcls,eclass); - SSVAL(outbuf,smb_err,ecode); - - DEBUG(3,("error packet at %s(%d) cmd=%d (%s) eclass=%d ecode=%d\n", - file, line, - (int)CVAL(outbuf,smb_com), - smb_fn_name(CVAL(outbuf,smb_com)), - eclass, - ecode)); + } else { + /* We're returning a DOS error only. */ + if (eclass == 0 && NT_STATUS_V(ntstatus)) { + ntstatus_to_dos(ntstatus, &eclass, &ecode); + } + + SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)&~FLAGS2_32_BIT_ERROR_CODES); + SSVAL(outbuf,smb_rcls,eclass); + SSVAL(outbuf,smb_err,ecode); + + DEBUG(3,("error packet at %s(%d) cmd=%d (%s) eclass=%d ecode=%d\n", + file, line, + (int)CVAL(outbuf,smb_com), + smb_fn_name(CVAL(outbuf,smb_com)), + eclass, + ecode)); + } return outsize; } -- cgit From 978ca8486031e43754a3c23757f361bf3a85f335 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 6 Apr 2005 16:28:04 +0000 Subject: r6225: get rid of warnings from my compiler about nested externs (This used to be commit efea76ac71412f8622cd233912309e91b9ea52da) --- source3/smbd/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 6988d74f91..090a2f6d81 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -23,6 +23,7 @@ /* From lib/error.c */ extern struct unix_error_map unix_dos_nt_errmap[]; +extern uint32 global_client_caps; /* these can be set by some functions to override the error codes */ static int override_ERR_class; static int override_ERR_code; @@ -114,7 +115,6 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code, NTSTATUS def_s int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) { int outsize = set_message(outbuf,0,0,True); - extern uint32 global_client_caps; BOOL force_nt_status = False; BOOL force_dos_status = False; -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/smbd/error.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 090a2f6d81..3cdcae5c7f 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -41,23 +41,22 @@ void set_saved_error_triple(int eclass, int ecode, NTSTATUS status) override_ERR_ntstatus = status; } +void set_saved_ntstatus(NTSTATUS status) +{ + uint8 tmp_eclass; /* Hmmm. override_ERR_class is not uint8... */ + override_ERR_ntstatus = status; + ntstatus_to_dos(status, &tmp_eclass, &override_ERR_code); + override_ERR_class = tmp_eclass; + +} + /**************************************************************************** Return the current settings of the error triple. Return True if any are set. ****************************************************************************/ -BOOL get_saved_error_triple(int *peclass, int *pecode, NTSTATUS *pstatus) +NTSTATUS get_saved_ntstatus(void) { - if (peclass) { - *peclass = override_ERR_class; - } - if (pecode) { - *pecode = override_ERR_code; - } - if (pstatus) { - *pstatus = override_ERR_ntstatus; - } - - return (override_ERR_class || !NT_STATUS_IS_OK(override_ERR_ntstatus)); + return override_ERR_ntstatus; } /**************************************************************************** -- cgit From 8d7c88667190fe286971ac4fffb64ee5bd9eeeb0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Oct 2005 03:24:00 +0000 Subject: r11137: Compile with only 2 warnings (I'm still working on that code) on a gcc4 x86_64 box. Jeremy. (This used to be commit d720867a788c735e56d53d63265255830ec21208) --- source3/smbd/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 3cdcae5c7f..fa236f0de0 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -26,7 +26,7 @@ extern struct unix_error_map unix_dos_nt_errmap[]; extern uint32 global_client_caps; /* these can be set by some functions to override the error codes */ static int override_ERR_class; -static int override_ERR_code; +static uint32 override_ERR_code; static NTSTATUS override_ERR_ntstatus; /**************************************************************************** -- cgit From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/smbd/error.c | 54 +++++++++------------------------------------------- 1 file changed, 9 insertions(+), 45 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index fa236f0de0..409781eaa9 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -24,40 +24,6 @@ extern struct unix_error_map unix_dos_nt_errmap[]; extern uint32 global_client_caps; -/* these can be set by some functions to override the error codes */ -static int override_ERR_class; -static uint32 override_ERR_code; -static NTSTATUS override_ERR_ntstatus; - -/**************************************************************************** - Setting eclass and ecode only and status to NT_STATUS_INVALID forces DOS errors. - Setting status only and eclass and ecode to -1 forces NT errors. -****************************************************************************/ - -void set_saved_error_triple(int eclass, int ecode, NTSTATUS status) -{ - override_ERR_class = eclass; - override_ERR_code = ecode; - override_ERR_ntstatus = status; -} - -void set_saved_ntstatus(NTSTATUS status) -{ - uint8 tmp_eclass; /* Hmmm. override_ERR_class is not uint8... */ - override_ERR_ntstatus = status; - ntstatus_to_dos(status, &tmp_eclass, &override_ERR_code); - override_ERR_class = tmp_eclass; - -} - -/**************************************************************************** - Return the current settings of the error triple. Return True if any are set. -****************************************************************************/ - -NTSTATUS get_saved_ntstatus(void) -{ - return override_ERR_ntstatus; -} /**************************************************************************** Create an error packet from a cached error. @@ -103,6 +69,10 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code, NTSTATUS def_s return error_packet(outbuf,eclass,ecode,ntstatus,line,file); } +BOOL use_nt_status(void) +{ + return lp_nt_status_support() && (global_client_caps & CAP_STATUS32); +} /**************************************************************************** Create an error packet. Normally called using the ERROR() macro. @@ -117,18 +87,9 @@ int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, in BOOL force_nt_status = False; BOOL force_dos_status = False; - if (override_ERR_class != SMB_SUCCESS || !NT_STATUS_IS_OK(override_ERR_ntstatus)) { - eclass = override_ERR_class; - ecode = override_ERR_code; - ntstatus = override_ERR_ntstatus; - override_ERR_class = SMB_SUCCESS; - override_ERR_code = 0; - override_ERR_ntstatus = NT_STATUS_OK; - } - if (eclass == (uint8)-1) { force_nt_status = True; - } else if (NT_STATUS_IS_INVALID(ntstatus)) { + } else if (NT_STATUS_IS_DOS(ntstatus)) { force_dos_status = True; } @@ -146,7 +107,10 @@ int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, in nt_errstr(ntstatus))); } else { /* We're returning a DOS error only. */ - if (eclass == 0 && NT_STATUS_V(ntstatus)) { + if (NT_STATUS_IS_DOS(ntstatus)) { + eclass = NT_STATUS_DOS_CLASS(ntstatus); + ecode = NT_STATUS_DOS_CODE(ntstatus); + } else if (eclass == 0 && NT_STATUS_V(ntstatus)) { ntstatus_to_dos(ntstatus, &eclass, &ecode); } -- cgit From 6fd4813ece5e03c92334acfa7e168cd7d0248919 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 14 Aug 2006 16:53:14 +0000 Subject: r17541: When returning a trans2 request, if the "max data bytes returned" is less than the amount we want to send, return what we can and set STATUS_BUFFER_OVERFLOW (doserror ERRDOS,ERRbufferoverflow). Required by OS/2 to handle EA's that are too large. It's hard to test this in Samba4 smbtorture as the max data bytes returned is hard coded at 0xffff (as it is in the Samba3 client libraries also). I used a custom version of Samba4 smbtorture to test this out. Might add a "max data bytes" param to make this testable in the build farm. Confirmed by "Guenter Kukkukk (sambaos2)" and Andreas Taegener that this fixes the issue. Jeremy. (This used to be commit ff2f1202b76991a404dae8df17c36f8135c8dc51) --- source3/smbd/error.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 409781eaa9..0860b7d1d9 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -81,9 +81,8 @@ BOOL use_nt_status(void) If the override errors are set they take precedence over any passed in values. ****************************************************************************/ -int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) +void error_packet_set(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) { - int outsize = set_message(outbuf,0,0,True); BOOL force_nt_status = False; BOOL force_dos_status = False; @@ -125,6 +124,11 @@ int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, in eclass, ecode)); } +} +int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) +{ + int outsize = set_message(outbuf,0,0,True); + error_packet_set(outbuf, eclass, ecode, ntstatus, line, file); return outsize; } -- cgit From 0829e1ad1c3646efecf50729f493b9ee72ef0517 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 Apr 2007 22:40:32 +0000 Subject: r22391: Looks bigger than it is. Make "inbuf" available to all callers of smb_setlen (via set_message() calls). This will allow the server to reflect back the correct encryption context. Jeremy. (This used to be commit 2d80a96120a5fe2fe726f00746d36d85044c4bdb) --- source3/smbd/error.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 0860b7d1d9..dc35c0fa64 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -29,7 +29,7 @@ extern uint32 global_client_caps; Create an error packet from a cached error. ****************************************************************************/ -int cached_error_packet(char *outbuf,files_struct *fsp,int line,const char *file) +int cached_error_packet(const char *inbuf,char *outbuf,files_struct *fsp,int line,const char *file) { write_bmpx_struct *wbmpx = fsp->wbmpx_ptr; int32 eclass = wbmpx->wr_errclass; @@ -38,14 +38,14 @@ int cached_error_packet(char *outbuf,files_struct *fsp,int line,const char *file /* We can now delete the auxiliary struct */ SAFE_FREE(fsp->wbmpx_ptr); - return error_packet(outbuf,eclass,err,ntstatus,line,file); + return error_packet(inbuf,outbuf,eclass,err,ntstatus,line,file); } /**************************************************************************** Create an error packet from errno. ****************************************************************************/ -int unix_error_packet(char *outbuf,int def_class,uint32 def_code, NTSTATUS def_status, int line, const char *file) +int unix_error_packet(const char *inbuf,char *outbuf,int def_class,uint32 def_code, NTSTATUS def_status, int line, const char *file) { int eclass=def_class; int ecode=def_code; @@ -66,7 +66,7 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code, NTSTATUS def_s } } - return error_packet(outbuf,eclass,ecode,ntstatus,line,file); + return error_packet(inbuf,outbuf,eclass,ecode,ntstatus,line,file); } BOOL use_nt_status(void) @@ -126,9 +126,9 @@ void error_packet_set(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatu } } -int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) +int error_packet(const char *inbuf, char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) { - int outsize = set_message(outbuf,0,0,True); + int outsize = set_message(inbuf,outbuf,0,0,True); error_packet_set(outbuf, eclass, ecode, ntstatus, line, file); return outsize; } -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/smbd/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index dc35c0fa64..9c858c40a2 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/smbd/error.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 9c858c40a2..12b57d5ab4 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From cc6a41017c577742af73b4bc60993d8d415ea580 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Jul 2007 09:36:09 +0000 Subject: r23997: Check in the infrastructure for getting rid of the global InBuffer/OutBuffer The complete history of this patch can be found under http://www.samba.org/~vlendec/inbuf-checkin/. Jeremy, Jerry: If possible I would like to see this in 3.2.0. I'm only checking into 3_2 at the moment, as it currently will slow down operations for all non-converted (i.e. all at this moment) operations, as it will copy the talloc'ed inbuf over the global InBuffer. It will need quite a bit of effort to convert everything necessary for the normal operations an XP box does. I have patches for negprot, session setup, tcon_and_X, open_and_X, close. More to come, but I would appreciate some help here. Volker (This used to be commit 5594af2b208c860d3f4b453af6a649d9e4295d1c) --- source3/smbd/error.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 12b57d5ab4..d00c61487a 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -131,3 +131,29 @@ int error_packet(const char *inbuf, char *outbuf, uint8 eclass, uint32 ecode, NT error_packet_set(outbuf, eclass, ecode, ntstatus, line, file); return outsize; } + +void reply_nt_error(struct smb_request *req, NTSTATUS ntstatus, + int line, const char *file) +{ + TALLOC_FREE(req->outbuf); + reply_outbuf(req, 0, 0); + error_packet_set((char *)req->outbuf, 0, 0, ntstatus, line, file); +} + +void reply_dos_error(struct smb_request *req, uint8 eclass, uint32 ecode, + int line, const char *file) +{ + TALLOC_FREE(req->outbuf); + reply_outbuf(req, 0, 0); + error_packet_set((char *)req->outbuf, eclass, ecode, NT_STATUS_OK, line, + file); +} + +void reply_both_error(struct smb_request *req, uint8 eclass, uint32 ecode, + NTSTATUS status, int line, const char *file) +{ + TALLOC_FREE(req->outbuf); + reply_outbuf(req, 0, 0); + error_packet_set((char *)req->outbuf, eclass, ecode, status, + line, file); +} -- cgit From 4392d47b34720d2dcd8ee47bd14a71bf1eab2c86 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 30 Jul 2007 10:23:26 +0000 Subject: r24078: Add reply_unixerror (This used to be commit 10ac991750e9476299d39ac6f763d1638ff8c619) --- source3/smbd/error.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index d00c61487a..023e1b7dcc 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -157,3 +157,33 @@ void reply_both_error(struct smb_request *req, uint8 eclass, uint32 ecode, error_packet_set((char *)req->outbuf, eclass, ecode, status, line, file); } + +void reply_unix_error(struct smb_request *req, uint8 defclass, uint32 defcode, + NTSTATUS defstatus, int line, const char *file) +{ + int eclass=defclass; + int ecode=defcode; + NTSTATUS ntstatus = defstatus; + int i=0; + + TALLOC_FREE(req->outbuf); + reply_outbuf(req, 0, 0); + + if (errno != 0) { + DEBUG(3,("unix_error_packet: error string = %s\n", + strerror(errno))); + + while (unix_dos_nt_errmap[i].dos_class != 0) { + if (unix_dos_nt_errmap[i].unix_error == errno) { + eclass = unix_dos_nt_errmap[i].dos_class; + ecode = unix_dos_nt_errmap[i].dos_code; + ntstatus = unix_dos_nt_errmap[i].nt_error; + break; + } + i++; + } + } + + error_packet_set((char *)req->outbuf, eclass, ecode, ntstatus, + line, file); +} -- cgit From a5f412f305ea2bdb0ee0efd5a38385525d4671c8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Aug 2007 10:28:09 +0000 Subject: r24311: add a reply_force_nterror() macro metze (This used to be commit b9ae00f4980c305f2f7334b139f9bc72fd9afbd6) --- source3/smbd/error.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 023e1b7dcc..dd9ff85640 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -140,6 +140,14 @@ void reply_nt_error(struct smb_request *req, NTSTATUS ntstatus, error_packet_set((char *)req->outbuf, 0, 0, ntstatus, line, file); } +void reply_force_nt_error(struct smb_request *req, NTSTATUS ntstatus, + int line, const char *file) +{ + TALLOC_FREE(req->outbuf); + reply_outbuf(req, 0, 0); + error_packet_set((char *)req->outbuf, -1, -1, ntstatus, line, file); +} + void reply_dos_error(struct smb_request *req, uint8 eclass, uint32 ecode, int line, const char *file) { -- cgit From 3dd3c4cd013dadd1a1f57ac3e0750018dc5a0698 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 15 Aug 2007 16:58:29 +0000 Subject: r24464: Now Volker removed the readbmpx we don't need cached errors any more. Jeremy. (This used to be commit 9256ec0a20f532c7dd7ddc2d3534336a47e6c2d2) --- source3/smbd/error.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index dd9ff85640..74029a2b05 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -24,22 +24,6 @@ extern struct unix_error_map unix_dos_nt_errmap[]; extern uint32 global_client_caps; -/**************************************************************************** - Create an error packet from a cached error. -****************************************************************************/ - -int cached_error_packet(const char *inbuf,char *outbuf,files_struct *fsp,int line,const char *file) -{ - write_bmpx_struct *wbmpx = fsp->wbmpx_ptr; - int32 eclass = wbmpx->wr_errclass; - int32 err = wbmpx->wr_error; - NTSTATUS ntstatus = wbmpx->wr_status; - - /* We can now delete the auxiliary struct */ - SAFE_FREE(fsp->wbmpx_ptr); - return error_packet(inbuf,outbuf,eclass,err,ntstatus,line,file); -} - /**************************************************************************** Create an error packet from errno. ****************************************************************************/ -- cgit From 077d5d2e369e4fcb3e8c8fec862da9e450398ef3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 16 Aug 2007 17:42:34 +0000 Subject: r24498: More extra code into a function, reply_openerror. Jeremy. (This used to be commit 43ddfb8c918bd27e2efd3b54077db815da80a53a) --- source3/smbd/error.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 74029a2b05..143417dce3 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -179,3 +179,20 @@ void reply_unix_error(struct smb_request *req, uint8 defclass, uint32 defcode, error_packet_set((char *)req->outbuf, eclass, ecode, ntstatus, line, file); } + +void reply_openerror(struct smb_request *req, NTSTATUS status) +{ + if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { + /* + * We hit an existing file, and if we're returning DOS + * error codes OBJECT_NAME_COLLISION would map to + * ERRDOS/183, we need to return ERRDOS/80, see bug + * 4852. + */ + reply_botherror(req, NT_STATUS_OBJECT_NAME_COLLISION, + ERRDOS, ERRfilexists); + } else { + reply_nterror(req, status); + } +} + -- cgit From e5a951325a6cac8567af3a66de6d2df577508ae4 Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Wed, 10 Oct 2007 15:34:30 -0500 Subject: [GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch. (This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab) --- source3/smbd/error.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 143417dce3..6cb63f0c49 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -28,7 +28,7 @@ extern uint32 global_client_caps; Create an error packet from errno. ****************************************************************************/ -int unix_error_packet(const char *inbuf,char *outbuf,int def_class,uint32 def_code, NTSTATUS def_status, int line, const char *file) +int unix_error_packet(char *outbuf,int def_class,uint32 def_code, NTSTATUS def_status, int line, const char *file) { int eclass=def_class; int ecode=def_code; @@ -49,7 +49,7 @@ int unix_error_packet(const char *inbuf,char *outbuf,int def_class,uint32 def_co } } - return error_packet(inbuf,outbuf,eclass,ecode,ntstatus,line,file); + return error_packet(outbuf,eclass,ecode,ntstatus,line,file); } BOOL use_nt_status(void) @@ -109,9 +109,9 @@ void error_packet_set(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatu } } -int error_packet(const char *inbuf, char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) +int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) { - int outsize = set_message(inbuf,outbuf,0,0,True); + int outsize = set_message(outbuf,0,0,True); error_packet_set(outbuf, eclass, ecode, ntstatus, line, file); return outsize; } -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/smbd/error.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 6cb63f0c49..12eff42023 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -52,7 +52,7 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code, NTSTATUS def_s return error_packet(outbuf,eclass,ecode,ntstatus,line,file); } -BOOL use_nt_status(void) +bool use_nt_status(void) { return lp_nt_status_support() && (global_client_caps & CAP_STATUS32); } @@ -66,8 +66,8 @@ BOOL use_nt_status(void) void error_packet_set(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) { - BOOL force_nt_status = False; - BOOL force_dos_status = False; + bool force_nt_status = False; + bool force_dos_status = False; if (eclass == (uint8)-1) { force_nt_status = True; -- cgit From afc93255d183eefb68e45b8ec6275f6a62cf9795 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 26 Dec 2007 17:12:36 -0800 Subject: Add SMB encryption. Still fixing client decrypt but negotiation works. Jeremy. (This used to be commit d78045601af787731f0737b8627450018902b104) --- source3/smbd/error.c | 71 ++++++++++++++++------------------------------------ 1 file changed, 21 insertions(+), 50 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 12eff42023..c669e74146 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -24,34 +24,6 @@ extern struct unix_error_map unix_dos_nt_errmap[]; extern uint32 global_client_caps; -/**************************************************************************** - Create an error packet from errno. -****************************************************************************/ - -int unix_error_packet(char *outbuf,int def_class,uint32 def_code, NTSTATUS def_status, int line, const char *file) -{ - int eclass=def_class; - int ecode=def_code; - NTSTATUS ntstatus = def_status; - int i=0; - - if (errno != 0) { - DEBUG(3,("unix_error_packet: error string = %s\n",strerror(errno))); - - while (unix_dos_nt_errmap[i].dos_class != 0) { - if (unix_dos_nt_errmap[i].unix_error == errno) { - eclass = unix_dos_nt_errmap[i].dos_class; - ecode = unix_dos_nt_errmap[i].dos_code; - ntstatus = unix_dos_nt_errmap[i].nt_error; - break; - } - i++; - } - } - - return error_packet(outbuf,eclass,ecode,ntstatus,line,file); -} - bool use_nt_status(void) { return lp_nt_status_support() && (global_client_caps & CAP_STATUS32); @@ -109,9 +81,9 @@ void error_packet_set(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatu } } -int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) +int error_packet(const char *inbuf, char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) { - int outsize = set_message(outbuf,0,0,True); + int outsize = srv_set_message(inbuf, outbuf,0,0,True); error_packet_set(outbuf, eclass, ecode, ntstatus, line, file); return outsize; } @@ -150,8 +122,24 @@ void reply_both_error(struct smb_request *req, uint8 eclass, uint32 ecode, line, file); } +void reply_openerror(struct smb_request *req, NTSTATUS status) +{ + if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { + /* + * We hit an existing file, and if we're returning DOS + * error codes OBJECT_NAME_COLLISION would map to + * ERRDOS/183, we need to return ERRDOS/80, see bug + * 4852. + */ + reply_botherror(req, NT_STATUS_OBJECT_NAME_COLLISION, + ERRDOS, ERRfilexists); + } else { + reply_nterror(req, status); + } +} + void reply_unix_error(struct smb_request *req, uint8 defclass, uint32 defcode, - NTSTATUS defstatus, int line, const char *file) + NTSTATUS defstatus, int line, const char *file) { int eclass=defclass; int ecode=defcode; @@ -163,7 +151,7 @@ void reply_unix_error(struct smb_request *req, uint8 defclass, uint32 defcode, if (errno != 0) { DEBUG(3,("unix_error_packet: error string = %s\n", - strerror(errno))); + strerror(errno))); while (unix_dos_nt_errmap[i].dos_class != 0) { if (unix_dos_nt_errmap[i].unix_error == errno) { @@ -177,22 +165,5 @@ void reply_unix_error(struct smb_request *req, uint8 defclass, uint32 defcode, } error_packet_set((char *)req->outbuf, eclass, ecode, ntstatus, - line, file); + line, file); } - -void reply_openerror(struct smb_request *req, NTSTATUS status) -{ - if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { - /* - * We hit an existing file, and if we're returning DOS - * error codes OBJECT_NAME_COLLISION would map to - * ERRDOS/183, we need to return ERRDOS/80, see bug - * 4852. - */ - reply_botherror(req, NT_STATUS_OBJECT_NAME_COLLISION, - ERRDOS, ERRfilexists); - } else { - reply_nterror(req, status); - } -} - -- cgit From 9254bb4ef1c3c3a52ea8e935edb0e7a86ec3ea7a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Jan 2008 12:56:23 -0800 Subject: Refactor the crypto code after a very helpful conversation with Volker. Mostly making sure we have data on the incoming packet type, not stored in the smb header. Jeremy. (This used to be commit c4e5a505043965eec77b5bb9bc60957e8f3b97c8) --- source3/smbd/error.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/error.c') diff --git a/source3/smbd/error.c b/source3/smbd/error.c index c669e74146..de2de088ec 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -81,9 +81,9 @@ void error_packet_set(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatu } } -int error_packet(const char *inbuf, char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) +int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file) { - int outsize = srv_set_message(inbuf, outbuf,0,0,True); + int outsize = srv_set_message(outbuf,0,0,True); error_packet_set(outbuf, eclass, ecode, ntstatus, line, file); return outsize; } -- cgit