1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +03:00

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 commit is contained in:
Andrew Tridgell
-
parent 9e0c9a99f6
commit 83d9896c1e
28 changed files with 1245 additions and 1590 deletions

View File

@ -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);
}