From 858e63cab3b6a23692678d6eb03f9e48c3c08603 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 25 Apr 2000 14:04:06 +0000 Subject: split clientgen.c into several parts the next step is splitting out the auth code, to make adding lukes NTLMSSP support easier (This used to be commit 10c5470835b43116ed48b3137c3b9cc867a20989) --- source3/libsmb/clierror.c | 213 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 source3/libsmb/clierror.c (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c new file mode 100644 index 0000000000..e09064bf0f --- /dev/null +++ b/source3/libsmb/clierror.c @@ -0,0 +1,213 @@ +/* + Unix SMB/Netbios implementation. + Version 3.0 + client error handling routines + Copyright (C) Andrew Tridgell 1994-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. +*/ + +#define NO_SYSLOG + +#include "includes.h" + + +extern int DEBUGLEVEL; + + +/***************************************************** + RAP error codes - a small start but will be extended. +*******************************************************/ + +static struct +{ + int err; + char *message; +} rap_errmap[] = +{ + {5, "User has insufficient privilege" }, + {86, "The specified password is invalid" }, + {2226, "Operation only permitted on a Primary Domain Controller" }, + {2242, "The password of this user has expired." }, + {2243, "The password of this user cannot change." }, + {2244, "This password cannot be used now (password history conflict)." }, + {2245, "The password is shorter than required." }, + {2246, "The password of this user is too recent to change."}, + + /* these really shouldn't be here ... */ + {0x80, "Not listening on called name"}, + {0x81, "Not listening for calling name"}, + {0x82, "Called name not present"}, + {0x83, "Called name present, but insufficient resources"}, + + {0, NULL} +}; + +/**************************************************************************** + return a description of an SMB error +****************************************************************************/ +static char *cli_smb_errstr(struct cli_state *cli) +{ + return smb_errstr(cli->inbuf); +} + +/****************************************************** + Return an error message - either an SMB error or a RAP + error. +*******************************************************/ + +char *cli_errstr(struct cli_state *cli) +{ + static fstring error_message; + uint8 errclass; + uint32 errnum; + uint32 nt_rpc_error; + int i; + + /* + * Errors are of three kinds - smb errors, + * dealt with by cli_smb_errstr, NT errors, + * whose code is in cli.nt_error, and rap + * errors, whose error code is in cli.rap_error. + */ + + cli_error(cli, &errclass, &errnum, &nt_rpc_error); + + if (errclass != 0) + { + return cli_smb_errstr(cli); + } + + /* + * Was it an NT error ? + */ + + if (nt_rpc_error) + { + char *nt_msg = get_nt_error_msg(nt_rpc_error); + + if (nt_msg == NULL) + { + slprintf(error_message, sizeof(fstring) - 1, "NT code %d", nt_rpc_error); + } + else + { + fstrcpy(error_message, nt_msg); + } + + return error_message; + } + + /* + * Must have been a rap error. + */ + + slprintf(error_message, sizeof(error_message) - 1, "code %d", cli->rap_error); + + for (i = 0; rap_errmap[i].message != NULL; i++) + { + if (rap_errmap[i].err == cli->rap_error) + { + fstrcpy( error_message, rap_errmap[i].message); + break; + } + } + + return error_message; +} + + +/**************************************************************************** + return error codes for the last packet + returns 0 if there was no error and the best approx of a unix errno + otherwise + + for 32 bit "warnings", a return code of 0 is expected. + +****************************************************************************/ +int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_error) +{ + int flgs2; + char rcls; + int code; + + if (eclass) *eclass = 0; + if (num ) *num = 0; + if (nt_rpc_error) *nt_rpc_error = 0; + + if(!cli->initialised) + return EINVAL; + + if(!cli->inbuf) + return ENOMEM; + + flgs2 = SVAL(cli->inbuf,smb_flg2); + if (nt_rpc_error) *nt_rpc_error = cli->nt_error; + + if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { + /* 32 bit error codes detected */ + uint32 nt_err = IVAL(cli->inbuf,smb_rcls); + if (num) *num = nt_err; + DEBUG(10,("cli_error: 32 bit codes: code=%08x\n", nt_err)); + if (!IS_BITS_SET_ALL(nt_err, 0xc0000000)) return 0; + + switch (nt_err & 0xFFFFFF) { + case NT_STATUS_ACCESS_VIOLATION: return EACCES; + case NT_STATUS_NO_SUCH_FILE: return ENOENT; + case NT_STATUS_NO_SUCH_DEVICE: return ENODEV; + case NT_STATUS_INVALID_HANDLE: return EBADF; + case NT_STATUS_NO_MEMORY: return ENOMEM; + case NT_STATUS_ACCESS_DENIED: return EACCES; + case NT_STATUS_OBJECT_NAME_NOT_FOUND: return ENOENT; + case NT_STATUS_SHARING_VIOLATION: return EBUSY; + case NT_STATUS_OBJECT_PATH_INVALID: return ENOTDIR; + case NT_STATUS_OBJECT_NAME_COLLISION: return EEXIST; + } + + /* for all other cases - a default code */ + return EINVAL; + } + + rcls = CVAL(cli->inbuf,smb_rcls); + code = SVAL(cli->inbuf,smb_err); + if (rcls == 0) return 0; + + if (eclass) *eclass = rcls; + if (num ) *num = code; + + if (rcls == ERRDOS) { + switch (code) { + case ERRbadfile: return ENOENT; + case ERRbadpath: return ENOTDIR; + case ERRnoaccess: return EACCES; + case ERRfilexists: return EEXIST; + case ERRrename: return EEXIST; + case ERRbadshare: return EBUSY; + case ERRlock: return EBUSY; + } + } + if (rcls == ERRSRV) { + switch (code) { + case ERRbadpw: return EPERM; + case ERRaccess: return EACCES; + case ERRnoresource: return ENOMEM; + case ERRinvdevice: return ENODEV; + case ERRinvnetname: return ENODEV; + } + } + /* for other cases */ + return EINVAL; +} + -- cgit From ddc9b8b40642c90fe7c34b088eae4f8075f4033a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 10 May 2000 09:49:55 +0000 Subject: more merging it is now at the stage that winbindd can compile in the head branch, but not link (This used to be commit d178c00aae77710ae6ff20a7f54a30e3bd8232bb) --- source3/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index e09064bf0f..78a7c9d451 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -163,7 +163,7 @@ int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_ DEBUG(10,("cli_error: 32 bit codes: code=%08x\n", nt_err)); if (!IS_BITS_SET_ALL(nt_err, 0xc0000000)) return 0; - switch (nt_err & 0xFFFFFF) { + switch (nt_err) { case NT_STATUS_ACCESS_VIOLATION: return EACCES; case NT_STATUS_NO_SUCH_FILE: return ENOENT; case NT_STATUS_NO_SUCH_DEVICE: return ENODEV; -- cgit From 7f36df301e28dc8ca0e5bfadc109d6e907d9ba2b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 1 Aug 2000 18:32:34 +0000 Subject: Tidyup removing many of the 0xC0000000 | NT_STATUS_XXX stuff (only need NT_STATUS_XXX). Removed IS_BITS_xxx macros as they were just reproducing "C" syntax in a more obscure way. Jeremy. (This used to be commit c55bcec817f47d6162466b193d533c877194124a) --- source3/libsmb/clierror.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 78a7c9d451..314b343f25 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -161,7 +161,8 @@ int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_ uint32 nt_err = IVAL(cli->inbuf,smb_rcls); if (num) *num = nt_err; DEBUG(10,("cli_error: 32 bit codes: code=%08x\n", nt_err)); - if (!IS_BITS_SET_ALL(nt_err, 0xc0000000)) return 0; + if (!(nt_err & 0xc0000000)) + return 0; switch (nt_err) { case NT_STATUS_ACCESS_VIOLATION: return EACCES; -- cgit From 553579bf6fd7c9dfecddddc1f6272b523bce69d9 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 4 Aug 2000 06:13:05 +0000 Subject: In cli_error() return ENOENT when an ERROR_INVALID_NAME is received instead of the generic EINVAL. (This used to be commit a290107aee01a85ca1ef5565f23c8f00e18e98c2) --- source3/libsmb/clierror.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 314b343f25..66bf83cfc5 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -197,6 +197,7 @@ int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_ case ERRrename: return EEXIST; case ERRbadshare: return EBUSY; case ERRlock: return EBUSY; + case ERROR_INVALID_NAME: return ENOENT; } } if (rcls == ERRSRV) { -- cgit From 8719c27726d3412edd0781beb956f48f76a62fb6 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 11 Oct 2000 05:31:39 +0000 Subject: changes to sync with 2.2. tree .cvsignore remove config.h - not in this directory include/profile.h profile changes lib/messages.c added message to return debug level libsmb/clierror.c cast to get rid of compiler warning libsmb/smbencrypt.c cast to get rid of compiler warning profile/profile.c add flush profile stats changes for profile struct rpc_parse/parse_samr.c fix for compiler warning rpc_server/srv_samr.c cast to get rid of compiler warning smbd/ipc.c profile stats message.c profile stats smbd/negprot.c profile stats smbd/nttrans.c profile stats smbd/trans2.c profile stats utils/smbcontrol.c new flush stats command (This used to be commit bbb24daa25dca4e4b6b1f8942cd84ee3aa1bed8e) --- source3/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 66bf83cfc5..4c6d9a49f2 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -96,7 +96,7 @@ char *cli_errstr(struct cli_state *cli) if (nt_rpc_error) { - char *nt_msg = get_nt_error_msg(nt_rpc_error); + char *nt_msg = (char *)get_nt_error_msg(nt_rpc_error); if (nt_msg == NULL) { -- cgit From e86cbff0a9f463eef7c3b92081908be4f83f595b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Jan 2001 23:41:15 +0000 Subject: Return EACCES for bad password. (This used to be commit 143006d32f0a0d339b870741b811ec49795b7099) --- source3/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 4c6d9a49f2..eb2ca624e8 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -202,7 +202,7 @@ int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_ } if (rcls == ERRSRV) { switch (code) { - case ERRbadpw: return EPERM; + case ERRbadpw: return EACCES; case ERRaccess: return EACCES; case ERRnoresource: return ENOMEM; case ERRinvdevice: return ENODEV; -- cgit From 7eea846f52f223855d1abe52f39a29b690f97099 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Mon, 29 Jan 2001 04:52:12 +0000 Subject: Add an extra error code translation to clierror.c so that libsmbclient gets some more error codes correct ... (This used to be commit bca6b7dd20839a15aa97b4e6ba03c60eab9ed237) --- source3/libsmb/clierror.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index eb2ca624e8..6d49986790 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -198,11 +198,12 @@ int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_ case ERRbadshare: return EBUSY; case ERRlock: return EBUSY; case ERROR_INVALID_NAME: return ENOENT; + case ERRnosuchshare: return ENODEV; } } if (rcls == ERRSRV) { switch (code) { - case ERRbadpw: return EACCES; + case ERRbadpw: return EPERM; case ERRaccess: return EACCES; case ERRnoresource: return ENOMEM; case ERRinvdevice: return ENODEV; -- cgit From f339bbbc30a7b8a2ee049c1f93d978ed0a2f1238 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 15 Jun 2001 07:13:12 +0000 Subject: Added a unix error code for NT_STATUS_PATH_NOT_COVERED. (This used to be commit 66e62245ea50fe7b996484ca919083eec2edfd14) --- source3/libsmb/clierror.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 6d49986790..77e2be805b 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -175,6 +175,7 @@ int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_ case NT_STATUS_SHARING_VIOLATION: return EBUSY; case NT_STATUS_OBJECT_PATH_INVALID: return ENOTDIR; case NT_STATUS_OBJECT_NAME_COLLISION: return EEXIST; + case NT_STATUS_PATH_NOT_COVERED: return ENOENT; } /* for all other cases - a default code */ -- cgit From 87fbb7092b8f8b2f0db0f361c3d625e19de57cd9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:15:53 +0000 Subject: The big character set handling changeover! This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a) --- source3/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 77e2be805b..f533eabb0b 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -120,7 +120,7 @@ char *cli_errstr(struct cli_state *cli) { if (rap_errmap[i].err == cli->rap_error) { - fstrcpy( error_message, rap_errmap[i].message); + fstrcpy(error_message, rap_errmap[i].message); break; } } -- cgit From 2ccfea3de7b2b7dc0be2438c3adb3f7be82a2dfc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 10 Aug 2001 06:00:33 +0000 Subject: A rewrite of the error handling in the libsmb client code. I've separated out the error handling into a bunch of separate functions rather than all being handled in one big function. Fetch error codes from the last received packet: void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *num); uint32 cli_nt_error(struct cli_state *); Convert errors to UNIX errno values: int cli_errno_from_dos(uint8 eclass, uint32 num); int cli_errno_from_nt(uint32 status); int cli_errno(struct cli_state *cli); Detect different kinds of errors: BOOL cli_is_dos_error(struct cli_state *cli); BOOL cli_is_nt_error(struct cli_state *cli); BOOL cli_is_error(struct cli_state *cli); This also means we now support CAP_STATUS32 as we can decode and understand NT errors instead of just DOS errors. Yay! Ported a whole bunch of files in libsmb to use this new API instead of the just the DOS error. (This used to be commit 6dbdb0d813f3c7ab20b38baa1223b0b479aadec9) --- source3/libsmb/clierror.c | 249 +++++++++++++++++++++++++++++----------------- 1 file changed, 157 insertions(+), 92 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index f533eabb0b..c2234e8ead 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -23,10 +23,8 @@ #include "includes.h" - extern int DEBUGLEVEL; - /***************************************************** RAP error codes - a small start but will be extended. *******************************************************/ @@ -63,134 +61,119 @@ static char *cli_smb_errstr(struct cli_state *cli) return smb_errstr(cli->inbuf); } -/****************************************************** - Return an error message - either an SMB error or a RAP - error. -*******************************************************/ +/*************************************************************************** + Return an error message - either an NT error, SMB error or a RAP error. + Note some of the NT errors are actually warnings or "informational" errors + in which case they can be safely ignored. +****************************************************************************/ char *cli_errstr(struct cli_state *cli) { static fstring error_message; - uint8 errclass; - uint32 errnum; - uint32 nt_rpc_error; - int i; - - /* - * Errors are of three kinds - smb errors, - * dealt with by cli_smb_errstr, NT errors, - * whose code is in cli.nt_error, and rap - * errors, whose error code is in cli.rap_error. - */ - - cli_error(cli, &errclass, &errnum, &nt_rpc_error); - - if (errclass != 0) - { - return cli_smb_errstr(cli); - } + uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), errnum; + uint8 errclass; + int i; - /* - * Was it an NT error ? - */ + /* Case #1: 32-bit NT errors */ - if (nt_rpc_error) - { - char *nt_msg = (char *)get_nt_error_msg(nt_rpc_error); + if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { + uint32 status = IVAL(cli->inbuf,smb_rcls); - if (nt_msg == NULL) - { - slprintf(error_message, sizeof(fstring) - 1, "NT code %d", nt_rpc_error); - } - else - { - fstrcpy(error_message, nt_msg); - } + return get_nt_error_msg(status); + } - return error_message; - } + cli_dos_error(cli, &errclass, &errnum); + + /* Case #2: SMB error */ - /* - * Must have been a rap error. - */ + if (errclass != 0) + return cli_smb_errstr(cli); - slprintf(error_message, sizeof(error_message) - 1, "code %d", cli->rap_error); + /* Case #3: RAP error */ - for (i = 0; rap_errmap[i].message != NULL; i++) - { - if (rap_errmap[i].err == cli->rap_error) - { - fstrcpy(error_message, rap_errmap[i].message); - break; + for (i = 0; rap_errmap[i].message != NULL; i++) { + if (rap_errmap[i].err == cli->rap_error) { + return rap_errmap[i].message; } } + slprintf(error_message, sizeof(error_message) - 1, "code %d", + cli->rap_error); + return error_message; } +/* Return the 32-bit NT status code from the last packet */ -/**************************************************************************** - return error codes for the last packet - returns 0 if there was no error and the best approx of a unix errno - otherwise +uint32 cli_nt_error(struct cli_state *cli) +{ + int flgs2 = SVAL(cli->inbuf,smb_flg2); - for 32 bit "warnings", a return code of 0 is expected. + if (!(flgs2 & FLAGS2_32_BIT_ERROR_CODES)) { -****************************************************************************/ -int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_error) + /* Eek! We've requested a NT error when the packet that + came back does not contain one. What do we return + here? */ + + DEBUG(1, ("ERROR: cli_error() called to read a status code " + "from a packet that does not contain one!\n")); + + return NT_STATUS_UNSUCCESSFUL; + } + + return IVAL(cli->inbuf,smb_rcls); +} + +/* Return the DOS error from the last packet - an error class and an error + code. */ + +void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *num) { int flgs2; char rcls; int code; - if (eclass) *eclass = 0; - if (num ) *num = 0; - if (nt_rpc_error) *nt_rpc_error = 0; + if (eclass) + *eclass = 0; + + if (num) + *num = 0; if(!cli->initialised) - return EINVAL; + return; if(!cli->inbuf) - return ENOMEM; + return; flgs2 = SVAL(cli->inbuf,smb_flg2); - if (nt_rpc_error) *nt_rpc_error = cli->nt_error; if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { - /* 32 bit error codes detected */ - uint32 nt_err = IVAL(cli->inbuf,smb_rcls); - if (num) *num = nt_err; - DEBUG(10,("cli_error: 32 bit codes: code=%08x\n", nt_err)); - if (!(nt_err & 0xc0000000)) - return 0; - - switch (nt_err) { - case NT_STATUS_ACCESS_VIOLATION: return EACCES; - case NT_STATUS_NO_SUCH_FILE: return ENOENT; - case NT_STATUS_NO_SUCH_DEVICE: return ENODEV; - case NT_STATUS_INVALID_HANDLE: return EBADF; - case NT_STATUS_NO_MEMORY: return ENOMEM; - case NT_STATUS_ACCESS_DENIED: return EACCES; - case NT_STATUS_OBJECT_NAME_NOT_FOUND: return ENOENT; - case NT_STATUS_SHARING_VIOLATION: return EBUSY; - case NT_STATUS_OBJECT_PATH_INVALID: return ENOTDIR; - case NT_STATUS_OBJECT_NAME_COLLISION: return EEXIST; - case NT_STATUS_PATH_NOT_COVERED: return ENOENT; - } + /* Eek! We've requested a DOS error when the packet that + came back does not contain one. What do we return + here? */ - /* for all other cases - a default code */ - return EINVAL; - } + DEBUG(1, ("ERROR: cli_error() called to read a dos error code " + "from a packet that does not contain one!\n")); + + return; + } rcls = CVAL(cli->inbuf,smb_rcls); code = SVAL(cli->inbuf,smb_err); - if (rcls == 0) return 0; + + if (rcls == 0) + return; if (eclass) *eclass = rcls; if (num ) *num = code; +} - if (rcls == ERRDOS) { - switch (code) { +/* Return a UNIX errno from a dos error class, error number tuple */ + +int cli_errno_from_dos(uint8 eclass, uint32 num) +{ + if (eclass == ERRDOS) { + switch (num) { case ERRbadfile: return ENOENT; case ERRbadpath: return ENOTDIR; case ERRnoaccess: return EACCES; @@ -198,12 +181,13 @@ int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_ case ERRrename: return EEXIST; case ERRbadshare: return EBUSY; case ERRlock: return EBUSY; - case ERROR_INVALID_NAME: return ENOENT; + case ERRinvalidname: return ENOENT; case ERRnosuchshare: return ENODEV; } } - if (rcls == ERRSRV) { - switch (code) { + + if (eclass == ERRSRV) { + switch (num) { case ERRbadpw: return EPERM; case ERRaccess: return EACCES; case ERRnoresource: return ENOMEM; @@ -211,7 +195,88 @@ int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_ case ERRinvnetname: return ENODEV; } } + /* for other cases */ return EINVAL; } +/* Return a UNIX errno from a NT status code */ + +int cli_errno_from_nt(uint32 status) +{ + DEBUG(10,("cli_errno_from_nt: 32 bit codes: code=%08x\n", status)); + + /* Status codes without this bit set are not errors */ + + if (!(status & 0xc0000000)) + return 0; + + switch (status) { + case NT_STATUS_ACCESS_VIOLATION: return EACCES; + case NT_STATUS_NO_SUCH_FILE: return ENOENT; + case NT_STATUS_NO_SUCH_DEVICE: return ENODEV; + case NT_STATUS_INVALID_HANDLE: return EBADF; + case NT_STATUS_NO_MEMORY: return ENOMEM; + case NT_STATUS_ACCESS_DENIED: return EACCES; + case NT_STATUS_OBJECT_NAME_NOT_FOUND: return ENOENT; + case NT_STATUS_SHARING_VIOLATION: return EBUSY; + case NT_STATUS_OBJECT_PATH_INVALID: return ENOTDIR; + case NT_STATUS_OBJECT_NAME_COLLISION: return EEXIST; + case NT_STATUS_PATH_NOT_COVERED: return ENOENT; + } + + /* for all other cases - a default code */ + return EINVAL; +} + +/* Return a UNIX errno appropriate for the error received in the last + packet. */ + +int cli_errno(struct cli_state *cli) +{ + uint32 status; + + if (cli_is_dos_error) { + uint8 eclass; + uint32 ecode; + + cli_dos_error(cli, &eclass, &ecode); + return cli_errno_from_dos(eclass, ecode); + } + + status = cli_nt_error(cli); + + return cli_errno_from_nt(status); +} + +/* Return true if the last packet was in error */ + +BOOL cli_is_error(struct cli_state *cli) +{ + uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), rcls = 0; + + if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) + rcls = IVAL(cli->inbuf, smb_rcls); + else + rcls = CVAL(cli->inbuf, smb_rcls); + + return (rcls == 0); +} + +/* Return true if the last error was an NT error */ + +BOOL cli_is_nt_error(struct cli_state *cli) +{ + uint32 flgs2 = SVAL(cli->inbuf,smb_flg2); + + return cli_is_error(cli) && (flgs2 & FLAGS2_32_BIT_ERROR_CODES); +} + +/* Return true if the last error was a DOS error */ + +BOOL cli_is_dos_error(struct cli_state *cli) +{ + uint32 flgs2 = SVAL(cli->inbuf,smb_flg2); + + return cli_is_error(cli) && !(flgs2 & FLAGS2_32_BIT_ERROR_CODES); +} -- cgit From ea43baeeb01dd302f3c5bfecb5d642228b029c3c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 10 Aug 2001 06:46:11 +0000 Subject: Had the test for cli_is_error() reversed. You idiot Stimpy! (This used to be commit e9ceb17d777f4bcb7a9ff6b509c178f063be4722) --- source3/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index c2234e8ead..bb2bbd0dff 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -260,7 +260,7 @@ BOOL cli_is_error(struct cli_state *cli) else rcls = CVAL(cli->inbuf, smb_rcls); - return (rcls == 0); + return (rcls != 0); } /* Return true if the last error was an NT error */ -- cgit From 5c47841335059ace57dfbf03e35872504d86b447 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 10 Aug 2001 07:41:18 +0000 Subject: Debug cleanups. (This used to be commit e98f9481235dce9a0a76450b84769b86eca57ca2) --- source3/libsmb/clierror.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index bb2bbd0dff..022e808fea 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -115,7 +115,7 @@ uint32 cli_nt_error(struct cli_state *cli) came back does not contain one. What do we return here? */ - DEBUG(1, ("ERROR: cli_error() called to read a status code " + DEBUG(1, ("ERROR: cli_nt_error() called to read a status code " "from a packet that does not contain one!\n")); return NT_STATUS_UNSUCCESSFUL; @@ -152,8 +152,8 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *num) came back does not contain one. What do we return here? */ - DEBUG(1, ("ERROR: cli_error() called to read a dos error code " - "from a packet that does not contain one!\n")); + DEBUG(1, ("ERROR: cli_dos_error() called to read a dos error " + "code from a packet that does not contain one!\n")); return; } -- cgit From 1b7fab220f7b30c7ddd73c00544902332ce8525d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 21 Aug 2001 03:04:41 +0000 Subject: Distinguish between NT informational and error codes. (This used to be commit 02fe0e18dfcb8cc83b3cf0b6c8dd4dc1ddb7e196) --- source3/libsmb/clierror.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 022e808fea..59a11dcc60 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -255,12 +255,18 @@ BOOL cli_is_error(struct cli_state *cli) { uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), rcls = 0; - if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) + if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { + + /* Return error is error bits are set */ + rcls = IVAL(cli->inbuf, smb_rcls); - else - rcls = CVAL(cli->inbuf, smb_rcls); + return (rcls & 0xF0000000) == 0xC0000000; + } + + /* Return error if error class in non-zero */ - return (rcls != 0); + rcls = CVAL(cli->inbuf, smb_rcls); + return rcls != 0; } /* Return true if the last error was an NT error */ -- 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/libsmb/clierror.c | 49 +++++++++++------------------------------------ 1 file changed, 11 insertions(+), 38 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 59a11dcc60..896360ce98 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -75,7 +75,6 @@ char *cli_errstr(struct cli_state *cli) int i; /* Case #1: 32-bit NT errors */ - if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { uint32 status = IVAL(cli->inbuf,smb_rcls); @@ -90,7 +89,6 @@ char *cli_errstr(struct cli_state *cli) return cli_smb_errstr(cli); /* Case #3: RAP error */ - for (i = 0; rap_errmap[i].message != NULL; i++) { if (rap_errmap[i].err == cli->rap_error) { return rap_errmap[i].message; @@ -103,69 +101,45 @@ char *cli_errstr(struct cli_state *cli) return error_message; } -/* Return the 32-bit NT status code from the last packet */ +/* Return the 32-bit NT status code from the last packet */ uint32 cli_nt_error(struct cli_state *cli) { int flgs2 = SVAL(cli->inbuf,smb_flg2); if (!(flgs2 & FLAGS2_32_BIT_ERROR_CODES)) { - - /* Eek! We've requested a NT error when the packet that - came back does not contain one. What do we return - here? */ - - DEBUG(1, ("ERROR: cli_nt_error() called to read a status code " - "from a packet that does not contain one!\n")); - - return NT_STATUS_UNSUCCESSFUL; + int class = CVAL(cli->inbuf,smb_rcls); + int code = SVAL(cli->inbuf,smb_err); + return dos_to_ntstatus(class, code); } return IVAL(cli->inbuf,smb_rcls); } + /* Return the DOS error from the last packet - an error class and an error code. */ - -void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *num) +void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) { int flgs2; char rcls; int code; - if (eclass) - *eclass = 0; - - if (num) - *num = 0; - - if(!cli->initialised) - return; - - if(!cli->inbuf) - return; + if(!cli->initialised) return; flgs2 = SVAL(cli->inbuf,smb_flg2); if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { - /* Eek! We've requested a DOS error when the packet that - came back does not contain one. What do we return - here? */ - - DEBUG(1, ("ERROR: cli_dos_error() called to read a dos error " - "code from a packet that does not contain one!\n")); - + uint32 ntstatus = IVAL(cli->inbuf, smb_rcls); + ntstatus_to_dos(ntstatus, eclass, ecode); return; } rcls = CVAL(cli->inbuf,smb_rcls); code = SVAL(cli->inbuf,smb_err); - if (rcls == 0) - return; - if (eclass) *eclass = rcls; - if (num ) *num = code; + if (ecode) *ecode = code; } /* Return a UNIX errno from a dos error class, error number tuple */ @@ -256,9 +230,7 @@ BOOL cli_is_error(struct cli_state *cli) uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), rcls = 0; if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { - /* Return error is error bits are set */ - rcls = IVAL(cli->inbuf, smb_rcls); return (rcls & 0xF0000000) == 0xC0000000; } @@ -286,3 +258,4 @@ BOOL cli_is_dos_error(struct cli_state *cli) return cli_is_error(cli) && !(flgs2 & FLAGS2_32_BIT_ERROR_CODES); } + -- 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/libsmb/clierror.c | 53 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 896360ce98..f485d328e2 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -76,7 +76,7 @@ char *cli_errstr(struct cli_state *cli) /* Case #1: 32-bit NT errors */ if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { - uint32 status = IVAL(cli->inbuf,smb_rcls); + NTSTATUS status = NT_STATUS(IVAL(cli->inbuf,smb_rcls)); return get_nt_error_msg(status); } @@ -103,7 +103,7 @@ char *cli_errstr(struct cli_state *cli) /* Return the 32-bit NT status code from the last packet */ -uint32 cli_nt_error(struct cli_state *cli) +NTSTATUS cli_nt_error(struct cli_state *cli) { int flgs2 = SVAL(cli->inbuf,smb_flg2); @@ -113,7 +113,7 @@ uint32 cli_nt_error(struct cli_state *cli) return dos_to_ntstatus(class, code); } - return IVAL(cli->inbuf,smb_rcls); + return NT_STATUS(IVAL(cli->inbuf,smb_rcls)); } @@ -130,7 +130,7 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) flgs2 = SVAL(cli->inbuf,smb_flg2); if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { - uint32 ntstatus = IVAL(cli->inbuf, smb_rcls); + NTSTATUS ntstatus = NT_STATUS(IVAL(cli->inbuf, smb_rcls)); ntstatus_to_dos(ntstatus, eclass, ecode); return; } @@ -175,29 +175,38 @@ int cli_errno_from_dos(uint8 eclass, uint32 num) } /* Return a UNIX errno from a NT status code */ - -int cli_errno_from_nt(uint32 status) +static struct { + NTSTATUS status; + int error; +} nt_errno_map[] = { + {NT_STATUS_ACCESS_VIOLATION, EACCES}, + {NT_STATUS_NO_SUCH_FILE, ENOENT}, + {NT_STATUS_NO_SUCH_DEVICE, ENODEV}, + {NT_STATUS_INVALID_HANDLE, EBADF}, + {NT_STATUS_NO_MEMORY, ENOMEM}, + {NT_STATUS_ACCESS_DENIED, EACCES}, + {NT_STATUS_OBJECT_NAME_NOT_FOUND, ENOENT}, + {NT_STATUS_SHARING_VIOLATION, EBUSY}, + {NT_STATUS_OBJECT_PATH_INVALID, ENOTDIR}, + {NT_STATUS_OBJECT_NAME_COLLISION, EEXIST}, + {NT_STATUS_PATH_NOT_COVERED, ENOENT}, + {NT_STATUS(0), 0} +}; + +int cli_errno_from_nt(NTSTATUS status) { - DEBUG(10,("cli_errno_from_nt: 32 bit codes: code=%08x\n", status)); + int i; + DEBUG(10,("cli_errno_from_nt: 32 bit codes: code=%08x\n", NT_STATUS_V(status))); /* Status codes without this bit set are not errors */ - if (!(status & 0xc0000000)) + if (!(NT_STATUS_V(status) & 0xc0000000)) return 0; - switch (status) { - case NT_STATUS_ACCESS_VIOLATION: return EACCES; - case NT_STATUS_NO_SUCH_FILE: return ENOENT; - case NT_STATUS_NO_SUCH_DEVICE: return ENODEV; - case NT_STATUS_INVALID_HANDLE: return EBADF; - case NT_STATUS_NO_MEMORY: return ENOMEM; - case NT_STATUS_ACCESS_DENIED: return EACCES; - case NT_STATUS_OBJECT_NAME_NOT_FOUND: return ENOENT; - case NT_STATUS_SHARING_VIOLATION: return EBUSY; - case NT_STATUS_OBJECT_PATH_INVALID: return ENOTDIR; - case NT_STATUS_OBJECT_NAME_COLLISION: return EEXIST; - case NT_STATUS_PATH_NOT_COVERED: return ENOENT; - } + for (i=0;nt_errno_map[i].error;i++) { + if (NT_STATUS_V(nt_errno_map[i].status) == + NT_STATUS_V(status)) return nt_errno_map[i].error; + } /* for all other cases - a default code */ return EINVAL; @@ -208,7 +217,7 @@ int cli_errno_from_nt(uint32 status) int cli_errno(struct cli_state *cli) { - uint32 status; + NTSTATUS status; if (cli_is_dos_error) { uint8 eclass; -- cgit From 1f079939001fa4a48b37c319049bc273db85a79f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 28 Aug 2001 01:28:01 +0000 Subject: fixed typo (This used to be commit 2d1829dfd041336a587443435d8dccab365a2b56) --- source3/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index f485d328e2..22c5dbaf77 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -219,7 +219,7 @@ int cli_errno(struct cli_state *cli) { NTSTATUS status; - if (cli_is_dos_error) { + if (cli_is_dos_error(cli)) { uint8 eclass; uint32 ecode; -- cgit From d53d5beeb29c0024556aae2f66f1d5bfe63960e5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 5 Sep 2001 11:32:59 +0000 Subject: use cli_is_error() instead of looking in smb_rcls, otherwise NT status codes don't work correctly (This used to be commit 55d5828e608671f070a9e96938be0d16d50aeb26) --- source3/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 22c5dbaf77..5bc3992944 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -58,7 +58,7 @@ static struct ****************************************************************************/ static char *cli_smb_errstr(struct cli_state *cli) { - return smb_errstr(cli->inbuf); + return smb_dos_errstr(cli->inbuf); } /*************************************************************************** -- 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/libsmb/clierror.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 5bc3992944..bcecc92d77 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -23,8 +23,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /***************************************************** RAP error codes - a small start but will be extended. *******************************************************/ @@ -267,4 +265,3 @@ BOOL cli_is_dos_error(struct cli_state *cli) return cli_is_error(cli) && !(flgs2 & FLAGS2_32_BIT_ERROR_CODES); } - -- cgit From fab88997b021ad66dd7f03220d95d1f7ee315140 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 29 Oct 2001 08:12:44 +0000 Subject: This patch applied, except without the structure changes to nmblib.c Andrew Bartlett. From kai@cmail.ru Mon Oct 29 18:50:42 2001 Date: Fri, 19 Oct 2001 17:26:06 +0300 From: Andrew V. Samoilov To: samba-technical@lists.samba.org Subject: [patch]: makes some arrays const to be shared between processes Hi! This patch makes some arrays const. So these arrays go to text/rodata segment and are shared between all of the processes which use shared library with these arrays. Regards, Andrew V. Samoilov. P.S. Please cc your answer to kai@cmail.ru, I don't subscribed to this list. ChangeLog: * cliconnect.c (prots): Make const. * clierror.c (rap_errmap): Likewise. * nmblib.c (nmb_header_opcode_names): Likewise. (lookup_opcode_name): Make opcode_namep const. Eliminate i. * nterr.c (nt_err_code_struct): Typedef const. * smberr.c (err_code_struct): Make const. (err_classes): Likewise. (This used to be commit cb84485a2b0e1fdcb6fa90e0bfb97e125ae1b3dd) --- source3/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index bcecc92d77..fe793d4b0e 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -27,7 +27,7 @@ RAP error codes - a small start but will be extended. *******************************************************/ -static struct +static const struct { int err; char *message; -- cgit From fc93f4f403a5160a4bd0e365b2312f32198598c8 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 26 Nov 2001 07:53:33 +0000 Subject: Fix --enable-developer shadow warning (This used to be commit 6a919bcf3d5848e09ddba1e8946f985661af8f67) --- source3/libsmb/clierror.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index fe793d4b0e..e4d931b965 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -67,7 +67,7 @@ static char *cli_smb_errstr(struct cli_state *cli) char *cli_errstr(struct cli_state *cli) { - static fstring error_message; + static fstring cli_error_message; uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), errnum; uint8 errclass; int i; @@ -93,10 +93,10 @@ char *cli_errstr(struct cli_state *cli) } } - slprintf(error_message, sizeof(error_message) - 1, "code %d", + slprintf(cli_error_message, sizeof(cli_error_message) - 1, "code %d", cli->rap_error); - return error_message; + return cli_error_message; } -- cgit From 775c3876dbd02a2beae0626b2e735583ccedffbb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Dec 2001 19:18:56 +0000 Subject: RAP error strings take precedence as they are not encoded in the SMB header (ie. the call can succeed, but still be an encoded error). Jeremy. (This used to be commit 3c68b94199ff08b205d1eb14da56804936b900a8) --- source3/libsmb/clierror.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index e4d931b965..cd1f86a476 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -72,7 +72,14 @@ char *cli_errstr(struct cli_state *cli) uint8 errclass; int i; - /* Case #1: 32-bit NT errors */ + /* Case #1: RAP error */ + for (i = 0; rap_errmap[i].message != NULL; i++) { + if (rap_errmap[i].err == cli->rap_error) { + return rap_errmap[i].message; + } + } + + /* Case #2: 32-bit NT errors */ if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { NTSTATUS status = NT_STATUS(IVAL(cli->inbuf,smb_rcls)); @@ -81,18 +88,11 @@ char *cli_errstr(struct cli_state *cli) cli_dos_error(cli, &errclass, &errnum); - /* Case #2: SMB error */ + /* Case #3: SMB error */ if (errclass != 0) return cli_smb_errstr(cli); - /* Case #3: RAP error */ - for (i = 0; rap_errmap[i].message != NULL; i++) { - if (rap_errmap[i].err == cli->rap_error) { - return rap_errmap[i].message; - } - } - slprintf(cli_error_message, sizeof(cli_error_message) - 1, "code %d", cli->rap_error); -- cgit From a427fafc1f95d472189e867781a4b75ab0c8adcb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Dec 2001 19:48:43 +0000 Subject: Treat RAP codes differently. Jeremy. (This used to be commit 919b11a787145139e6255674179b2ff7e587475d) --- source3/libsmb/clierror.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index cd1f86a476..81e8be36a8 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -69,34 +69,35 @@ char *cli_errstr(struct cli_state *cli) { static fstring cli_error_message; uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), errnum; - uint8 errclass; - int i; + uint8 errclass; + int i; - /* Case #1: RAP error */ - for (i = 0; rap_errmap[i].message != NULL; i++) { - if (rap_errmap[i].err == cli->rap_error) { - return rap_errmap[i].message; + /* Case #1: RAP error */ + if (cli->rap_error) { + for (i = 0; rap_errmap[i].message != NULL; i++) { + if (rap_errmap[i].err == cli->rap_error) { + return rap_errmap[i].message; + } } - } - /* Case #2: 32-bit NT errors */ - if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { - NTSTATUS status = NT_STATUS(IVAL(cli->inbuf,smb_rcls)); + slprintf(cli_error_message, sizeof(cli_error_message) - 1, "RAP code %d", + cli->rap_error); - return get_nt_error_msg(status); - } + return cli_error_message; + } - cli_dos_error(cli, &errclass, &errnum); + /* Case #2: 32-bit NT errors */ + if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { + NTSTATUS status = NT_STATUS(IVAL(cli->inbuf,smb_rcls)); - /* Case #3: SMB error */ + return get_nt_error_msg(status); + } - if (errclass != 0) - return cli_smb_errstr(cli); + cli_dos_error(cli, &errclass, &errnum); - slprintf(cli_error_message, sizeof(cli_error_message) - 1, "code %d", - cli->rap_error); + /* Case #3: SMB error */ - return cli_error_message; + return cli_smb_errstr(cli); } -- cgit From c69d1b943470aeebcee0dfcb4fd1051b8b070e29 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Tue, 22 Jan 2002 05:11:28 +0000 Subject: Add more string explanations of RAP errors that are already documented in clirap2. (This used to be commit 935955b50ff503d18265f745e6e0df90d3e5dd4b) --- source3/libsmb/clierror.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 81e8be36a8..637f362ae8 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -25,6 +25,10 @@ /***************************************************** RAP error codes - a small start but will be extended. + + XXX: Perhaps these should move into a common function because they're + duplicated in clirap2.c + *******************************************************/ static const struct @@ -33,14 +37,19 @@ static const struct char *message; } rap_errmap[] = { - {5, "User has insufficient privilege" }, - {86, "The specified password is invalid" }, - {2226, "Operation only permitted on a Primary Domain Controller" }, - {2242, "The password of this user has expired." }, - {2243, "The password of this user cannot change." }, - {2244, "This password cannot be used now (password history conflict)." }, - {2245, "The password is shorter than required." }, - {2246, "The password of this user is too recent to change."}, + {5, "RAP5: User has insufficient privilege" }, + {50, "RAP50: Not supported by server" }, + {65, "RAP65: Access denied" }, + {86, "RAP86: The specified password is invalid" }, + {2220, "RAP2220: Group does not exist" }, + {2221, "RAP2221: User does not exist" }, + {2226, "RAP2226: Operation only permitted on a Primary Domain Controller" }, + {2237, "RAP2237: User is not in group" }, + {2242, "RAP2242: The password of this user has expired." }, + {2243, "RAP2243: The password of this user cannot change." }, + {2244, "RAP2244: This password cannot be used now (password history conflict)." }, + {2245, "RAP2245: The password is shorter than required." }, + {2246, "RAP2246: The password of this user is too recent to change."}, /* these really shouldn't be here ... */ {0x80, "Not listening on called name"}, -- 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/libsmb/clierror.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 637f362ae8..89550d18ed 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 3.0 + Unix SMB/CIFS implementation. client error handling routines Copyright (C) Andrew Tridgell 1994-1998 -- cgit From 8cd8cfd4cfc916cab4e5d695722da91d9b1f05df Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 13 Feb 2002 16:44:49 +0000 Subject: merge from 2.2 (This used to be commit 50fa21c995d33601920b3b56a3e03b09262e7fd9) --- source3/libsmb/clierror.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 89550d18ed..13ea6b1997 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -80,6 +80,11 @@ char *cli_errstr(struct cli_state *cli) uint8 errclass; int i; + if (!cli->initialised) { + fstrcpy(cli_error_message, "[Programmer's error] cli_errstr called on unitialized cli_stat struct!\n"); + return cli_error_message; + } + /* Case #1: RAP error */ if (cli->rap_error) { for (i = 0; rap_errmap[i].message != NULL; i++) { -- 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/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 13ea6b1997..591c04db22 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -103,7 +103,7 @@ char *cli_errstr(struct cli_state *cli) if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { NTSTATUS status = NT_STATUS(IVAL(cli->inbuf,smb_rcls)); - return get_nt_error_msg(status); + return nt_errstr(status); } cli_dos_error(cli, &errclass, &errnum); -- cgit From a834a73e341059be154426390304a42e4a011f72 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 25 Sep 2002 15:19:00 +0000 Subject: sync'ing up for 3.0alpha20 release (This used to be commit 65e7b5273bb58802bf0c389b77f7fcae0a1f6139) --- source3/libsmb/clierror.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 591c04db22..e1507c6048 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -156,7 +156,7 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) /* Return a UNIX errno from a dos error class, error number tuple */ -int cli_errno_from_dos(uint8 eclass, uint32 num) +static int cli_errno_from_dos(uint8 eclass, uint32 num) { if (eclass == ERRDOS) { switch (num) { @@ -205,7 +205,7 @@ static struct { {NT_STATUS(0), 0} }; -int cli_errno_from_nt(NTSTATUS status) +static int cli_errno_from_nt(NTSTATUS status) { int i; DEBUG(10,("cli_errno_from_nt: 32 bit codes: code=%08x\n", NT_STATUS_V(status))); -- cgit From 5cec60b31b63821ebc35f0a3f02b96329a08387d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 1 Oct 2002 01:41:20 +0000 Subject: Added error string for server timeout on client call. Jeremy. (This used to be commit 28d2eb934318818a3b0527e391987ea139dbf4a3) --- source3/libsmb/clierror.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index e1507c6048..fb88b66786 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -85,6 +85,14 @@ char *cli_errstr(struct cli_state *cli) return cli_error_message; } + /* Was it server timeout ? */ + if (cli->fd == -1 && cli->timeout > 0 && cli->smb_read_error == READ_TIMEOUT) { + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Call timed out: server did not respond after %d milliseconds", + cli->timeout); + return cli_error_message; + } + /* Case #1: RAP error */ if (cli->rap_error) { for (i = 0; rap_errmap[i].message != NULL; i++) { -- cgit From 8147df0b6b4674670e70b45c603e8323e5c61c33 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 1 Oct 2002 06:50:38 +0000 Subject: Cope with rw errors and timeout to peer. Jeremy. (This used to be commit d8d351eb01ea7c84828dbc96224d7b13d643b558) --- source3/libsmb/clierror.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index fb88b66786..f5281eb047 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -85,11 +85,31 @@ char *cli_errstr(struct cli_state *cli) return cli_error_message; } - /* Was it server timeout ? */ - if (cli->fd == -1 && cli->timeout > 0 && cli->smb_read_error == READ_TIMEOUT) { - slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Call timed out: server did not respond after %d milliseconds", - cli->timeout); + /* Was it server socket error ? */ + if (cli->fd == -1 && cli->smb_rw_error) { + switch(cli->smb_rw_error) { + case READ_TIMEOUT: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Call timed out: server did not respond after %d milliseconds", + cli->timeout); + break; + case READ_EOF: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Call returned zero bytes (EOF)\n" ); + break; + case READ_ERROR: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Read error: %s\n", strerror(errno) ); + break; + case WRITE_ERROR: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Write error: %s\n", strerror(errno) ); + break; + default: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Unknown error code %d\n", cli->smb_rw_error ); + break; + } return cli_error_message; } -- cgit From 634c54310c92c48dd4eceec602e230a021bdcfc5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 3 Jan 2003 08:28:12 +0000 Subject: Merge from HEAD - make Samba compile with -Wwrite-strings without additional warnings. (Adds a lot of const). Andrew Bartlett (This used to be commit 3a7458f9472432ef12c43008414925fd1ce8ea0c) --- source3/libsmb/clierror.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index f5281eb047..12a7b5dba1 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -33,7 +33,7 @@ static const struct { int err; - char *message; + const char *message; } rap_errmap[] = { {5, "RAP5: User has insufficient privilege" }, @@ -62,7 +62,7 @@ static const struct /**************************************************************************** return a description of an SMB error ****************************************************************************/ -static char *cli_smb_errstr(struct cli_state *cli) +static const char *cli_smb_errstr(struct cli_state *cli) { return smb_dos_errstr(cli->inbuf); } @@ -73,7 +73,7 @@ static char *cli_smb_errstr(struct cli_state *cli) in which case they can be safely ignored. ****************************************************************************/ -char *cli_errstr(struct cli_state *cli) +const char *cli_errstr(struct cli_state *cli) { static fstring cli_error_message; uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), errnum; -- cgit From a0e8344a8d1e8fbbde4cc4ca5a5722ee1e2c2bcf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 15 Apr 2003 14:42:06 +0000 Subject: Add some more NT to unix error code mappings (from HEAD) (This used to be commit 62dac3d6ebc72bec24f3c0df4c8d8e37029473e2) --- source3/libsmb/clierror.c | 95 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 12a7b5dba1..cea736ef18 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -2,6 +2,7 @@ Unix SMB/CIFS implementation. client error handling routines Copyright (C) Andrew Tridgell 1994-1998 + Copyright (C) Jelmer Vernooij 2003 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 @@ -220,16 +221,104 @@ static struct { int error; } nt_errno_map[] = { {NT_STATUS_ACCESS_VIOLATION, EACCES}, - {NT_STATUS_NO_SUCH_FILE, ENOENT}, - {NT_STATUS_NO_SUCH_DEVICE, ENODEV}, {NT_STATUS_INVALID_HANDLE, EBADF}, - {NT_STATUS_NO_MEMORY, ENOMEM}, {NT_STATUS_ACCESS_DENIED, EACCES}, {NT_STATUS_OBJECT_NAME_NOT_FOUND, ENOENT}, {NT_STATUS_SHARING_VIOLATION, EBUSY}, {NT_STATUS_OBJECT_PATH_INVALID, ENOTDIR}, {NT_STATUS_OBJECT_NAME_COLLISION, EEXIST}, {NT_STATUS_PATH_NOT_COVERED, ENOENT}, + {NT_STATUS_UNSUCCESSFUL, EINVAL}, + {NT_STATUS_NOT_IMPLEMENTED, ENOSYS}, + {NT_STATUS_IN_PAGE_ERROR, EFAULT}, + {NT_STATUS_BAD_NETWORK_NAME, ENOENT}, +#ifdef EDQUOT + {NT_STATUS_PAGEFILE_QUOTA, EDQUOT}, + {NT_STATUS_QUOTA_EXCEEDED, EDQUOT}, + {NT_STATUS_REGISTRY_QUOTA_LIMIT, EDQUOT}, + {NT_STATUS_LICENSE_QUOTA_EXCEEDED, EDQUOT}, +#endif +#ifdef ETIME + {NT_STATUS_TIMER_NOT_CANCELED, ETIME}, +#endif + {NT_STATUS_INVALID_PARAMETER, EINVAL}, + {NT_STATUS_NO_SUCH_DEVICE, ENODEV}, + {NT_STATUS_NO_SUCH_FILE, ENOENT}, +#ifdef ENODATA + {NT_STATUS_END_OF_FILE, ENODATA}, +#endif +#ifdef ENOMEDIUM + {NT_STATUS_NO_MEDIA_IN_DEVICE, ENOMEDIUM}, + {NT_STATUS_NO_MEDIA, ENOMEDIUM}, +#endif + {NT_STATUS_NONEXISTENT_SECTOR, ESPIPE}, + {NT_STATUS_NO_MEMORY, ENOMEM}, + {NT_STATUS_CONFLICTING_ADDRESSES, EADDRINUSE}, + {NT_STATUS_NOT_MAPPED_VIEW, EINVAL}, + {NT_STATUS_UNABLE_TO_FREE_VM, EADDRINUSE}, + {NT_STATUS_ACCESS_DENIED, EACCES}, + {NT_STATUS_BUFFER_TOO_SMALL, ENOBUFS}, + {NT_STATUS_WRONG_PASSWORD, EACCES}, + {NT_STATUS_LOGON_FAILURE, EACCES}, + {NT_STATUS_INVALID_WORKSTATION, EACCES}, + {NT_STATUS_INVALID_LOGON_HOURS, EACCES}, + {NT_STATUS_PASSWORD_EXPIRED, EACCES}, + {NT_STATUS_ACCOUNT_DISABLED, EACCES}, + {NT_STATUS_DISK_FULL, ENOSPC}, + {NT_STATUS_INVALID_PIPE_STATE, EPIPE}, + {NT_STATUS_PIPE_BUSY, EPIPE}, + {NT_STATUS_PIPE_DISCONNECTED, EPIPE}, + {NT_STATUS_PIPE_NOT_AVAILABLE, ENOSYS}, + {NT_STATUS_FILE_IS_A_DIRECTORY, EISDIR}, + {NT_STATUS_NOT_SUPPORTED, ENOSYS}, + {NT_STATUS_NOT_A_DIRECTORY, ENOTDIR}, + {NT_STATUS_DIRECTORY_NOT_EMPTY, ENOTEMPTY}, + {NT_STATUS_NETWORK_UNREACHABLE, ENETUNREACH}, + {NT_STATUS_HOST_UNREACHABLE, EHOSTUNREACH}, + {NT_STATUS_CONNECTION_ABORTED, ECONNABORTED}, + {NT_STATUS_CONNECTION_REFUSED, ECONNREFUSED}, + {NT_STATUS_TOO_MANY_LINKS, EMLINK}, + {NT_STATUS_NETWORK_BUSY, EBUSY}, + {NT_STATUS_DEVICE_DOES_NOT_EXIST, ENODEV}, +#ifdef ELIBACC + {NT_STATUS_DLL_NOT_FOUND, ELIBACC}, +#endif + {NT_STATUS_PIPE_BROKEN, EPIPE}, + {NT_STATUS_REMOTE_NOT_LISTENING, ECONNREFUSED}, + {NT_STATUS_NETWORK_ACCESS_DENIED, EACCES}, + {NT_STATUS_TOO_MANY_OPENED_FILES, EMFILE}, +#ifdef EPROTO + {NT_STATUS_DEVICE_PROTOCOL_ERROR, EPROTO}, +#endif + {NT_STATUS_FLOAT_OVERFLOW, ERANGE}, + {NT_STATUS_FLOAT_UNDERFLOW, ERANGE}, + {NT_STATUS_INTEGER_OVERFLOW, ERANGE}, + {NT_STATUS_MEDIA_WRITE_PROTECTED, EROFS}, + {NT_STATUS_PIPE_CONNECTED, EISCONN}, + {NT_STATUS_MEMORY_NOT_ALLOCATED, EFAULT}, + {NT_STATUS_FLOAT_INEXACT_RESULT, ERANGE}, + {NT_STATUS_ILL_FORMED_PASSWORD, EACCES}, + {NT_STATUS_PASSWORD_RESTRICTION, EACCES}, + {NT_STATUS_ACCOUNT_RESTRICTION, EACCES}, + {NT_STATUS_PORT_CONNECTION_REFUSED, ECONNREFUSED}, + {NT_STATUS_NAME_TOO_LONG, ENAMETOOLONG}, + {NT_STATUS_REMOTE_DISCONNECT, ESHUTDOWN}, + {NT_STATUS_CONNECTION_DISCONNECTED, ECONNABORTED}, + {NT_STATUS_CONNECTION_RESET, ENETRESET}, +#ifdef ENOTUNIQ + {NT_STATUS_IP_ADDRESS_CONFLICT1, ENOTUNIQ}, + {NT_STATUS_IP_ADDRESS_CONFLICT2, ENOTUNIQ}, +#endif + {NT_STATUS_PORT_MESSAGE_TOO_LONG, EMSGSIZE}, + {NT_STATUS_PROTOCOL_UNREACHABLE, ENOPROTOOPT}, + {NT_STATUS_ADDRESS_ALREADY_EXISTS, EADDRINUSE}, + {NT_STATUS_PORT_UNREACHABLE, EHOSTUNREACH}, + {NT_STATUS_IO_TIMEOUT, ETIMEDOUT}, + {NT_STATUS_RETRY, EAGAIN}, +#ifdef ECOMM + {NT_STATUS_NET_WRITE_FAULT, ECOMM}, +#endif + {NT_STATUS(0), 0} }; -- cgit From 1e2147fc0f677914fb2e3168b4fd4d7ddb4b9867 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 21 Apr 2003 13:00:39 +0000 Subject: Merge SMB signing, cli buffer clobber and NTLMSSP signing tweaks from HEAD. (This used to be commit c6c4f69b8ddc500890a65829e1b9fb7a3e9839e9) --- source3/libsmb/clierror.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index cea736ef18..9ee181a90f 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -96,17 +96,21 @@ const char *cli_errstr(struct cli_state *cli) break; case READ_EOF: slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Call returned zero bytes (EOF)\n" ); + "Call returned zero bytes (EOF)" ); break; case READ_ERROR: slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Read error: %s\n", strerror(errno) ); + "Read error: %s", strerror(errno) ); break; case WRITE_ERROR: slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Write error: %s\n", strerror(errno) ); + "Write error: %s", strerror(errno) ); break; - default: + case READ_BAD_SIG: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Server packet had invalid SMB signiture!"); + break; + default: slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Unknown error code %d\n", cli->smb_rw_error ); break; -- cgit From aed434ea9baf430bf7513ca3fb1f7b2f01792341 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 16 Jul 2003 05:51:10 +0000 Subject: Spelling. (This used to be commit 2750418752e491c5e87f0f2adf253291e31ee4c2) --- source3/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 9ee181a90f..656671823c 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -108,7 +108,7 @@ const char *cli_errstr(struct cli_state *cli) break; case READ_BAD_SIG: slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Server packet had invalid SMB signiture!"); + "Server packet had invalid SMB signature!"); break; default: slprintf(cli_error_message, sizeof(cli_error_message) - 1, -- cgit From 5ab2b1e9219a99b8e3b01a977e0703e76b57debb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 30 Jul 2003 18:57:37 +0000 Subject: Eliminate valgrind error when client gets bad sig on list. Some reformatting. Jeremy. (This used to be commit b8f6b836468b3a0ae75977dc65cae8400f74734c) --- source3/libsmb/clierror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 656671823c..c27e1955e2 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -371,6 +371,9 @@ BOOL cli_is_error(struct cli_state *cli) { uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), rcls = 0; + if (cli->fd == -1 && cli->smb_rw_error != 0) + return True; + if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { /* Return error is error bits are set */ rcls = IVAL(cli->inbuf, smb_rcls); -- cgit From 22cf8924a9b799bc7c833ac8a6caabbee381d6cb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 May 2004 09:50:43 +0000 Subject: r547: Add entry for NT_STATUS_DUPLICATE_NAME in the ntstatus to unix error mapping table (This used to be commit 31c21d520d030e27e4adc6075a50026724b87173) --- source3/libsmb/clierror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index c27e1955e2..ec0ca53a85 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -319,6 +319,9 @@ static struct { {NT_STATUS_PORT_UNREACHABLE, EHOSTUNREACH}, {NT_STATUS_IO_TIMEOUT, ETIMEDOUT}, {NT_STATUS_RETRY, EAGAIN}, +#ifdef ENOTUNIQ + {NT_STATUS_DUPLICATE_NAME, ENOTUNIQ}, +#endif #ifdef ECOMM {NT_STATUS_NET_WRITE_FAULT, ECOMM}, #endif -- cgit From 19ca97a70f6b7b41d251eaa76e4d3c980c6eedff Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 24 Jun 2005 20:25:18 +0000 Subject: r7882: Looks like a large patch - but what it actually does is make Samba safe for using our headers and linking with C++ modules. Stops us from using C++ reserved keywords in our code. Jeremy (This used to be commit 9506b8e145982b1160a2f0aee5c9b7a54980940a) --- source3/libsmb/clierror.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index ec0ca53a85..a16c1f5241 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -153,9 +153,9 @@ NTSTATUS cli_nt_error(struct cli_state *cli) int flgs2 = SVAL(cli->inbuf,smb_flg2); if (!(flgs2 & FLAGS2_32_BIT_ERROR_CODES)) { - int class = CVAL(cli->inbuf,smb_rcls); + int e_class = CVAL(cli->inbuf,smb_rcls); int code = SVAL(cli->inbuf,smb_err); - return dos_to_ntstatus(class, code); + return dos_to_ntstatus(e_class, code); } return NT_STATUS(IVAL(cli->inbuf,smb_rcls)); -- cgit From ab398643a4e44211696ef5ce72b62ab7ecee7bc9 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 19 Jul 2005 02:37:04 +0000 Subject: r8572: Remove crufty #define NO_SYSLOG as it's not used at all anymore. (This used to be commit 985dbb47d925e79c1195ca219f7ab5d6648b22b8) --- source3/libsmb/clierror.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index a16c1f5241..355a2adf34 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -19,8 +19,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define NO_SYSLOG - #include "includes.h" /***************************************************** -- 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/libsmb/clierror.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 355a2adf34..6938702e1e 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -404,3 +404,20 @@ BOOL cli_is_dos_error(struct cli_state *cli) return cli_is_error(cli) && !(flgs2 & FLAGS2_32_BIT_ERROR_CODES); } + +/* Return the last error always as an NTSTATUS. */ + +NTSTATUS cli_get_nt_error(struct cli_state *cli) +{ + if (cli_is_nt_error(cli)) { + return cli_nt_error(cli); + } else if (cli_is_dos_error(cli)) { + uint32 ecode; + uint8 eclass; + cli_dos_error(cli, &eclass, &ecode); + return dos_to_ntstatus(eclass, ecode); + } else { + /* Something went wrong, we don't know what. */ + return NT_STATUS_UNSUCCESSFUL; + } +} -- cgit From ffba826a17f0631d25d479c238d9a1bf5e9cf3e9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 24 Feb 2006 05:05:09 +0000 Subject: r13664: Fix the cli_error codes to always detect a socket error. This code needs a tidyup and common code with libsmb/errormap.c merging. Should fix the winbindd crash Jerry found (I hope). Jeremy. (This used to be commit e81227d044fbe7c73c121e540ccafc7f6517c4ea) --- source3/libsmb/clierror.c | 146 +++++++++++++++++++++++++++++++++------------- 1 file changed, 107 insertions(+), 39 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 6938702e1e..9d7555a720 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -3,6 +3,7 @@ client error handling routines Copyright (C) Andrew Tridgell 1994-1998 Copyright (C) Jelmer Vernooij 2003 + Copyright (C) Jeremy Allison 2006 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 @@ -29,49 +30,73 @@ *******************************************************/ -static const struct -{ - int err; - const char *message; -} rap_errmap[] = -{ - {5, "RAP5: User has insufficient privilege" }, - {50, "RAP50: Not supported by server" }, - {65, "RAP65: Access denied" }, - {86, "RAP86: The specified password is invalid" }, - {2220, "RAP2220: Group does not exist" }, - {2221, "RAP2221: User does not exist" }, - {2226, "RAP2226: Operation only permitted on a Primary Domain Controller" }, - {2237, "RAP2237: User is not in group" }, - {2242, "RAP2242: The password of this user has expired." }, - {2243, "RAP2243: The password of this user cannot change." }, - {2244, "RAP2244: This password cannot be used now (password history conflict)." }, - {2245, "RAP2245: The password is shorter than required." }, - {2246, "RAP2246: The password of this user is too recent to change."}, - - /* these really shouldn't be here ... */ - {0x80, "Not listening on called name"}, - {0x81, "Not listening for calling name"}, - {0x82, "Called name not present"}, - {0x83, "Called name present, but insufficient resources"}, - - {0, NULL} +static const struct { + int err; + const char *message; +} rap_errmap[] = { + {5, "RAP5: User has insufficient privilege" }, + {50, "RAP50: Not supported by server" }, + {65, "RAP65: Access denied" }, + {86, "RAP86: The specified password is invalid" }, + {2220, "RAP2220: Group does not exist" }, + {2221, "RAP2221: User does not exist" }, + {2226, "RAP2226: Operation only permitted on a Primary Domain Controller" }, + {2237, "RAP2237: User is not in group" }, + {2242, "RAP2242: The password of this user has expired." }, + {2243, "RAP2243: The password of this user cannot change." }, + {2244, "RAP2244: This password cannot be used now (password history conflict)." }, + {2245, "RAP2245: The password is shorter than required." }, + {2246, "RAP2246: The password of this user is too recent to change."}, + + /* these really shouldn't be here ... */ + {0x80, "Not listening on called name"}, + {0x81, "Not listening for calling name"}, + {0x82, "Called name not present"}, + {0x83, "Called name present, but insufficient resources"}, + + {0, NULL} }; /**************************************************************************** - return a description of an SMB error + Return a description of an SMB error. ****************************************************************************/ + static const char *cli_smb_errstr(struct cli_state *cli) { return smb_dos_errstr(cli->inbuf); } +/**************************************************************************** + Convert a socket error into an NTSTATUS. +****************************************************************************/ + +static NTSTATUS cli_smb_rw_error_to_ntstatus(struct cli_state *cli) +{ + switch(cli->smb_rw_error) { + case READ_TIMEOUT: + return NT_STATUS_IO_TIMEOUT; + case READ_EOF: + return NT_STATUS_END_OF_FILE; + /* What we shoud really do for read/write errors is convert from errno. */ + /* FIXME. JRA. */ + case READ_ERROR: + return NT_STATUS_INVALID_NETWORK_RESPONSE; + case WRITE_ERROR: + return NT_STATUS_UNEXPECTED_NETWORK_ERROR; + case READ_BAD_SIG: + return NT_STATUS_INVALID_PARAMETER; + default: + break; + } + return NT_STATUS_UNSUCCESSFUL; +} + /*************************************************************************** Return an error message - either an NT error, SMB error or a RAP error. Note some of the NT errors are actually warnings or "informational" errors in which case they can be safely ignored. ****************************************************************************/ - + const char *cli_errstr(struct cli_state *cli) { static fstring cli_error_message; @@ -145,11 +170,19 @@ const char *cli_errstr(struct cli_state *cli) } -/* Return the 32-bit NT status code from the last packet */ +/**************************************************************************** + Return the 32-bit NT status code from the last packet. +****************************************************************************/ + NTSTATUS cli_nt_error(struct cli_state *cli) { int flgs2 = SVAL(cli->inbuf,smb_flg2); + /* Deal with socket errors first. */ + if (cli->fd == -1 && cli->smb_rw_error) { + return cli_smb_rw_error_to_ntstatus(cli); + } + if (!(flgs2 & FLAGS2_32_BIT_ERROR_CODES)) { int e_class = CVAL(cli->inbuf,smb_rcls); int code = SVAL(cli->inbuf,smb_err); @@ -160,15 +193,27 @@ NTSTATUS cli_nt_error(struct cli_state *cli) } -/* Return the DOS error from the last packet - an error class and an error - code. */ +/**************************************************************************** + Return the DOS error from the last packet - an error class and an error + code. +****************************************************************************/ + void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) { int flgs2; char rcls; int code; - if(!cli->initialised) return; + if(!cli->initialised) { + return; + } + + /* Deal with socket errors first. */ + if (cli->fd == -1 && cli->smb_rw_error) { + NTSTATUS status = cli_smb_rw_error_to_ntstatus(cli); + ntstatus_to_dos( status, eclass, ecode); + return; + } flgs2 = SVAL(cli->inbuf,smb_flg2); @@ -185,6 +230,10 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) if (ecode) *ecode = code; } +/**************************************************************************** + The following mappings need tidying up and moving into libsmb/errormap.c... +****************************************************************************/ + /* Return a UNIX errno from a dos error class, error number tuple */ static int cli_errno_from_dos(uint8 eclass, uint32 num) @@ -327,6 +376,10 @@ static struct { {NT_STATUS(0), 0} }; +/**************************************************************************** + The following mappings need tidying up and moving into libsmb/errormap.c... +****************************************************************************/ + static int cli_errno_from_nt(NTSTATUS status) { int i; @@ -334,8 +387,9 @@ static int cli_errno_from_nt(NTSTATUS status) /* Status codes without this bit set are not errors */ - if (!(NT_STATUS_V(status) & 0xc0000000)) + if (!(NT_STATUS_V(status) & 0xc0000000)) { return 0; + } for (i=0;nt_errno_map[i].error;i++) { if (NT_STATUS_V(nt_errno_map[i].status) == @@ -351,7 +405,10 @@ static int cli_errno_from_nt(NTSTATUS status) int cli_errno(struct cli_state *cli) { - NTSTATUS status; + if (cli_is_nt_error(cli)) { + NTSTATUS status = cli_nt_error(cli); + return cli_errno_from_nt(status); + } if (cli_is_dos_error(cli)) { uint8 eclass; @@ -361,9 +418,8 @@ int cli_errno(struct cli_state *cli) return cli_errno_from_dos(eclass, ecode); } - status = cli_nt_error(cli); - - return cli_errno_from_nt(status); + /* for other cases */ + return EINVAL; } /* Return true if the last packet was in error */ @@ -372,8 +428,10 @@ BOOL cli_is_error(struct cli_state *cli) { uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), rcls = 0; - if (cli->fd == -1 && cli->smb_rw_error != 0) + /* A socket error is always an error. */ + if (cli->fd == -1 && cli->smb_rw_error != 0) { return True; + } if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) { /* Return error is error bits are set */ @@ -393,6 +451,11 @@ BOOL cli_is_nt_error(struct cli_state *cli) { uint32 flgs2 = SVAL(cli->inbuf,smb_flg2); + /* A socket error is always an NT error. */ + if (cli->fd == -1 && cli->smb_rw_error != 0) { + return True; + } + return cli_is_error(cli) && (flgs2 & FLAGS2_32_BIT_ERROR_CODES); } @@ -402,6 +465,11 @@ BOOL cli_is_dos_error(struct cli_state *cli) { uint32 flgs2 = SVAL(cli->inbuf,smb_flg2); + /* A socket error is always a DOS error. */ + if (cli->fd == -1 && cli->smb_rw_error != 0) { + return True; + } + return cli_is_error(cli) && !(flgs2 & FLAGS2_32_BIT_ERROR_CODES); } -- cgit From f690a968e789da8a77338afbe5490b865c25cc99 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 24 Feb 2006 05:47:19 +0000 Subject: r13669: Get rid of poor errno mapping table. Bounce through NTSTATUS instead. DO NOT MERGE FOR 3.0.21c PLEASE. Jeremy. (This used to be commit 3de0d9af6925e3dc0328c02c2a30127ea5c82a83) --- source3/libsmb/clierror.c | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 9d7555a720..b84a8ee70f 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -230,42 +230,6 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) if (ecode) *ecode = code; } -/**************************************************************************** - The following mappings need tidying up and moving into libsmb/errormap.c... -****************************************************************************/ - -/* Return a UNIX errno from a dos error class, error number tuple */ - -static int cli_errno_from_dos(uint8 eclass, uint32 num) -{ - if (eclass == ERRDOS) { - switch (num) { - case ERRbadfile: return ENOENT; - case ERRbadpath: return ENOTDIR; - case ERRnoaccess: return EACCES; - case ERRfilexists: return EEXIST; - case ERRrename: return EEXIST; - case ERRbadshare: return EBUSY; - case ERRlock: return EBUSY; - case ERRinvalidname: return ENOENT; - case ERRnosuchshare: return ENODEV; - } - } - - if (eclass == ERRSRV) { - switch (num) { - case ERRbadpw: return EPERM; - case ERRaccess: return EACCES; - case ERRnoresource: return ENOMEM; - case ERRinvdevice: return ENODEV; - case ERRinvnetname: return ENODEV; - } - } - - /* for other cases */ - return EINVAL; -} - /* Return a UNIX errno from a NT status code */ static struct { NTSTATUS status; @@ -405,9 +369,11 @@ static int cli_errno_from_nt(NTSTATUS status) int cli_errno(struct cli_state *cli) { + NTSTATUS status; + if (cli_is_nt_error(cli)) { - NTSTATUS status = cli_nt_error(cli); - return cli_errno_from_nt(status); + status = cli_nt_error(cli); + return cli_errno_from_nt(status); } if (cli_is_dos_error(cli)) { @@ -415,7 +381,8 @@ int cli_errno(struct cli_state *cli) uint32 ecode; cli_dos_error(cli, &eclass, &ecode); - return cli_errno_from_dos(eclass, ecode); + status = dos_to_ntstatus(eclass, ecode); + return cli_errno_from_nt(status); } /* for other cases */ -- cgit From 6ee700bd65ea12bf172fce42adf332f6e30ab626 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 28 Aug 2006 01:56:17 +0000 Subject: r17863: Fix unneeded NULL check on pointer parameters causing the Stanford checker to flag null deref. Jeremy. (This used to be commit b7fc023e9025127855fab71002d556e5f84e00b4) --- source3/libsmb/clierror.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index b84a8ee70f..44573bd29b 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -201,8 +201,6 @@ NTSTATUS cli_nt_error(struct cli_state *cli) void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) { int flgs2; - char rcls; - int code; if(!cli->initialised) { return; @@ -223,11 +221,8 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) return; } - rcls = CVAL(cli->inbuf,smb_rcls); - code = SVAL(cli->inbuf,smb_err); - - if (eclass) *eclass = rcls; - if (ecode) *ecode = code; + *eclass = CVAL(cli->inbuf,smb_rcls); + *ecode = SVAL(cli->inbuf,smb_err); } /* Return a UNIX errno from a NT status code */ -- cgit From 96f2a97e011b195c5d445fd8baa0bdcfa03ec174 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 23 Sep 2006 21:41:41 +0000 Subject: r18858: arrgh! - since HAVE_IMMEDIATE_STRUCTURES were last enabled the code can no longer handle it (at least with gcc 4.1.2). Disable it until investigated and fixed properly. (This used to be commit c8670b33b490daeaff987c21fcb0ec601a91d54e) --- source3/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 44573bd29b..01c42bd36a 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -226,7 +226,7 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) } /* Return a UNIX errno from a NT status code */ -static struct { +struct { NTSTATUS status; int error; } nt_errno_map[] = { -- cgit From 0c3194816b513e3743ddcacd1eca2b683ca39b88 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 24 Sep 2006 02:32:34 +0000 Subject: r18865: fixed some of the most obvious NTSTATUS/WERROR mixups in Samba3. It still doesn't compile with immediate structures and the NTSTATUS/WERROR separation, as there are still several places where the two error types are mixed up. I haven't fixed those as they require decisions about the rpcclient code that I really don't want to get into (the error handling there is a mess) So samba3 compiles now, but only becaise HAVE_IMMEDIATE_STRUCTURES is not used (look for HAVE_IMMEDIATE_STRUCTURES_XX_DISABLED) (This used to be commit 8438a6a7d4506d395c8b4bd0e99f9c100e5e3c4e) --- source3/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 01c42bd36a..fcedc3bdab 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -226,7 +226,7 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) } /* Return a UNIX errno from a NT status code */ -struct { +static const struct { NTSTATUS status; int error; } nt_errno_map[] = { -- cgit From 3e12cf85ace31638d2dd924cc202c9d2f31f7890 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Feb 2007 00:35:58 +0000 Subject: r21576: Patch based on work from Todd Stecher to allow client to fragment large SPNEGO blobs (large krb5 tickets). Tested against W2K3R2. Should fix bug #4400. Jeremy. (This used to be commit b81c5c6adce51cec06df0e993534064b20666a8e) --- source3/libsmb/clierror.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index fcedc3bdab..f85fc5c552 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -451,3 +451,12 @@ NTSTATUS cli_get_nt_error(struct cli_state *cli) return NT_STATUS_UNSUCCESSFUL; } } + +/* Push an error code into the inbuf to be returned on the next + * query. */ + +void cli_set_nt_error(struct cli_state *cli, NTSTATUS status) +{ + SSVAL(cli->inbuf,smb_flg2, SVAL(cli->inbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES); + SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(status)); +} -- cgit From ecd496f06654e8316260c9a6ddab5e473f9cc452 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 17 Mar 2007 00:32:54 +0000 Subject: r21865: Add in the stubs for SMB transport encryption. Will flesh these out as I implement. Don't add to SAMBA_3_0_25, this is experimental code. NFSv4 you're now officially on notice... :-). Jeremy. (This used to be commit 5bfe638f2172e272741997100ee5ae8ff280494d) --- source3/libsmb/clierror.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index f85fc5c552..4b222c9015 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -84,6 +84,7 @@ static NTSTATUS cli_smb_rw_error_to_ntstatus(struct cli_state *cli) case WRITE_ERROR: return NT_STATUS_UNEXPECTED_NETWORK_ERROR; case READ_BAD_SIG: + case READ_BAD_DECRYPT: return NT_STATUS_INVALID_PARAMETER; default: break; @@ -133,6 +134,10 @@ const char *cli_errstr(struct cli_state *cli) slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Server packet had invalid SMB signature!"); break; + case READ_BAD_DECRYPT: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Server packet could not be decrypted !"); + break; default: slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Unknown error code %d\n", cli->smb_rw_error ); -- cgit From d1153fc79076741571b203b1d70f1536bde208f0 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 7 May 2007 03:07:39 +0000 Subject: r22732: - Testing of libsmbclient against Vista revealed what is likely a bug in Vista. Vista provides a plethora of kludges to simulate older versions of Windows. The kludges are in the form of shortcuts (or more likely symbolic links, but I don't know enough about Vista to determine that definitively) and in most cases, attempts to access them get back an "access denied" error. On one particular folder, however, "/Users/All Users", it returns an unknown (to ethereal and the Samba3 code) NT status code: 0x8000002d. Although this code does not have a high byte of 0xc0 indicating that it is an error, it appears to be an alternate form of "access denied". Without this patch, libsmbclient times out on an attempt to enumerate that folder rather than returning an error to the caller. This patch corrects that problem. (This used to be commit cc0cd3a12f76b8cd711e3165d4cfe920552f256d) --- source3/libsmb/clierror.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 4b222c9015..d98f428217 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -385,6 +385,15 @@ int cli_errno(struct cli_state *cli) return cli_errno_from_nt(status); } + /* + * Yuck! A special case for this Vista error. Since its high-order + * byte isn't 0xc0, it doesn't match cli_is_nt_error() above. + */ + status = cli_nt_error(cli); + if (NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_INACCESSIBLE_SYSTEM_SHORTCUT)) { + return EACCES; + } + /* for other cases */ return EINVAL; } -- cgit From 4ce65137d927a1f464dcd8f3e5b7b13c71adda27 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 5 Jul 2007 13:46:47 +0000 Subject: r23723: Alexander Larsson pointed me at a missing mapping in clierror.c When renaming a file across 2 filesystem a samba server returns NT_STATUS_NOT_SAME_DEVICE but thius is not translated to EXDEV, and the generic EINVAL is returned instead. This should fix it, Jeremy or Derrel please check if this is ok. (This used to be commit b35038fa4e3e69f1397758497a46dc0d37edee79) --- source3/libsmb/clierror.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index d98f428217..90e82c5101 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -336,7 +336,9 @@ static const struct { #ifdef ECOMM {NT_STATUS_NET_WRITE_FAULT, ECOMM}, #endif - +#ifdef EXDEV + {NT_STATUS_NOT_SAME_DEVICE, EXDEV}, +#endif {NT_STATUS(0), 0} }; -- 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/libsmb/clierror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 90e82c5101..8a66e397c5 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -7,7 +7,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/libsmb/clierror.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 8a66e397c5..374fdfa5e4 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -16,8 +16,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 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/libsmb/clierror.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 374fdfa5e4..be018074eb 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -83,7 +83,6 @@ static NTSTATUS cli_smb_rw_error_to_ntstatus(struct cli_state *cli) case WRITE_ERROR: return NT_STATUS_UNEXPECTED_NETWORK_ERROR; case READ_BAD_SIG: - case READ_BAD_DECRYPT: return NT_STATUS_INVALID_PARAMETER; default: break; @@ -133,10 +132,6 @@ const char *cli_errstr(struct cli_state *cli) slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Server packet had invalid SMB signature!"); break; - case READ_BAD_DECRYPT: - slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Server packet could not be decrypted !"); - break; default: slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Unknown error code %d\n", cli->smb_rw_error ); -- 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/libsmb/clierror.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index be018074eb..4ab1c237dc 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -396,7 +396,7 @@ int cli_errno(struct cli_state *cli) /* Return true if the last packet was in error */ -BOOL cli_is_error(struct cli_state *cli) +bool cli_is_error(struct cli_state *cli) { uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), rcls = 0; @@ -419,7 +419,7 @@ BOOL cli_is_error(struct cli_state *cli) /* Return true if the last error was an NT error */ -BOOL cli_is_nt_error(struct cli_state *cli) +bool cli_is_nt_error(struct cli_state *cli) { uint32 flgs2 = SVAL(cli->inbuf,smb_flg2); @@ -433,7 +433,7 @@ BOOL cli_is_nt_error(struct cli_state *cli) /* Return true if the last error was a DOS error */ -BOOL cli_is_dos_error(struct cli_state *cli) +bool cli_is_dos_error(struct cli_state *cli) { uint32 flgs2 = SVAL(cli->inbuf,smb_flg2); -- cgit From 73d407968002587eadd0ff13eb413ddf07c78771 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Nov 2007 15:12:42 -0700 Subject: Remove the smb_read_error global variable and replace it with accessor functions. "One global or pstring a day...." :-). Jeremy. (This used to be commit d50d14c300abc83b7015718ec48acc8b3227a273) --- source3/libsmb/clierror.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 4ab1c237dc..1c35bcf146 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -72,17 +72,17 @@ static const char *cli_smb_errstr(struct cli_state *cli) static NTSTATUS cli_smb_rw_error_to_ntstatus(struct cli_state *cli) { switch(cli->smb_rw_error) { - case READ_TIMEOUT: + case SMB_READ_TIMEOUT: return NT_STATUS_IO_TIMEOUT; - case READ_EOF: + case SMB_READ_EOF: return NT_STATUS_END_OF_FILE; /* What we shoud really do for read/write errors is convert from errno. */ /* FIXME. JRA. */ - case READ_ERROR: + case SMB_READ_ERROR: return NT_STATUS_INVALID_NETWORK_RESPONSE; - case WRITE_ERROR: + case SMB_WRITE_ERROR: return NT_STATUS_UNEXPECTED_NETWORK_ERROR; - case READ_BAD_SIG: + case SMB_READ_BAD_SIG: return NT_STATUS_INVALID_PARAMETER; default: break; @@ -111,24 +111,24 @@ const char *cli_errstr(struct cli_state *cli) /* Was it server socket error ? */ if (cli->fd == -1 && cli->smb_rw_error) { switch(cli->smb_rw_error) { - case READ_TIMEOUT: + case SMB_READ_TIMEOUT: slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Call timed out: server did not respond after %d milliseconds", cli->timeout); break; - case READ_EOF: + case SMB_READ_EOF: slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Call returned zero bytes (EOF)" ); break; - case READ_ERROR: + case SMB_READ_ERROR: slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Read error: %s", strerror(errno) ); break; - case WRITE_ERROR: + case SMB_WRITE_ERROR: slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Write error: %s", strerror(errno) ); break; - case READ_BAD_SIG: + case SMB_READ_BAD_SIG: slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Server packet had invalid SMB signature!"); break; -- cgit From 6069670f1bebc37527c8363a72a653e43fff7c0b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 11 Nov 2007 15:30:01 +0100 Subject: Some pstring removal Hi! Feel free to push :-) Volker From 7fae6b3709a973bd0a5a13d3f5c880c61d5e35de Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 11 Nov 2007 15:28:59 +0100 Subject: [PATCH] Remove some static pstrings (This used to be commit c3a66b4ee97a902c5cf43c3bb145541849a029ed) --- source3/libsmb/clierror.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 1c35bcf146..2232ee27a7 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -98,14 +98,15 @@ static NTSTATUS cli_smb_rw_error_to_ntstatus(struct cli_state *cli) const char *cli_errstr(struct cli_state *cli) { - static fstring cli_error_message; + fstring cli_error_message; uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), errnum; uint8 errclass; int i; + char *result; if (!cli->initialised) { fstrcpy(cli_error_message, "[Programmer's error] cli_errstr called on unitialized cli_stat struct!\n"); - return cli_error_message; + goto done; } /* Was it server socket error ? */ @@ -137,7 +138,7 @@ const char *cli_errstr(struct cli_state *cli) "Unknown error code %d\n", cli->smb_rw_error ); break; } - return cli_error_message; + goto done; } /* Case #1: RAP error */ @@ -151,7 +152,7 @@ const char *cli_errstr(struct cli_state *cli) slprintf(cli_error_message, sizeof(cli_error_message) - 1, "RAP code %d", cli->rap_error); - return cli_error_message; + goto done; } /* Case #2: 32-bit NT errors */ @@ -166,6 +167,11 @@ const char *cli_errstr(struct cli_state *cli) /* Case #3: SMB error */ return cli_smb_errstr(cli); + + done: + result = talloc_strdup(talloc_tos(), cli_error_message); + SMB_ASSERT(result); + return result; } -- cgit From bff221cf1b52552fc556aa2c880a7e386b1cb2ac Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 25 Nov 2007 12:54:52 +0100 Subject: In libsmbclient, map NT_STATUS_OBJECT_PATH_NOT_FOUND to ENOENT Thanks to SATOH Fumiyasu! This fixes bug 4974 (This used to be commit 41e07682dc1fa535ddaf405efa26fabb33c8bbf9) --- source3/libsmb/clierror.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 2232ee27a7..c9c5a6cd30 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -239,6 +239,7 @@ static const struct { {NT_STATUS_INVALID_HANDLE, EBADF}, {NT_STATUS_ACCESS_DENIED, EACCES}, {NT_STATUS_OBJECT_NAME_NOT_FOUND, ENOENT}, + {NT_STATUS_OBJECT_PATH_NOT_FOUND, ENOENT}, {NT_STATUS_SHARING_VIOLATION, EBUSY}, {NT_STATUS_OBJECT_PATH_INVALID, ENOTDIR}, {NT_STATUS_OBJECT_NAME_COLLISION, EEXIST}, -- cgit From d2cf97aeba14a4d336fb57b01f19bd5a08dcb003 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Nov 2007 13:24:54 -0800 Subject: Remove the explicit TALLOC_CTX * from cli_struct. Make us very explicit about how long a talloc ctx should last. Jeremy. (This used to be commit ba9e2be2b5a59684e854609f9d82ea1633448c62) --- source3/libsmb/clierror.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index c9c5a6cd30..587abade59 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -84,6 +84,8 @@ static NTSTATUS cli_smb_rw_error_to_ntstatus(struct cli_state *cli) return NT_STATUS_UNEXPECTED_NETWORK_ERROR; case SMB_READ_BAD_SIG: return NT_STATUS_INVALID_PARAMETER; + case SMB_NO_MEMORY: + return NT_STATUS_NO_MEMORY; default: break; } @@ -133,6 +135,10 @@ const char *cli_errstr(struct cli_state *cli) slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Server packet had invalid SMB signature!"); break; + case SMB_NO_MEMORY: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Out of memory"); + break; default: slprintf(cli_error_message, sizeof(cli_error_message) - 1, "Unknown error code %d\n", cli->smb_rw_error ); -- cgit From 1d940490e815bbdb7e4af23ace05ec9ac8fddae8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 28 Feb 2008 02:22:13 -0800 Subject: Fix from Guenter Kukkukk to fix listing against OS/2 servers. OS/2 returns eclass == ERRDOS && ecode == ERRnofiles for a zero entry directory listing. Jeremy. (This used to be commit b34da627053581a9584367e177566d4a2cef7e82) --- source3/libsmb/clierror.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/libsmb/clierror.c') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 587abade59..36746419f7 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -483,3 +483,15 @@ void cli_set_nt_error(struct cli_state *cli, NTSTATUS status) SSVAL(cli->inbuf,smb_flg2, SVAL(cli->inbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES); SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(status)); } + +/* Reset an error. */ + +void cli_reset_error(struct cli_state *cli) +{ + if (SVAL(cli->inbuf,smb_flg2) & FLAGS2_32_BIT_ERROR_CODES) { + SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(NT_STATUS_OK)); + } else { + SCVAL(cli->inbuf,smb_rcls,0); + SSVAL(cli->inbuf,smb_err,0); + } +} -- cgit