summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-08-27 08:19:43 +0000
committerAndrew Tridgell <tridge@samba.org>2001-08-27 08:19:43 +0000
commite8e98c9ea0690e3acf1126b50882e59e1056c7b3 (patch)
tree2fa75bc825f7e5da041809fe49080e3319656506 /source3/libsmb
parent3820578473da81b7ae0dfa978605da809be59f62 (diff)
downloadsamba-e8e98c9ea0690e3acf1126b50882e59e1056c7b3.tar.gz
samba-e8e98c9ea0690e3acf1126b50882e59e1056c7b3.tar.bz2
samba-e8e98c9ea0690e3acf1126b50882e59e1056c7b3.zip
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)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/clientgen.c3
-rw-r--r--source3/libsmb/clierror.c49
-rw-r--r--source3/libsmb/clitrans.c29
-rw-r--r--source3/libsmb/libsmbclient.c2
4 files changed, 32 insertions, 51 deletions
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index b3933f41e0..87c8348853 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -112,6 +112,9 @@ void cli_setup_packet(struct cli_state *cli)
if (cli->capabilities & CAP_UNICODE) {
flags2 |= FLAGS2_UNICODE_STRINGS;
}
+ if (cli->capabilities & CAP_STATUS32) {
+ flags2 |= FLAGS2_32_BIT_ERROR_CODES;
+ }
SSVAL(cli->outbuf,smb_flg2, flags2);
}
}
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);
}
+
diff --git a/source3/libsmb/clitrans.c b/source3/libsmb/clitrans.c
index 4822508e38..6ae1014435 100644
--- a/source3/libsmb/clitrans.c
+++ b/source3/libsmb/clitrans.c
@@ -412,20 +412,25 @@ BOOL cli_receive_nt_trans(struct cli_state *cli,
total_param = SVAL(cli->inbuf,smb_ntr_TotalParameterCount);
/* allocate it */
- tdata = Realloc(*data,total_data);
- if (!tdata) {
- DEBUG(0,("cli_receive_nt_trans: failed to enlarge buffer"));
- return False;
+ if (total_data) {
+ tdata = Realloc(*data,total_data);
+ if (!tdata) {
+ DEBUG(0,("cli_receive_nt_trans: failed to enlarge data buffer to %d\n",total_data));
+ return False;
+ } else {
+ *data = tdata;
+ }
}
- else
- *data = tdata;
- tparam = Realloc(*param,total_param);
- if (!tparam) {
- DEBUG(0,("cli_receive_nt_trans: failed to enlarge buffer"));
- return False;
+
+ if (total_param) {
+ tparam = Realloc(*param,total_param);
+ if (!tparam) {
+ DEBUG(0,("cli_receive_nt_trans: failed to enlarge param buffer to %d\n", total_param));
+ return False;
+ } else {
+ *param = tparam;
+ }
}
- else
- *param = tparam;
while (1) {
this_data = SVAL(cli->inbuf,smb_ntr_DataCount);
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c
index 581af9b957..c0c586eceb 100644
--- a/source3/libsmb/libsmbclient.c
+++ b/source3/libsmb/libsmbclient.c
@@ -1650,7 +1650,7 @@ int smbc_opendir(const char *fname)
free(smbc_file_table[slot]);
}
smbc_file_table[slot] = NULL;
- errno = cli_error(&srv->cli);
+ errno = cli_errno(&srv->cli);
return -1;
}