summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2001-11-25 02:35:37 +0000
committerAndrew Bartlett <abartlet@samba.org>2001-11-25 02:35:37 +0000
commita71f3f66a1b47a70e402c4d82736f376449b923c (patch)
treef1a553543427f3bddda2f8f12babf00e10676c4a /source3/libsmb
parent97346ea795f43a9d9487d9c1a63af4016a72e753 (diff)
downloadsamba-a71f3f66a1b47a70e402c4d82736f376449b923c.tar.gz
samba-a71f3f66a1b47a70e402c4d82736f376449b923c.tar.bz2
samba-a71f3f66a1b47a70e402c4d82736f376449b923c.zip
Add a new torture test to extract a NT->DOS error map from an NT member of a
samba domain. The PDC must be running a special authenticaion module that spits out NT errors based on username. Andrew Bartlett (This used to be commit adc7a6048c13342b79b6228beafb5142c50f318d)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/cliconnect.c5
-rw-r--r--source3/libsmb/clientgen.c7
-rw-r--r--source3/libsmb/nterr.c21
-rw-r--r--source3/libsmb/smberr.c46
4 files changed, 74 insertions, 5 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 4ea19db9ec..ed4bfcd9e3 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -117,10 +117,7 @@ static uint32 cli_session_setup_capabilities(struct cli_state *cli)
{
uint32 capabilities = CAP_NT_SMBS;
- /* Set the CLI_FORCE_DOSERR environment variable to test
- client routines using DOS errors instead of STATUS32
- ones. This intended only as a temporary hack. */
- if (!getenv("CLI_FORCE_DOSERR")) {
+ if (!cli->force_dos_errors) {
capabilities |= CAP_STATUS32;
}
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 0f1fa2e42e..0e09388803 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -198,6 +198,13 @@ struct cli_state *cli_initialise(struct cli_state *cli)
cli->oplock_handler = cli_oplock_ack;
cli->use_spnego = True;
+ /* Set the CLI_FORCE_DOSERR environment variable to test
+ client routines using DOS errors instead of STATUS32
+ ones. This intended only as a temporary hack. */
+ if (getenv("CLI_FORCE_DOSERR")) {
+ cli->force_dos_errors = True;
+ }
+
if (!cli->outbuf || !cli->inbuf)
goto error;
diff --git a/source3/libsmb/nterr.c b/source3/libsmb/nterr.c
index 238908d6cd..25286156ee 100644
--- a/source3/libsmb/nterr.c
+++ b/source3/libsmb/nterr.c
@@ -558,3 +558,24 @@ char *get_nt_error_msg(NTSTATUS nt_code)
return msg;
}
+
+/*****************************************************************************
+ returns an NT_STATUS constant as a string for inclusion in autogen C code
+ *****************************************************************************/
+char *get_nt_error_c_code(NTSTATUS nt_code)
+{
+ static pstring out;
+ int idx = 0;
+
+ while (nt_errs[idx].nt_errstr != NULL) {
+ if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
+ NT_STATUS_V(nt_code)) {
+ return nt_errs[idx].nt_errstr;
+ }
+ idx++;
+ }
+
+ slprintf(out, sizeof(out), "NT_STATUS(0x%08x)", NT_STATUS_V(nt_code));
+
+ return out;
+}
diff --git a/source3/libsmb/smberr.c b/source3/libsmb/smberr.c
index a43e4764e8..d0aa8f6024 100644
--- a/source3/libsmb/smberr.c
+++ b/source3/libsmb/smberr.c
@@ -156,7 +156,51 @@ const struct
/****************************************************************************
-return a SMB error string from a SMB buffer
+return a SMB error name from a class and code
+****************************************************************************/
+char *smb_dos_err_name(uint8 class, uint16 num)
+{
+ static pstring ret;
+ int i,j;
+
+ for (i=0;err_classes[i].class;i++)
+ if (err_classes[i].code == class) {
+ if (err_classes[i].err_msgs) {
+ err_code_struct *err = err_classes[i].err_msgs;
+ for (j=0;err[j].name;j++)
+ if (num == err[j].code) {
+ return err[j].name;
+ }
+ }
+ slprintf(ret, sizeof(ret) - 1, "%d",num);
+ return ret;
+ }
+
+ slprintf(ret, sizeof(ret) - 1, "Error: Unknown error class (%d,%d)",class,num);
+ return(ret);
+}
+
+
+/****************************************************************************
+return a SMB error class name as a string.
+****************************************************************************/
+char *smb_dos_err_class(uint8 class)
+{
+ static pstring ret;
+ int i;
+
+ for (i=0;err_classes[i].class;i++) {
+ if (err_classes[i].code == class) {
+ return err_classes[i].class;
+ }
+ }
+
+ slprintf(ret, sizeof(ret) - 1, "Error: Unknown class (%d)",class);
+ return(ret);
+}
+
+/****************************************************************************
+return a SMB string from an SMB buffer
****************************************************************************/
char *smb_dos_errstr(char *inbuf)
{