From ef2e26c91b80556af033d3335e55f5dfa6fff31d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Aug 2003 01:53:07 +0000 Subject: first public release of samba4 code (This used to be commit b0510b5428b3461aeb9bbe3cc95f62fc73e2b97f) --- source4/libcli/util/asn1.c | 428 ++++++++++ source4/libcli/util/clierror.c | 99 +++ source4/libcli/util/cliutil.c | 110 +++ source4/libcli/util/credentials.c | 215 +++++ source4/libcli/util/doserr.c | 91 +++ source4/libcli/util/errormap.c | 1546 ++++++++++++++++++++++++++++++++++++ source4/libcli/util/nterr.c | 715 +++++++++++++++++ source4/libcli/util/ntlmssp_sign.c | 226 ++++++ source4/libcli/util/pwd_cache.c | 72 ++ source4/libcli/util/smbdes.c | 415 ++++++++++ source4/libcli/util/smbencrypt.c | 418 ++++++++++ source4/libcli/util/smberr.c | 181 +++++ 12 files changed, 4516 insertions(+) create mode 100644 source4/libcli/util/asn1.c create mode 100644 source4/libcli/util/clierror.c create mode 100644 source4/libcli/util/cliutil.c create mode 100644 source4/libcli/util/credentials.c create mode 100644 source4/libcli/util/doserr.c create mode 100644 source4/libcli/util/errormap.c create mode 100644 source4/libcli/util/nterr.c create mode 100644 source4/libcli/util/ntlmssp_sign.c create mode 100644 source4/libcli/util/pwd_cache.c create mode 100644 source4/libcli/util/smbdes.c create mode 100644 source4/libcli/util/smbencrypt.c create mode 100644 source4/libcli/util/smberr.c (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c new file mode 100644 index 0000000000..09d4fbb6c9 --- /dev/null +++ b/source4/libcli/util/asn1.c @@ -0,0 +1,428 @@ +/* + Unix SMB/CIFS implementation. + simple SPNEGO routines + Copyright (C) Andrew Tridgell 2001 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* free an asn1 structure */ +void asn1_free(ASN1_DATA *data) +{ + SAFE_FREE(data->data); +} + +/* write to the ASN1 buffer, advancing the buffer pointer */ +BOOL asn1_write(ASN1_DATA *data, const void *p, int len) +{ + if (data->has_error) return False; + if (data->length < data->ofs+len) { + uint8 *newp; + newp = Realloc(data->data, data->ofs+len); + if (!newp) { + SAFE_FREE(data->data); + data->has_error = True; + return False; + } + data->data = newp; + data->length = data->ofs+len; + } + memcpy(data->data + data->ofs, p, len); + data->ofs += len; + return True; +} + +/* useful fn for writing a uint8 */ +BOOL asn1_write_uint8(ASN1_DATA *data, uint8 v) +{ + return asn1_write(data, &v, 1); +} + +/* push a tag onto the asn1 data buffer. Used for nested structures */ +BOOL asn1_push_tag(ASN1_DATA *data, uint8 tag) +{ + struct nesting *nesting; + + asn1_write_uint8(data, tag); + nesting = (struct nesting *)malloc(sizeof(struct nesting)); + if (!nesting) { + data->has_error = True; + return False; + } + + nesting->start = data->ofs; + nesting->next = data->nesting; + data->nesting = nesting; + return asn1_write_uint8(data, 0xff); +} + +/* pop a tag */ +BOOL asn1_pop_tag(ASN1_DATA *data) +{ + struct nesting *nesting; + size_t len; + + nesting = data->nesting; + + if (!nesting) { + data->has_error = True; + return False; + } + len = data->ofs - (nesting->start+1); + /* yes, this is ugly. We don't know in advance how many bytes the length + of a tag will take, so we assumed 1 byte. If we were wrong then we + need to correct our mistake */ + if (len > 255) { + data->data[nesting->start] = 0x82; + if (!asn1_write_uint8(data, 0)) return False; + if (!asn1_write_uint8(data, 0)) return False; + memmove(data->data+nesting->start+3, data->data+nesting->start+1, len); + data->data[nesting->start+1] = len>>8; + data->data[nesting->start+2] = len&0xff; + } else if (len > 127) { + data->data[nesting->start] = 0x81; + if (!asn1_write_uint8(data, 0)) return False; + memmove(data->data+nesting->start+2, data->data+nesting->start+1, len); + data->data[nesting->start+1] = len; + } else { + data->data[nesting->start] = len; + } + + data->nesting = nesting->next; + free(nesting); + return True; +} + + +/* write an integer */ +BOOL asn1_write_Integer(ASN1_DATA *data, int i) +{ + if (!asn1_push_tag(data, ASN1_INTEGER)) return False; + do { + asn1_write_uint8(data, i); + i = i >> 8; + } while (i); + return asn1_pop_tag(data); +} + +/* write an object ID to a ASN1 buffer */ +BOOL asn1_write_OID(ASN1_DATA *data, const char *OID) +{ + unsigned v, v2; + const char *p = (const char *)OID; + char *newp; + + if (!asn1_push_tag(data, ASN1_OID)) + return False; + v = strtol(p, &newp, 10); + p = newp; + v2 = strtol(p, &newp, 10); + p = newp; + if (!asn1_write_uint8(data, 40*v + v2)) + return False; + + while (*p) { + v = strtol(p, &newp, 10); + p = newp; + if (v >= (1<<28)) asn1_write_uint8(data, 0x80 | ((v>>28)&0xff)); + if (v >= (1<<21)) asn1_write_uint8(data, 0x80 | ((v>>21)&0xff)); + if (v >= (1<<14)) asn1_write_uint8(data, 0x80 | ((v>>14)&0xff)); + if (v >= (1<<7)) asn1_write_uint8(data, 0x80 | ((v>>7)&0xff)); + if (!asn1_write_uint8(data, v&0x7f)) + return False; + } + return asn1_pop_tag(data); +} + +/* write an octet string */ +BOOL asn1_write_OctetString(ASN1_DATA *data, const void *p, size_t length) +{ + asn1_push_tag(data, ASN1_OCTET_STRING); + asn1_write(data, p, length); + asn1_pop_tag(data); + return !data->has_error; +} + +/* write a general string */ +BOOL asn1_write_GeneralString(ASN1_DATA *data, const char *s) +{ + asn1_push_tag(data, ASN1_GENERAL_STRING); + asn1_write(data, s, strlen(s)); + asn1_pop_tag(data); + return !data->has_error; +} + +/* write a BOOLEAN */ +BOOL asn1_write_BOOLEAN(ASN1_DATA *data, BOOL v) +{ + asn1_write_uint8(data, ASN1_BOOLEAN); + asn1_write_uint8(data, v); + return !data->has_error; +} + +/* write a BOOLEAN - hmm, I suspect this one is the correct one, and the + above boolean is bogus. Need to check */ +BOOL asn1_write_BOOLEAN2(ASN1_DATA *data, BOOL v) +{ + asn1_push_tag(data, ASN1_BOOLEAN); + asn1_write_uint8(data, v); + asn1_pop_tag(data); + return !data->has_error; +} + +/* check a BOOLEAN */ +BOOL asn1_check_BOOLEAN(ASN1_DATA *data, BOOL v) +{ + uint8 b = 0; + + asn1_read_uint8(data, &b); + if (b != ASN1_BOOLEAN) { + data->has_error = True; + return False; + } + asn1_read_uint8(data, &b); + if (b != v) { + data->has_error = True; + return False; + } + return !data->has_error; +} + + +/* load a ASN1_DATA structure with a lump of data, ready to be parsed */ +BOOL asn1_load(ASN1_DATA *data, DATA_BLOB blob) +{ + ZERO_STRUCTP(data); + data->data = memdup(blob.data, blob.length); + if (!data->data) { + data->has_error = True; + return False; + } + data->length = blob.length; + return True; +} + +/* read from a ASN1 buffer, advancing the buffer pointer */ +BOOL asn1_read(ASN1_DATA *data, void *p, int len) +{ + if (data->ofs + len > data->length) { + data->has_error = True; + return False; + } + memcpy(p, data->data + data->ofs, len); + data->ofs += len; + return True; +} + +/* read a uint8 from a ASN1 buffer */ +BOOL asn1_read_uint8(ASN1_DATA *data, uint8 *v) +{ + return asn1_read(data, v, 1); +} + +/* start reading a nested asn1 structure */ +BOOL asn1_start_tag(ASN1_DATA *data, uint8 tag) +{ + uint8 b; + struct nesting *nesting; + + if (!asn1_read_uint8(data, &b)) + return False; + + if (b != tag) { + data->has_error = True; + return False; + } + nesting = (struct nesting *)malloc(sizeof(struct nesting)); + if (!nesting) { + data->has_error = True; + return False; + } + + if (!asn1_read_uint8(data, &b)) { + return False; + } + + if (b & 0x80) { + int n = b & 0x7f; + if (!asn1_read_uint8(data, &b)) + return False; + nesting->taglen = b; + while (n > 1) { + if (!asn1_read_uint8(data, &b)) + return False; + nesting->taglen = (nesting->taglen << 8) | b; + n--; + } + } else { + nesting->taglen = b; + } + nesting->start = data->ofs; + nesting->next = data->nesting; + data->nesting = nesting; + return !data->has_error; +} + + +/* stop reading a tag */ +BOOL asn1_end_tag(ASN1_DATA *data) +{ + struct nesting *nesting; + + /* make sure we read it all */ + if (asn1_tag_remaining(data) != 0) { + data->has_error = True; + return False; + } + + nesting = data->nesting; + + if (!nesting) { + data->has_error = True; + return False; + } + + data->nesting = nesting->next; + free(nesting); + return True; +} + +/* work out how many bytes are left in this nested tag */ +int asn1_tag_remaining(ASN1_DATA *data) +{ + if (!data->nesting) { + data->has_error = True; + return -1; + } + return data->nesting->taglen - (data->ofs - data->nesting->start); +} + +/* read an object ID from a ASN1 buffer */ +BOOL asn1_read_OID(ASN1_DATA *data, char **OID) +{ + uint8 b; + pstring oid; + fstring el; + + if (!asn1_start_tag(data, ASN1_OID)) return False; + asn1_read_uint8(data, &b); + + oid[0] = 0; + snprintf(el, sizeof(el), "%u", b/40); + pstrcat(oid, el); + snprintf(el, sizeof(el), " %u", b%40); + pstrcat(oid, el); + + while (asn1_tag_remaining(data) > 0) { + unsigned v = 0; + do { + asn1_read_uint8(data, &b); + v = (v<<7) | (b&0x7f); + } while (!data->has_error && b & 0x80); + snprintf(el, sizeof(el), " %u", v); + pstrcat(oid, el); + } + + asn1_end_tag(data); + + *OID = strdup(oid); + + return !data->has_error; +} + +/* check that the next object ID is correct */ +BOOL asn1_check_OID(ASN1_DATA *data, const char *OID) +{ + char *id; + + if (!asn1_read_OID(data, &id)) return False; + + if (strcmp(id, OID) != 0) { + data->has_error = True; + return False; + } + free(id); + return True; +} + +/* read a GeneralString from a ASN1 buffer */ +BOOL asn1_read_GeneralString(ASN1_DATA *data, char **s) +{ + int len; + if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False; + len = asn1_tag_remaining(data); + *s = malloc(len+1); + if (! *s) { + data->has_error = True; + return False; + } + asn1_read(data, *s, len); + (*s)[len] = 0; + asn1_end_tag(data); + return !data->has_error; +} + +/* read a octet string blob */ +BOOL asn1_read_OctetString(ASN1_DATA *data, DATA_BLOB *blob) +{ + int len; + ZERO_STRUCTP(blob); + if (!asn1_start_tag(data, ASN1_OCTET_STRING)) return False; + len = asn1_tag_remaining(data); + *blob = data_blob(NULL, len); + asn1_read(data, blob->data, len); + asn1_end_tag(data); + return !data->has_error; +} + +/* read an interger */ +BOOL asn1_read_Integer(ASN1_DATA *data, int *i) +{ + uint8 b; + *i = 0; + + if (!asn1_start_tag(data, ASN1_INTEGER)) return False; + while (asn1_tag_remaining(data)>0) { + asn1_read_uint8(data, &b); + *i = (*i << 8) + b; + } + return asn1_end_tag(data); + +} + +/* check a enumarted value is correct */ +BOOL asn1_check_enumerated(ASN1_DATA *data, int v) +{ + uint8 b; + if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False; + asn1_read_uint8(data, &b); + asn1_end_tag(data); + + if (v != b) + data->has_error = False; + + return !data->has_error; +} + +/* write an enumarted value to the stream */ +BOOL asn1_write_enumerated(ASN1_DATA *data, uint8 v) +{ + if (!asn1_push_tag(data, ASN1_ENUMERATED)) return False; + asn1_write_uint8(data, v); + asn1_pop_tag(data); + return !data->has_error; +} diff --git a/source4/libcli/util/clierror.c b/source4/libcli/util/clierror.c new file mode 100644 index 0000000000..4fa1daa3be --- /dev/null +++ b/source4/libcli/util/clierror.c @@ -0,0 +1,99 @@ +/* + Unix SMB/CIFS implementation. + client error handling routines + Copyright (C) Andrew Tridgell 1994-1998 + Copyright (C) James Myers 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + + +/*************************************************************************** + Return an error message from the last response +****************************************************************************/ +const char *cli_errstr(struct cli_state *cli) +{ + switch (cli->transport->error.etype) { + case ETYPE_DOS: + return dos_errstr(cli->transport->error.e.dos.eclass, + cli->transport->error.e.dos.ecode); + case ETYPE_NT: + return nt_errstr(cli->transport->error.e.nt_status); + + case ETYPE_SOCKET: + return "socket_error"; + + case ETYPE_NBT: + return "nbt_error"; + + case ETYPE_NONE: + return "no_error"; + } + return NULL; +} + + +/* Return the 32-bit NT status code from the last packet */ +NTSTATUS cli_nt_error(struct cli_state *cli) +{ + switch (cli->transport->error.etype) { + case ETYPE_NT: + return cli->transport->error.e.nt_status; + + case ETYPE_DOS: + return dos_to_ntstatus(cli->transport->error.e.dos.eclass, + cli->transport->error.e.dos.ecode); + case ETYPE_SOCKET: + return NT_STATUS_UNSUCCESSFUL; + + case ETYPE_NBT: + return NT_STATUS_UNSUCCESSFUL; + + case ETYPE_NONE: + return NT_STATUS_OK; + } + + return NT_STATUS_UNSUCCESSFUL; +} + + +/* 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) +{ + if (cli->transport->error.etype == ETYPE_DOS) { + ntstatus_to_dos(cli->transport->error.e.nt_status, + eclass, ecode); + return; + } + + if (eclass) *eclass = cli->transport->error.e.dos.eclass; + if (ecode) *ecode = cli->transport->error.e.dos.ecode; +} + + +/* Return true if the last packet was an error */ +BOOL cli_is_error(struct cli_state *cli) +{ + return NT_STATUS_IS_ERR(cli_nt_error(cli)); +} + +/* Return true if the last error was a DOS error */ +BOOL cli_is_dos_error(struct cli_state *cli) +{ + return cli->transport->error.etype == ETYPE_DOS; +} diff --git a/source4/libcli/util/cliutil.c b/source4/libcli/util/cliutil.c new file mode 100644 index 0000000000..47f94992a4 --- /dev/null +++ b/source4/libcli/util/cliutil.c @@ -0,0 +1,110 @@ +/* + Unix SMB/CIFS implementation. + client utility routines + Copyright (C) Andrew Tridgell 2001 + Copyright (C) James Myers 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +/******************************************************************* + Functions nicked from lib/util.c needed by client. +*******************************************************************/ + +/* a default finfo structure to ensure all fields are sensible */ +file_info def_finfo = {-1,0,0,0,0,0,0,"",""}; + +/******************************************************************* + A wrapper that handles case sensitivity and the special handling + of the ".." name. +*******************************************************************/ + +BOOL mask_match(struct cli_state *cli, const char *string, char *pattern, BOOL is_case_sensitive) +{ + fstring p2, s2; + + if (strcmp(string,"..") == 0) + string = "."; + if (strcmp(pattern,".") == 0) + return False; + + if (is_case_sensitive) + return ms_fnmatch(pattern, string, + cli->transport->negotiate.protocol) == 0; + + fstrcpy(p2, pattern); + fstrcpy(s2, string); + strlower(p2); + strlower(s2); + return ms_fnmatch(p2, s2, cli->transport->negotiate.protocol) == 0; +} + +/**************************************************************************** + Put up a yes/no prompt. +****************************************************************************/ + +BOOL yesno(char *p) +{ + pstring ans; + printf("%s",p); + + if (!fgets(ans,sizeof(ans)-1,stdin)) + return(False); + + if (*ans == 'y' || *ans == 'Y') + return(True); + + return(False); +} + +/******************************************************************* + A readdir wrapper which just returns the file name. + ********************************************************************/ + +const char *readdirname(DIR *p) +{ + SMB_STRUCT_DIRENT *ptr; + char *dname; + + if (!p) + return(NULL); + + ptr = (SMB_STRUCT_DIRENT *)sys_readdir(p); + if (!ptr) + return(NULL); + + dname = ptr->d_name; + +#ifdef NEXT2 + if (telldir(p) < 0) + return(NULL); +#endif + +#ifdef HAVE_BROKEN_READDIR + /* using /usr/ucb/cc is BAD */ + dname = dname - 2; +#endif + + { + static pstring buf; + int len = NAMLEN(ptr); + memcpy(buf, dname, len); + buf[len] = 0; + dname = buf; + } + + return(dname); +} diff --git a/source4/libcli/util/credentials.c b/source4/libcli/util/credentials.c new file mode 100644 index 0000000000..0d521bae8a --- /dev/null +++ b/source4/libcli/util/credentials.c @@ -0,0 +1,215 @@ +/* + Unix SMB/CIFS implementation. + code to manipulate domain credentials + Copyright (C) Andrew Tridgell 1997-1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/**************************************************************************** +represent a credential as a string +****************************************************************************/ +char *credstr(const uchar *cred) +{ + static fstring buf; + slprintf(buf, sizeof(buf) - 1, "%02X%02X%02X%02X%02X%02X%02X%02X", + cred[0], cred[1], cred[2], cred[3], + cred[4], cred[5], cred[6], cred[7]); + return buf; +} + + +/**************************************************************************** + setup the session key. +Input: 8 byte challenge block + 8 byte server challenge block + 16 byte md4 encrypted password +Output: + 8 byte session key +****************************************************************************/ +void cred_session_key(const DOM_CHAL *clnt_chal, const DOM_CHAL *srv_chal, const uchar *pass, + uchar session_key[8]) +{ + uint32 sum[2]; + unsigned char sum2[8]; + + sum[0] = IVAL(clnt_chal->data, 0) + IVAL(srv_chal->data, 0); + sum[1] = IVAL(clnt_chal->data, 4) + IVAL(srv_chal->data, 4); + + SIVAL(sum2,0,sum[0]); + SIVAL(sum2,4,sum[1]); + + cred_hash1(session_key, sum2, pass); + + /* debug output */ + DEBUG(4,("cred_session_key\n")); + + DEBUG(5,(" clnt_chal: %s\n", credstr(clnt_chal->data))); + DEBUG(5,(" srv_chal : %s\n", credstr(srv_chal->data))); + DEBUG(5,(" clnt+srv : %s\n", credstr(sum2))); + DEBUG(5,(" sess_key : %s\n", credstr(session_key))); +} + + +/**************************************************************************** +create a credential + +Input: + 8 byte sesssion key + 8 byte stored credential + 4 byte timestamp + +Output: + 8 byte credential +****************************************************************************/ +void cred_create(uchar session_key[8], DOM_CHAL *stor_cred, UTIME timestamp, + DOM_CHAL *cred) +{ + DOM_CHAL time_cred; + + SIVAL(time_cred.data, 0, IVAL(stor_cred->data, 0) + timestamp.time); + SIVAL(time_cred.data, 4, IVAL(stor_cred->data, 4)); + + cred_hash2(cred->data, time_cred.data, session_key); + + /* debug output*/ + DEBUG(4,("cred_create\n")); + + DEBUG(5,(" sess_key : %s\n", credstr(session_key))); + DEBUG(5,(" stor_cred: %s\n", credstr(stor_cred->data))); + DEBUG(5,(" timestamp: %x\n" , timestamp.time)); + DEBUG(5,(" timecred : %s\n", credstr(time_cred.data))); + DEBUG(5,(" calc_cred: %s\n", credstr(cred->data))); +} + + +/**************************************************************************** + check a supplied credential + +Input: + 8 byte received credential + 8 byte sesssion key + 8 byte stored credential + 4 byte timestamp + +Output: + returns 1 if computed credential matches received credential + returns 0 otherwise +****************************************************************************/ +int cred_assert(DOM_CHAL *cred, uchar session_key[8], DOM_CHAL *stored_cred, + UTIME timestamp) +{ + DOM_CHAL cred2; + + cred_create(session_key, stored_cred, timestamp, &cred2); + + /* debug output*/ + DEBUG(4,("cred_assert\n")); + + DEBUG(5,(" challenge : %s\n", credstr(cred->data))); + DEBUG(5,(" calculated: %s\n", credstr(cred2.data))); + + if (memcmp(cred->data, cred2.data, 8) == 0) + { + DEBUG(5, ("credentials check ok\n")); + return True; + } + else + { + DEBUG(5, ("credentials check wrong\n")); + return False; + } +} + + +/**************************************************************************** + checks credentials; generates next step in the credential chain +****************************************************************************/ +BOOL clnt_deal_with_creds(uchar sess_key[8], + DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_srv_cred) +{ + UTIME new_clnt_time; + uint32 new_cred; + + DEBUG(5,("clnt_deal_with_creds: %d\n", __LINE__)); + + /* increment client time by one second */ + new_clnt_time.time = sto_clnt_cred->timestamp.time + 1; + + /* check that the received server credentials are valid */ + if (!cred_assert(&rcv_srv_cred->challenge, sess_key, + &sto_clnt_cred->challenge, new_clnt_time)) + { + return False; + } + + /* first 4 bytes of the new seed is old client 4 bytes + clnt time + 1 */ + new_cred = IVAL(sto_clnt_cred->challenge.data, 0); + new_cred += new_clnt_time.time; + + /* store new seed in client credentials */ + SIVAL(sto_clnt_cred->challenge.data, 0, new_cred); + + DEBUG(5,(" new clnt cred: %s\n", credstr(sto_clnt_cred->challenge.data))); + return True; +} + + +/**************************************************************************** + checks credentials; generates next step in the credential chain +****************************************************************************/ +BOOL deal_with_creds(uchar sess_key[8], + DOM_CRED *sto_clnt_cred, + DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred) +{ + UTIME new_clnt_time; + uint32 new_cred; + + DEBUG(5,("deal_with_creds: %d\n", __LINE__)); + + /* check that the received client credentials are valid */ + if (!cred_assert(&rcv_clnt_cred->challenge, sess_key, + &sto_clnt_cred->challenge, rcv_clnt_cred->timestamp)) + { + return False; + } + + /* increment client time by one second */ + new_clnt_time.time = rcv_clnt_cred->timestamp.time + 1; + + /* first 4 bytes of the new seed is old client 4 bytes + clnt time + 1 */ + new_cred = IVAL(sto_clnt_cred->challenge.data, 0); + new_cred += new_clnt_time.time; + + DEBUG(5,("deal_with_creds: new_cred[0]=%x\n", new_cred)); + + /* doesn't matter that server time is 0 */ + rtn_srv_cred->timestamp.time = 0; + + DEBUG(5,("deal_with_creds: new_clnt_time=%x\n", new_clnt_time.time)); + + /* create return credentials for inclusion in the reply */ + cred_create(sess_key, &sto_clnt_cred->challenge, new_clnt_time, + &rtn_srv_cred->challenge); + + DEBUG(5,("deal_with_creds: clnt_cred=%s\n", credstr(sto_clnt_cred->challenge.data))); + + /* store new seed in client credentials */ + SIVAL(sto_clnt_cred->challenge.data, 0, new_cred); + + return True; +} diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c new file mode 100644 index 0000000000..28bad6109d --- /dev/null +++ b/source4/libcli/util/doserr.c @@ -0,0 +1,91 @@ +/* + * Unix SMB/CIFS implementation. + * DOS error routines + * Copyright (C) Tim Potter 2002. + * + * 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. + */ + +/* DOS error codes. please read doserr.h */ + +#include "includes.h" + +typedef const struct +{ + const char *dos_errstr; + WERROR werror; +} werror_code_struct; + +werror_code_struct dos_errs[] = +{ + { "WERR_OK", WERR_OK }, + { "WERR_BADFILE", WERR_BADFILE }, + { "WERR_ACCESS_DENIED", WERR_ACCESS_DENIED }, + { "WERR_BADFID", WERR_BADFID }, + { "WERR_BADFUNC", WERR_BADFUNC }, + { "WERR_INSUFFICIENT_BUFFER", WERR_INSUFFICIENT_BUFFER }, + { "WERR_NO_SUCH_SHARE", WERR_NO_SUCH_SHARE }, + { "WERR_ALREADY_EXISTS", WERR_ALREADY_EXISTS }, + { "WERR_INVALID_PARAM", WERR_INVALID_PARAM }, + { "WERR_NOT_SUPPORTED", WERR_NOT_SUPPORTED }, + { "WERR_BAD_PASSWORD", WERR_BAD_PASSWORD }, + { "WERR_NOMEM", WERR_NOMEM }, + { "WERR_INVALID_NAME", WERR_INVALID_NAME }, + { "WERR_UNKNOWN_LEVEL", WERR_UNKNOWN_LEVEL }, + { "WERR_OBJECT_PATH_INVALID", WERR_OBJECT_PATH_INVALID }, + { "WERR_NO_MORE_ITEMS", WERR_NO_MORE_ITEMS }, + { "WERR_MORE_DATA", WERR_MORE_DATA }, + { "WERR_UNKNOWN_PRINTER_DRIVER", WERR_UNKNOWN_PRINTER_DRIVER }, + { "WERR_INVALID_PRINTER_NAME", WERR_INVALID_PRINTER_NAME }, + { "WERR_PRINTER_ALREADY_EXISTS", WERR_PRINTER_ALREADY_EXISTS }, + { "WERR_INVALID_DATATYPE", WERR_INVALID_DATATYPE }, + { "WERR_INVALID_ENVIRONMENT", WERR_INVALID_ENVIRONMENT }, + { "WERR_INVALID_FORM_NAME", WERR_INVALID_FORM_NAME }, + { "WERR_INVALID_FORM_SIZE", WERR_INVALID_FORM_SIZE }, + { "WERR_BUF_TOO_SMALL", WERR_BUF_TOO_SMALL }, + { "WERR_JOB_NOT_FOUND", WERR_JOB_NOT_FOUND }, + { "WERR_DEST_NOT_FOUND", WERR_DEST_NOT_FOUND }, + { "WERR_NOT_LOCAL_DOMAIN", WERR_NOT_LOCAL_DOMAIN }, + { "WERR_PRINTER_DRIVER_IN_USE", WERR_PRINTER_DRIVER_IN_USE }, + { "WERR_STATUS_MORE_ENTRIES ", WERR_STATUS_MORE_ENTRIES }, + { "WERR_DFS_NO_SUCH_VOL", WERR_DFS_NO_SUCH_VOL }, + { "WERR_DFS_NO_SUCH_SHARE", WERR_DFS_NO_SUCH_SHARE }, + { "WERR_DFS_NO_SUCH_SERVER", WERR_DFS_NO_SUCH_SERVER }, + { "WERR_DFS_INTERNAL_ERROR", WERR_DFS_INTERNAL_ERROR }, + { "WERR_DFS_CANT_CREATE_JUNCT", WERR_DFS_CANT_CREATE_JUNCT }, + { "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR }, + { "WERR_INVALID_OWNER", WERR_INVALID_OWNER }, + { NULL, W_ERROR(0) } +}; + +/***************************************************************************** + returns a windows error message. not amazingly helpful, but better than a number. + *****************************************************************************/ +const char *win_errstr(WERROR werror) +{ + static pstring msg; + int idx = 0; + + slprintf(msg, sizeof(msg), "DOS code 0x%08x", W_ERROR_V(werror)); + + while (dos_errs[idx].dos_errstr != NULL) { + if (W_ERROR_V(dos_errs[idx].werror) == + W_ERROR_V(werror)) + return dos_errs[idx].dos_errstr; + idx++; + } + + return msg; +} diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c new file mode 100644 index 0000000000..a257c2d0ea --- /dev/null +++ b/source4/libcli/util/errormap.c @@ -0,0 +1,1546 @@ +/* + * Unix SMB/CIFS implementation. + * error mapping functions + * Copyright (C) Andrew Tridgell 2001 + * Copyright (C) Andrew Bartlett 2001 + * Copyright (C) Tim Potter 2000 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +/* This map was extracted by the ERRMAPEXTRACT smbtorture command. + The setup was a Samba HEAD (2002-01-03) PDC and an Win2k member + workstation. The PDC was modified (by using the 'name_to_nt_status' + authentication module) to convert the username (in hex) into the + corresponding NTSTATUS error return. + + By opening two nbt sessions to the Win2k workstation, one negotiating + DOS and one negotiating NT errors it was possible to extract the + error mapping. (Because the server only supplies NT errors, the + NT4 workstation had to use its own error tables to convert these + to dos errors). + + Some errors show up as 'squashed' because the NT error connection + got back a different error to the one it sent, so a mapping could + not be determined (a guess has been made in this case, to map the + error as squashed). This is done mainly to prevent users from getting + NT_STATUS_WRONG_PASSWORD and NT_STATUS_NO_SUCH_USER errors (they get + NT_STATUS_LOGON_FAILURE instead. + + -- abartlet (2002-01-03) +*/ + +/* NT status -> dos error map */ +static const struct { + uint8 dos_class; + uint32 dos_code; + NTSTATUS ntstatus; +} ntstatus_to_dos_map[] = { + {ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, + {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, + {ERRDOS, 87, NT_STATUS_INVALID_INFO_CLASS}, + {ERRDOS, 24, NT_STATUS_INFO_LENGTH_MISMATCH}, + {ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION}, + {ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA}, + {ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_INITIAL_STACK}, + {ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC}, + {ERRDOS, 87, NT_STATUS_INVALID_CID}, + {ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER}, + {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE}, + {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, + {ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST}, + {ERRDOS, 38, NT_STATUS_END_OF_FILE}, + {ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, + {ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE}, + {ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA}, + {ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR}, +/** Session setup succeeded. This shouldn't happen...*/ +/** Session setup succeeded. This shouldn't happen...*/ +/** NT error on DOS connection! (NT_STATUS_OK) */ +/* { This NT error code was 'sqashed' + from NT_STATUS_MORE_PROCESSING_REQUIRED to NT_STATUS_OK + during the session setup } +*/ +#if 0 + {SUCCESS, 0, NT_STATUS_OK}, +#endif + {ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY}, + {ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES}, + {ERRDOS, 487, NT_STATUS_NOT_MAPPED_VIEW}, + {ERRDOS, 87, NT_STATUS_UNABLE_TO_FREE_VM}, + {ERRDOS, 87, NT_STATUS_UNABLE_TO_DELETE_SECTION}, + {ERRDOS, 2142, NT_STATUS_INVALID_SYSTEM_SERVICE}, + {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_INSTRUCTION}, + {ERRDOS, ERRnoaccess, NT_STATUS_INVALID_LOCK_SEQUENCE}, + {ERRDOS, ERRnoaccess, NT_STATUS_INVALID_VIEW_SIZE}, + {ERRDOS, 193, NT_STATUS_INVALID_FILE_FOR_SECTION}, + {ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED}, +/* { This NT error code was 'sqashed' + from NT_STATUS_ACCESS_DENIED to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE + during the session setup } +*/ + {ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED}, + {ERRDOS, 111, NT_STATUS_BUFFER_TOO_SMALL}, + {ERRDOS, ERRbadfid, NT_STATUS_OBJECT_TYPE_MISMATCH}, + {ERRHRD, ERRgeneral, NT_STATUS_NONCONTINUABLE_EXCEPTION}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DISPOSITION}, + {ERRHRD, ERRgeneral, NT_STATUS_UNWIND}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_STACK}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_UNWIND_TARGET}, + {ERRDOS, 158, NT_STATUS_NOT_LOCKED}, + {ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR}, + {ERRDOS, 487, NT_STATUS_UNABLE_TO_DECOMMIT_VM}, + {ERRDOS, 487, NT_STATUS_NOT_COMMITTED}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES}, + {ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_MIX}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER}, + {ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, + {ERRDOS, ERRinvalidname, NT_STATUS_OBJECT_NAME_INVALID}, + {ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, + {ERRDOS, 183, NT_STATUS_OBJECT_NAME_COLLISION}, + {ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, + {ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED}, + {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED}, + {ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID}, + {ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, + {ERRDOS, 161, NT_STATUS_OBJECT_PATH_SYNTAX_BAD}, + {ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN}, + {ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR}, + {ERRDOS, 23, NT_STATUS_DATA_ERROR}, + {ERRDOS, 23, NT_STATUS_CRC_ERROR}, + {ERRDOS, ERRnomem, NT_STATUS_SECTION_TOO_BIG}, + {ERRDOS, ERRnoaccess, NT_STATUS_PORT_CONNECTION_REFUSED}, + {ERRDOS, ERRbadfid, NT_STATUS_INVALID_PORT_HANDLE}, + {ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, + {ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED}, + {ERRDOS, 87, NT_STATUS_INVALID_PAGE_PROTECTION}, + {ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED}, + {ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, + {ERRDOS, 87, NT_STATUS_PORT_ALREADY_SET}, + {ERRDOS, 87, NT_STATUS_SECTION_NOT_IMAGE}, + {ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, + {ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING}, + {ERRDOS, 87, NT_STATUS_BAD_WORKING_SET_LIMIT}, + {ERRDOS, 87, NT_STATUS_INCOMPATIBLE_FILE_MAP}, + {ERRDOS, 87, NT_STATUS_SECTION_PROTECTION}, + {ERRDOS, 282, NT_STATUS_EAS_NOT_SUPPORTED}, + {ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, + {ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE}, + {ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR}, + {ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, + {ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED}, + {ERRDOS, ERRnoaccess, NT_STATUS_DELETE_PENDING}, + {ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, + {ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION}, + {ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_OWNER}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PRIMARY_GROUP}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_IMPERSONATION_TOKEN}, + {ERRHRD, ERRgeneral, NT_STATUS_CANT_DISABLE_MANDATORY}, + {ERRDOS, 2215, NT_STATUS_NO_LOGON_SERVERS}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_LOGON_SESSION}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PRIVILEGE}, + {ERRDOS, ERRnoaccess, NT_STATUS_PRIVILEGE_NOT_HELD}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACCOUNT_NAME}, + {ERRHRD, ERRgeneral, NT_STATUS_USER_EXISTS}, +/* { This NT error code was 'sqashed' + from NT_STATUS_NO_SUCH_USER to NT_STATUS_LOGON_FAILURE + during the session setup } +*/ + {ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, + {ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP}, + {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP}, + {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_GROUP}, + {ERRHRD, ERRgeneral, NT_STATUS_LAST_ADMIN}, +/* { This NT error code was 'sqashed' + from NT_STATUS_WRONG_PASSWORD to NT_STATUS_LOGON_FAILURE + during the session setup } +*/ + {ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD}, + {ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD}, + {ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, + {ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE}, + {ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION}, + {ERRSRV, 2241, NT_STATUS_INVALID_LOGON_HOURS}, + {ERRSRV, 2240, NT_STATUS_INVALID_WORKSTATION}, + {ERRSRV, 2242, NT_STATUS_PASSWORD_EXPIRED}, + {ERRSRV, 2239, NT_STATUS_ACCOUNT_DISABLED}, + {ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED}, + {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, + {ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SUB_AUTHORITY}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACL}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SID}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SECURITY_DESCR}, + {ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, + {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_FORMAT}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_TOKEN}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_INHERITANCE_ACL}, + {ERRDOS, 158, NT_STATUS_RANGE_NOT_LOCKED}, + {ERRDOS, 112, NT_STATUS_DISK_FULL}, + {ERRHRD, ERRgeneral, NT_STATUS_SERVER_DISABLED}, + {ERRHRD, ERRgeneral, NT_STATUS_SERVER_NOT_DISABLED}, + {ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, + {ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ID_AUTHORITY}, + {ERRDOS, 259, NT_STATUS_AGENTS_EXHAUSTED}, + {ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL}, + {ERRDOS, ERRres, NT_STATUS_SECTION_NOT_EXTENDED}, + {ERRDOS, 487, NT_STATUS_NOT_MAPPED_DATA}, + {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_DATA_NOT_FOUND}, + {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_TYPE_NOT_FOUND}, + {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_NAME_NOT_FOUND}, + {ERRHRD, ERRgeneral, NT_STATUS_ARRAY_BOUNDS_EXCEEDED}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DENORMAL_OPERAND}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DIVIDE_BY_ZERO}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INEXACT_RESULT}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INVALID_OPERATION}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_OVERFLOW}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_STACK_CHECK}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_UNDERFLOW}, + {ERRHRD, ERRgeneral, NT_STATUS_INTEGER_DIVIDE_BY_ZERO}, + {ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW}, + {ERRHRD, ERRgeneral, NT_STATUS_PRIVILEGED_INSTRUCTION}, + {ERRDOS, ERRnomem, NT_STATUS_TOO_MANY_PAGING_FILES}, + {ERRHRD, ERRgeneral, NT_STATUS_FILE_INVALID}, + {ERRHRD, ERRgeneral, NT_STATUS_ALLOTTED_SPACE_EXCEEDED}, +/* { This NT error code was 'sqashed' + from NT_STATUS_INSUFFICIENT_RESOURCES to NT_STATUS_INSUFF_SERVER_RESOURCES + during the session setup } +*/ + {ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES}, + {ERRDOS, ERRbadpath, NT_STATUS_DFS_EXIT_PATH_FOUND}, + {ERRDOS, 23, NT_STATUS_DEVICE_DATA_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_CONNECTED}, + {ERRDOS, 21, NT_STATUS_DEVICE_POWER_FAILURE}, + {ERRDOS, 487, NT_STATUS_FREE_VM_NOT_AT_BASE}, + {ERRDOS, 487, NT_STATUS_MEMORY_NOT_ALLOCATED}, + {ERRHRD, ERRgeneral, NT_STATUS_WORKING_SET_QUOTA}, + {ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED}, + {ERRDOS, 21, NT_STATUS_DEVICE_NOT_READY}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_GROUP_ATTRIBUTES}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_IMPERSONATION_LEVEL}, + {ERRHRD, ERRgeneral, NT_STATUS_CANT_OPEN_ANONYMOUS}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_VALIDATION_CLASS}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_TOKEN_TYPE}, + {ERRDOS, 87, NT_STATUS_BAD_MASTER_BOOT_RECORD}, + {ERRHRD, ERRgeneral, NT_STATUS_INSTRUCTION_MISALIGNMENT}, + {ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE}, + {ERRDOS, ERRpipebusy, NT_STATUS_PIPE_NOT_AVAILABLE}, + {ERRDOS, ERRbadpipe, NT_STATUS_INVALID_PIPE_STATE}, + {ERRDOS, ERRpipebusy, NT_STATUS_PIPE_BUSY}, + {ERRDOS, ERRbadfunc, NT_STATUS_ILLEGAL_FUNCTION}, + {ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED}, + {ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING}, + {ERRHRD, ERRgeneral, NT_STATUS_PIPE_CONNECTED}, + {ERRHRD, ERRgeneral, NT_STATUS_PIPE_LISTENING}, + {ERRDOS, ERRbadpipe, NT_STATUS_INVALID_READ_MODE}, + {ERRDOS, 121, NT_STATUS_IO_TIMEOUT}, + {ERRDOS, 38, NT_STATUS_FILE_FORCED_CLOSED}, + {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STARTED}, + {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STOPPED}, + {ERRHRD, ERRgeneral, NT_STATUS_COULD_NOT_INTERPRET}, + {ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY}, + {ERRDOS, ERRunsup, NT_STATUS_NOT_SUPPORTED}, + {ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING}, + {ERRDOS, 52, NT_STATUS_DUPLICATE_NAME}, + {ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH}, + {ERRDOS, 54, NT_STATUS_NETWORK_BUSY}, + {ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, + {ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS}, + {ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, + {ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, + {ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, + {ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, + {ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL}, + {ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE}, + {ERRDOS, 63, NT_STATUS_PRINT_CANCELLED}, + {ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED}, + {ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, + {ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE}, + {ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME}, + {ERRDOS, 68, NT_STATUS_TOO_MANY_NAMES}, + {ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS}, + {ERRDOS, 70, NT_STATUS_SHARING_PAUSED}, + {ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, + {ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED}, + {ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT}, + {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_AT_LIMIT}, + {ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE}, + {ERRDOS, ERRnoaccess, NT_STATUS_FILE_RENAMED}, + {ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_SECURITY_ON_OBJECT}, + {ERRHRD, ERRgeneral, NT_STATUS_CANT_WAIT}, + {ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_EMPTY}, + {ERRHRD, ERRgeneral, NT_STATUS_CANT_ACCESS_DOMAIN_INFO}, + {ERRHRD, ERRgeneral, NT_STATUS_CANT_TERMINATE_SELF}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SERVER_STATE}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_STATE}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_ROLE}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_DOMAIN}, + {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_EXISTS}, + {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_LIMIT_EXCEEDED}, + {ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, + {ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, + {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_CORRUPTION}, + {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_GENERIC_NOT_MAPPED}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_DESCRIPTOR_FORMAT}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_USER_BUFFER}, + {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_IO_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_CREATE_ERR}, + {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_MAP_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_EXTEND_ERR}, + {ERRHRD, ERRgeneral, NT_STATUS_NOT_LOGON_PROCESS}, + {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_EXISTS}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_1}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_2}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_3}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_4}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_5}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_6}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_7}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_8}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_9}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_10}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_11}, + {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_12}, + {ERRDOS, ERRbadpath, NT_STATUS_REDIRECTOR_NOT_STARTED}, + {ERRHRD, ERRgeneral, NT_STATUS_REDIRECTOR_STARTED}, + {ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PACKAGE}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_FUNCTION_TABLE}, + {ERRDOS, 203, NT_STATUS(0xc0000100)}, + {ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, + {ERRHRD, ERRgeneral, NT_STATUS_FILE_CORRUPT_ERROR}, + {ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_LOGON_SESSION_STATE}, + {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_COLLISION}, + {ERRDOS, 206, NT_STATUS_NAME_TOO_LONG}, + {ERRDOS, 2401, NT_STATUS_FILES_OPEN}, + {ERRDOS, 2404, NT_STATUS_CONNECTION_IN_USE}, + {ERRHRD, ERRgeneral, NT_STATUS_MESSAGE_NOT_FOUND}, + {ERRDOS, ERRnoaccess, NT_STATUS_PROCESS_IS_TERMINATING}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LOGON_TYPE}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_GUID_TRANSLATION}, + {ERRHRD, ERRgeneral, NT_STATUS_CANNOT_IMPERSONATE}, + {ERRHRD, ERRgeneral, NT_STATUS_IMAGE_ALREADY_LOADED}, + {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_PRESENT}, + {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_NOT_EXIST}, + {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_ALREADY_OWNED}, + {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_LID_OWNER}, + {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_COMMAND}, + {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_LID}, + {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE}, + {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_SELECTOR}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_LDT}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_SIZE}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_OFFSET}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_DESCRIPTOR}, + {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NE_FORMAT}, + {ERRHRD, ERRgeneral, NT_STATUS_RXACT_INVALID_STATE}, + {ERRHRD, ERRgeneral, NT_STATUS_RXACT_COMMIT_FAILURE}, + {ERRHRD, ERRgeneral, NT_STATUS_MAPPED_FILE_SIZE_ZERO}, + {ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES}, + {ERRHRD, ERRgeneral, NT_STATUS_CANCELLED}, + {ERRDOS, ERRnoaccess, NT_STATUS_CANNOT_DELETE}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_COMPUTER_NAME}, + {ERRDOS, ERRnoaccess, NT_STATUS_FILE_DELETED}, + {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_ACCOUNT}, + {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_GROUP}, + {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_USER}, + {ERRHRD, ERRgeneral, NT_STATUS_MEMBERS_PRIMARY_GROUP}, + {ERRDOS, ERRbadfid, NT_STATUS_FILE_CLOSED}, + {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_THREADS}, + {ERRHRD, ERRgeneral, NT_STATUS_THREAD_NOT_IN_PROCESS}, + {ERRHRD, ERRgeneral, NT_STATUS_TOKEN_ALREADY_IN_USE}, + {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA_EXCEEDED}, + {ERRHRD, ERRgeneral, NT_STATUS_COMMITMENT_LIMIT}, + {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_LE_FORMAT}, + {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NOT_MZ}, + {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_PROTECT}, + {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_WIN_16}, + {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SERVER_CONFLICT}, + {ERRHRD, ERRgeneral, NT_STATUS_TIME_DIFFERENCE_AT_DC}, + {ERRHRD, ERRgeneral, NT_STATUS_SYNCHRONIZATION_REQUIRED}, + {ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND}, + {ERRHRD, ERRgeneral, NT_STATUS_OPEN_FAILED}, + {ERRHRD, ERRgeneral, NT_STATUS_IO_PRIVILEGE_FAILED}, + {ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND}, + {ERRDOS, 127, NT_STATUS_ENTRYPOINT_NOT_FOUND}, + {ERRHRD, ERRgeneral, NT_STATUS_CONTROL_C_EXIT}, + {ERRDOS, 64, NT_STATUS_LOCAL_DISCONNECT}, + {ERRDOS, 64, NT_STATUS_REMOTE_DISCONNECT}, + {ERRDOS, 51, NT_STATUS_REMOTE_RESOURCES}, + {ERRDOS, 59, NT_STATUS_LINK_FAILED}, + {ERRDOS, 59, NT_STATUS_LINK_TIMEOUT}, + {ERRDOS, 59, NT_STATUS_INVALID_CONNECTION}, + {ERRDOS, 59, NT_STATUS_INVALID_ADDRESS}, + {ERRHRD, ERRgeneral, NT_STATUS_DLL_INIT_FAILED}, + {ERRHRD, ERRgeneral, NT_STATUS_MISSING_SYSTEMFILE}, + {ERRHRD, ERRgeneral, NT_STATUS_UNHANDLED_EXCEPTION}, + {ERRHRD, ERRgeneral, NT_STATUS_APP_INIT_FAILURE}, + {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_CREATE_FAILED}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_PAGEFILE}, + {ERRDOS, 124, NT_STATUS_INVALID_LEVEL}, + {ERRDOS, 86, NT_STATUS_WRONG_PASSWORD_CORE}, + {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_FLOAT_CONTEXT}, + {ERRDOS, 109, NT_STATUS_PIPE_BROKEN}, + {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_CORRUPT}, + {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_IO_FAILED}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_EVENT_PAIR}, + {ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_VOLUME}, + {ERRHRD, ERRgeneral, NT_STATUS_SERIAL_NO_DEVICE_INITED}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_ALIAS}, + {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_ALIAS}, + {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_ALIAS}, + {ERRHRD, ERRgeneral, NT_STATUS_ALIAS_EXISTS}, + {ERRHRD, ERRgeneral, NT_STATUS_LOGON_NOT_GRANTED}, + {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SECRETS}, + {ERRHRD, ERRgeneral, NT_STATUS_SECRET_TOO_LONG}, + {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_FULLSCREEN_MODE}, + {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_CONTEXT_IDS}, + {ERRDOS, ERRnoaccess, NT_STATUS_LOGON_TYPE_NOT_GRANTED}, + {ERRHRD, ERRgeneral, NT_STATUS_NOT_REGISTRY_FILE}, + {ERRHRD, ERRgeneral, NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED}, + {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_FT_MISSING_MEMBER}, + {ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_SERVICE_ENTRY}, + {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_CHARACTER}, + {ERRHRD, ERRgeneral, NT_STATUS_UNMAPPABLE_CHARACTER}, + {ERRHRD, ERRgeneral, NT_STATUS_UNDEFINED_CHARACTER}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_VOLUME}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_WRONG_CYLINDER}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_UNKNOWN_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_BAD_REGISTERS}, + {ERRHRD, ERRgeneral, NT_STATUS_DISK_RECALIBRATE_FAILED}, + {ERRHRD, ERRgeneral, NT_STATUS_DISK_OPERATION_FAILED}, + {ERRHRD, ERRgeneral, NT_STATUS_DISK_RESET_FAILED}, + {ERRHRD, ERRgeneral, NT_STATUS_SHARED_IRQ_BUSY}, + {ERRHRD, ERRgeneral, NT_STATUS_FT_ORPHANING}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc000016e)}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc000016f)}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc0000170)}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc0000171)}, + {ERRHRD, ERRgeneral, NT_STATUS_PARTITION_FAILURE}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_BLOCK_LENGTH}, + {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_PARTITIONED}, + {ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_LOCK_MEDIA}, + {ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_UNLOAD_MEDIA}, + {ERRHRD, ERRgeneral, NT_STATUS_EOM_OVERFLOW}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_MEDIA}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc0000179)}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_MEMBER}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_MEMBER}, + {ERRHRD, ERRgeneral, NT_STATUS_KEY_DELETED}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_LOG_SPACE}, + {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SIDS}, + {ERRHRD, ERRgeneral, NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED}, + {ERRHRD, ERRgeneral, NT_STATUS_KEY_HAS_CHILDREN}, + {ERRHRD, ERRgeneral, NT_STATUS_CHILD_MUST_BE_VOLATILE}, + {ERRDOS, 87, NT_STATUS_DEVICE_CONFIGURATION_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_DRIVER_INTERNAL_ERROR}, + {ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE}, + {ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_PROTOCOL_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_BACKUP_CONTROLLER}, + {ERRHRD, ERRgeneral, NT_STATUS_LOG_FILE_FULL}, + {ERRDOS, 19, NT_STATUS_TOO_LATE}, + {ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_LSA_SECRET}, +/* { This NT error code was 'sqashed' + from NT_STATUS_NO_TRUST_SAM_ACCOUNT to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE + during the session setup } +*/ + {ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_SAM_ACCOUNT}, + {ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_DOMAIN_FAILURE}, + {ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE}, + {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CORRUPT}, + {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_CANT_START}, + {ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE}, + {ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED}, + {ERRDOS, ERRinvgroup, NT_STATUS_NETLOGON_NOT_STARTED}, + {ERRSRV, 2239, NT_STATUS_ACCOUNT_EXPIRED}, + {ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK}, + {ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, + {ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT}, + {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CHANGED}, + {ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT}, + {ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT}, + {ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT}, +/* { This NT error code was 'sqashed' + from NT_STATUS_DOMAIN_TRUST_INCONSISTENT to NT_STATUS_LOGON_FAILURE + during the session setup } +*/ + {ERRDOS, ERRnoaccess, NT_STATUS_DOMAIN_TRUST_INCONSISTENT}, + {ERRHRD, ERRgeneral, NT_STATUS_FS_DRIVER_REQUIRED}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_USER_SESSION_KEY}, + {ERRDOS, 59, NT_STATUS_USER_SESSION_DELETED}, + {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_LANG_NOT_FOUND}, + {ERRDOS, ERRnomem, NT_STATUS_INSUFF_SERVER_RESOURCES}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_BUFFER_SIZE}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_COMPONENT}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_WILDCARD}, + {ERRDOS, 68, NT_STATUS_TOO_MANY_ADDRESSES}, + {ERRDOS, 52, NT_STATUS_ADDRESS_ALREADY_EXISTS}, + {ERRDOS, 64, NT_STATUS_ADDRESS_CLOSED}, + {ERRDOS, 64, NT_STATUS_CONNECTION_DISCONNECTED}, + {ERRDOS, 64, NT_STATUS_CONNECTION_RESET}, + {ERRDOS, 68, NT_STATUS_TOO_MANY_NODES}, + {ERRDOS, 59, NT_STATUS_TRANSACTION_ABORTED}, + {ERRDOS, 59, NT_STATUS_TRANSACTION_TIMED_OUT}, + {ERRDOS, 59, NT_STATUS_TRANSACTION_NO_RELEASE}, + {ERRDOS, 59, NT_STATUS_TRANSACTION_NO_MATCH}, + {ERRDOS, 59, NT_STATUS_TRANSACTION_RESPONDED}, + {ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_ID}, + {ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_TYPE}, + {ERRDOS, ERRunsup, NT_STATUS_NOT_SERVER_SESSION}, + {ERRDOS, ERRunsup, NT_STATUS_NOT_CLIENT_SESSION}, + {ERRHRD, ERRgeneral, NT_STATUS_CANNOT_LOAD_REGISTRY_FILE}, + {ERRHRD, ERRgeneral, NT_STATUS_DEBUG_ATTACH_FAILED}, + {ERRHRD, ERRgeneral, NT_STATUS_SYSTEM_PROCESS_TERMINATED}, + {ERRHRD, ERRgeneral, NT_STATUS_DATA_NOT_ACCEPTED}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_BROWSER_SERVERS_FOUND}, + {ERRHRD, ERRgeneral, NT_STATUS_VDM_HARD_ERROR}, + {ERRHRD, ERRgeneral, NT_STATUS_DRIVER_CANCEL_TIMEOUT}, + {ERRHRD, ERRgeneral, NT_STATUS_REPLY_MESSAGE_MISMATCH}, + {ERRHRD, ERRgeneral, NT_STATUS_MAPPED_ALIGNMENT}, + {ERRDOS, 193, NT_STATUS_IMAGE_CHECKSUM_MISMATCH}, + {ERRHRD, ERRgeneral, NT_STATUS_LOST_WRITEBEHIND_DATA}, + {ERRHRD, ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID}, + {ERRSRV, 2242, NT_STATUS_PASSWORD_MUST_CHANGE}, + {ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND}, + {ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM}, + {ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE}, + {ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW_READ}, + {ERRHRD, ERRgeneral, NT_STATUS_FAIL_CHECK}, + {ERRHRD, ERRgeneral, NT_STATUS_DUPLICATE_OBJECTID}, + {ERRHRD, ERRgeneral, NT_STATUS_OBJECTID_EXISTS}, + {ERRHRD, ERRgeneral, NT_STATUS_CONVERT_TO_LARGE}, + {ERRHRD, ERRgeneral, NT_STATUS_RETRY}, + {ERRHRD, ERRgeneral, NT_STATUS_FOUND_OUT_OF_SCOPE}, + {ERRHRD, ERRgeneral, NT_STATUS_ALLOCATE_BUCKET}, + {ERRHRD, ERRgeneral, NT_STATUS_PROPSET_NOT_FOUND}, + {ERRHRD, ERRgeneral, NT_STATUS_MARSHALL_OVERFLOW}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_VARIANT}, + {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND}, + {ERRDOS, ERRnoaccess, NT_STATUS_ACCOUNT_LOCKED_OUT}, + {ERRDOS, ERRbadfid, NT_STATUS_HANDLE_NOT_CLOSABLE}, + {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED}, + {ERRHRD, ERRgeneral, NT_STATUS_GRACEFUL_DISCONNECT}, + {ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED}, + {ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_NOT_ASSOCIATED}, + {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_INVALID}, + {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ACTIVE}, + {ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE}, + {ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE}, + {ERRHRD, ERRgeneral, NT_STATUS_PROTOCOL_UNREACHABLE}, + {ERRHRD, ERRgeneral, NT_STATUS_PORT_UNREACHABLE}, + {ERRHRD, ERRgeneral, NT_STATUS_REQUEST_ABORTED}, + {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_COMPRESSION_BUFFER}, + {ERRHRD, ERRgeneral, NT_STATUS_USER_MAPPED_FILE}, + {ERRHRD, ERRgeneral, NT_STATUS_AUDIT_FAILED}, + {ERRHRD, ERRgeneral, NT_STATUS_TIMER_RESOLUTION_NOT_SET}, + {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_COUNT_LIMIT}, + {ERRHRD, ERRgeneral, NT_STATUS_LOGIN_TIME_RESTRICTION}, + {ERRHRD, ERRgeneral, NT_STATUS_LOGIN_WKSTA_RESTRICTION}, + {ERRDOS, 193, NT_STATUS_IMAGE_MP_UP_MISMATCH}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc000024a)}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc000024b)}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc000024c)}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc000024d)}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc000024e)}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc000024f)}, + {ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT}, + {ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT}, + {ERRHRD, ERRgeneral, NT_STATUS_LPC_REPLY_LOST}, + {ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT1}, + {ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT2}, + {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_QUOTA_LIMIT}, + {ERRSRV, ERRbadtype, NT_STATUS_PATH_NOT_COVERED}, + {ERRHRD, ERRgeneral, NT_STATUS_NO_CALLBACK_ACTIVE}, + {ERRHRD, ERRgeneral, NT_STATUS_LICENSE_QUOTA_EXCEEDED}, + {ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT}, + {ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT}, + {ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc000025d)}, + {ERRHRD, ERRgeneral, NT_STATUS_PLUGPLAY_NO_DEVICE}, + {ERRHRD, ERRgeneral, NT_STATUS_UNSUPPORTED_COMPRESSION}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_HW_PROFILE}, + {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH}, + {ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, + {ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, + {ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED}, + {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LINKS}, + {ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT}, + {ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE}, + {ERRDOS, 21, NT_STATUS(0xc000026e)}, + {ERRDOS, 161, NT_STATUS(0xc0000281)}, + {ERRDOS, ERRnoaccess, NT_STATUS(0xc000028a)}, + {ERRDOS, ERRnoaccess, NT_STATUS(0xc000028b)}, + {ERRHRD, ERRgeneral, NT_STATUS(0xc000028c)}, + {ERRDOS, ERRnoaccess, NT_STATUS(0xc000028d)}, + {ERRDOS, ERRnoaccess, NT_STATUS(0xc000028e)}, + {ERRDOS, ERRnoaccess, NT_STATUS(0xc000028f)}, + {ERRDOS, ERRnoaccess, NT_STATUS(0xc0000290)}, + {ERRDOS, ERRbadfunc, NT_STATUS(0xc000029c)}, +}; + + +/* dos -> nt status error map */ +static const struct { + uint8 dos_class; + uint32 dos_code; + NTSTATUS ntstatus; +} dos_to_ntstatus_map[] = { + {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, + {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, + {ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, + {ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES}, + {ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED}, + {ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, + {ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES}, + {ERRDOS, ERRbadaccess, NT_STATUS_INVALID_LOCK_SEQUENCE}, + {ERRDOS, ERRbaddata, NT_STATUS_DATA_ERROR}, + {ERRDOS, 14, NT_STATUS_SECTION_NOT_EXTENDED}, + {ERRDOS, ERRremcd, NT_STATUS_DIRECTORY_NOT_EMPTY}, + {ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE}, + {ERRDOS, ERRnofiles, NT_STATUS(0x80000006)}, + {ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED}, + {ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE}, + {ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE}, + {ERRDOS, 23, NT_STATUS_DATA_ERROR}, + {ERRDOS, 24, NT_STATUS_DATA_ERROR}, + {ERRDOS, 26, NT_STATUS_DISK_CORRUPT_ERROR}, + {ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR}, + {ERRDOS, 28, NT_STATUS(0x8000000e)}, + {ERRDOS, 31, NT_STATUS_UNSUCCESSFUL}, + {ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, + {ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, + {ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, + {ERRDOS, 38, NT_STATUS_END_OF_FILE}, + {ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, + {ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING}, + {ERRDOS, 52, NT_STATUS_DUPLICATE_NAME}, + {ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH}, + {ERRDOS, 54, NT_STATUS_NETWORK_BUSY}, + {ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, + {ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS}, + {ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, + {ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, + {ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, + {ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, + {ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL}, + {ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE}, + {ERRDOS, 63, NT_STATUS_PRINT_CANCELLED}, + {ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED}, + {ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, + {ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE}, + {ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME}, + {ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, + {ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS}, + {ERRDOS, 70, NT_STATUS_SHARING_PAUSED}, + {ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, + {ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED}, + {ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION}, + {ERRDOS, 86, NT_STATUS_WRONG_PASSWORD}, + {ERRDOS, 87, NT_STATUS_INVALID_INFO_CLASS}, + {ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT}, + {ERRDOS, 109, NT_STATUS_PIPE_BROKEN}, + {ERRDOS, 111, STATUS_MORE_ENTRIES}, + {ERRDOS, 112, NT_STATUS_DISK_FULL}, + {ERRDOS, 121, NT_STATUS_IO_TIMEOUT}, + {ERRDOS, 122, NT_STATUS_BUFFER_TOO_SMALL}, + {ERRDOS, ERRinvalidname, NT_STATUS_OBJECT_NAME_INVALID}, + {ERRDOS, 124, NT_STATUS_INVALID_LEVEL}, + {ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND}, + {ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, + {ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, + {ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL}, + {ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, + {ERRDOS, 158, NT_STATUS_NOT_LOCKED}, + {ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID}, + {ERRDOS, 170, NT_STATUS(0x80000011)}, + {ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND}, + {ERRDOS, 183, NT_STATUS_OBJECT_NAME_COLLISION}, + {ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC}, + {ERRDOS, 203, NT_STATUS(0xc0000100)}, + {ERRDOS, 206, NT_STATUS_NAME_TOO_LONG}, + {ERRDOS, ERRbadpipe, NT_STATUS_INVALID_INFO_CLASS}, + {ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE}, + {ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING}, + {ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED}, + {ERRDOS, ERRmoredata, NT_STATUS_MORE_PROCESSING_REQUIRED}, + {ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, + {ERRDOS, 254, NT_STATUS(0x80000013)}, + {ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, + {ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED}, + {ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY}, + {ERRDOS, 275, NT_STATUS_EA_TOO_LARGE}, + {ERRDOS, 276, NT_STATUS_NONEXISTENT_EA_ENTRY}, + {ERRDOS, 277, NT_STATUS_NONEXISTENT_EA_ENTRY}, + {ERRDOS, 278, NT_STATUS_NONEXISTENT_EA_ENTRY}, + {ERRDOS, 282, NT_STATUS_EAS_NOT_SUPPORTED}, + {ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED}, + {ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, + {ERRDOS, 299, NT_STATUS(0x8000000d)}, + {ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, + {ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, + {ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES}, + {ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW}, + {ERRDOS, 535, NT_STATUS_PIPE_CONNECTED}, + {ERRDOS, 536, NT_STATUS_PIPE_LISTENING}, + {ERRDOS, 995, NT_STATUS_CANCELLED}, + {ERRDOS, 997, NT_STATUS(0x00000103)}, + {ERRDOS, 998, NT_STATUS_ACCESS_VIOLATION}, + {ERRDOS, 999, NT_STATUS_IN_PAGE_ERROR}, + {ERRDOS, 1001, NT_STATUS_BAD_INITIAL_STACK}, + {ERRDOS, 1005, NT_STATUS_UNRECOGNIZED_VOLUME}, + {ERRDOS, 1006, NT_STATUS_FILE_INVALID}, + {ERRDOS, 1007, NT_STATUS_FULLSCREEN_MODE}, + {ERRDOS, 1008, NT_STATUS_NO_TOKEN}, + {ERRDOS, 1009, NT_STATUS_REGISTRY_CORRUPT}, + {ERRDOS, 1016, NT_STATUS_REGISTRY_IO_FAILED}, + {ERRDOS, 1017, NT_STATUS_NOT_REGISTRY_FILE}, + {ERRDOS, 1018, NT_STATUS_KEY_DELETED}, + {ERRDOS, 1019, NT_STATUS_NO_LOG_SPACE}, + {ERRDOS, 1020, NT_STATUS_KEY_HAS_CHILDREN}, + {ERRDOS, 1021, NT_STATUS_CHILD_MUST_BE_VOLATILE}, + {ERRDOS, 1022, NT_STATUS(0x0000010c)}, + {ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD}, + {ERRSRV, ERRbadtype, NT_STATUS_BAD_DEVICE_TYPE}, + {ERRSRV, ERRaccess, NT_STATUS_NETWORK_ACCESS_DENIED}, + {ERRSRV, ERRinvnid, NT_STATUS_NETWORK_NAME_DELETED}, + {ERRSRV, ERRinvnetname, NT_STATUS_BAD_NETWORK_NAME}, + {ERRSRV, ERRinvdevice, NT_STATUS_BAD_DEVICE_TYPE}, + {ERRSRV, ERRqfull, NT_STATUS_PRINT_QUEUE_FULL}, + {ERRSRV, ERRqtoobig, NT_STATUS_NO_SPOOL_SPACE}, + {ERRSRV, ERRinvpfid, NT_STATUS_PRINT_CANCELLED}, + {ERRSRV, ERRsmbcmd, NT_STATUS_NOT_IMPLEMENTED}, + {ERRSRV, ERRbadpermits, NT_STATUS_NETWORK_ACCESS_DENIED}, + {ERRSRV, ERRpaused, NT_STATUS_SHARING_PAUSED}, + {ERRSRV, ERRmsgoff, NT_STATUS_REQUEST_NOT_ACCEPTED}, + {ERRSRV, ERRnoroom, NT_STATUS_DISK_FULL}, + {ERRSRV, ERRnoresource, NT_STATUS_REQUEST_NOT_ACCEPTED}, + {ERRSRV, ERRtoomanyuids, NT_STATUS_TOO_MANY_SESSIONS}, + {ERRSRV, 123, NT_STATUS_OBJECT_NAME_INVALID}, + {ERRSRV, 206, NT_STATUS_OBJECT_NAME_INVALID}, + {ERRHRD, 1, NT_STATUS_NOT_IMPLEMENTED}, + {ERRHRD, 2, NT_STATUS_NO_SUCH_DEVICE}, + {ERRHRD, 3, NT_STATUS_OBJECT_PATH_NOT_FOUND}, + {ERRHRD, 4, NT_STATUS_TOO_MANY_OPENED_FILES}, + {ERRHRD, 5, NT_STATUS_INVALID_LOCK_SEQUENCE}, + {ERRHRD, 6, NT_STATUS_INVALID_HANDLE}, + {ERRHRD, 8, NT_STATUS_INSUFFICIENT_RESOURCES}, + {ERRHRD, 12, NT_STATUS_INVALID_LOCK_SEQUENCE}, + {ERRHRD, 13, NT_STATUS_DATA_ERROR}, + {ERRHRD, 14, NT_STATUS_SECTION_NOT_EXTENDED}, + {ERRHRD, 16, NT_STATUS_DIRECTORY_NOT_EMPTY}, + {ERRHRD, 17, NT_STATUS_NOT_SAME_DEVICE}, + {ERRHRD, 18, NT_STATUS(0x80000006)}, + {ERRHRD, ERRnowrite, NT_STATUS_MEDIA_WRITE_PROTECTED}, + {ERRHRD, ERRnotready, NT_STATUS_NO_MEDIA_IN_DEVICE}, + {ERRHRD, ERRbadcmd, NT_STATUS_INVALID_DEVICE_STATE}, + {ERRHRD, ERRdata, NT_STATUS_DATA_ERROR}, + {ERRHRD, ERRbadreq, NT_STATUS_DATA_ERROR}, + {ERRHRD, ERRbadmedia, NT_STATUS_DISK_CORRUPT_ERROR}, + {ERRHRD, ERRbadsector, NT_STATUS_NONEXISTENT_SECTOR}, + {ERRHRD, ERRnopaper, NT_STATUS(0x8000000e)}, + {ERRHRD, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, + {ERRHRD, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, + {ERRHRD, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, + {ERRHRD, ERRwrongdisk, NT_STATUS_WRONG_VOLUME}, + {ERRHRD, 38, NT_STATUS_END_OF_FILE}, + {ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL}, + {ERRHRD, 50, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, + {ERRHRD, 51, NT_STATUS_REMOTE_NOT_LISTENING}, + {ERRHRD, 52, NT_STATUS_DUPLICATE_NAME}, + {ERRHRD, 53, NT_STATUS_BAD_NETWORK_PATH}, + {ERRHRD, 54, NT_STATUS_NETWORK_BUSY}, + {ERRHRD, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, + {ERRHRD, 56, NT_STATUS_TOO_MANY_COMMANDS}, + {ERRHRD, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, + {ERRHRD, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, + {ERRHRD, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, + {ERRHRD, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, + {ERRHRD, 61, NT_STATUS_PRINT_QUEUE_FULL}, + {ERRHRD, 62, NT_STATUS_NO_SPOOL_SPACE}, + {ERRHRD, 63, NT_STATUS_PRINT_CANCELLED}, + {ERRHRD, 64, NT_STATUS_NETWORK_NAME_DELETED}, + {ERRHRD, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, + {ERRHRD, 66, NT_STATUS_BAD_DEVICE_TYPE}, + {ERRHRD, 67, NT_STATUS_BAD_NETWORK_NAME}, + {ERRHRD, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, + {ERRHRD, 69, NT_STATUS_TOO_MANY_SESSIONS}, + {ERRHRD, 70, NT_STATUS_SHARING_PAUSED}, + {ERRHRD, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, + {ERRHRD, 72, NT_STATUS_REDIRECTOR_PAUSED}, + {ERRHRD, 80, NT_STATUS_OBJECT_NAME_COLLISION}, + {ERRHRD, 86, NT_STATUS_WRONG_PASSWORD}, + {ERRHRD, 87, NT_STATUS_INVALID_INFO_CLASS}, + {ERRHRD, 88, NT_STATUS_NET_WRITE_FAULT}, + {ERRHRD, 109, NT_STATUS_PIPE_BROKEN}, + {ERRHRD, 111, STATUS_MORE_ENTRIES}, + {ERRHRD, 112, NT_STATUS_DISK_FULL}, + {ERRHRD, 121, NT_STATUS_IO_TIMEOUT}, + {ERRHRD, 122, NT_STATUS_BUFFER_TOO_SMALL}, + {ERRHRD, 123, NT_STATUS_OBJECT_NAME_INVALID}, + {ERRHRD, 124, NT_STATUS_INVALID_LEVEL}, + {ERRHRD, 126, NT_STATUS_DLL_NOT_FOUND}, + {ERRHRD, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, + {ERRHRD, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, + {ERRHRD, 154, NT_STATUS_INVALID_VOLUME_LABEL}, + {ERRHRD, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, + {ERRHRD, 158, NT_STATUS_NOT_LOCKED}, + {ERRHRD, 161, NT_STATUS_OBJECT_PATH_INVALID}, + {ERRHRD, 170, NT_STATUS(0x80000011)}, + {ERRHRD, 182, NT_STATUS_ORDINAL_NOT_FOUND}, + {ERRHRD, 183, NT_STATUS_OBJECT_NAME_COLLISION}, + {ERRHRD, 193, NT_STATUS_BAD_INITIAL_PC}, + {ERRHRD, 203, NT_STATUS(0xc0000100)}, + {ERRHRD, 206, NT_STATUS_NAME_TOO_LONG}, + {ERRHRD, 230, NT_STATUS_INVALID_INFO_CLASS}, + {ERRHRD, 231, NT_STATUS_INSTANCE_NOT_AVAILABLE}, + {ERRHRD, 232, NT_STATUS_PIPE_CLOSING}, + {ERRHRD, 233, NT_STATUS_PIPE_DISCONNECTED}, + {ERRHRD, 234, STATUS_MORE_ENTRIES}, + {ERRHRD, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, + {ERRHRD, 254, NT_STATUS(0x80000013)}, + {ERRHRD, 255, NT_STATUS_EA_TOO_LARGE}, + {ERRHRD, 259, NT_STATUS_GUIDS_EXHAUSTED}, + {ERRHRD, 267, NT_STATUS_NOT_A_DIRECTORY}, + {ERRHRD, 275, NT_STATUS_EA_TOO_LARGE}, + {ERRHRD, 276, NT_STATUS_NONEXISTENT_EA_ENTRY}, + {ERRHRD, 277, NT_STATUS_NONEXISTENT_EA_ENTRY}, + {ERRHRD, 278, NT_STATUS_NONEXISTENT_EA_ENTRY}, + {ERRHRD, 282, NT_STATUS_EAS_NOT_SUPPORTED}, + {ERRHRD, 288, NT_STATUS_MUTANT_NOT_OWNED}, + {ERRHRD, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, + {ERRHRD, 299, NT_STATUS(0x8000000d)}, + {ERRHRD, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, + {ERRHRD, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, + {ERRHRD, 487, NT_STATUS_CONFLICTING_ADDRESSES}, + {ERRHRD, 534, NT_STATUS_INTEGER_OVERFLOW}, + {ERRHRD, 535, NT_STATUS_PIPE_CONNECTED}, + {ERRHRD, 536, NT_STATUS_PIPE_LISTENING}, + {ERRHRD, 995, NT_STATUS_CANCELLED}, + {ERRHRD, 997, NT_STATUS(0x00000103)}, + {ERRHRD, 998, NT_STATUS_ACCESS_VIOLATION}, + {ERRHRD, 999, NT_STATUS_IN_PAGE_ERROR}, + {ERRHRD, 1001, NT_STATUS_BAD_INITIAL_STACK}, + {ERRHRD, 1005, NT_STATUS_UNRECOGNIZED_VOLUME}, + {ERRHRD, 1006, NT_STATUS_FILE_INVALID}, + {ERRHRD, 1007, NT_STATUS_FULLSCREEN_MODE}, + {ERRHRD, 1008, NT_STATUS_NO_TOKEN}, + {ERRHRD, 1009, NT_STATUS_REGISTRY_CORRUPT}, + {ERRHRD, 1016, NT_STATUS_REGISTRY_IO_FAILED}, + {ERRHRD, 1017, NT_STATUS_NOT_REGISTRY_FILE}, + {ERRHRD, 1018, NT_STATUS_KEY_DELETED}, + {ERRHRD, 1019, NT_STATUS_NO_LOG_SPACE}, + {ERRHRD, 1020, NT_STATUS_KEY_HAS_CHILDREN}, + {ERRHRD, 1021, NT_STATUS_CHILD_MUST_BE_VOLATILE}, + {ERRHRD, 1022, NT_STATUS(0x0000010c)}, +}; + +/* errmap NTSTATUS->Win32 */ +static const struct { + NTSTATUS ntstatus; + WERROR werror; +} ntstatus_to_werror_map[] = { + {NT_STATUS(0x103), W_ERROR(0x3e5)}, + {NT_STATUS(0x105), W_ERROR(0xea)}, + {NT_STATUS(0x106), W_ERROR(0x514)}, + {NT_STATUS(0x107), W_ERROR(0x515)}, + {NT_STATUS(0x10c), W_ERROR(0x3fe)}, + {NT_STATUS(0x10d), W_ERROR(0x516)}, + {NT_STATUS(0x121), W_ERROR(0x2009)}, + {NT_STATUS(0xc0000001), W_ERROR(0x1f)}, + {NT_STATUS(0xc0000002), W_ERROR(0x1)}, + {NT_STATUS(0xc0000003), W_ERROR(0x57)}, + {NT_STATUS(0xc0000004), W_ERROR(0x18)}, + {NT_STATUS(0xc0000005), W_ERROR(0x3e6)}, + {NT_STATUS(0xc0000006), W_ERROR(0x3e7)}, + {NT_STATUS(0xc0000007), W_ERROR(0x5ae)}, + {NT_STATUS(0xc0000008), W_ERROR(0x6)}, + {NT_STATUS(0xc0000009), W_ERROR(0x3e9)}, + {NT_STATUS(0xc000000a), W_ERROR(0xc1)}, + {NT_STATUS(0xc000000b), W_ERROR(0x57)}, + {NT_STATUS(0xc000000d), W_ERROR(0x57)}, + {NT_STATUS(0xc000000e), W_ERROR(0x2)}, + {NT_STATUS(0xc000000f), W_ERROR(0x2)}, + {NT_STATUS(0xc0000010), W_ERROR(0x1)}, + {NT_STATUS(0xc0000011), W_ERROR(0x26)}, + {NT_STATUS(0xc0000012), W_ERROR(0x22)}, + {NT_STATUS(0xc0000013), W_ERROR(0x15)}, + {NT_STATUS(0xc0000014), W_ERROR(0x6f9)}, + {NT_STATUS(0xc0000015), W_ERROR(0x1b)}, + {NT_STATUS(0xc0000016), W_ERROR(0xea)}, + {NT_STATUS(0xc0000017), W_ERROR(0x8)}, + {NT_STATUS(0xc0000018), W_ERROR(0x1e7)}, + {NT_STATUS(0xc0000019), W_ERROR(0x1e7)}, + {NT_STATUS(0xc000001a), W_ERROR(0x57)}, + {NT_STATUS(0xc000001b), W_ERROR(0x57)}, + {NT_STATUS(0xc000001c), W_ERROR(0x1)}, + {NT_STATUS(0xc000001d), W_ERROR(0xc000001d)}, + {NT_STATUS(0xc000001e), W_ERROR(0x5)}, + {NT_STATUS(0xc000001f), W_ERROR(0x5)}, + {NT_STATUS(0xc0000020), W_ERROR(0xc1)}, + {NT_STATUS(0xc0000021), W_ERROR(0x5)}, + {NT_STATUS(0xc0000022), W_ERROR(0x5)}, + {NT_STATUS(0xc0000023), W_ERROR(0x7a)}, + {NT_STATUS(0xc0000024), W_ERROR(0x6)}, + {NT_STATUS(0xc0000025), W_ERROR(0xc0000025)}, + {NT_STATUS(0xc0000026), W_ERROR(0xc0000026)}, + {NT_STATUS(0xc000002a), W_ERROR(0x9e)}, + {NT_STATUS(0xc000002b), W_ERROR(0xc000002b)}, + {NT_STATUS(0xc000002c), W_ERROR(0x1e7)}, + {NT_STATUS(0xc000002d), W_ERROR(0x1e7)}, + {NT_STATUS(0xc0000030), W_ERROR(0x57)}, + {NT_STATUS(0xc0000032), W_ERROR(0x571)}, + {NT_STATUS(0xc0000033), W_ERROR(0x7b)}, + {NT_STATUS(0xc0000034), W_ERROR(0x2)}, + {NT_STATUS(0xc0000035), W_ERROR(0xb7)}, + {NT_STATUS(0xc0000037), W_ERROR(0x6)}, + {NT_STATUS(0xc0000039), W_ERROR(0xa1)}, + {NT_STATUS(0xc000003a), W_ERROR(0x3)}, + {NT_STATUS(0xc000003b), W_ERROR(0xa1)}, + {NT_STATUS(0xc000003c), W_ERROR(0x45d)}, + {NT_STATUS(0xc000003d), W_ERROR(0x45d)}, + {NT_STATUS(0xc000003e), W_ERROR(0x17)}, + {NT_STATUS(0xc000003f), W_ERROR(0x17)}, + {NT_STATUS(0xc0000040), W_ERROR(0x8)}, + {NT_STATUS(0xc0000041), W_ERROR(0x5)}, + {NT_STATUS(0xc0000042), W_ERROR(0x6)}, + {NT_STATUS(0xc0000043), W_ERROR(0x20)}, + {NT_STATUS(0xc0000044), W_ERROR(0x718)}, + {NT_STATUS(0xc0000045), W_ERROR(0x57)}, + {NT_STATUS(0xc0000046), W_ERROR(0x120)}, + {NT_STATUS(0xc0000047), W_ERROR(0x12a)}, + {NT_STATUS(0xc0000048), W_ERROR(0x57)}, + {NT_STATUS(0xc0000049), W_ERROR(0x57)}, + {NT_STATUS(0xc000004a), W_ERROR(0x9c)}, + {NT_STATUS(0xc000004b), W_ERROR(0x5)}, + {NT_STATUS(0xc000004c), W_ERROR(0x57)}, + {NT_STATUS(0xc000004d), W_ERROR(0x57)}, + {NT_STATUS(0xc000004e), W_ERROR(0x57)}, + {NT_STATUS(0xc000004f), W_ERROR(0x11a)}, + {NT_STATUS(0xc0000050), W_ERROR(0xff)}, + {NT_STATUS(0xc0000051), W_ERROR(0x570)}, + {NT_STATUS(0xc0000052), W_ERROR(0x570)}, + {NT_STATUS(0xc0000053), W_ERROR(0x570)}, + {NT_STATUS(0xc0000054), W_ERROR(0x21)}, + {NT_STATUS(0xc0000055), W_ERROR(0x21)}, + {NT_STATUS(0xc0000056), W_ERROR(0x5)}, + {NT_STATUS(0xc0000057), W_ERROR(0x32)}, + {NT_STATUS(0xc0000058), W_ERROR(0x519)}, + {NT_STATUS(0xc0000059), W_ERROR(0x51a)}, + {NT_STATUS(0xc000005a), W_ERROR(0x51b)}, + {NT_STATUS(0xc000005b), W_ERROR(0x51c)}, + {NT_STATUS(0xc000005c), W_ERROR(0x51d)}, + {NT_STATUS(0xc000005d), W_ERROR(0x51e)}, + {NT_STATUS(0xc000005e), W_ERROR(0x51f)}, + {NT_STATUS(0xc000005f), W_ERROR(0x520)}, + {NT_STATUS(0xc0000060), W_ERROR(0x521)}, + {NT_STATUS(0xc0000061), W_ERROR(0x522)}, + {NT_STATUS(0xc0000062), W_ERROR(0x523)}, + {NT_STATUS(0xc0000063), W_ERROR(0x524)}, + {NT_STATUS(0xc0000064), W_ERROR(0x525)}, + {NT_STATUS(0xc0000065), W_ERROR(0x526)}, + {NT_STATUS(0xc0000066), W_ERROR(0x527)}, + {NT_STATUS(0xc0000067), W_ERROR(0x528)}, + {NT_STATUS(0xc0000068), W_ERROR(0x529)}, + {NT_STATUS(0xc0000069), W_ERROR(0x52a)}, + {NT_STATUS(0xc000006a), W_ERROR(0x56)}, + {NT_STATUS(0xc000006b), W_ERROR(0x52c)}, + {NT_STATUS(0xc000006c), W_ERROR(0x52d)}, + {NT_STATUS(0xc000006d), W_ERROR(0x52e)}, + {NT_STATUS(0xc000006e), W_ERROR(0x52f)}, + {NT_STATUS(0xc000006f), W_ERROR(0x530)}, + {NT_STATUS(0xc0000070), W_ERROR(0x531)}, + {NT_STATUS(0xc0000071), W_ERROR(0x532)}, + {NT_STATUS(0xc0000072), W_ERROR(0x533)}, + {NT_STATUS(0xc0000073), W_ERROR(0x534)}, + {NT_STATUS(0xc0000074), W_ERROR(0x535)}, + {NT_STATUS(0xc0000075), W_ERROR(0x536)}, + {NT_STATUS(0xc0000076), W_ERROR(0x537)}, + {NT_STATUS(0xc0000077), W_ERROR(0x538)}, + {NT_STATUS(0xc0000078), W_ERROR(0x539)}, + {NT_STATUS(0xc0000079), W_ERROR(0x53a)}, + {NT_STATUS(0xc000007a), W_ERROR(0x7f)}, + {NT_STATUS(0xc000007b), W_ERROR(0xc1)}, + {NT_STATUS(0xc000007c), W_ERROR(0x3f0)}, + {NT_STATUS(0xc000007d), W_ERROR(0x53c)}, + {NT_STATUS(0xc000007e), W_ERROR(0x9e)}, + {NT_STATUS(0xc000007f), W_ERROR(0x70)}, + {NT_STATUS(0xc0000080), W_ERROR(0x53d)}, + {NT_STATUS(0xc0000081), W_ERROR(0x53e)}, + {NT_STATUS(0xc0000082), W_ERROR(0x44)}, + {NT_STATUS(0xc0000083), W_ERROR(0x103)}, + {NT_STATUS(0xc0000084), W_ERROR(0x53f)}, + {NT_STATUS(0xc0000085), W_ERROR(0x103)}, + {NT_STATUS(0xc0000086), W_ERROR(0x9a)}, + {NT_STATUS(0xc0000087), W_ERROR(0xe)}, + {NT_STATUS(0xc0000088), W_ERROR(0x1e7)}, + {NT_STATUS(0xc0000089), W_ERROR(0x714)}, + {NT_STATUS(0xc000008a), W_ERROR(0x715)}, + {NT_STATUS(0xc000008b), W_ERROR(0x716)}, + {NT_STATUS(0xc000008c), W_ERROR(0xc000008c)}, + {NT_STATUS(0xc000008d), W_ERROR(0xc000008d)}, + {NT_STATUS(0xc000008e), W_ERROR(0xc000008e)}, + {NT_STATUS(0xc000008f), W_ERROR(0xc000008f)}, + {NT_STATUS(0xc0000090), W_ERROR(0xc0000090)}, + {NT_STATUS(0xc0000091), W_ERROR(0xc0000091)}, + {NT_STATUS(0xc0000092), W_ERROR(0xc0000092)}, + {NT_STATUS(0xc0000093), W_ERROR(0xc0000093)}, + {NT_STATUS(0xc0000094), W_ERROR(0xc0000094)}, + {NT_STATUS(0xc0000095), W_ERROR(0x216)}, + {NT_STATUS(0xc0000096), W_ERROR(0xc0000096)}, + {NT_STATUS(0xc0000097), W_ERROR(0x8)}, + {NT_STATUS(0xc0000098), W_ERROR(0x3ee)}, + {NT_STATUS(0xc0000099), W_ERROR(0x540)}, + {NT_STATUS(0xc000009a), W_ERROR(0x5aa)}, + {NT_STATUS(0xc000009b), W_ERROR(0x3)}, + {NT_STATUS(0xc000009c), W_ERROR(0x17)}, + {NT_STATUS(0xc000009d), W_ERROR(0x48f)}, + {NT_STATUS(0xc000009e), W_ERROR(0x15)}, + {NT_STATUS(0xc000009f), W_ERROR(0x1e7)}, + {NT_STATUS(0xc00000a0), W_ERROR(0x1e7)}, + {NT_STATUS(0xc00000a1), W_ERROR(0x5ad)}, + {NT_STATUS(0xc00000a2), W_ERROR(0x13)}, + {NT_STATUS(0xc00000a3), W_ERROR(0x15)}, + {NT_STATUS(0xc00000a4), W_ERROR(0x541)}, + {NT_STATUS(0xc00000a5), W_ERROR(0x542)}, + {NT_STATUS(0xc00000a6), W_ERROR(0x543)}, + {NT_STATUS(0xc00000a7), W_ERROR(0x544)}, + {NT_STATUS(0xc00000a8), W_ERROR(0x545)}, + {NT_STATUS(0xc00000a9), W_ERROR(0x57)}, + {NT_STATUS(0xc00000ab), W_ERROR(0xe7)}, + {NT_STATUS(0xc00000ac), W_ERROR(0xe7)}, + {NT_STATUS(0xc00000ad), W_ERROR(0xe6)}, + {NT_STATUS(0xc00000ae), W_ERROR(0xe7)}, + {NT_STATUS(0xc00000af), W_ERROR(0x1)}, + {NT_STATUS(0xc00000b0), W_ERROR(0xe9)}, + {NT_STATUS(0xc00000b1), W_ERROR(0xe8)}, + {NT_STATUS(0xc00000b2), W_ERROR(0x217)}, + {NT_STATUS(0xc00000b3), W_ERROR(0x218)}, + {NT_STATUS(0xc00000b4), W_ERROR(0xe6)}, + {NT_STATUS(0xc00000b5), W_ERROR(0x79)}, + {NT_STATUS(0xc00000b6), W_ERROR(0x26)}, + {NT_STATUS(0xc00000ba), W_ERROR(0x5)}, + {NT_STATUS(0xc00000bb), W_ERROR(0x32)}, + {NT_STATUS(0xc00000bc), W_ERROR(0x33)}, + {NT_STATUS(0xc00000bd), W_ERROR(0x34)}, + {NT_STATUS(0xc00000be), W_ERROR(0x35)}, + {NT_STATUS(0xc00000bf), W_ERROR(0x36)}, + {NT_STATUS(0xc00000c0), W_ERROR(0x37)}, + {NT_STATUS(0xc00000c1), W_ERROR(0x38)}, + {NT_STATUS(0xc00000c2), W_ERROR(0x39)}, + {NT_STATUS(0xc00000c3), W_ERROR(0x3a)}, + {NT_STATUS(0xc00000c4), W_ERROR(0x3b)}, + {NT_STATUS(0xc00000c5), W_ERROR(0x3c)}, + {NT_STATUS(0xc00000c6), W_ERROR(0x3d)}, + {NT_STATUS(0xc00000c7), W_ERROR(0x3e)}, + {NT_STATUS(0xc00000c8), W_ERROR(0x3f)}, + {NT_STATUS(0xc00000c9), W_ERROR(0x40)}, + {NT_STATUS(0xc00000ca), W_ERROR(0x41)}, + {NT_STATUS(0xc00000cb), W_ERROR(0x42)}, + {NT_STATUS(0xc00000cc), W_ERROR(0x43)}, + {NT_STATUS(0xc00000cd), W_ERROR(0x44)}, + {NT_STATUS(0xc00000ce), W_ERROR(0x45)}, + {NT_STATUS(0xc00000cf), W_ERROR(0x46)}, + {NT_STATUS(0xc00000d0), W_ERROR(0x47)}, + {NT_STATUS(0xc00000d1), W_ERROR(0x48)}, + {NT_STATUS(0xc00000d2), W_ERROR(0x58)}, + {NT_STATUS(0xc00000d4), W_ERROR(0x11)}, + {NT_STATUS(0xc00000d5), W_ERROR(0x5)}, + {NT_STATUS(0xc00000d6), W_ERROR(0xf0)}, + {NT_STATUS(0xc00000d7), W_ERROR(0x546)}, + {NT_STATUS(0xc00000d9), W_ERROR(0xe8)}, + {NT_STATUS(0xc00000da), W_ERROR(0x547)}, + {NT_STATUS(0xc00000dc), W_ERROR(0x548)}, + {NT_STATUS(0xc00000dd), W_ERROR(0x549)}, + {NT_STATUS(0xc00000de), W_ERROR(0x54a)}, + {NT_STATUS(0xc00000df), W_ERROR(0x54b)}, + {NT_STATUS(0xc00000e0), W_ERROR(0x54c)}, + {NT_STATUS(0xc00000e1), W_ERROR(0x54d)}, + {NT_STATUS(0xc00000e2), W_ERROR(0x12c)}, + {NT_STATUS(0xc00000e3), W_ERROR(0x12d)}, + {NT_STATUS(0xc00000e4), W_ERROR(0x54e)}, + {NT_STATUS(0xc00000e5), W_ERROR(0x54f)}, + {NT_STATUS(0xc00000e6), W_ERROR(0x550)}, + {NT_STATUS(0xc00000e7), W_ERROR(0x551)}, + {NT_STATUS(0xc00000e8), W_ERROR(0x6f8)}, + {NT_STATUS(0xc00000ed), W_ERROR(0x552)}, + {NT_STATUS(0xc00000ee), W_ERROR(0x553)}, + {NT_STATUS(0xc00000ef), W_ERROR(0x57)}, + {NT_STATUS(0xc00000f0), W_ERROR(0x57)}, + {NT_STATUS(0xc00000f1), W_ERROR(0x57)}, + {NT_STATUS(0xc00000f2), W_ERROR(0x57)}, + {NT_STATUS(0xc00000f3), W_ERROR(0x57)}, + {NT_STATUS(0xc00000f4), W_ERROR(0x57)}, + {NT_STATUS(0xc00000f5), W_ERROR(0x57)}, + {NT_STATUS(0xc00000f6), W_ERROR(0x57)}, + {NT_STATUS(0xc00000f7), W_ERROR(0x57)}, + {NT_STATUS(0xc00000f8), W_ERROR(0x57)}, + {NT_STATUS(0xc00000f9), W_ERROR(0x57)}, + {NT_STATUS(0xc00000fa), W_ERROR(0x57)}, + {NT_STATUS(0xc00000fb), W_ERROR(0x3)}, + {NT_STATUS(0xc00000fd), W_ERROR(0x3e9)}, + {NT_STATUS(0xc00000fe), W_ERROR(0x554)}, + {NT_STATUS(0xc0000100), W_ERROR(0xcb)}, + {NT_STATUS(0xc0000101), W_ERROR(0x91)}, + {NT_STATUS(0xc0000102), W_ERROR(0x570)}, + {NT_STATUS(0xc0000103), W_ERROR(0x10b)}, + {NT_STATUS(0xc0000104), W_ERROR(0x555)}, + {NT_STATUS(0xc0000105), W_ERROR(0x556)}, + {NT_STATUS(0xc0000106), W_ERROR(0xce)}, + {NT_STATUS(0xc0000107), W_ERROR(0x961)}, + {NT_STATUS(0xc0000108), W_ERROR(0x964)}, + {NT_STATUS(0xc000010a), W_ERROR(0x5)}, + {NT_STATUS(0xc000010b), W_ERROR(0x557)}, + {NT_STATUS(0xc000010d), W_ERROR(0x558)}, + {NT_STATUS(0xc000010e), W_ERROR(0x420)}, + {NT_STATUS(0xc0000117), W_ERROR(0x5a4)}, + {NT_STATUS(0xc000011b), W_ERROR(0xc1)}, + {NT_STATUS(0xc000011c), W_ERROR(0x559)}, + {NT_STATUS(0xc000011d), W_ERROR(0x55a)}, + {NT_STATUS(0xc000011e), W_ERROR(0x3ee)}, + {NT_STATUS(0xc000011f), W_ERROR(0x4)}, + {NT_STATUS(0xc0000120), W_ERROR(0x3e3)}, + {NT_STATUS(0xc0000121), W_ERROR(0x5)}, + {NT_STATUS(0xc0000122), W_ERROR(0x4ba)}, + {NT_STATUS(0xc0000123), W_ERROR(0x5)}, + {NT_STATUS(0xc0000124), W_ERROR(0x55b)}, + {NT_STATUS(0xc0000125), W_ERROR(0x55c)}, + {NT_STATUS(0xc0000126), W_ERROR(0x55d)}, + {NT_STATUS(0xc0000127), W_ERROR(0x55e)}, + {NT_STATUS(0xc0000128), W_ERROR(0x6)}, + {NT_STATUS(0xc000012b), W_ERROR(0x55f)}, + {NT_STATUS(0xc000012d), W_ERROR(0x5af)}, + {NT_STATUS(0xc000012e), W_ERROR(0xc1)}, + {NT_STATUS(0xc000012f), W_ERROR(0xc1)}, + {NT_STATUS(0xc0000130), W_ERROR(0xc1)}, + {NT_STATUS(0xc0000131), W_ERROR(0xc1)}, + {NT_STATUS(0xc0000133), W_ERROR(0x576)}, + {NT_STATUS(0xc0000135), W_ERROR(0x7e)}, + {NT_STATUS(0xc0000138), W_ERROR(0xb6)}, + {NT_STATUS(0xc0000139), W_ERROR(0x7f)}, + {NT_STATUS(0xc000013b), W_ERROR(0x40)}, + {NT_STATUS(0xc000013c), W_ERROR(0x40)}, + {NT_STATUS(0xc000013d), W_ERROR(0x33)}, + {NT_STATUS(0xc000013e), W_ERROR(0x3b)}, + {NT_STATUS(0xc000013f), W_ERROR(0x3b)}, + {NT_STATUS(0xc0000140), W_ERROR(0x3b)}, + {NT_STATUS(0xc0000141), W_ERROR(0x3b)}, + {NT_STATUS(0xc0000142), W_ERROR(0x45a)}, + {NT_STATUS(0xc0000148), W_ERROR(0x7c)}, + {NT_STATUS(0xc0000149), W_ERROR(0x56)}, + {NT_STATUS(0xc000014b), W_ERROR(0x6d)}, + {NT_STATUS(0xc000014c), W_ERROR(0x3f1)}, + {NT_STATUS(0xc000014d), W_ERROR(0x3f8)}, + {NT_STATUS(0xc000014f), W_ERROR(0x3ed)}, + {NT_STATUS(0xc0000150), W_ERROR(0x45e)}, + {NT_STATUS(0xc0000151), W_ERROR(0x560)}, + {NT_STATUS(0xc0000152), W_ERROR(0x561)}, + {NT_STATUS(0xc0000153), W_ERROR(0x562)}, + {NT_STATUS(0xc0000154), W_ERROR(0x563)}, + {NT_STATUS(0xc0000155), W_ERROR(0x564)}, + {NT_STATUS(0xc0000156), W_ERROR(0x565)}, + {NT_STATUS(0xc0000157), W_ERROR(0x566)}, + {NT_STATUS(0xc0000158), W_ERROR(0x567)}, + {NT_STATUS(0xc0000159), W_ERROR(0x3ef)}, + {NT_STATUS(0xc000015a), W_ERROR(0x568)}, + {NT_STATUS(0xc000015b), W_ERROR(0x569)}, + {NT_STATUS(0xc000015c), W_ERROR(0x3f9)}, + {NT_STATUS(0xc000015d), W_ERROR(0x56a)}, + {NT_STATUS(0xc000015f), W_ERROR(0x45d)}, + {NT_STATUS(0xc0000162), W_ERROR(0x459)}, + {NT_STATUS(0xc0000165), W_ERROR(0x462)}, + {NT_STATUS(0xc0000166), W_ERROR(0x463)}, + {NT_STATUS(0xc0000167), W_ERROR(0x464)}, + {NT_STATUS(0xc0000168), W_ERROR(0x465)}, + {NT_STATUS(0xc0000169), W_ERROR(0x466)}, + {NT_STATUS(0xc000016a), W_ERROR(0x467)}, + {NT_STATUS(0xc000016b), W_ERROR(0x468)}, + {NT_STATUS(0xc000016c), W_ERROR(0x45f)}, + {NT_STATUS(0xc000016d), W_ERROR(0x45d)}, + {NT_STATUS(0xc0000172), W_ERROR(0x451)}, + {NT_STATUS(0xc0000173), W_ERROR(0x452)}, + {NT_STATUS(0xc0000174), W_ERROR(0x453)}, + {NT_STATUS(0xc0000175), W_ERROR(0x454)}, + {NT_STATUS(0xc0000176), W_ERROR(0x455)}, + {NT_STATUS(0xc0000177), W_ERROR(0x469)}, + {NT_STATUS(0xc0000178), W_ERROR(0x458)}, + {NT_STATUS(0xc000017a), W_ERROR(0x56b)}, + {NT_STATUS(0xc000017b), W_ERROR(0x56c)}, + {NT_STATUS(0xc000017c), W_ERROR(0x3fa)}, + {NT_STATUS(0xc000017d), W_ERROR(0x3fb)}, + {NT_STATUS(0xc000017e), W_ERROR(0x56d)}, + {NT_STATUS(0xc000017f), W_ERROR(0x56e)}, + {NT_STATUS(0xc0000180), W_ERROR(0x3fc)}, + {NT_STATUS(0xc0000181), W_ERROR(0x3fd)}, + {NT_STATUS(0xc0000182), W_ERROR(0x57)}, + {NT_STATUS(0xc0000183), W_ERROR(0x45d)}, + {NT_STATUS(0xc0000184), W_ERROR(0x16)}, + {NT_STATUS(0xc0000185), W_ERROR(0x45d)}, + {NT_STATUS(0xc0000186), W_ERROR(0x45d)}, + {NT_STATUS(0xc0000188), W_ERROR(0x5de)}, + {NT_STATUS(0xc0000189), W_ERROR(0x13)}, + {NT_STATUS(0xc000018a), W_ERROR(0x6fa)}, + {NT_STATUS(0xc000018b), W_ERROR(0x6fb)}, + {NT_STATUS(0xc000018c), W_ERROR(0x6fc)}, + {NT_STATUS(0xc000018d), W_ERROR(0x6fd)}, + {NT_STATUS(0xc000018e), W_ERROR(0x5dc)}, + {NT_STATUS(0xc000018f), W_ERROR(0x5dd)}, + {NT_STATUS(0xc0000190), W_ERROR(0x6fe)}, + {NT_STATUS(0xc0000192), W_ERROR(0x700)}, + {NT_STATUS(0xc0000193), W_ERROR(0x701)}, + {NT_STATUS(0xc0000194), W_ERROR(0x46b)}, + {NT_STATUS(0xc0000195), W_ERROR(0x4c3)}, + {NT_STATUS(0xc0000196), W_ERROR(0x4c4)}, + {NT_STATUS(0xc0000197), W_ERROR(0x5df)}, + {NT_STATUS(0xc0000198), W_ERROR(0x70f)}, + {NT_STATUS(0xc0000199), W_ERROR(0x710)}, + {NT_STATUS(0xc000019a), W_ERROR(0x711)}, + {NT_STATUS(0xc000019b), W_ERROR(0x712)}, + {NT_STATUS(0xc0000202), W_ERROR(0x572)}, + {NT_STATUS(0xc0000203), W_ERROR(0x3b)}, + {NT_STATUS(0xc0000204), W_ERROR(0x717)}, + {NT_STATUS(0xc0000205), W_ERROR(0x46a)}, + {NT_STATUS(0xc0000206), W_ERROR(0x6f8)}, + {NT_STATUS(0xc0000207), W_ERROR(0x4be)}, + {NT_STATUS(0xc0000208), W_ERROR(0x4be)}, + {NT_STATUS(0xc0000209), W_ERROR(0x44)}, + {NT_STATUS(0xc000020a), W_ERROR(0x34)}, + {NT_STATUS(0xc000020b), W_ERROR(0x40)}, + {NT_STATUS(0xc000020c), W_ERROR(0x40)}, + {NT_STATUS(0xc000020d), W_ERROR(0x40)}, + {NT_STATUS(0xc000020e), W_ERROR(0x44)}, + {NT_STATUS(0xc000020f), W_ERROR(0x3b)}, + {NT_STATUS(0xc0000210), W_ERROR(0x3b)}, + {NT_STATUS(0xc0000211), W_ERROR(0x3b)}, + {NT_STATUS(0xc0000212), W_ERROR(0x3b)}, + {NT_STATUS(0xc0000213), W_ERROR(0x3b)}, + {NT_STATUS(0xc0000214), W_ERROR(0x3b)}, + {NT_STATUS(0xc0000215), W_ERROR(0x3b)}, + {NT_STATUS(0xc0000216), W_ERROR(0x32)}, + {NT_STATUS(0xc0000217), W_ERROR(0x32)}, + {NT_STATUS(0xc000021c), W_ERROR(0x17e6)}, + {NT_STATUS(0xc0000220), W_ERROR(0x46c)}, + {NT_STATUS(0xc0000221), W_ERROR(0xc1)}, + {NT_STATUS(0xc0000224), W_ERROR(0x773)}, + {NT_STATUS(0xc0000225), W_ERROR(0x490)}, + {NT_STATUS(0xc000022a), W_ERROR(0xc000022a)}, + {NT_STATUS(0xc000022b), W_ERROR(0xc000022b)}, + {NT_STATUS(0xc000022d), W_ERROR(0x4d5)}, + {NT_STATUS(0xc0000230), W_ERROR(0x492)}, + {NT_STATUS(0xc0000233), W_ERROR(0x774)}, + {NT_STATUS(0xc0000234), W_ERROR(0x775)}, + {NT_STATUS(0xc0000235), W_ERROR(0x6)}, + {NT_STATUS(0xc0000236), W_ERROR(0x4c9)}, + {NT_STATUS(0xc0000237), W_ERROR(0x4ca)}, + {NT_STATUS(0xc0000238), W_ERROR(0x4cb)}, + {NT_STATUS(0xc0000239), W_ERROR(0x4cc)}, + {NT_STATUS(0xc000023a), W_ERROR(0x4cd)}, + {NT_STATUS(0xc000023b), W_ERROR(0x4ce)}, + {NT_STATUS(0xc000023c), W_ERROR(0x4cf)}, + {NT_STATUS(0xc000023d), W_ERROR(0x4d0)}, + {NT_STATUS(0xc000023e), W_ERROR(0x4d1)}, + {NT_STATUS(0xc000023f), W_ERROR(0x4d2)}, + {NT_STATUS(0xc0000240), W_ERROR(0x4d3)}, + {NT_STATUS(0xc0000241), W_ERROR(0x4d4)}, + {NT_STATUS(0xc0000243), W_ERROR(0x4c8)}, + {NT_STATUS(0xc0000246), W_ERROR(0x4d6)}, + {NT_STATUS(0xc0000247), W_ERROR(0x4d7)}, + {NT_STATUS(0xc0000248), W_ERROR(0x4d8)}, + {NT_STATUS(0xc0000249), W_ERROR(0xc1)}, + {NT_STATUS(0xc0000253), W_ERROR(0x54f)}, + {NT_STATUS(0xc0000257), W_ERROR(0x4d0)}, + {NT_STATUS(0xc0000259), W_ERROR(0x573)}, + {NT_STATUS(0xc000025e), W_ERROR(0x422)}, + {NT_STATUS(0xc0000262), W_ERROR(0xb6)}, + {NT_STATUS(0xc0000263), W_ERROR(0x7f)}, + {NT_STATUS(0xc0000264), W_ERROR(0x120)}, + {NT_STATUS(0xc0000265), W_ERROR(0x476)}, + {NT_STATUS(0xc0000267), W_ERROR(0x10fe)}, + {NT_STATUS(0xc000026c), W_ERROR(0x7d1)}, + {NT_STATUS(0xc000026d), W_ERROR(0x4b1)}, + {NT_STATUS(0xc000026e), W_ERROR(0x15)}, + {NT_STATUS(0xc0000272), W_ERROR(0x491)}, + {NT_STATUS(0xc0000275), W_ERROR(0x1126)}, + {NT_STATUS(0xc0000276), W_ERROR(0x1129)}, + {NT_STATUS(0xc0000277), W_ERROR(0x112a)}, + {NT_STATUS(0xc0000278), W_ERROR(0x1128)}, + {NT_STATUS(0xc0000279), W_ERROR(0x780)}, + {NT_STATUS(0xc0000280), W_ERROR(0x781)}, + {NT_STATUS(0xc0000281), W_ERROR(0xa1)}, + {NT_STATUS(0xc0000283), W_ERROR(0x488)}, + {NT_STATUS(0xc0000284), W_ERROR(0x489)}, + {NT_STATUS(0xc0000285), W_ERROR(0x48a)}, + {NT_STATUS(0xc0000286), W_ERROR(0x48b)}, + {NT_STATUS(0xc0000287), W_ERROR(0x48c)}, + {NT_STATUS(0xc000028a), W_ERROR(0x5)}, + {NT_STATUS(0xc000028b), W_ERROR(0x5)}, + {NT_STATUS(0xc000028d), W_ERROR(0x5)}, + {NT_STATUS(0xc000028e), W_ERROR(0x5)}, + {NT_STATUS(0xc000028f), W_ERROR(0x5)}, + {NT_STATUS(0xc0000290), W_ERROR(0x5)}, + {NT_STATUS(0xc0000291), W_ERROR(0x1777)}, + {NT_STATUS(0xc0000292), W_ERROR(0x1778)}, + {NT_STATUS(0xc0000293), W_ERROR(0x1772)}, + {NT_STATUS(0xc0000295), W_ERROR(0x1068)}, + {NT_STATUS(0xc0000296), W_ERROR(0x1069)}, + {NT_STATUS(0xc0000297), W_ERROR(0x106a)}, + {NT_STATUS(0xc0000298), W_ERROR(0x106b)}, + {NT_STATUS(0xc0000299), W_ERROR(0x201a)}, + {NT_STATUS(0xc000029a), W_ERROR(0x201b)}, + {NT_STATUS(0xc000029b), W_ERROR(0x201c)}, + {NT_STATUS(0xc000029c), W_ERROR(0x1)}, + {NT_STATUS(0xc000029d), W_ERROR(0x10ff)}, + {NT_STATUS(0xc000029e), W_ERROR(0x1100)}, + {NT_STATUS(0xc000029f), W_ERROR(0x494)}, + {NT_STATUS(0xc00002a1), W_ERROR(0x200a)}, + {NT_STATUS(0xc00002a2), W_ERROR(0x200b)}, + {NT_STATUS(0xc00002a3), W_ERROR(0x200c)}, + {NT_STATUS(0xc00002a4), W_ERROR(0x200d)}, + {NT_STATUS(0xc00002a5), W_ERROR(0x200e)}, + {NT_STATUS(0xc00002a6), W_ERROR(0x200f)}, + {NT_STATUS(0xc00002a7), W_ERROR(0x2010)}, + {NT_STATUS(0xc00002a8), W_ERROR(0x2011)}, + {NT_STATUS(0xc00002a9), W_ERROR(0x2012)}, + {NT_STATUS(0xc00002aa), W_ERROR(0x2013)}, + {NT_STATUS(0xc00002ab), W_ERROR(0x2014)}, + {NT_STATUS(0xc00002ac), W_ERROR(0x2015)}, + {NT_STATUS(0xc00002ad), W_ERROR(0x2016)}, + {NT_STATUS(0xc00002ae), W_ERROR(0x2017)}, + {NT_STATUS(0xc00002af), W_ERROR(0x2018)}, + {NT_STATUS(0xc00002b0), W_ERROR(0x2019)}, + {NT_STATUS(0xc00002b1), W_ERROR(0x211e)}, + {NT_STATUS(0xc00002b2), W_ERROR(0x1127)}, + {NT_STATUS(0xc00002b6), W_ERROR(0x651)}, + {NT_STATUS(0xc00002b7), W_ERROR(0x49a)}, + {NT_STATUS(0xc00002b8), W_ERROR(0x49b)}, + {NT_STATUS(0xc00002c1), W_ERROR(0x2024)}, + {NT_STATUS(0xc00002c3), W_ERROR(0x575)}, + {NT_STATUS(0xc00002c5), W_ERROR(0x3e6)}, + {NT_STATUS(0xc00002c6), W_ERROR(0x1075)}, + {NT_STATUS(0xc00002c7), W_ERROR(0x1076)}, + {NT_STATUS(0xc00002ca), W_ERROR(0x10e8)}, + {NT_STATUS(0xc00002cb), W_ERROR(0x2138)}, + {NT_STATUS(0xc00002cc), W_ERROR(0x4e3)}, + {NT_STATUS(0xc00002cd), W_ERROR(0x2139)}, + {NT_STATUS(0xc00002cf), W_ERROR(0x49d)}, + {NT_STATUS(0xc00002d0), W_ERROR(0x213a)}, + {NT_STATUS(0xc00002d4), W_ERROR(0x2141)}, + {NT_STATUS(0xc00002d5), W_ERROR(0x2142)}, + {NT_STATUS(0xc00002d6), W_ERROR(0x2143)}, + {NT_STATUS(0xc00002d7), W_ERROR(0x2144)}, + {NT_STATUS(0xc00002d8), W_ERROR(0x2145)}, + {NT_STATUS(0xc00002d9), W_ERROR(0x2146)}, + {NT_STATUS(0xc00002da), W_ERROR(0x2147)}, + {NT_STATUS(0xc00002db), W_ERROR(0x2148)}, + {NT_STATUS(0xc00002dc), W_ERROR(0x2149)}, + {NT_STATUS(0xc00002dd), W_ERROR(0x32)}, + {NT_STATUS(0xc00002df), W_ERROR(0x2151)}, + {NT_STATUS(0xc00002e0), W_ERROR(0x2152)}, + {NT_STATUS(0xc00002e1), W_ERROR(0x2153)}, + {NT_STATUS(0xc00002e2), W_ERROR(0x2154)}, + {NT_STATUS(0xc00002e3), W_ERROR(0x215d)}, + {NT_STATUS(0xc00002e4), W_ERROR(0x2163)}, + {NT_STATUS(0xc00002e5), W_ERROR(0x2164)}, + {NT_STATUS(0xc00002e6), W_ERROR(0x2165)}, + {NT_STATUS(0xc00002e7), W_ERROR(0x216d)}, + {NT_STATUS(0xc00002fe), W_ERROR(0x45b)}, + {NT_STATUS(0xc00002ff), W_ERROR(0x4e7)}, + {NT_STATUS(0xc0000300), W_ERROR(0x4e6)}, + {NT_STATUS(0x80000001), W_ERROR(0x80000001)}, + {NT_STATUS(0x80000002), W_ERROR(0x3e6)}, + {NT_STATUS(0x80000003), W_ERROR(0x80000003)}, + {NT_STATUS(0x80000004), W_ERROR(0x80000004)}, + {NT_STATUS(0x80000005), W_ERROR(0xea)}, + {NT_STATUS(0x80000006), W_ERROR(0x12)}, + {NT_STATUS(0x8000000b), W_ERROR(0x56f)}, + {NT_STATUS(0x8000000d), W_ERROR(0x12b)}, + {NT_STATUS(0x8000000e), W_ERROR(0x1c)}, + {NT_STATUS(0x8000000f), W_ERROR(0x15)}, + {NT_STATUS(0x80000010), W_ERROR(0x15)}, + {NT_STATUS(0x80000011), W_ERROR(0xaa)}, + {NT_STATUS(0x80000012), W_ERROR(0x103)}, + {NT_STATUS(0x80000013), W_ERROR(0xfe)}, + {NT_STATUS(0x80000014), W_ERROR(0xff)}, + {NT_STATUS(0x80000015), W_ERROR(0xff)}, + {NT_STATUS(0x80000016), W_ERROR(0x456)}, + {NT_STATUS(0x8000001a), W_ERROR(0x103)}, + {NT_STATUS(0x8000001b), W_ERROR(0x44d)}, + {NT_STATUS(0x8000001c), W_ERROR(0x456)}, + {NT_STATUS(0x8000001d), W_ERROR(0x457)}, + {NT_STATUS(0x8000001e), W_ERROR(0x44c)}, + {NT_STATUS(0x8000001f), W_ERROR(0x44e)}, + {NT_STATUS(0x80000021), W_ERROR(0x44f)}, + {NT_STATUS(0x80000022), W_ERROR(0x450)}, + {NT_STATUS(0x80000025), W_ERROR(0x962)}, + {NT_STATUS(0x80000288), W_ERROR(0x48d)}, + {NT_STATUS(0x80000289), W_ERROR(0x48e)}, + {NT_STATUS_OK, WERR_OK}}; + + +/***************************************************************************** +convert a dos eclas/ecode to a NT status32 code + *****************************************************************************/ +NTSTATUS dos_to_ntstatus(uint8 eclass, uint32 ecode) +{ + int i; + if (eclass == 0 && ecode == 0) return NT_STATUS_OK; + for (i=0; NT_STATUS_V(dos_to_ntstatus_map[i].ntstatus); i++) { + if (eclass == dos_to_ntstatus_map[i].dos_class && + ecode == dos_to_ntstatus_map[i].dos_code) { + return dos_to_ntstatus_map[i].ntstatus; + } + } + return NT_STATUS_UNSUCCESSFUL; +} + + +/***************************************************************************** +convert a NT status code to a dos class/code + *****************************************************************************/ +void ntstatus_to_dos(NTSTATUS ntstatus, uint8 *eclass, uint32 *ecode) +{ + int i; + if (NT_STATUS_IS_OK(ntstatus)) { + *eclass = 0; + *ecode = 0; + return; + } + for (i=0; NT_STATUS_V(ntstatus_to_dos_map[i].ntstatus); i++) { + if (NT_STATUS_V(ntstatus) == + NT_STATUS_V(ntstatus_to_dos_map[i].ntstatus)) { + *eclass = ntstatus_to_dos_map[i].dos_class; + *ecode = ntstatus_to_dos_map[i].dos_code; + return; + } + } + *eclass = ERRHRD; + *ecode = ERRgeneral; +} + + +/***************************************************************************** +convert a WERROR to a NT status32 code + *****************************************************************************/ +NTSTATUS werror_to_ntstatus(WERROR error) +{ + int i; + if (W_ERROR_IS_OK(error)) return NT_STATUS_OK; + for (i=0; NT_STATUS_V(ntstatus_to_werror_map[i].ntstatus); i++) { + if (W_ERROR_V(error) == + W_ERROR_V(ntstatus_to_werror_map[i].werror)) { + return ntstatus_to_werror_map[i].ntstatus; + } + } + + /* just guess ... */ + return NT_STATUS(W_ERROR_V(error) | 0xc0000000); +} + +/***************************************************************************** +convert a NTSTATUS to a WERROR + *****************************************************************************/ +WERROR ntstatus_to_werror(NTSTATUS error) +{ + int i; + if (NT_STATUS_IS_OK(error)) return WERR_OK; + for (i=0; NT_STATUS_V(ntstatus_to_werror_map[i].ntstatus); i++) { + if (NT_STATUS_V(error) == + NT_STATUS_V(ntstatus_to_werror_map[i].ntstatus)) { + return ntstatus_to_werror_map[i].werror; + } + } + + /* a lame guess */ + return W_ERROR(NT_STATUS_V(error) & 0xffff); +} + +/* Mapping between Unix, DOS and NT error numbers */ + +const struct unix_error_map unix_dos_nt_errmap[] = { + { EPERM, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, + { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, + { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND }, + { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR }, + { EBADF, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE }, + { EINVAL, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE }, + { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION}, + { ENFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES }, + { EMFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES }, + { ENOSPC, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, + { EISDIR, ERRDOS, ERRbadpath, NT_STATUS_FILE_IS_A_DIRECTORY }, +#ifdef EDQUOT + { EDQUOT, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, +#endif +#ifdef ENOTEMPTY + { ENOTEMPTY, ERRDOS, ERRnoaccess, NT_STATUS_DIRECTORY_NOT_EMPTY }, +#endif +#ifdef EXDEV + { EXDEV, ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE }, +#endif +#ifdef EROFS + { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED }, +#endif +#ifdef ENAMETOOLONG + { ENAMETOOLONG, ERRDOS, 206, NT_STATUS_OBJECT_NAME_INVALID }, +#endif +#ifdef EFBIG + { EFBIG, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, +#endif +#ifdef EFBIG + { EBUSY, ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION }, +#endif + { 0, 0, 0, NT_STATUS_OK } +}; + +/********************************************************************* + Map an NT error code from a Unix error code. +*********************************************************************/ + +NTSTATUS map_nt_error_from_unix(int unix_error) +{ + int i = 0; + + if (unix_error == 0) + return NT_STATUS_OK; + + /* Look through list */ + while(unix_dos_nt_errmap[i].unix_error != 0) { + if (unix_dos_nt_errmap[i].unix_error == unix_error) + return unix_dos_nt_errmap[i].nt_error; + i++; + } + + /* Default return */ + return NT_STATUS_ACCESS_DENIED; +} diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c new file mode 100644 index 0000000000..6c4b7c8417 --- /dev/null +++ b/source4/libcli/util/nterr.c @@ -0,0 +1,715 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Luke Kenneth Casson Leighton 1997-2001. + * + * 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. + */ + +/* NT error codes. please read nterr.h */ + +#include "includes.h" + +typedef struct +{ + const char *nt_errstr; + NTSTATUS nt_errcode; +} nt_err_code_struct; + +static const nt_err_code_struct nt_errs[] = +{ + { "NT_STATUS_OK", NT_STATUS_OK }, + { "NT_STATUS_UNSUCCESSFUL", NT_STATUS_UNSUCCESSFUL }, + { "NT_STATUS_NOT_IMPLEMENTED", NT_STATUS_NOT_IMPLEMENTED }, + { "NT_STATUS_INVALID_INFO_CLASS", NT_STATUS_INVALID_INFO_CLASS }, + { "NT_STATUS_INFO_LENGTH_MISMATCH", NT_STATUS_INFO_LENGTH_MISMATCH }, + { "NT_STATUS_ACCESS_VIOLATION", NT_STATUS_ACCESS_VIOLATION }, + { "STATUS_BUFFER_OVERFLOW", STATUS_BUFFER_OVERFLOW }, + { "NT_STATUS_IN_PAGE_ERROR", NT_STATUS_IN_PAGE_ERROR }, + { "NT_STATUS_PAGEFILE_QUOTA", NT_STATUS_PAGEFILE_QUOTA }, + { "NT_STATUS_INVALID_HANDLE", NT_STATUS_INVALID_HANDLE }, + { "NT_STATUS_BAD_INITIAL_STACK", NT_STATUS_BAD_INITIAL_STACK }, + { "NT_STATUS_BAD_INITIAL_PC", NT_STATUS_BAD_INITIAL_PC }, + { "NT_STATUS_INVALID_CID", NT_STATUS_INVALID_CID }, + { "NT_STATUS_TIMER_NOT_CANCELED", NT_STATUS_TIMER_NOT_CANCELED }, + { "NT_STATUS_INVALID_PARAMETER", NT_STATUS_INVALID_PARAMETER }, + { "NT_STATUS_NO_SUCH_DEVICE", NT_STATUS_NO_SUCH_DEVICE }, + { "NT_STATUS_NO_SUCH_FILE", NT_STATUS_NO_SUCH_FILE }, + { "NT_STATUS_INVALID_DEVICE_REQUEST", NT_STATUS_INVALID_DEVICE_REQUEST }, + { "NT_STATUS_END_OF_FILE", NT_STATUS_END_OF_FILE }, + { "NT_STATUS_WRONG_VOLUME", NT_STATUS_WRONG_VOLUME }, + { "NT_STATUS_NO_MEDIA_IN_DEVICE", NT_STATUS_NO_MEDIA_IN_DEVICE }, + { "NT_STATUS_UNRECOGNIZED_MEDIA", NT_STATUS_UNRECOGNIZED_MEDIA }, + { "NT_STATUS_NONEXISTENT_SECTOR", NT_STATUS_NONEXISTENT_SECTOR }, + { "NT_STATUS_MORE_PROCESSING_REQUIRED", NT_STATUS_MORE_PROCESSING_REQUIRED }, + { "NT_STATUS_NO_MEMORY", NT_STATUS_NO_MEMORY }, + { "NT_STATUS_CONFLICTING_ADDRESSES", NT_STATUS_CONFLICTING_ADDRESSES }, + { "NT_STATUS_NOT_MAPPED_VIEW", NT_STATUS_NOT_MAPPED_VIEW }, + { "NT_STATUS_UNABLE_TO_FREE_VM", NT_STATUS_UNABLE_TO_FREE_VM }, + { "NT_STATUS_UNABLE_TO_DELETE_SECTION", NT_STATUS_UNABLE_TO_DELETE_SECTION }, + { "NT_STATUS_INVALID_SYSTEM_SERVICE", NT_STATUS_INVALID_SYSTEM_SERVICE }, + { "NT_STATUS_ILLEGAL_INSTRUCTION", NT_STATUS_ILLEGAL_INSTRUCTION }, + { "NT_STATUS_INVALID_LOCK_SEQUENCE", NT_STATUS_INVALID_LOCK_SEQUENCE }, + { "NT_STATUS_INVALID_VIEW_SIZE", NT_STATUS_INVALID_VIEW_SIZE }, + { "NT_STATUS_INVALID_FILE_FOR_SECTION", NT_STATUS_INVALID_FILE_FOR_SECTION }, + { "NT_STATUS_ALREADY_COMMITTED", NT_STATUS_ALREADY_COMMITTED }, + { "NT_STATUS_ACCESS_DENIED", NT_STATUS_ACCESS_DENIED }, + { "NT_STATUS_BUFFER_TOO_SMALL", NT_STATUS_BUFFER_TOO_SMALL }, + { "NT_STATUS_OBJECT_TYPE_MISMATCH", NT_STATUS_OBJECT_TYPE_MISMATCH }, + { "NT_STATUS_NONCONTINUABLE_EXCEPTION", NT_STATUS_NONCONTINUABLE_EXCEPTION }, + { "NT_STATUS_INVALID_DISPOSITION", NT_STATUS_INVALID_DISPOSITION }, + { "NT_STATUS_UNWIND", NT_STATUS_UNWIND }, + { "NT_STATUS_BAD_STACK", NT_STATUS_BAD_STACK }, + { "NT_STATUS_INVALID_UNWIND_TARGET", NT_STATUS_INVALID_UNWIND_TARGET }, + { "NT_STATUS_NOT_LOCKED", NT_STATUS_NOT_LOCKED }, + { "NT_STATUS_PARITY_ERROR", NT_STATUS_PARITY_ERROR }, + { "NT_STATUS_UNABLE_TO_DECOMMIT_VM", NT_STATUS_UNABLE_TO_DECOMMIT_VM }, + { "NT_STATUS_NOT_COMMITTED", NT_STATUS_NOT_COMMITTED }, + { "NT_STATUS_INVALID_PORT_ATTRIBUTES", NT_STATUS_INVALID_PORT_ATTRIBUTES }, + { "NT_STATUS_PORT_MESSAGE_TOO_LONG", NT_STATUS_PORT_MESSAGE_TOO_LONG }, + { "NT_STATUS_INVALID_PARAMETER_MIX", NT_STATUS_INVALID_PARAMETER_MIX }, + { "NT_STATUS_INVALID_QUOTA_LOWER", NT_STATUS_INVALID_QUOTA_LOWER }, + { "NT_STATUS_DISK_CORRUPT_ERROR", NT_STATUS_DISK_CORRUPT_ERROR }, + { "NT_STATUS_OBJECT_NAME_INVALID", NT_STATUS_OBJECT_NAME_INVALID }, + { "NT_STATUS_OBJECT_NAME_NOT_FOUND", NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { "NT_STATUS_OBJECT_NAME_COLLISION", NT_STATUS_OBJECT_NAME_COLLISION }, + { "NT_STATUS_HANDLE_NOT_WAITABLE", NT_STATUS_HANDLE_NOT_WAITABLE }, + { "NT_STATUS_PORT_DISCONNECTED", NT_STATUS_PORT_DISCONNECTED }, + { "NT_STATUS_DEVICE_ALREADY_ATTACHED", NT_STATUS_DEVICE_ALREADY_ATTACHED }, + { "NT_STATUS_OBJECT_PATH_INVALID", NT_STATUS_OBJECT_PATH_INVALID }, + { "NT_STATUS_OBJECT_PATH_NOT_FOUND", NT_STATUS_OBJECT_PATH_NOT_FOUND }, + { "NT_STATUS_OBJECT_PATH_SYNTAX_BAD", NT_STATUS_OBJECT_PATH_SYNTAX_BAD }, + { "NT_STATUS_DATA_OVERRUN", NT_STATUS_DATA_OVERRUN }, + { "NT_STATUS_DATA_LATE_ERROR", NT_STATUS_DATA_LATE_ERROR }, + { "NT_STATUS_DATA_ERROR", NT_STATUS_DATA_ERROR }, + { "NT_STATUS_CRC_ERROR", NT_STATUS_CRC_ERROR }, + { "NT_STATUS_SECTION_TOO_BIG", NT_STATUS_SECTION_TOO_BIG }, + { "NT_STATUS_PORT_CONNECTION_REFUSED", NT_STATUS_PORT_CONNECTION_REFUSED }, + { "NT_STATUS_INVALID_PORT_HANDLE", NT_STATUS_INVALID_PORT_HANDLE }, + { "NT_STATUS_SHARING_VIOLATION", NT_STATUS_SHARING_VIOLATION }, + { "NT_STATUS_QUOTA_EXCEEDED", NT_STATUS_QUOTA_EXCEEDED }, + { "NT_STATUS_INVALID_PAGE_PROTECTION", NT_STATUS_INVALID_PAGE_PROTECTION }, + { "NT_STATUS_MUTANT_NOT_OWNED", NT_STATUS_MUTANT_NOT_OWNED }, + { "NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED", NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED }, + { "NT_STATUS_PORT_ALREADY_SET", NT_STATUS_PORT_ALREADY_SET }, + { "NT_STATUS_SECTION_NOT_IMAGE", NT_STATUS_SECTION_NOT_IMAGE }, + { "NT_STATUS_SUSPEND_COUNT_EXCEEDED", NT_STATUS_SUSPEND_COUNT_EXCEEDED }, + { "NT_STATUS_THREAD_IS_TERMINATING", NT_STATUS_THREAD_IS_TERMINATING }, + { "NT_STATUS_BAD_WORKING_SET_LIMIT", NT_STATUS_BAD_WORKING_SET_LIMIT }, + { "NT_STATUS_INCOMPATIBLE_FILE_MAP", NT_STATUS_INCOMPATIBLE_FILE_MAP }, + { "NT_STATUS_SECTION_PROTECTION", NT_STATUS_SECTION_PROTECTION }, + { "NT_STATUS_EAS_NOT_SUPPORTED", NT_STATUS_EAS_NOT_SUPPORTED }, + { "NT_STATUS_EA_TOO_LARGE", NT_STATUS_EA_TOO_LARGE }, + { "NT_STATUS_NONEXISTENT_EA_ENTRY", NT_STATUS_NONEXISTENT_EA_ENTRY }, + { "NT_STATUS_NO_EAS_ON_FILE", NT_STATUS_NO_EAS_ON_FILE }, + { "NT_STATUS_EA_CORRUPT_ERROR", NT_STATUS_EA_CORRUPT_ERROR }, + { "NT_STATUS_FILE_LOCK_CONFLICT", NT_STATUS_FILE_LOCK_CONFLICT }, + { "NT_STATUS_LOCK_NOT_GRANTED", NT_STATUS_LOCK_NOT_GRANTED }, + { "NT_STATUS_DELETE_PENDING", NT_STATUS_DELETE_PENDING }, + { "NT_STATUS_CTL_FILE_NOT_SUPPORTED", NT_STATUS_CTL_FILE_NOT_SUPPORTED }, + { "NT_STATUS_UNKNOWN_REVISION", NT_STATUS_UNKNOWN_REVISION }, + { "NT_STATUS_REVISION_MISMATCH", NT_STATUS_REVISION_MISMATCH }, + { "NT_STATUS_INVALID_OWNER", NT_STATUS_INVALID_OWNER }, + { "NT_STATUS_INVALID_PRIMARY_GROUP", NT_STATUS_INVALID_PRIMARY_GROUP }, + { "NT_STATUS_NO_IMPERSONATION_TOKEN", NT_STATUS_NO_IMPERSONATION_TOKEN }, + { "NT_STATUS_CANT_DISABLE_MANDATORY", NT_STATUS_CANT_DISABLE_MANDATORY }, + { "NT_STATUS_NO_LOGON_SERVERS", NT_STATUS_NO_LOGON_SERVERS }, + { "NT_STATUS_NO_SUCH_LOGON_SESSION", NT_STATUS_NO_SUCH_LOGON_SESSION }, + { "NT_STATUS_NO_SUCH_PRIVILEGE", NT_STATUS_NO_SUCH_PRIVILEGE }, + { "NT_STATUS_PRIVILEGE_NOT_HELD", NT_STATUS_PRIVILEGE_NOT_HELD }, + { "NT_STATUS_INVALID_ACCOUNT_NAME", NT_STATUS_INVALID_ACCOUNT_NAME }, + { "NT_STATUS_USER_EXISTS", NT_STATUS_USER_EXISTS }, + { "NT_STATUS_NO_SUCH_USER", NT_STATUS_NO_SUCH_USER }, + { "NT_STATUS_GROUP_EXISTS", NT_STATUS_GROUP_EXISTS }, + { "NT_STATUS_NO_SUCH_GROUP", NT_STATUS_NO_SUCH_GROUP }, + { "NT_STATUS_MEMBER_IN_GROUP", NT_STATUS_MEMBER_IN_GROUP }, + { "NT_STATUS_MEMBER_NOT_IN_GROUP", NT_STATUS_MEMBER_NOT_IN_GROUP }, + { "NT_STATUS_LAST_ADMIN", NT_STATUS_LAST_ADMIN }, + { "NT_STATUS_WRONG_PASSWORD", NT_STATUS_WRONG_PASSWORD }, + { "NT_STATUS_ILL_FORMED_PASSWORD", NT_STATUS_ILL_FORMED_PASSWORD }, + { "NT_STATUS_PASSWORD_RESTRICTION", NT_STATUS_PASSWORD_RESTRICTION }, + { "NT_STATUS_LOGON_FAILURE", NT_STATUS_LOGON_FAILURE }, + { "NT_STATUS_ACCOUNT_RESTRICTION", NT_STATUS_ACCOUNT_RESTRICTION }, + { "NT_STATUS_INVALID_LOGON_HOURS", NT_STATUS_INVALID_LOGON_HOURS }, + { "NT_STATUS_INVALID_WORKSTATION", NT_STATUS_INVALID_WORKSTATION }, + { "NT_STATUS_PASSWORD_EXPIRED", NT_STATUS_PASSWORD_EXPIRED }, + { "NT_STATUS_ACCOUNT_DISABLED", NT_STATUS_ACCOUNT_DISABLED }, + { "NT_STATUS_NONE_MAPPED", NT_STATUS_NONE_MAPPED }, + { "NT_STATUS_TOO_MANY_LUIDS_REQUESTED", NT_STATUS_TOO_MANY_LUIDS_REQUESTED }, + { "NT_STATUS_LUIDS_EXHAUSTED", NT_STATUS_LUIDS_EXHAUSTED }, + { "NT_STATUS_INVALID_SUB_AUTHORITY", NT_STATUS_INVALID_SUB_AUTHORITY }, + { "NT_STATUS_INVALID_ACL", NT_STATUS_INVALID_ACL }, + { "NT_STATUS_INVALID_SID", NT_STATUS_INVALID_SID }, + { "NT_STATUS_INVALID_SECURITY_DESCR", NT_STATUS_INVALID_SECURITY_DESCR }, + { "NT_STATUS_PROCEDURE_NOT_FOUND", NT_STATUS_PROCEDURE_NOT_FOUND }, + { "NT_STATUS_INVALID_IMAGE_FORMAT", NT_STATUS_INVALID_IMAGE_FORMAT }, + { "NT_STATUS_NO_TOKEN", NT_STATUS_NO_TOKEN }, + { "NT_STATUS_BAD_INHERITANCE_ACL", NT_STATUS_BAD_INHERITANCE_ACL }, + { "NT_STATUS_RANGE_NOT_LOCKED", NT_STATUS_RANGE_NOT_LOCKED }, + { "NT_STATUS_DISK_FULL", NT_STATUS_DISK_FULL }, + { "NT_STATUS_SERVER_DISABLED", NT_STATUS_SERVER_DISABLED }, + { "NT_STATUS_SERVER_NOT_DISABLED", NT_STATUS_SERVER_NOT_DISABLED }, + { "NT_STATUS_TOO_MANY_GUIDS_REQUESTED", NT_STATUS_TOO_MANY_GUIDS_REQUESTED }, + { "NT_STATUS_GUIDS_EXHAUSTED", NT_STATUS_GUIDS_EXHAUSTED }, + { "NT_STATUS_INVALID_ID_AUTHORITY", NT_STATUS_INVALID_ID_AUTHORITY }, + { "NT_STATUS_AGENTS_EXHAUSTED", NT_STATUS_AGENTS_EXHAUSTED }, + { "NT_STATUS_INVALID_VOLUME_LABEL", NT_STATUS_INVALID_VOLUME_LABEL }, + { "NT_STATUS_SECTION_NOT_EXTENDED", NT_STATUS_SECTION_NOT_EXTENDED }, + { "NT_STATUS_NOT_MAPPED_DATA", NT_STATUS_NOT_MAPPED_DATA }, + { "NT_STATUS_RESOURCE_DATA_NOT_FOUND", NT_STATUS_RESOURCE_DATA_NOT_FOUND }, + { "NT_STATUS_RESOURCE_TYPE_NOT_FOUND", NT_STATUS_RESOURCE_TYPE_NOT_FOUND }, + { "NT_STATUS_RESOURCE_NAME_NOT_FOUND", NT_STATUS_RESOURCE_NAME_NOT_FOUND }, + { "NT_STATUS_ARRAY_BOUNDS_EXCEEDED", NT_STATUS_ARRAY_BOUNDS_EXCEEDED }, + { "NT_STATUS_FLOAT_DENORMAL_OPERAND", NT_STATUS_FLOAT_DENORMAL_OPERAND }, + { "NT_STATUS_FLOAT_DIVIDE_BY_ZERO", NT_STATUS_FLOAT_DIVIDE_BY_ZERO }, + { "NT_STATUS_FLOAT_INEXACT_RESULT", NT_STATUS_FLOAT_INEXACT_RESULT }, + { "NT_STATUS_FLOAT_INVALID_OPERATION", NT_STATUS_FLOAT_INVALID_OPERATION }, + { "NT_STATUS_FLOAT_OVERFLOW", NT_STATUS_FLOAT_OVERFLOW }, + { "NT_STATUS_FLOAT_STACK_CHECK", NT_STATUS_FLOAT_STACK_CHECK }, + { "NT_STATUS_FLOAT_UNDERFLOW", NT_STATUS_FLOAT_UNDERFLOW }, + { "NT_STATUS_INTEGER_DIVIDE_BY_ZERO", NT_STATUS_INTEGER_DIVIDE_BY_ZERO }, + { "NT_STATUS_INTEGER_OVERFLOW", NT_STATUS_INTEGER_OVERFLOW }, + { "NT_STATUS_PRIVILEGED_INSTRUCTION", NT_STATUS_PRIVILEGED_INSTRUCTION }, + { "NT_STATUS_TOO_MANY_PAGING_FILES", NT_STATUS_TOO_MANY_PAGING_FILES }, + { "NT_STATUS_FILE_INVALID", NT_STATUS_FILE_INVALID }, + { "NT_STATUS_ALLOTTED_SPACE_EXCEEDED", NT_STATUS_ALLOTTED_SPACE_EXCEEDED }, + { "NT_STATUS_INSUFFICIENT_RESOURCES", NT_STATUS_INSUFFICIENT_RESOURCES }, + { "NT_STATUS_DFS_EXIT_PATH_FOUND", NT_STATUS_DFS_EXIT_PATH_FOUND }, + { "NT_STATUS_DEVICE_DATA_ERROR", NT_STATUS_DEVICE_DATA_ERROR }, + { "NT_STATUS_DEVICE_NOT_CONNECTED", NT_STATUS_DEVICE_NOT_CONNECTED }, + { "NT_STATUS_DEVICE_POWER_FAILURE", NT_STATUS_DEVICE_POWER_FAILURE }, + { "NT_STATUS_FREE_VM_NOT_AT_BASE", NT_STATUS_FREE_VM_NOT_AT_BASE }, + { "NT_STATUS_MEMORY_NOT_ALLOCATED", NT_STATUS_MEMORY_NOT_ALLOCATED }, + { "NT_STATUS_WORKING_SET_QUOTA", NT_STATUS_WORKING_SET_QUOTA }, + { "NT_STATUS_MEDIA_WRITE_PROTECTED", NT_STATUS_MEDIA_WRITE_PROTECTED }, + { "NT_STATUS_DEVICE_NOT_READY", NT_STATUS_DEVICE_NOT_READY }, + { "NT_STATUS_INVALID_GROUP_ATTRIBUTES", NT_STATUS_INVALID_GROUP_ATTRIBUTES }, + { "NT_STATUS_BAD_IMPERSONATION_LEVEL", NT_STATUS_BAD_IMPERSONATION_LEVEL }, + { "NT_STATUS_CANT_OPEN_ANONYMOUS", NT_STATUS_CANT_OPEN_ANONYMOUS }, + { "NT_STATUS_BAD_VALIDATION_CLASS", NT_STATUS_BAD_VALIDATION_CLASS }, + { "NT_STATUS_BAD_TOKEN_TYPE", NT_STATUS_BAD_TOKEN_TYPE }, + { "NT_STATUS_BAD_MASTER_BOOT_RECORD", NT_STATUS_BAD_MASTER_BOOT_RECORD }, + { "NT_STATUS_INSTRUCTION_MISALIGNMENT", NT_STATUS_INSTRUCTION_MISALIGNMENT }, + { "NT_STATUS_INSTANCE_NOT_AVAILABLE", NT_STATUS_INSTANCE_NOT_AVAILABLE }, + { "NT_STATUS_PIPE_NOT_AVAILABLE", NT_STATUS_PIPE_NOT_AVAILABLE }, + { "NT_STATUS_INVALID_PIPE_STATE", NT_STATUS_INVALID_PIPE_STATE }, + { "NT_STATUS_PIPE_BUSY", NT_STATUS_PIPE_BUSY }, + { "NT_STATUS_ILLEGAL_FUNCTION", NT_STATUS_ILLEGAL_FUNCTION }, + { "NT_STATUS_PIPE_DISCONNECTED", NT_STATUS_PIPE_DISCONNECTED }, + { "NT_STATUS_PIPE_CLOSING", NT_STATUS_PIPE_CLOSING }, + { "NT_STATUS_PIPE_CONNECTED", NT_STATUS_PIPE_CONNECTED }, + { "NT_STATUS_PIPE_LISTENING", NT_STATUS_PIPE_LISTENING }, + { "NT_STATUS_INVALID_READ_MODE", NT_STATUS_INVALID_READ_MODE }, + { "NT_STATUS_IO_TIMEOUT", NT_STATUS_IO_TIMEOUT }, + { "NT_STATUS_FILE_FORCED_CLOSED", NT_STATUS_FILE_FORCED_CLOSED }, + { "NT_STATUS_PROFILING_NOT_STARTED", NT_STATUS_PROFILING_NOT_STARTED }, + { "NT_STATUS_PROFILING_NOT_STOPPED", NT_STATUS_PROFILING_NOT_STOPPED }, + { "NT_STATUS_COULD_NOT_INTERPRET", NT_STATUS_COULD_NOT_INTERPRET }, + { "NT_STATUS_FILE_IS_A_DIRECTORY", NT_STATUS_FILE_IS_A_DIRECTORY }, + { "NT_STATUS_NOT_SUPPORTED", NT_STATUS_NOT_SUPPORTED }, + { "NT_STATUS_REMOTE_NOT_LISTENING", NT_STATUS_REMOTE_NOT_LISTENING }, + { "NT_STATUS_DUPLICATE_NAME", NT_STATUS_DUPLICATE_NAME }, + { "NT_STATUS_BAD_NETWORK_PATH", NT_STATUS_BAD_NETWORK_PATH }, + { "NT_STATUS_NETWORK_BUSY", NT_STATUS_NETWORK_BUSY }, + { "NT_STATUS_DEVICE_DOES_NOT_EXIST", NT_STATUS_DEVICE_DOES_NOT_EXIST }, + { "NT_STATUS_TOO_MANY_COMMANDS", NT_STATUS_TOO_MANY_COMMANDS }, + { "NT_STATUS_ADAPTER_HARDWARE_ERROR", NT_STATUS_ADAPTER_HARDWARE_ERROR }, + { "NT_STATUS_INVALID_NETWORK_RESPONSE", NT_STATUS_INVALID_NETWORK_RESPONSE }, + { "NT_STATUS_UNEXPECTED_NETWORK_ERROR", NT_STATUS_UNEXPECTED_NETWORK_ERROR }, + { "NT_STATUS_BAD_REMOTE_ADAPTER", NT_STATUS_BAD_REMOTE_ADAPTER }, + { "NT_STATUS_PRINT_QUEUE_FULL", NT_STATUS_PRINT_QUEUE_FULL }, + { "NT_STATUS_NO_SPOOL_SPACE", NT_STATUS_NO_SPOOL_SPACE }, + { "NT_STATUS_PRINT_CANCELLED", NT_STATUS_PRINT_CANCELLED }, + { "NT_STATUS_NETWORK_NAME_DELETED", NT_STATUS_NETWORK_NAME_DELETED }, + { "NT_STATUS_NETWORK_ACCESS_DENIED", NT_STATUS_NETWORK_ACCESS_DENIED }, + { "NT_STATUS_BAD_DEVICE_TYPE", NT_STATUS_BAD_DEVICE_TYPE }, + { "NT_STATUS_BAD_NETWORK_NAME", NT_STATUS_BAD_NETWORK_NAME }, + { "NT_STATUS_TOO_MANY_NAMES", NT_STATUS_TOO_MANY_NAMES }, + { "NT_STATUS_TOO_MANY_SESSIONS", NT_STATUS_TOO_MANY_SESSIONS }, + { "NT_STATUS_SHARING_PAUSED", NT_STATUS_SHARING_PAUSED }, + { "NT_STATUS_REQUEST_NOT_ACCEPTED", NT_STATUS_REQUEST_NOT_ACCEPTED }, + { "NT_STATUS_REDIRECTOR_PAUSED", NT_STATUS_REDIRECTOR_PAUSED }, + { "NT_STATUS_NET_WRITE_FAULT", NT_STATUS_NET_WRITE_FAULT }, + { "NT_STATUS_PROFILING_AT_LIMIT", NT_STATUS_PROFILING_AT_LIMIT }, + { "NT_STATUS_NOT_SAME_DEVICE", NT_STATUS_NOT_SAME_DEVICE }, + { "NT_STATUS_FILE_RENAMED", NT_STATUS_FILE_RENAMED }, + { "NT_STATUS_VIRTUAL_CIRCUIT_CLOSED", NT_STATUS_VIRTUAL_CIRCUIT_CLOSED }, + { "NT_STATUS_NO_SECURITY_ON_OBJECT", NT_STATUS_NO_SECURITY_ON_OBJECT }, + { "NT_STATUS_CANT_WAIT", NT_STATUS_CANT_WAIT }, + { "NT_STATUS_PIPE_EMPTY", NT_STATUS_PIPE_EMPTY }, + { "NT_STATUS_CANT_ACCESS_DOMAIN_INFO", NT_STATUS_CANT_ACCESS_DOMAIN_INFO }, + { "NT_STATUS_CANT_TERMINATE_SELF", NT_STATUS_CANT_TERMINATE_SELF }, + { "NT_STATUS_INVALID_SERVER_STATE", NT_STATUS_INVALID_SERVER_STATE }, + { "NT_STATUS_INVALID_DOMAIN_STATE", NT_STATUS_INVALID_DOMAIN_STATE }, + { "NT_STATUS_INVALID_DOMAIN_ROLE", NT_STATUS_INVALID_DOMAIN_ROLE }, + { "NT_STATUS_NO_SUCH_DOMAIN", NT_STATUS_NO_SUCH_DOMAIN }, + { "NT_STATUS_DOMAIN_EXISTS", NT_STATUS_DOMAIN_EXISTS }, + { "NT_STATUS_DOMAIN_LIMIT_EXCEEDED", NT_STATUS_DOMAIN_LIMIT_EXCEEDED }, + { "NT_STATUS_OPLOCK_NOT_GRANTED", NT_STATUS_OPLOCK_NOT_GRANTED }, + { "NT_STATUS_INVALID_OPLOCK_PROTOCOL", NT_STATUS_INVALID_OPLOCK_PROTOCOL }, + { "NT_STATUS_INTERNAL_DB_CORRUPTION", NT_STATUS_INTERNAL_DB_CORRUPTION }, + { "NT_STATUS_INTERNAL_ERROR", NT_STATUS_INTERNAL_ERROR }, + { "NT_STATUS_GENERIC_NOT_MAPPED", NT_STATUS_GENERIC_NOT_MAPPED }, + { "NT_STATUS_BAD_DESCRIPTOR_FORMAT", NT_STATUS_BAD_DESCRIPTOR_FORMAT }, + { "NT_STATUS_INVALID_USER_BUFFER", NT_STATUS_INVALID_USER_BUFFER }, + { "NT_STATUS_UNEXPECTED_IO_ERROR", NT_STATUS_UNEXPECTED_IO_ERROR }, + { "NT_STATUS_UNEXPECTED_MM_CREATE_ERR", NT_STATUS_UNEXPECTED_MM_CREATE_ERR }, + { "NT_STATUS_UNEXPECTED_MM_MAP_ERROR", NT_STATUS_UNEXPECTED_MM_MAP_ERROR }, + { "NT_STATUS_UNEXPECTED_MM_EXTEND_ERR", NT_STATUS_UNEXPECTED_MM_EXTEND_ERR }, + { "NT_STATUS_NOT_LOGON_PROCESS", NT_STATUS_NOT_LOGON_PROCESS }, + { "NT_STATUS_LOGON_SESSION_EXISTS", NT_STATUS_LOGON_SESSION_EXISTS }, + { "NT_STATUS_INVALID_PARAMETER_1", NT_STATUS_INVALID_PARAMETER_1 }, + { "NT_STATUS_INVALID_PARAMETER_2", NT_STATUS_INVALID_PARAMETER_2 }, + { "NT_STATUS_INVALID_PARAMETER_3", NT_STATUS_INVALID_PARAMETER_3 }, + { "NT_STATUS_INVALID_PARAMETER_4", NT_STATUS_INVALID_PARAMETER_4 }, + { "NT_STATUS_INVALID_PARAMETER_5", NT_STATUS_INVALID_PARAMETER_5 }, + { "NT_STATUS_INVALID_PARAMETER_6", NT_STATUS_INVALID_PARAMETER_6 }, + { "NT_STATUS_INVALID_PARAMETER_7", NT_STATUS_INVALID_PARAMETER_7 }, + { "NT_STATUS_INVALID_PARAMETER_8", NT_STATUS_INVALID_PARAMETER_8 }, + { "NT_STATUS_INVALID_PARAMETER_9", NT_STATUS_INVALID_PARAMETER_9 }, + { "NT_STATUS_INVALID_PARAMETER_10", NT_STATUS_INVALID_PARAMETER_10 }, + { "NT_STATUS_INVALID_PARAMETER_11", NT_STATUS_INVALID_PARAMETER_11 }, + { "NT_STATUS_INVALID_PARAMETER_12", NT_STATUS_INVALID_PARAMETER_12 }, + { "NT_STATUS_REDIRECTOR_NOT_STARTED", NT_STATUS_REDIRECTOR_NOT_STARTED }, + { "NT_STATUS_REDIRECTOR_STARTED", NT_STATUS_REDIRECTOR_STARTED }, + { "NT_STATUS_STACK_OVERFLOW", NT_STATUS_STACK_OVERFLOW }, + { "NT_STATUS_NO_SUCH_PACKAGE", NT_STATUS_NO_SUCH_PACKAGE }, + { "NT_STATUS_BAD_FUNCTION_TABLE", NT_STATUS_BAD_FUNCTION_TABLE }, + { "NT_STATUS_DIRECTORY_NOT_EMPTY", NT_STATUS_DIRECTORY_NOT_EMPTY }, + { "NT_STATUS_FILE_CORRUPT_ERROR", NT_STATUS_FILE_CORRUPT_ERROR }, + { "NT_STATUS_NOT_A_DIRECTORY", NT_STATUS_NOT_A_DIRECTORY }, + { "NT_STATUS_BAD_LOGON_SESSION_STATE", NT_STATUS_BAD_LOGON_SESSION_STATE }, + { "NT_STATUS_LOGON_SESSION_COLLISION", NT_STATUS_LOGON_SESSION_COLLISION }, + { "NT_STATUS_NAME_TOO_LONG", NT_STATUS_NAME_TOO_LONG }, + { "NT_STATUS_FILES_OPEN", NT_STATUS_FILES_OPEN }, + { "NT_STATUS_CONNECTION_IN_USE", NT_STATUS_CONNECTION_IN_USE }, + { "NT_STATUS_MESSAGE_NOT_FOUND", NT_STATUS_MESSAGE_NOT_FOUND }, + { "NT_STATUS_PROCESS_IS_TERMINATING", NT_STATUS_PROCESS_IS_TERMINATING }, + { "NT_STATUS_INVALID_LOGON_TYPE", NT_STATUS_INVALID_LOGON_TYPE }, + { "NT_STATUS_NO_GUID_TRANSLATION", NT_STATUS_NO_GUID_TRANSLATION }, + { "NT_STATUS_CANNOT_IMPERSONATE", NT_STATUS_CANNOT_IMPERSONATE }, + { "NT_STATUS_IMAGE_ALREADY_LOADED", NT_STATUS_IMAGE_ALREADY_LOADED }, + { "NT_STATUS_ABIOS_NOT_PRESENT", NT_STATUS_ABIOS_NOT_PRESENT }, + { "NT_STATUS_ABIOS_LID_NOT_EXIST", NT_STATUS_ABIOS_LID_NOT_EXIST }, + { "NT_STATUS_ABIOS_LID_ALREADY_OWNED", NT_STATUS_ABIOS_LID_ALREADY_OWNED }, + { "NT_STATUS_ABIOS_NOT_LID_OWNER", NT_STATUS_ABIOS_NOT_LID_OWNER }, + { "NT_STATUS_ABIOS_INVALID_COMMAND", NT_STATUS_ABIOS_INVALID_COMMAND }, + { "NT_STATUS_ABIOS_INVALID_LID", NT_STATUS_ABIOS_INVALID_LID }, + { "NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE", NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE }, + { "NT_STATUS_ABIOS_INVALID_SELECTOR", NT_STATUS_ABIOS_INVALID_SELECTOR }, + { "NT_STATUS_NO_LDT", NT_STATUS_NO_LDT }, + { "NT_STATUS_INVALID_LDT_SIZE", NT_STATUS_INVALID_LDT_SIZE }, + { "NT_STATUS_INVALID_LDT_OFFSET", NT_STATUS_INVALID_LDT_OFFSET }, + { "NT_STATUS_INVALID_LDT_DESCRIPTOR", NT_STATUS_INVALID_LDT_DESCRIPTOR }, + { "NT_STATUS_INVALID_IMAGE_NE_FORMAT", NT_STATUS_INVALID_IMAGE_NE_FORMAT }, + { "NT_STATUS_RXACT_INVALID_STATE", NT_STATUS_RXACT_INVALID_STATE }, + { "NT_STATUS_RXACT_COMMIT_FAILURE", NT_STATUS_RXACT_COMMIT_FAILURE }, + { "NT_STATUS_MAPPED_FILE_SIZE_ZERO", NT_STATUS_MAPPED_FILE_SIZE_ZERO }, + { "NT_STATUS_TOO_MANY_OPENED_FILES", NT_STATUS_TOO_MANY_OPENED_FILES }, + { "NT_STATUS_CANCELLED", NT_STATUS_CANCELLED }, + { "NT_STATUS_CANNOT_DELETE", NT_STATUS_CANNOT_DELETE }, + { "NT_STATUS_INVALID_COMPUTER_NAME", NT_STATUS_INVALID_COMPUTER_NAME }, + { "NT_STATUS_FILE_DELETED", NT_STATUS_FILE_DELETED }, + { "NT_STATUS_SPECIAL_ACCOUNT", NT_STATUS_SPECIAL_ACCOUNT }, + { "NT_STATUS_SPECIAL_GROUP", NT_STATUS_SPECIAL_GROUP }, + { "NT_STATUS_SPECIAL_USER", NT_STATUS_SPECIAL_USER }, + { "NT_STATUS_MEMBERS_PRIMARY_GROUP", NT_STATUS_MEMBERS_PRIMARY_GROUP }, + { "NT_STATUS_FILE_CLOSED", NT_STATUS_FILE_CLOSED }, + { "NT_STATUS_TOO_MANY_THREADS", NT_STATUS_TOO_MANY_THREADS }, + { "NT_STATUS_THREAD_NOT_IN_PROCESS", NT_STATUS_THREAD_NOT_IN_PROCESS }, + { "NT_STATUS_TOKEN_ALREADY_IN_USE", NT_STATUS_TOKEN_ALREADY_IN_USE }, + { "NT_STATUS_PAGEFILE_QUOTA_EXCEEDED", NT_STATUS_PAGEFILE_QUOTA_EXCEEDED }, + { "NT_STATUS_COMMITMENT_LIMIT", NT_STATUS_COMMITMENT_LIMIT }, + { "NT_STATUS_INVALID_IMAGE_LE_FORMAT", NT_STATUS_INVALID_IMAGE_LE_FORMAT }, + { "NT_STATUS_INVALID_IMAGE_NOT_MZ", NT_STATUS_INVALID_IMAGE_NOT_MZ }, + { "NT_STATUS_INVALID_IMAGE_PROTECT", NT_STATUS_INVALID_IMAGE_PROTECT }, + { "NT_STATUS_INVALID_IMAGE_WIN_16", NT_STATUS_INVALID_IMAGE_WIN_16 }, + { "NT_STATUS_LOGON_SERVER_CONFLICT", NT_STATUS_LOGON_SERVER_CONFLICT }, + { "NT_STATUS_TIME_DIFFERENCE_AT_DC", NT_STATUS_TIME_DIFFERENCE_AT_DC }, + { "NT_STATUS_SYNCHRONIZATION_REQUIRED", NT_STATUS_SYNCHRONIZATION_REQUIRED }, + { "NT_STATUS_DLL_NOT_FOUND", NT_STATUS_DLL_NOT_FOUND }, + { "NT_STATUS_OPEN_FAILED", NT_STATUS_OPEN_FAILED }, + { "NT_STATUS_IO_PRIVILEGE_FAILED", NT_STATUS_IO_PRIVILEGE_FAILED }, + { "NT_STATUS_ORDINAL_NOT_FOUND", NT_STATUS_ORDINAL_NOT_FOUND }, + { "NT_STATUS_ENTRYPOINT_NOT_FOUND", NT_STATUS_ENTRYPOINT_NOT_FOUND }, + { "NT_STATUS_CONTROL_C_EXIT", NT_STATUS_CONTROL_C_EXIT }, + { "NT_STATUS_LOCAL_DISCONNECT", NT_STATUS_LOCAL_DISCONNECT }, + { "NT_STATUS_REMOTE_DISCONNECT", NT_STATUS_REMOTE_DISCONNECT }, + { "NT_STATUS_REMOTE_RESOURCES", NT_STATUS_REMOTE_RESOURCES }, + { "NT_STATUS_LINK_FAILED", NT_STATUS_LINK_FAILED }, + { "NT_STATUS_LINK_TIMEOUT", NT_STATUS_LINK_TIMEOUT }, + { "NT_STATUS_INVALID_CONNECTION", NT_STATUS_INVALID_CONNECTION }, + { "NT_STATUS_INVALID_ADDRESS", NT_STATUS_INVALID_ADDRESS }, + { "NT_STATUS_DLL_INIT_FAILED", NT_STATUS_DLL_INIT_FAILED }, + { "NT_STATUS_MISSING_SYSTEMFILE", NT_STATUS_MISSING_SYSTEMFILE }, + { "NT_STATUS_UNHANDLED_EXCEPTION", NT_STATUS_UNHANDLED_EXCEPTION }, + { "NT_STATUS_APP_INIT_FAILURE", NT_STATUS_APP_INIT_FAILURE }, + { "NT_STATUS_PAGEFILE_CREATE_FAILED", NT_STATUS_PAGEFILE_CREATE_FAILED }, + { "NT_STATUS_NO_PAGEFILE", NT_STATUS_NO_PAGEFILE }, + { "NT_STATUS_INVALID_LEVEL", NT_STATUS_INVALID_LEVEL }, + { "NT_STATUS_WRONG_PASSWORD_CORE", NT_STATUS_WRONG_PASSWORD_CORE }, + { "NT_STATUS_ILLEGAL_FLOAT_CONTEXT", NT_STATUS_ILLEGAL_FLOAT_CONTEXT }, + { "NT_STATUS_PIPE_BROKEN", NT_STATUS_PIPE_BROKEN }, + { "NT_STATUS_REGISTRY_CORRUPT", NT_STATUS_REGISTRY_CORRUPT }, + { "NT_STATUS_REGISTRY_IO_FAILED", NT_STATUS_REGISTRY_IO_FAILED }, + { "NT_STATUS_NO_EVENT_PAIR", NT_STATUS_NO_EVENT_PAIR }, + { "NT_STATUS_UNRECOGNIZED_VOLUME", NT_STATUS_UNRECOGNIZED_VOLUME }, + { "NT_STATUS_SERIAL_NO_DEVICE_INITED", NT_STATUS_SERIAL_NO_DEVICE_INITED }, + { "NT_STATUS_NO_SUCH_ALIAS", NT_STATUS_NO_SUCH_ALIAS }, + { "NT_STATUS_MEMBER_NOT_IN_ALIAS", NT_STATUS_MEMBER_NOT_IN_ALIAS }, + { "NT_STATUS_MEMBER_IN_ALIAS", NT_STATUS_MEMBER_IN_ALIAS }, + { "NT_STATUS_ALIAS_EXISTS", NT_STATUS_ALIAS_EXISTS }, + { "NT_STATUS_LOGON_NOT_GRANTED", NT_STATUS_LOGON_NOT_GRANTED }, + { "NT_STATUS_TOO_MANY_SECRETS", NT_STATUS_TOO_MANY_SECRETS }, + { "NT_STATUS_SECRET_TOO_LONG", NT_STATUS_SECRET_TOO_LONG }, + { "NT_STATUS_INTERNAL_DB_ERROR", NT_STATUS_INTERNAL_DB_ERROR }, + { "NT_STATUS_FULLSCREEN_MODE", NT_STATUS_FULLSCREEN_MODE }, + { "NT_STATUS_TOO_MANY_CONTEXT_IDS", NT_STATUS_TOO_MANY_CONTEXT_IDS }, + { "NT_STATUS_LOGON_TYPE_NOT_GRANTED", NT_STATUS_LOGON_TYPE_NOT_GRANTED }, + { "NT_STATUS_NOT_REGISTRY_FILE", NT_STATUS_NOT_REGISTRY_FILE }, + { "NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED", NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED }, + { "NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR", NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR }, + { "NT_STATUS_FT_MISSING_MEMBER", NT_STATUS_FT_MISSING_MEMBER }, + { "NT_STATUS_ILL_FORMED_SERVICE_ENTRY", NT_STATUS_ILL_FORMED_SERVICE_ENTRY }, + { "NT_STATUS_ILLEGAL_CHARACTER", NT_STATUS_ILLEGAL_CHARACTER }, + { "NT_STATUS_UNMAPPABLE_CHARACTER", NT_STATUS_UNMAPPABLE_CHARACTER }, + { "NT_STATUS_UNDEFINED_CHARACTER", NT_STATUS_UNDEFINED_CHARACTER }, + { "NT_STATUS_FLOPPY_VOLUME", NT_STATUS_FLOPPY_VOLUME }, + { "NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND", NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND }, + { "NT_STATUS_FLOPPY_WRONG_CYLINDER", NT_STATUS_FLOPPY_WRONG_CYLINDER }, + { "NT_STATUS_FLOPPY_UNKNOWN_ERROR", NT_STATUS_FLOPPY_UNKNOWN_ERROR }, + { "NT_STATUS_FLOPPY_BAD_REGISTERS", NT_STATUS_FLOPPY_BAD_REGISTERS }, + { "NT_STATUS_DISK_RECALIBRATE_FAILED", NT_STATUS_DISK_RECALIBRATE_FAILED }, + { "NT_STATUS_DISK_OPERATION_FAILED", NT_STATUS_DISK_OPERATION_FAILED }, + { "NT_STATUS_DISK_RESET_FAILED", NT_STATUS_DISK_RESET_FAILED }, + { "NT_STATUS_SHARED_IRQ_BUSY", NT_STATUS_SHARED_IRQ_BUSY }, + { "NT_STATUS_FT_ORPHANING", NT_STATUS_FT_ORPHANING }, + { "NT_STATUS_PARTITION_FAILURE", NT_STATUS_PARTITION_FAILURE }, + { "NT_STATUS_INVALID_BLOCK_LENGTH", NT_STATUS_INVALID_BLOCK_LENGTH }, + { "NT_STATUS_DEVICE_NOT_PARTITIONED", NT_STATUS_DEVICE_NOT_PARTITIONED }, + { "NT_STATUS_UNABLE_TO_LOCK_MEDIA", NT_STATUS_UNABLE_TO_LOCK_MEDIA }, + { "NT_STATUS_UNABLE_TO_UNLOAD_MEDIA", NT_STATUS_UNABLE_TO_UNLOAD_MEDIA }, + { "NT_STATUS_EOM_OVERFLOW", NT_STATUS_EOM_OVERFLOW }, + { "NT_STATUS_NO_MEDIA", NT_STATUS_NO_MEDIA }, + { "NT_STATUS_NO_SUCH_MEMBER", NT_STATUS_NO_SUCH_MEMBER }, + { "NT_STATUS_INVALID_MEMBER", NT_STATUS_INVALID_MEMBER }, + { "NT_STATUS_KEY_DELETED", NT_STATUS_KEY_DELETED }, + { "NT_STATUS_NO_LOG_SPACE", NT_STATUS_NO_LOG_SPACE }, + { "NT_STATUS_TOO_MANY_SIDS", NT_STATUS_TOO_MANY_SIDS }, + { "NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED", NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED }, + { "NT_STATUS_KEY_HAS_CHILDREN", NT_STATUS_KEY_HAS_CHILDREN }, + { "NT_STATUS_CHILD_MUST_BE_VOLATILE", NT_STATUS_CHILD_MUST_BE_VOLATILE }, + { "NT_STATUS_DEVICE_CONFIGURATION_ERROR", NT_STATUS_DEVICE_CONFIGURATION_ERROR }, + { "NT_STATUS_DRIVER_INTERNAL_ERROR", NT_STATUS_DRIVER_INTERNAL_ERROR }, + { "NT_STATUS_INVALID_DEVICE_STATE", NT_STATUS_INVALID_DEVICE_STATE }, + { "NT_STATUS_IO_DEVICE_ERROR", NT_STATUS_IO_DEVICE_ERROR }, + { "NT_STATUS_DEVICE_PROTOCOL_ERROR", NT_STATUS_DEVICE_PROTOCOL_ERROR }, + { "NT_STATUS_BACKUP_CONTROLLER", NT_STATUS_BACKUP_CONTROLLER }, + { "NT_STATUS_LOG_FILE_FULL", NT_STATUS_LOG_FILE_FULL }, + { "NT_STATUS_TOO_LATE", NT_STATUS_TOO_LATE }, + { "NT_STATUS_NO_TRUST_LSA_SECRET", NT_STATUS_NO_TRUST_LSA_SECRET }, + { "NT_STATUS_NO_TRUST_SAM_ACCOUNT", NT_STATUS_NO_TRUST_SAM_ACCOUNT }, + { "NT_STATUS_TRUSTED_DOMAIN_FAILURE", NT_STATUS_TRUSTED_DOMAIN_FAILURE }, + { "NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE", NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE }, + { "NT_STATUS_EVENTLOG_FILE_CORRUPT", NT_STATUS_EVENTLOG_FILE_CORRUPT }, + { "NT_STATUS_EVENTLOG_CANT_START", NT_STATUS_EVENTLOG_CANT_START }, + { "NT_STATUS_TRUST_FAILURE", NT_STATUS_TRUST_FAILURE }, + { "NT_STATUS_MUTANT_LIMIT_EXCEEDED", NT_STATUS_MUTANT_LIMIT_EXCEEDED }, + { "NT_STATUS_NETLOGON_NOT_STARTED", NT_STATUS_NETLOGON_NOT_STARTED }, + { "NT_STATUS_ACCOUNT_EXPIRED", NT_STATUS_ACCOUNT_EXPIRED }, + { "NT_STATUS_POSSIBLE_DEADLOCK", NT_STATUS_POSSIBLE_DEADLOCK }, + { "NT_STATUS_NETWORK_CREDENTIAL_CONFLICT", NT_STATUS_NETWORK_CREDENTIAL_CONFLICT }, + { "NT_STATUS_REMOTE_SESSION_LIMIT", NT_STATUS_REMOTE_SESSION_LIMIT }, + { "NT_STATUS_EVENTLOG_FILE_CHANGED", NT_STATUS_EVENTLOG_FILE_CHANGED }, + { "NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT", NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT }, + { "NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT", NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT }, + { "NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT", NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT }, + { "NT_STATUS_DOMAIN_TRUST_INCONSISTENT", NT_STATUS_DOMAIN_TRUST_INCONSISTENT }, + { "NT_STATUS_FS_DRIVER_REQUIRED", NT_STATUS_FS_DRIVER_REQUIRED }, + { "NT_STATUS_NO_USER_SESSION_KEY", NT_STATUS_NO_USER_SESSION_KEY }, + { "NT_STATUS_USER_SESSION_DELETED", NT_STATUS_USER_SESSION_DELETED }, + { "NT_STATUS_RESOURCE_LANG_NOT_FOUND", NT_STATUS_RESOURCE_LANG_NOT_FOUND }, + { "NT_STATUS_INSUFF_SERVER_RESOURCES", NT_STATUS_INSUFF_SERVER_RESOURCES }, + { "NT_STATUS_INVALID_BUFFER_SIZE", NT_STATUS_INVALID_BUFFER_SIZE }, + { "NT_STATUS_INVALID_ADDRESS_COMPONENT", NT_STATUS_INVALID_ADDRESS_COMPONENT }, + { "NT_STATUS_INVALID_ADDRESS_WILDCARD", NT_STATUS_INVALID_ADDRESS_WILDCARD }, + { "NT_STATUS_TOO_MANY_ADDRESSES", NT_STATUS_TOO_MANY_ADDRESSES }, + { "NT_STATUS_ADDRESS_ALREADY_EXISTS", NT_STATUS_ADDRESS_ALREADY_EXISTS }, + { "NT_STATUS_ADDRESS_CLOSED", NT_STATUS_ADDRESS_CLOSED }, + { "NT_STATUS_CONNECTION_DISCONNECTED", NT_STATUS_CONNECTION_DISCONNECTED }, + { "NT_STATUS_CONNECTION_RESET", NT_STATUS_CONNECTION_RESET }, + { "NT_STATUS_TOO_MANY_NODES", NT_STATUS_TOO_MANY_NODES }, + { "NT_STATUS_TRANSACTION_ABORTED", NT_STATUS_TRANSACTION_ABORTED }, + { "NT_STATUS_TRANSACTION_TIMED_OUT", NT_STATUS_TRANSACTION_TIMED_OUT }, + { "NT_STATUS_TRANSACTION_NO_RELEASE", NT_STATUS_TRANSACTION_NO_RELEASE }, + { "NT_STATUS_TRANSACTION_NO_MATCH", NT_STATUS_TRANSACTION_NO_MATCH }, + { "NT_STATUS_TRANSACTION_RESPONDED", NT_STATUS_TRANSACTION_RESPONDED }, + { "NT_STATUS_TRANSACTION_INVALID_ID", NT_STATUS_TRANSACTION_INVALID_ID }, + { "NT_STATUS_TRANSACTION_INVALID_TYPE", NT_STATUS_TRANSACTION_INVALID_TYPE }, + { "NT_STATUS_NOT_SERVER_SESSION", NT_STATUS_NOT_SERVER_SESSION }, + { "NT_STATUS_NOT_CLIENT_SESSION", NT_STATUS_NOT_CLIENT_SESSION }, + { "NT_STATUS_CANNOT_LOAD_REGISTRY_FILE", NT_STATUS_CANNOT_LOAD_REGISTRY_FILE }, + { "NT_STATUS_DEBUG_ATTACH_FAILED", NT_STATUS_DEBUG_ATTACH_FAILED }, + { "NT_STATUS_SYSTEM_PROCESS_TERMINATED", NT_STATUS_SYSTEM_PROCESS_TERMINATED }, + { "NT_STATUS_DATA_NOT_ACCEPTED", NT_STATUS_DATA_NOT_ACCEPTED }, + { "NT_STATUS_NO_BROWSER_SERVERS_FOUND", NT_STATUS_NO_BROWSER_SERVERS_FOUND }, + { "NT_STATUS_VDM_HARD_ERROR", NT_STATUS_VDM_HARD_ERROR }, + { "NT_STATUS_DRIVER_CANCEL_TIMEOUT", NT_STATUS_DRIVER_CANCEL_TIMEOUT }, + { "NT_STATUS_REPLY_MESSAGE_MISMATCH", NT_STATUS_REPLY_MESSAGE_MISMATCH }, + { "NT_STATUS_MAPPED_ALIGNMENT", NT_STATUS_MAPPED_ALIGNMENT }, + { "NT_STATUS_IMAGE_CHECKSUM_MISMATCH", NT_STATUS_IMAGE_CHECKSUM_MISMATCH }, + { "NT_STATUS_LOST_WRITEBEHIND_DATA", NT_STATUS_LOST_WRITEBEHIND_DATA }, + { "NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID", NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID }, + { "NT_STATUS_PASSWORD_MUST_CHANGE", NT_STATUS_PASSWORD_MUST_CHANGE }, + { "NT_STATUS_NOT_FOUND", NT_STATUS_NOT_FOUND }, + { "NT_STATUS_NOT_TINY_STREAM", NT_STATUS_NOT_TINY_STREAM }, + { "NT_STATUS_RECOVERY_FAILURE", NT_STATUS_RECOVERY_FAILURE }, + { "NT_STATUS_STACK_OVERFLOW_READ", NT_STATUS_STACK_OVERFLOW_READ }, + { "NT_STATUS_FAIL_CHECK", NT_STATUS_FAIL_CHECK }, + { "NT_STATUS_DUPLICATE_OBJECTID", NT_STATUS_DUPLICATE_OBJECTID }, + { "NT_STATUS_OBJECTID_EXISTS", NT_STATUS_OBJECTID_EXISTS }, + { "NT_STATUS_CONVERT_TO_LARGE", NT_STATUS_CONVERT_TO_LARGE }, + { "NT_STATUS_RETRY", NT_STATUS_RETRY }, + { "NT_STATUS_FOUND_OUT_OF_SCOPE", NT_STATUS_FOUND_OUT_OF_SCOPE }, + { "NT_STATUS_ALLOCATE_BUCKET", NT_STATUS_ALLOCATE_BUCKET }, + { "NT_STATUS_PROPSET_NOT_FOUND", NT_STATUS_PROPSET_NOT_FOUND }, + { "NT_STATUS_MARSHALL_OVERFLOW", NT_STATUS_MARSHALL_OVERFLOW }, + { "NT_STATUS_INVALID_VARIANT", NT_STATUS_INVALID_VARIANT }, + { "NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND", NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND }, + { "NT_STATUS_ACCOUNT_LOCKED_OUT", NT_STATUS_ACCOUNT_LOCKED_OUT }, + { "NT_STATUS_HANDLE_NOT_CLOSABLE", NT_STATUS_HANDLE_NOT_CLOSABLE }, + { "NT_STATUS_CONNECTION_REFUSED", NT_STATUS_CONNECTION_REFUSED }, + { "NT_STATUS_GRACEFUL_DISCONNECT", NT_STATUS_GRACEFUL_DISCONNECT }, + { "NT_STATUS_ADDRESS_ALREADY_ASSOCIATED", NT_STATUS_ADDRESS_ALREADY_ASSOCIATED }, + { "NT_STATUS_ADDRESS_NOT_ASSOCIATED", NT_STATUS_ADDRESS_NOT_ASSOCIATED }, + { "NT_STATUS_CONNECTION_INVALID", NT_STATUS_CONNECTION_INVALID }, + { "NT_STATUS_CONNECTION_ACTIVE", NT_STATUS_CONNECTION_ACTIVE }, + { "NT_STATUS_NETWORK_UNREACHABLE", NT_STATUS_NETWORK_UNREACHABLE }, + { "NT_STATUS_HOST_UNREACHABLE", NT_STATUS_HOST_UNREACHABLE }, + { "NT_STATUS_PROTOCOL_UNREACHABLE", NT_STATUS_PROTOCOL_UNREACHABLE }, + { "NT_STATUS_PORT_UNREACHABLE", NT_STATUS_PORT_UNREACHABLE }, + { "NT_STATUS_REQUEST_ABORTED", NT_STATUS_REQUEST_ABORTED }, + { "NT_STATUS_CONNECTION_ABORTED", NT_STATUS_CONNECTION_ABORTED }, + { "NT_STATUS_BAD_COMPRESSION_BUFFER", NT_STATUS_BAD_COMPRESSION_BUFFER }, + { "NT_STATUS_USER_MAPPED_FILE", NT_STATUS_USER_MAPPED_FILE }, + { "NT_STATUS_AUDIT_FAILED", NT_STATUS_AUDIT_FAILED }, + { "NT_STATUS_TIMER_RESOLUTION_NOT_SET", NT_STATUS_TIMER_RESOLUTION_NOT_SET }, + { "NT_STATUS_CONNECTION_COUNT_LIMIT", NT_STATUS_CONNECTION_COUNT_LIMIT }, + { "NT_STATUS_LOGIN_TIME_RESTRICTION", NT_STATUS_LOGIN_TIME_RESTRICTION }, + { "NT_STATUS_LOGIN_WKSTA_RESTRICTION", NT_STATUS_LOGIN_WKSTA_RESTRICTION }, + { "NT_STATUS_IMAGE_MP_UP_MISMATCH", NT_STATUS_IMAGE_MP_UP_MISMATCH }, + { "NT_STATUS_INSUFFICIENT_LOGON_INFO", NT_STATUS_INSUFFICIENT_LOGON_INFO }, + { "NT_STATUS_BAD_DLL_ENTRYPOINT", NT_STATUS_BAD_DLL_ENTRYPOINT }, + { "NT_STATUS_BAD_SERVICE_ENTRYPOINT", NT_STATUS_BAD_SERVICE_ENTRYPOINT }, + { "NT_STATUS_LPC_REPLY_LOST", NT_STATUS_LPC_REPLY_LOST }, + { "NT_STATUS_IP_ADDRESS_CONFLICT1", NT_STATUS_IP_ADDRESS_CONFLICT1 }, + { "NT_STATUS_IP_ADDRESS_CONFLICT2", NT_STATUS_IP_ADDRESS_CONFLICT2 }, + { "NT_STATUS_REGISTRY_QUOTA_LIMIT", NT_STATUS_REGISTRY_QUOTA_LIMIT }, + { "NT_STATUS_PATH_NOT_COVERED", NT_STATUS_PATH_NOT_COVERED }, + { "NT_STATUS_NO_CALLBACK_ACTIVE", NT_STATUS_NO_CALLBACK_ACTIVE }, + { "NT_STATUS_LICENSE_QUOTA_EXCEEDED", NT_STATUS_LICENSE_QUOTA_EXCEEDED }, + { "NT_STATUS_PWD_TOO_SHORT", NT_STATUS_PWD_TOO_SHORT }, + { "NT_STATUS_PWD_TOO_RECENT", NT_STATUS_PWD_TOO_RECENT }, + { "NT_STATUS_PWD_HISTORY_CONFLICT", NT_STATUS_PWD_HISTORY_CONFLICT }, + { "NT_STATUS_PLUGPLAY_NO_DEVICE", NT_STATUS_PLUGPLAY_NO_DEVICE }, + { "NT_STATUS_UNSUPPORTED_COMPRESSION", NT_STATUS_UNSUPPORTED_COMPRESSION }, + { "NT_STATUS_INVALID_HW_PROFILE", NT_STATUS_INVALID_HW_PROFILE }, + { "NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH", NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH }, + { "NT_STATUS_DRIVER_ORDINAL_NOT_FOUND", NT_STATUS_DRIVER_ORDINAL_NOT_FOUND }, + { "NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND", NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND }, + { "NT_STATUS_RESOURCE_NOT_OWNED", NT_STATUS_RESOURCE_NOT_OWNED }, + { "NT_STATUS_TOO_MANY_LINKS", NT_STATUS_TOO_MANY_LINKS }, + { "NT_STATUS_QUOTA_LIST_INCONSISTENT", NT_STATUS_QUOTA_LIST_INCONSISTENT }, + { "NT_STATUS_FILE_IS_OFFLINE", NT_STATUS_FILE_IS_OFFLINE }, + { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES }, + { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES }, + { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED }, + { NULL, NT_STATUS(0) } +}; + +static const nt_err_code_struct nt_err_desc[] = +{ + { "Success", NT_STATUS_OK }, + { "Undetermined error", NT_STATUS_UNSUCCESSFUL }, + { "Access denied", NT_STATUS_ACCESS_DENIED }, + { "Account locked out", NT_STATUS_ACCOUNT_LOCKED_OUT }, + { "Must change password", NT_STATUS_PASSWORD_MUST_CHANGE }, + { "Password is too short", NT_STATUS_PWD_TOO_SHORT }, + { "Password is too recent", NT_STATUS_PWD_TOO_RECENT }, + { "Password history conflict", NT_STATUS_PWD_HISTORY_CONFLICT }, + { "No logon servers", NT_STATUS_NO_LOGON_SERVERS }, + { "Improperly formed account name", NT_STATUS_INVALID_ACCOUNT_NAME }, + { "User exists", NT_STATUS_USER_EXISTS }, + { "No such user", NT_STATUS_NO_SUCH_USER }, + { "Group exists", NT_STATUS_GROUP_EXISTS }, + { "No such group", NT_STATUS_NO_SUCH_GROUP }, + { "Member not in group", NT_STATUS_MEMBER_NOT_IN_GROUP }, + { "Wrong Password", NT_STATUS_WRONG_PASSWORD }, + { "Ill formed password", NT_STATUS_ILL_FORMED_PASSWORD }, + { "Password restriction", NT_STATUS_PASSWORD_RESTRICTION }, + { "Logon failure", NT_STATUS_LOGON_FAILURE }, + { "Account restriction", NT_STATUS_ACCOUNT_RESTRICTION }, + { "Invalid logon hours", NT_STATUS_INVALID_LOGON_HOURS }, + { "Invalid workstation", NT_STATUS_INVALID_WORKSTATION }, + { "Password expired", NT_STATUS_PASSWORD_EXPIRED }, + { "Account disabled", NT_STATUS_ACCOUNT_DISABLED }, + { "Unexpected information received", NT_STATUS_INVALID_PARAMETER }, + { "Memory allocation error", NT_STATUS_NO_MEMORY }, + { "No domain controllers located", NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND }, + { "Account locked out", NT_STATUS_ACCOUNT_LOCKED_OUT }, + { "Named pipe not available", NT_STATUS_PIPE_NOT_AVAILABLE }, + { "Not implemented", NT_STATUS_NOT_IMPLEMENTED }, + { "Invalid information class", NT_STATUS_INVALID_INFO_CLASS }, + { "Information length mismatch", NT_STATUS_INFO_LENGTH_MISMATCH }, + { "Access violation", NT_STATUS_ACCESS_VIOLATION }, + { "Invalid handle", NT_STATUS_INVALID_HANDLE }, + { "Invalid parameter", NT_STATUS_INVALID_PARAMETER }, + { "No memory", NT_STATUS_NO_MEMORY }, + { "Buffer too small", NT_STATUS_BUFFER_TOO_SMALL }, + { "Revision mismatch", NT_STATUS_REVISION_MISMATCH }, + { "No logon servers", NT_STATUS_NO_LOGON_SERVERS }, + { "No such logon session", NT_STATUS_NO_SUCH_LOGON_SESSION }, + { "No such privilege", NT_STATUS_NO_SUCH_PRIVILEGE }, + { "Procedure not found", NT_STATUS_PROCEDURE_NOT_FOUND }, + { "Server disabled", NT_STATUS_SERVER_DISABLED }, + { "Invalid pipe state", NT_STATUS_INVALID_PIPE_STATE }, + { "Named pipe busy", NT_STATUS_PIPE_BUSY }, + { "Illegal function", NT_STATUS_ILLEGAL_FUNCTION }, + { "Named pipe dicconnected", NT_STATUS_PIPE_DISCONNECTED }, + { "Named pipe closing", NT_STATUS_PIPE_CLOSING }, + { "Remote host not listening", NT_STATUS_REMOTE_NOT_LISTENING }, + { "Duplicate name on network", NT_STATUS_DUPLICATE_NAME }, + { "Print queue is full", NT_STATUS_PRINT_QUEUE_FULL }, + { "No print spool space available", NT_STATUS_NO_SPOOL_SPACE }, + { "Too many names", NT_STATUS_TOO_MANY_NAMES }, + { "Too many sessions", NT_STATUS_TOO_MANY_SESSIONS }, + { "Invalid server state", NT_STATUS_INVALID_SERVER_STATE }, + { "Invalid domain state", NT_STATUS_INVALID_DOMAIN_STATE }, + { "Invalid domain role", NT_STATUS_INVALID_DOMAIN_ROLE }, + { "No such domain", NT_STATUS_NO_SUCH_DOMAIN }, + { "Domain exists", NT_STATUS_DOMAIN_EXISTS }, + { "Domain limit exceeded", NT_STATUS_DOMAIN_LIMIT_EXCEEDED }, + { "Bad logon session state", NT_STATUS_BAD_LOGON_SESSION_STATE }, + { "Logon session collision", NT_STATUS_LOGON_SESSION_COLLISION }, + { "Invalid logon type", NT_STATUS_INVALID_LOGON_TYPE }, + { "Cancelled", NT_STATUS_CANCELLED }, + { "Invalid computer name", NT_STATUS_INVALID_COMPUTER_NAME }, + { "Logon server conflict", NT_STATUS_LOGON_SERVER_CONFLICT }, + { "Time difference at domain controller", NT_STATUS_TIME_DIFFERENCE_AT_DC }, + { "Pipe broken", NT_STATUS_PIPE_BROKEN }, + { "Registry corrupt", NT_STATUS_REGISTRY_CORRUPT }, + { "Too many secrets", NT_STATUS_TOO_MANY_SECRETS }, + { "Too many SIDs", NT_STATUS_TOO_MANY_SIDS }, + { "Lanmanager cross encryption required", NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED }, + { "Log file full", NT_STATUS_LOG_FILE_FULL }, + { "No trusted LSA secret", NT_STATUS_NO_TRUST_LSA_SECRET }, + { "No trusted SAM account", NT_STATUS_NO_TRUST_SAM_ACCOUNT }, + { "Trusted domain failure", NT_STATUS_TRUSTED_DOMAIN_FAILURE }, + { "Trust relationship failure", NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE }, + { "Trust failure", NT_STATUS_TRUST_FAILURE }, + { "Netlogon service not started", NT_STATUS_NETLOGON_NOT_STARTED }, + { "Account expired", NT_STATUS_ACCOUNT_EXPIRED }, + { "Network credential conflict", NT_STATUS_NETWORK_CREDENTIAL_CONFLICT }, + { "Remote session limit", NT_STATUS_REMOTE_SESSION_LIMIT }, + { "No logon interdomain trust account", NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT }, + { "No logon workstation trust account", NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT }, + { "No logon server trust account", NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT }, + { "Domain trust inconsistent", NT_STATUS_DOMAIN_TRUST_INCONSISTENT }, + { "No user session key available", NT_STATUS_NO_USER_SESSION_KEY }, + { "User session deleted", NT_STATUS_USER_SESSION_DELETED }, + { "Insufficient server resources", NT_STATUS_INSUFF_SERVER_RESOURCES }, + { "Insufficient logon information", NT_STATUS_INSUFFICIENT_LOGON_INFO }, + + { "License quota exceeded", NT_STATUS_LICENSE_QUOTA_EXCEEDED }, + + { NULL, NT_STATUS(0) } +}; + + +/***************************************************************************** + returns an NT error message. not amazingly helpful, but better than a number. + *****************************************************************************/ +const char *nt_errstr(NTSTATUS nt_code) +{ + static pstring msg; + int idx = 0; + + slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code)); + + 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++; + } + + return msg; +} + +/************************************************************************ + Print friendler version fo NT error code + ***********************************************************************/ +const char *get_friendly_nt_error_msg(NTSTATUS nt_code) +{ + int idx = 0; + + while (nt_err_desc[idx].nt_errstr != NULL) { + if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) { + return nt_err_desc[idx].nt_errstr; + } + idx++; + } + + /* fall back to NT_STATUS_XXX string */ + return nt_errstr(nt_code); +} + +/***************************************************************************** + returns an NT_STATUS constant as a string for inclusion in autogen C code + *****************************************************************************/ +const 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; +} + +/***************************************************************************** + returns the NT_STATUS constant matching the string supplied (as an NTSTATUS) + *****************************************************************************/ +NTSTATUS nt_status_string_to_code(char *nt_status_str) +{ + int idx = 0; + + while (nt_errs[idx].nt_errstr != NULL) { + if (strcmp(nt_errs[idx].nt_errstr, nt_status_str) == 0) { + return nt_errs[idx].nt_errcode; + } + idx++; + } + return NT_STATUS_UNSUCCESSFUL; +} diff --git a/source4/libcli/util/ntlmssp_sign.c b/source4/libcli/util/ntlmssp_sign.c new file mode 100644 index 0000000000..bd6d64d842 --- /dev/null +++ b/source4/libcli/util/ntlmssp_sign.c @@ -0,0 +1,226 @@ +/* + * Unix SMB/CIFS implementation. + * Version 3.0 + * NTLMSSP Signing routines + * Copyright (C) Luke Kenneth Casson Leighton 1996-2001 + * Copyright (C) Andrew Bartlett 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 + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "includes.h" + +#define CLI_SIGN "session key to client-to-server signing key magic constant" +#define CLI_SEAL "session key to client-to-server sealing key magic constant" +#define SRV_SIGN "session key to server-to-client signing key magic constant" +#define SRV_SEAL "session key to server-to-client sealing key magic constant" + +static void NTLMSSPcalc_ap( unsigned char *hash, unsigned char *data, int len) +{ + unsigned char index_i = hash[256]; + unsigned char index_j = hash[257]; + int ind; + + for (ind = 0; ind < len; ind++) + { + unsigned char tc; + unsigned char t; + + index_i++; + index_j += hash[index_i]; + + tc = hash[index_i]; + hash[index_i] = hash[index_j]; + hash[index_j] = tc; + + t = hash[index_i] + hash[index_j]; + data[ind] = data[ind] ^ hash[t]; + } + + hash[256] = index_i; + hash[257] = index_j; +} + +static void calc_hash(unsigned char *hash, const char *k2, int k2l) +{ + unsigned char j = 0; + int ind; + + for (ind = 0; ind < 256; ind++) + { + hash[ind] = (unsigned char)ind; + } + + for (ind = 0; ind < 256; ind++) + { + unsigned char tc; + + j += (hash[ind] + k2[ind%k2l]); + + tc = hash[ind]; + hash[ind] = hash[j]; + hash[j] = tc; + } + + hash[256] = 0; + hash[257] = 0; +} + +static void calc_ntlmv2_hash(unsigned char hash[16], char digest[16], + const char encrypted_response[16], + const char *constant) +{ + struct MD5Context ctx3; + + MD5Init(&ctx3); + MD5Update(&ctx3, encrypted_response, 5); + MD5Update(&ctx3, constant, strlen(constant)); + MD5Final(digest, &ctx3); + + calc_hash(hash, digest, 16); +} + +enum ntlmssp_direction { + NTLMSSP_SEND, + NTLMSSP_RECEIVE +}; + +static NTSTATUS ntlmssp_make_packet_signiture(NTLMSSP_CLIENT_STATE *ntlmssp_state, + const uchar *data, size_t length, + enum ntlmssp_direction direction, + DATA_BLOB *sig) +{ + if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) { + HMACMD5Context ctx; + char seq_num[4]; + uchar digest[16]; + SIVAL(seq_num, 0, ntlmssp_state->ntlmssp_seq_num); + + hmac_md5_init_limK_to_64(ntlmssp_state->cli_sign_const, 16, &ctx); + hmac_md5_update(seq_num, 4, &ctx); + hmac_md5_update(data, length, &ctx); + hmac_md5_final(digest, &ctx); + + if (!msrpc_gen(sig, "Bd", digest, sizeof(digest), ntlmssp_state->ntlmssp_seq_num)) { + return NT_STATUS_NO_MEMORY; + } + switch (direction) { + case NTLMSSP_SEND: + NTLMSSPcalc_ap(ntlmssp_state->cli_sign_hash, sig->data, sig->length); + break; + case NTLMSSP_RECEIVE: + NTLMSSPcalc_ap(ntlmssp_state->srv_sign_hash, sig->data, sig->length); + break; + } + } else { + uint32 crc; + crc = crc32_buffer(data, length); + if (!msrpc_gen(sig, "ddd", 0, crc, ntlmssp_state->ntlmssp_seq_num)) { + return NT_STATUS_NO_MEMORY; + } + + NTLMSSPcalc_ap(ntlmssp_state->ntlmssp_hash, sig->data, sig->length); + } + return NT_STATUS_OK; +} + +NTSTATUS ntlmssp_client_sign_packet(NTLMSSP_CLIENT_STATE *ntlmssp_state, + const uchar *data, size_t length, + DATA_BLOB *sig) +{ + ntlmssp_state->ntlmssp_seq_num++; + return ntlmssp_make_packet_signiture(ntlmssp_state, data, length, NTLMSSP_SEND, sig); +} + +/** + * Check the signature of an incoming packet + * @note caller *must* check that the signature is the size it expects + * + */ + +NTSTATUS ntlmssp_client_check_packet(NTLMSSP_CLIENT_STATE *ntlmssp_state, + const uchar *data, size_t length, + const DATA_BLOB *sig) +{ + DATA_BLOB local_sig; + NTSTATUS nt_status; + + if (sig->length < 8) { + DEBUG(0, ("NTLMSSP packet check failed due to short signiture (%u bytes)!\n", + sig->length)); + } + + nt_status = ntlmssp_make_packet_signiture(ntlmssp_state, data, + length, NTLMSSP_RECEIVE, &local_sig); + + if (!NT_STATUS_IS_OK(nt_status)) { + DEBUG(0, ("NTLMSSP packet check failed with %s\n", nt_errstr(nt_status))); + return nt_status; + } + + if (memcmp(sig->data, local_sig.data, MIN(sig->length, local_sig.length)) == 0) { + return NT_STATUS_OK; + } else { + DEBUG(5, ("BAD SIG: wanted signature of\n")); + dump_data(5, local_sig.data, local_sig.length); + + DEBUG(5, ("BAD SIG: got signature of\n")); + dump_data(5, sig->data, sig->length); + + DEBUG(0, ("NTLMSSP packet check failed due to invalid signiture!\n")); + return NT_STATUS_ACCESS_DENIED; + } +} + +/** + Initialise the state for NTLMSSP signing. +*/ +NTSTATUS ntlmssp_client_sign_init(NTLMSSP_CLIENT_STATE *ntlmssp_state) +{ + unsigned char p24[24]; + unsigned char lm_hash[16]; + + if (!ntlmssp_state->lm_resp.data) { + /* can't sign or check signitures yet */ + return NT_STATUS_UNSUCCESSFUL; + } + + E_deshash(ntlmssp_state->password, lm_hash); + + NTLMSSPOWFencrypt(lm_hash, ntlmssp_state->lm_resp.data, p24); + + if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) + { + calc_ntlmv2_hash(ntlmssp_state->cli_sign_hash, ntlmssp_state->cli_sign_const, p24, CLI_SIGN); + calc_ntlmv2_hash(ntlmssp_state->cli_seal_hash, ntlmssp_state->cli_seal_const, p24, CLI_SEAL); + calc_ntlmv2_hash(ntlmssp_state->srv_sign_hash, ntlmssp_state->srv_sign_const, p24, SRV_SIGN); + calc_ntlmv2_hash(ntlmssp_state->srv_seal_hash, ntlmssp_state->srv_seal_const, p24, SRV_SEAL); + } + else + { + char k2[8]; + memcpy(k2, p24, 5); + k2[5] = 0xe5; + k2[6] = 0x38; + k2[7] = 0xb0; + + calc_hash(ntlmssp_state->ntlmssp_hash, k2, 8); + } + + ntlmssp_state->ntlmssp_seq_num = 0; + + ZERO_STRUCT(lm_hash); + return NT_STATUS_OK; +} diff --git a/source4/libcli/util/pwd_cache.c b/source4/libcli/util/pwd_cache.c new file mode 100644 index 0000000000..0d84f04ee3 --- /dev/null +++ b/source4/libcli/util/pwd_cache.c @@ -0,0 +1,72 @@ +/* + Unix SMB/CIFS implementation. + Password cacheing. obfuscation is planned + Copyright (C) Luke Kenneth Casson Leighton 1996-1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/**************************************************************************** + Initialises a password structure. +****************************************************************************/ + +static void pwd_init(struct pwd_info *pwd) +{ + memset((char *)pwd->password , '\0', sizeof(pwd->password )); + memset((char *)pwd->smb_lm_pwd, '\0', sizeof(pwd->smb_lm_pwd)); + memset((char *)pwd->smb_nt_pwd, '\0', sizeof(pwd->smb_nt_pwd)); + memset((char *)pwd->smb_lm_owf, '\0', sizeof(pwd->smb_lm_owf)); + memset((char *)pwd->smb_nt_owf, '\0', sizeof(pwd->smb_nt_owf)); + + pwd->null_pwd = True; /* safest option... */ + pwd->cleartext = False; + pwd->crypted = False; +} + +/**************************************************************************** + Makes lm and nt hashed passwords. +****************************************************************************/ + +static void pwd_make_lm_nt_16(struct pwd_info *pwd, const char *clr) +{ + pstring dos_passwd; + + pwd_init(pwd); + + push_ascii_pstring(dos_passwd, clr); + + nt_lm_owf_gen(dos_passwd, pwd->smb_nt_pwd, pwd->smb_lm_pwd); + pwd->null_pwd = False; + pwd->cleartext = False; + pwd->crypted = False; +} + +/**************************************************************************** + Stores a cleartext password. +****************************************************************************/ + +void pwd_set_cleartext(struct pwd_info *pwd, const char *clr) +{ + pwd_init(pwd); + push_ascii_fstring(pwd->password, clr); + pwd->cleartext = True; + pwd->null_pwd = False; + pwd->crypted = False; + pwd_make_lm_nt_16(pwd, clr); +} + + diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c new file mode 100644 index 0000000000..cde77f94a3 --- /dev/null +++ b/source4/libcli/util/smbdes.c @@ -0,0 +1,415 @@ +/* + Unix SMB/CIFS implementation. + + a partial implementation of DES designed for use in the + SMB authentication protocol + + Copyright (C) Andrew Tridgell 1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* NOTES: + + This code makes no attempt to be fast! In fact, it is a very + slow implementation + + This code is NOT a complete DES implementation. It implements only + the minimum necessary for SMB authentication, as used by all SMB + products (including every copy of Microsoft Windows95 ever sold) + + In particular, it can only do a unchained forward DES pass. This + means it is not possible to use this code for encryption/decryption + of data, instead it is only useful as a "hash" algorithm. + + There is no entry point into this code that allows normal DES operation. + + I believe this means that this code does not come under ITAR + regulations but this is NOT a legal opinion. If you are concerned + about the applicability of ITAR regulations to this code then you + should confirm it for yourself (and maybe let me know if you come + up with a different answer to the one above) +*/ + + +#define uchar unsigned char + +static const uchar perm1[56] = {57, 49, 41, 33, 25, 17, 9, + 1, 58, 50, 42, 34, 26, 18, + 10, 2, 59, 51, 43, 35, 27, + 19, 11, 3, 60, 52, 44, 36, + 63, 55, 47, 39, 31, 23, 15, + 7, 62, 54, 46, 38, 30, 22, + 14, 6, 61, 53, 45, 37, 29, + 21, 13, 5, 28, 20, 12, 4}; + +static const uchar perm2[48] = {14, 17, 11, 24, 1, 5, + 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, + 16, 7, 27, 20, 13, 2, + 41, 52, 31, 37, 47, 55, + 30, 40, 51, 45, 33, 48, + 44, 49, 39, 56, 34, 53, + 46, 42, 50, 36, 29, 32}; + +static const uchar perm3[64] = {58, 50, 42, 34, 26, 18, 10, 2, + 60, 52, 44, 36, 28, 20, 12, 4, + 62, 54, 46, 38, 30, 22, 14, 6, + 64, 56, 48, 40, 32, 24, 16, 8, + 57, 49, 41, 33, 25, 17, 9, 1, + 59, 51, 43, 35, 27, 19, 11, 3, + 61, 53, 45, 37, 29, 21, 13, 5, + 63, 55, 47, 39, 31, 23, 15, 7}; + +static const uchar perm4[48] = { 32, 1, 2, 3, 4, 5, + 4, 5, 6, 7, 8, 9, + 8, 9, 10, 11, 12, 13, + 12, 13, 14, 15, 16, 17, + 16, 17, 18, 19, 20, 21, + 20, 21, 22, 23, 24, 25, + 24, 25, 26, 27, 28, 29, + 28, 29, 30, 31, 32, 1}; + +static const uchar perm5[32] = { 16, 7, 20, 21, + 29, 12, 28, 17, + 1, 15, 23, 26, + 5, 18, 31, 10, + 2, 8, 24, 14, + 32, 27, 3, 9, + 19, 13, 30, 6, + 22, 11, 4, 25}; + + +static const uchar perm6[64] ={ 40, 8, 48, 16, 56, 24, 64, 32, + 39, 7, 47, 15, 55, 23, 63, 31, + 38, 6, 46, 14, 54, 22, 62, 30, + 37, 5, 45, 13, 53, 21, 61, 29, + 36, 4, 44, 12, 52, 20, 60, 28, + 35, 3, 43, 11, 51, 19, 59, 27, + 34, 2, 42, 10, 50, 18, 58, 26, + 33, 1, 41, 9, 49, 17, 57, 25}; + + +static const uchar sc[16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1}; + +static const uchar sbox[8][4][16] = { + {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7}, + {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8}, + {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0}, + {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}}, + + {{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10}, + {3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5}, + {0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15}, + {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}}, + + {{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8}, + {13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1}, + {13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7}, + {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}}, + + {{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15}, + {13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9}, + {10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4}, + {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}}, + + {{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9}, + {14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6}, + {4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14}, + {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}}, + + {{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11}, + {10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8}, + {9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6}, + {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}}, + + {{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1}, + {13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6}, + {1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2}, + {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}}, + + {{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7}, + {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2}, + {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8}, + {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}}}; + +static void permute(char *out, const char *in, const uchar *p, int n) +{ + int i; + for (i=0;i>1; + key[1] = ((str[0]&0x01)<<6) | (str[1]>>2); + key[2] = ((str[1]&0x03)<<5) | (str[2]>>3); + key[3] = ((str[2]&0x07)<<4) | (str[3]>>4); + key[4] = ((str[3]&0x0F)<<3) | (str[4]>>5); + key[5] = ((str[4]&0x1F)<<2) | (str[5]>>6); + key[6] = ((str[5]&0x3F)<<1) | (str[6]>>7); + key[7] = str[6]&0x7F; + for (i=0;i<8;i++) { + key[i] = (key[i]<<1); + } +} + + +static void smbhash(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw) +{ + int i; + char outb[64]; + char inb[64]; + char keyb[64]; + unsigned char key2[8]; + + str_to_key(key, key2); + + for (i=0;i<64;i++) { + inb[i] = (in[i/8] & (1<<(7-(i%8)))) ? 1 : 0; + keyb[i] = (key2[i/8] & (1<<(7-(i%8)))) ? 1 : 0; + outb[i] = 0; + } + + dohash(outb, inb, keyb, forw); + + for (i=0;i<8;i++) { + out[i] = 0; + } + + for (i=0;i<64;i++) { + if (outb[i]) + out[i/8] |= (1<<(7-(i%8))); + } +} + +void E_P16(const unsigned char *p14,unsigned char *p16) +{ + unsigned char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; + smbhash(p16, sp8, p14, 1); + smbhash(p16+8, sp8, p14+7, 1); +} + +void E_P24(const unsigned char *p21, const unsigned char *c8, unsigned char *p24) +{ + smbhash(p24, c8, p21, 1); + smbhash(p24+8, c8, p21+7, 1); + smbhash(p24+16, c8, p21+14, 1); +} + +void D_P16(const unsigned char *p14, const unsigned char *in, unsigned char *out) +{ + smbhash(out, in, p14, 0); + smbhash(out+8, in+8, p14+7, 0); +} + +void E_old_pw_hash( unsigned char *p14, const unsigned char *in, unsigned char *out) +{ + smbhash(out, in, p14, 1); + smbhash(out+8, in+8, p14+7, 1); +} + +void cred_hash1(unsigned char *out, const unsigned char *in, const unsigned char *key) +{ + unsigned char buf[8]; + + smbhash(buf, in, key, 1); + smbhash(out, buf, key+9, 1); +} + +void cred_hash2(unsigned char *out, const unsigned char *in, const unsigned char *key) +{ + unsigned char buf[8]; + static unsigned char key2[8]; + + smbhash(buf, in, key, 1); + key2[0] = key[7]; + smbhash(out, buf, key2, 1); +} + +void cred_hash3(unsigned char *out, unsigned char *in, const unsigned char *key, int forw) +{ + static unsigned char key2[8]; + + smbhash(out, in, key, forw); + key2[0] = key[7]; + smbhash(out + 8, in + 8, key2, forw); +} + +void SamOEMhash( unsigned char *data, const unsigned char *key, int val) +{ + unsigned char s_box[256]; + unsigned char index_i = 0; + unsigned char index_j = 0; + unsigned char j = 0; + int ind; + + for (ind = 0; ind < 256; ind++) + { + s_box[ind] = (unsigned char)ind; + } + + for( ind = 0; ind < 256; ind++) + { + unsigned char tc; + + j += (s_box[ind] + key[ind%16]); + + tc = s_box[ind]; + s_box[ind] = s_box[j]; + s_box[j] = tc; + } + for( ind = 0; ind < val; ind++) + { + unsigned char tc; + unsigned char t; + + index_i++; + index_j += s_box[index_i]; + + tc = s_box[index_i]; + s_box[index_i] = s_box[index_j]; + s_box[index_j] = tc; + + t = s_box[index_i] + s_box[index_j]; + data[ind] = data[ind] ^ s_box[t]; + } +} + +/* Decode a sam password hash into a password. The password hash is the + same method used to store passwords in the NT registry. The DES key + used is based on the RID of the user. */ + +void sam_pwd_hash(unsigned int rid, const uchar *in, uchar *out, int forw) +{ + uchar s[14]; + + s[0] = s[4] = s[8] = s[12] = (uchar)(rid & 0xFF); + s[1] = s[5] = s[9] = s[13] = (uchar)((rid >> 8) & 0xFF); + s[2] = s[6] = s[10] = (uchar)((rid >> 16) & 0xFF); + s[3] = s[7] = s[11] = (uchar)((rid >> 24) & 0xFF); + + smbhash(out, in, s, forw); + smbhash(out+8, in+8, s+7, forw); +} diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c new file mode 100644 index 0000000000..00c2b58146 --- /dev/null +++ b/source4/libcli/util/smbencrypt.c @@ -0,0 +1,418 @@ +/* + Unix SMB/CIFS implementation. + SMB parameters and setup + Copyright (C) Andrew Tridgell 1992-1998 + Modified by Jeremy Allison 1995. + Copyright (C) Jeremy Allison 1995-2000. + Copyright (C) Luke Kennethc Casson Leighton 1996-2000. + Copyright (C) Andrew Bartlett 2002-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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "byteorder.h" + +/* + This implements the X/Open SMB password encryption + It takes a password ('unix' string), a 8 byte "crypt key" + and puts 24 bytes of encrypted password into p24 */ +void SMBencrypt(const char *passwd, const uchar *c8, uchar p24[24]) +{ + uchar p21[21]; + + memset(p21,'\0',21); + E_deshash(passwd, p21); + + SMBOWFencrypt(p21, c8, p24); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("SMBencrypt: lm#, challenge, response\n")); + dump_data(100, (char *)p21, 16); + dump_data(100, (const char *)c8, 8); + dump_data(100, (char *)p24, 24); +#endif +} + +/** + * Creates the MD4 Hash of the users password in NT UNICODE. + * @param passwd password in 'unix' charset. + * @param p16 return password hashed with md4, caller allocated 16 byte buffer + */ + +void E_md4hash(const char *passwd, uchar p16[16]) +{ + int len; + smb_ucs2_t wpwd[129]; + + /* Password must be converted to NT unicode - null terminated. */ + push_ucs2(NULL, wpwd, (const char *)passwd, 256, STR_UNICODE|STR_NOALIGN|STR_TERMINATE); + /* Calculate length in bytes */ + len = strlen_w(wpwd) * sizeof(int16); + + mdfour(p16, (unsigned char *)wpwd, len); + ZERO_STRUCT(wpwd); +} + +/** + * Creates the DES forward-only Hash of the users password in DOS ASCII charset + * @param passwd password in 'unix' charset. + * @param p16 return password hashed with DES, caller allocated 16 byte buffer + */ + +void E_deshash(const char *passwd, uchar p16[16]) +{ + fstring dospwd; + ZERO_STRUCT(dospwd); + ZERO_STRUCTP(p16); + + /* Password must be converted to DOS charset - null terminated, uppercase. */ + push_ascii(dospwd, (const char *)passwd, sizeof(dospwd), STR_UPPER|STR_TERMINATE); + + /* Only the fisrt 14 chars are considered, password need not be null terminated. */ + E_P16(dospwd, p16); + + ZERO_STRUCT(dospwd); +} + +/** + * Creates the MD4 and DES (LM) Hash of the users password. + * MD4 is of the NT Unicode, DES is of the DOS UPPERCASE password. + * @param passwd password in 'unix' charset. + * @param nt_p16 return password hashed with md4, caller allocated 16 byte buffer + * @param p16 return password hashed with des, caller allocated 16 byte buffer + */ + +/* Does both the NT and LM owfs of a user's password */ +void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar p16[16]) +{ + /* Calculate the MD4 hash (NT compatible) of the password */ + memset(nt_p16, '\0', 16); + E_md4hash(pwd, nt_p16); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("nt_lm_owf_gen: pwd, nt#\n")); + dump_data(120, pwd, strlen(pwd)); + dump_data(100, (char *)nt_p16, 16); +#endif + + E_deshash(pwd, (uchar *)p16); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("nt_lm_owf_gen: pwd, lm#\n")); + dump_data(120, pwd, strlen(pwd)); + dump_data(100, (char *)p16, 16); +#endif +} + +/* Does both the NTLMv2 owfs of a user's password */ +BOOL ntv2_owf_gen(const uchar owf[16], + const char *user_in, const char *domain_in, uchar kr_buf[16]) +{ + smb_ucs2_t *user; + smb_ucs2_t *domain; + + size_t user_byte_len; + size_t domain_byte_len; + + HMACMD5Context ctx; + + user_byte_len = push_ucs2_allocate(&user, user_in); + if (user_byte_len == (size_t)-1) { + DEBUG(0, ("push_uss2_allocate() for user returned -1 (probably malloc() failure)\n")); + return False; + } + + domain_byte_len = push_ucs2_allocate(&domain, domain_in); + if (domain_byte_len == (size_t)-1) { + DEBUG(0, ("push_uss2_allocate() for domain returned -1 (probably malloc() failure)\n")); + return False; + } + + strupper_w(user); + strupper_w(domain); + + SMB_ASSERT(user_byte_len >= 2); + SMB_ASSERT(domain_byte_len >= 2); + + /* We don't want null termination */ + user_byte_len = user_byte_len - 2; + domain_byte_len = domain_byte_len - 2; + + hmac_md5_init_limK_to_64(owf, 16, &ctx); + hmac_md5_update((const unsigned char *)user, user_byte_len, &ctx); + hmac_md5_update((const unsigned char *)domain, domain_byte_len, &ctx); + hmac_md5_final(kr_buf, &ctx); + +#ifdef DEBUG_PASSWORD + DEBUG(100, ("ntv2_owf_gen: user, domain, owfkey, kr\n")); + dump_data(100, (const char *)user, user_byte_len); + dump_data(100, (const char *)domain, domain_byte_len); + dump_data(100, owf, 16); + dump_data(100, kr_buf, 16); +#endif + + SAFE_FREE(user); + SAFE_FREE(domain); + return True; +} + +/* Does the des encryption from the NT or LM MD4 hash. */ +void SMBOWFencrypt(const uchar passwd[16], const uchar *c8, uchar p24[24]) +{ + uchar p21[21]; + + ZERO_STRUCT(p21); + + memcpy(p21, passwd, 16); + E_P24(p21, c8, p24); +} + +/* Does the des encryption from the FIRST 8 BYTES of the NT or LM MD4 hash. */ +void NTLMSSPOWFencrypt(const uchar passwd[8], const uchar *ntlmchalresp, uchar p24[24]) +{ + uchar p21[21]; + + memset(p21,'\0',21); + memcpy(p21, passwd, 8); + memset(p21 + 8, 0xbd, 8); + + E_P24(p21, ntlmchalresp, p24); +#ifdef DEBUG_PASSWORD + DEBUG(100,("NTLMSSPOWFencrypt: p21, c8, p24\n")); + dump_data(100, (char *)p21, 21); + dump_data(100, (const char *)ntlmchalresp, 8); + dump_data(100, (char *)p24, 24); +#endif +} + + +/* Does the NT MD4 hash then des encryption. */ + +void SMBNTencrypt(const char *passwd, uchar *c8, uchar *p24) +{ + uchar p21[21]; + + memset(p21,'\0',21); + + E_md4hash(passwd, p21); + SMBOWFencrypt(p21, c8, p24); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("SMBNTencrypt: nt#, challenge, response\n")); + dump_data(100, (char *)p21, 16); + dump_data(100, (char *)c8, 8); + dump_data(100, (char *)p24, 24); +#endif +} + +BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode) +{ + int new_pw_len = strlen(passwd) * (unicode ? 2 : 1); + + if (new_pw_len > 512) + { + DEBUG(0,("make_oem_passwd_hash: new password is too long.\n")); + return False; + } + + /* + * Now setup the data area. + * We need to generate a random fill + * for this area to make it harder to + * decrypt. JRA. + */ + generate_random_buffer((unsigned char *)data, 516, False); + push_string(NULL, &data[512 - new_pw_len], passwd, new_pw_len, + STR_NOALIGN | (unicode?STR_UNICODE:STR_ASCII)); + SIVAL(data, 512, new_pw_len); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("make_oem_passwd_hash\n")); + dump_data(100, data, 516); +#endif + SamOEMhash( (unsigned char *)data, (unsigned char *)old_pw_hash, 516); + + return True; +} + +/* Does the md5 encryption from the NT hash for NTLMv2. */ +void SMBOWFencrypt_ntv2(const uchar kr[16], + const DATA_BLOB srv_chal, + const DATA_BLOB cli_chal, + uchar resp_buf[16]) +{ + HMACMD5Context ctx; + + hmac_md5_init_limK_to_64(kr, 16, &ctx); + hmac_md5_update(srv_chal.data, srv_chal.length, &ctx); + hmac_md5_update(cli_chal.data, cli_chal.length, &ctx); + hmac_md5_final(resp_buf, &ctx); + +#ifdef DEBUG_PASSWORD + DEBUG(100, ("SMBOWFencrypt_ntv2: srv_chal, cli_chal, resp_buf\n")); + dump_data(100, srv_chal.data, srv_chal.length); + dump_data(100, cli_chal.data, cli_chal.length); + dump_data(100, resp_buf, 16); +#endif +} + +void SMBsesskeygen_ntv2(const uchar kr[16], + const uchar * nt_resp, uint8 sess_key[16]) +{ + HMACMD5Context ctx; + + hmac_md5_init_limK_to_64(kr, 16, &ctx); + hmac_md5_update(nt_resp, 16, &ctx); + hmac_md5_final((unsigned char *)sess_key, &ctx); + +#ifdef DEBUG_PASSWORD + DEBUG(100, ("SMBsesskeygen_ntv2:\n")); + dump_data(100, sess_key, 16); +#endif +} + +void SMBsesskeygen_ntv1(const uchar kr[16], + const uchar * nt_resp, uint8 sess_key[16]) +{ + mdfour((unsigned char *)sess_key, kr, 16); + +#ifdef DEBUG_PASSWORD + DEBUG(100, ("SMBsesskeygen_ntv1:\n")); + dump_data(100, sess_key, 16); +#endif +} + +DATA_BLOB NTLMv2_generate_response(uchar ntlm_v2_hash[16], + DATA_BLOB server_chal, size_t client_chal_length) +{ + uchar ntlmv2_response[16]; + DATA_BLOB ntlmv2_client_data; + DATA_BLOB final_response; + + /* NTLMv2 */ + + /* We also get to specify some random data */ + ntlmv2_client_data = data_blob(NULL, client_chal_length); + generate_random_buffer(ntlmv2_client_data.data, ntlmv2_client_data.length, False); + + /* Given that data, and the challenge from the server, generate a response */ + SMBOWFencrypt_ntv2(ntlm_v2_hash, server_chal, ntlmv2_client_data, ntlmv2_response); + + /* put it into nt_response, for the code below to put into the packet */ + final_response = data_blob(NULL, ntlmv2_client_data.length + sizeof(ntlmv2_response)); + memcpy(final_response.data, ntlmv2_response, sizeof(ntlmv2_response)); + /* after the first 16 bytes is the random data we generated above, so the server can verify us with it */ + memcpy(final_response.data + sizeof(ntlmv2_response), ntlmv2_client_data.data, ntlmv2_client_data.length); + data_blob_free(&ntlmv2_client_data); + + return final_response; +} + +BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password, + const DATA_BLOB server_chal, + DATA_BLOB *lm_response, DATA_BLOB *nt_response, + DATA_BLOB *session_key) +{ + uchar nt_hash[16]; + uchar ntlm_v2_hash[16]; + E_md4hash(password, nt_hash); + + /* We don't use the NT# directly. Instead we use it mashed up with + the username and domain. + This prevents username swapping during the auth exchange + */ + if (!ntv2_owf_gen(nt_hash, user, domain, ntlm_v2_hash)) { + return False; + } + + *nt_response = NTLMv2_generate_response(ntlm_v2_hash, server_chal, 64 /* pick a number, > 8 */); + + /* LMv2 */ + + *lm_response = NTLMv2_generate_response(ntlm_v2_hash, server_chal, 8); + + *session_key = data_blob(NULL, 16); + + /* The NTLMv2 calculations also provide a session key, for signing etc later */ + /* use only the first 16 bytes of nt_response for session key */ + SMBsesskeygen_ntv2(ntlm_v2_hash, nt_response->data, session_key->data); + + return True; +} + +/*********************************************************** + encode a password buffer. The caller gets to figure out + what to put in it. +************************************************************/ +BOOL encode_pw_buffer(char buffer[516], char *new_pw, int new_pw_length) +{ + generate_random_buffer((unsigned char *)buffer, 516, True); + + memcpy(&buffer[512 - new_pw_length], new_pw, new_pw_length); + + /* + * The length of the new password is in the last 4 bytes of + * the data buffer. + */ + SIVAL(buffer, 512, new_pw_length); + + return True; +} + +/*********************************************************** + decode a password buffer + *new_pw_len is the length in bytes of the possibly mulitbyte + returned password including termination. +************************************************************/ +BOOL decode_pw_buffer(char in_buffer[516], char *new_pwrd, + int new_pwrd_size, uint32 *new_pw_len) +{ + int byte_len=0; + + /* + Warning !!! : This function is called from some rpc call. + The password IN the buffer is a UNICODE string. + The password IN new_pwrd is an ASCII string + If you reuse that code somewhere else check first. + */ + + /* The length of the new password is in the last 4 bytes of the data buffer. */ + + byte_len = IVAL(in_buffer, 512); + +#ifdef DEBUG_PASSWORD + dump_data(100, in_buffer, 516); +#endif + + /* Password cannot be longer than 128 characters */ + if ( (byte_len < 0) || (byte_len > new_pwrd_size - 1)) { + DEBUG(0, ("decode_pw_buffer: incorrect password length (%d).\n", byte_len)); + DEBUG(0, ("decode_pw_buffer: check that 'encrypt passwords = yes'\n")); + return False; + } + + /* decode into the return buffer. Buffer must be a pstring */ + *new_pw_len = pull_string(NULL, new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, byte_len, STR_UNICODE); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("decode_pw_buffer: new_pwrd: ")); + dump_data(100, (char *)new_pwrd, *new_pw_len); + DEBUG(100,("multibyte len:%d\n", *new_pw_len)); + DEBUG(100,("original char len:%d\n", byte_len/2)); +#endif + + return True; +} diff --git a/source4/libcli/util/smberr.c b/source4/libcli/util/smberr.c new file mode 100644 index 0000000000..d6eabcfbce --- /dev/null +++ b/source4/libcli/util/smberr.c @@ -0,0 +1,181 @@ +/* + Unix SMB/CIFS implementation. + Copyright (C) Andrew Tridgell 1998-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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* + error code stuff - put together by Merik Karman + merik@blackadder.dsh.oz.au +*/ + +struct err_code_struct { + const char *name; + int code; + const char *message; +}; + +/* Dos Error Messages */ +static const struct err_code_struct dos_msgs[] = { + {"ERRbadfunc",ERRbadfunc,"Invalid function."}, + {"ERRbadfile",ERRbadfile,"File not found."}, + {"ERRbadpath",ERRbadpath,"Directory invalid."}, + {"ERRnofids",ERRnofids,"No file descriptors available"}, + {"ERRnoaccess",ERRnoaccess,"Access denied."}, + {"ERRbadfid",ERRbadfid,"Invalid file handle."}, + {"ERRbadmcb",ERRbadmcb,"Memory control blocks destroyed."}, + {"ERRnomem",ERRnomem,"Insufficient server memory to perform the requested function."}, + {"ERRbadmem",ERRbadmem,"Invalid memory block address."}, + {"ERRbadenv",ERRbadenv,"Invalid environment."}, + {"ERRbadformat",11,"Invalid format."}, + {"ERRbadaccess",ERRbadaccess,"Invalid open mode."}, + {"ERRbaddata",ERRbaddata,"Invalid data."}, + {"ERRres",ERRres,"reserved."}, + {"ERRbaddrive",ERRbaddrive,"Invalid drive specified."}, + {"ERRremcd",ERRremcd,"A Delete Directory request attempted to remove the server's current directory."}, + {"ERRdiffdevice",ERRdiffdevice,"Not same device."}, + {"ERRnofiles",ERRnofiles,"A File Search command can find no more files matching the specified criteria."}, + {"ERRbadshare",ERRbadshare,"The sharing mode specified for an Open conflicts with existing FIDs on the file."}, + {"ERRlock",ERRlock,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."}, + {"ERRunsup", ERRunsup, "The operation is unsupported"}, + {"ERRnosuchshare", ERRnosuchshare, "You specified an invalid share name"}, + {"ERRfilexists",ERRfilexists,"The file named in a Create Directory, Make New File or Link request already exists."}, + {"ERRinvalidname",ERRinvalidname, "Invalid name"}, + {"ERRbadpipe",ERRbadpipe,"Pipe invalid."}, + {"ERRpipebusy",ERRpipebusy,"All instances of the requested pipe are busy."}, + {"ERRpipeclosing",ERRpipeclosing,"Pipe close in progress."}, + {"ERRnotconnected",ERRnotconnected,"No process on other end of pipe."}, + {"ERRmoredata",ERRmoredata,"There is more data to be returned."}, + {"ERRinvgroup",ERRinvgroup,"Invalid workgroup (try the -W option)"}, + {"ERRlogonfailure",ERRlogonfailure,"Logon failure"}, + {"ERRdiskfull",ERRdiskfull,"Disk full"}, + {"ERRgeneral",ERRgeneral, "General failure"}, + {"ERRunknownlevel",ERRunknownlevel, "Unknown info level"}, + {NULL,-1,NULL}}; + +/* Server Error Messages */ +static const struct err_code_struct server_msgs[] = { + {"ERRerror",1,"Non-specific error code."}, + {"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."}, + {"ERRbadtype",3,"reserved."}, + {"ERRaccess",4,"The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID."}, + {"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."}, + {"ERRinvnetname",6,"Invalid network name in tree connect."}, + {"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."}, + {"ERRqfull",49,"Print queue full (files) -- returned by open print file."}, + {"ERRqtoobig",50,"Print queue full -- no space."}, + {"ERRqeof",51,"EOF on print queue dump."}, + {"ERRinvpfid",52,"Invalid print file FID."}, + {"ERRsmbcmd",64,"The server did not recognize the command received."}, + {"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."}, + {"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."}, + {"ERRreserved",68,"reserved."}, + {"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."}, + {"ERRreserved",70,"reserved."}, + {"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."}, + {"ERRpaused",81,"Server is paused."}, + {"ERRmsgoff",82,"Not receiving messages."}, + {"ERRnoroom",83,"No room to buffer message."}, + {"ERRrmuns",87,"Too many remote user names."}, + {"ERRtimeout",88,"Operation timed out."}, + {"ERRnoresource",89,"No resources currently available for request."}, + {"ERRtoomanyuids",90,"Too many UIDs active on this session."}, + {"ERRbaduid",91,"The UID is not known as a valid ID on this session."}, + {"ERRusempx",250,"Temp unable to support Raw, use MPX mode."}, + {"ERRusestd",251,"Temp unable to support Raw, use standard read/write."}, + {"ERRcontmpx",252,"Continue in MPX mode."}, + {"ERRreserved",253,"reserved."}, + {"ERRreserved",254,"reserved."}, + {"ERRnosupport",0xFFFF,"Function not supported."}, + {NULL,-1,NULL}}; + +/* Hard Error Messages */ +static const struct err_code_struct hard_msgs[] = { + {"ERRnowrite",19,"Attempt to write on write-protected diskette."}, + {"ERRbadunit",20,"Unknown unit."}, + {"ERRnotready",21,"Drive not ready."}, + {"ERRbadcmd",22,"Unknown command."}, + {"ERRdata",23,"Data error (CRC)."}, + {"ERRbadreq",24,"Bad request structure length."}, + {"ERRseek",25 ,"Seek error."}, + {"ERRbadmedia",26,"Unknown media type."}, + {"ERRbadsector",27,"Sector not found."}, + {"ERRnopaper",28,"Printer out of paper."}, + {"ERRwrite",29,"Write fault."}, + {"ERRread",30,"Read fault."}, + {"ERRgeneral",31,"General failure."}, + {"ERRbadshare",32,"An open conflicts with an existing open."}, + {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."}, + {"ERRwrongdisk",34,"The wrong disk was found in a drive."}, + {"ERRFCBUnavail",35,"No FCBs are available to process request."}, + {"ERRsharebufexc",36,"A sharing buffer has been exceeded."}, + {NULL,-1,NULL}}; + + +static const struct { + uint8 class; + const char *class_name; + const struct err_code_struct *err_msgs; +} err_classes[] = { + {0,"SUCCESS",NULL}, + {0x01,"ERRDOS",dos_msgs}, + {0x02,"ERRSRV",server_msgs}, + {0x03,"ERRHRD",hard_msgs}, + {0x04,"ERRXOS",NULL}, + {0xE1,"ERRRMX1",NULL}, + {0xE2,"ERRRMX2",NULL}, + {0xE3,"ERRRMX3",NULL}, + {0xFF,"ERRCMD",NULL}, + {-1,NULL,NULL}}; + + +/* return a dos error string given a error class and error code */ +const char *dos_errstr(uint8 class, uint16 code) +{ + static char *msg; + int i, j; + const struct err_code_struct *err_msgs; + + if (msg) { + free(msg); + msg = NULL; + } + + for (i=0;err_classes[i].class_name;i++) { + if (class == err_classes[i].class) break; + } + if (!err_classes[i].class_name) { + asprintf(&msg, "Unknown DOS error %d:%d\n", class, code); + return msg; + } + + err_msgs = err_classes[i].err_msgs; + + for (j=0;err_msgs && err_msgs[j].name;j++) { + if (err_msgs[j].code == code) { + asprintf(&msg, "%s:%s (%s)\n", + err_classes[i].class_name, + err_msgs[j].name, + err_msgs[j].message); + return msg; + } + } + + asprintf(&msg, "Unknown DOS error %s:%d\n", err_classes[i].class_name, code); + return msg; +} -- cgit From d285c6f14f7ad7037e1a81d59da8b3c892a49884 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Nov 2003 11:55:56 +0000 Subject: * add another WERR err code * use the top-level function argument printing to show more detail in RPC-* tests (This used to be commit 33bb8785625b1845750f28f2d810e7096afe9f8e) --- source4/libcli/util/doserr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 28bad6109d..c4ec869961 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -35,6 +35,7 @@ werror_code_struct dos_errs[] = { "WERR_ACCESS_DENIED", WERR_ACCESS_DENIED }, { "WERR_BADFID", WERR_BADFID }, { "WERR_BADFUNC", WERR_BADFUNC }, + { "WERR_BAD_NETPATH", WERR_BAD_NETPATH }, { "WERR_INSUFFICIENT_BUFFER", WERR_INSUFFICIENT_BUFFER }, { "WERR_NO_SUCH_SHARE", WERR_NO_SUCH_SHARE }, { "WERR_ALREADY_EXISTS", WERR_ALREADY_EXISTS }, -- cgit From d47d14f2ffc7a6d2cc306530b777f364767998b3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Nov 2003 01:53:54 +0000 Subject: reduced the number of magic types we need in mkproto.pl In general I prefer "struct foo" to just "foo" for most structures. There are exceptions. (This used to be commit 04eb12b56c653f98801ab29411f47564ab32fa58) --- source4/libcli/util/cliutil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/cliutil.c b/source4/libcli/util/cliutil.c index 47f94992a4..13b3dad0bf 100644 --- a/source4/libcli/util/cliutil.c +++ b/source4/libcli/util/cliutil.c @@ -76,13 +76,13 @@ BOOL yesno(char *p) const char *readdirname(DIR *p) { - SMB_STRUCT_DIRENT *ptr; + struct smb_dirent *ptr; char *dname; if (!p) return(NULL); - ptr = (SMB_STRUCT_DIRENT *)sys_readdir(p); + ptr = (struct smb_dirent *)sys_readdir(p); if (!ptr) return(NULL); -- cgit From e0ac659917066dbf7f8fdbcc7684ce2b49dd04d9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 26 Nov 2003 01:16:41 +0000 Subject: signed DCERPC over TCP now works ! * moved ntlmssp code into libcli/auth/, and updated to latest ntlmssp code from samba3 (thanks Andrew! the new interface is great) * added signing/ntlmssp support in the dcerpc code * added a dcerpc_auth.c module for the various dcerpc auth mechanisms (This used to be commit c18c9b5585a3e5f7868562820c14f7cb529cdbcd) --- source4/libcli/util/ntlmssp_sign.c | 226 ------------------------------------- source4/libcli/util/smbencrypt.c | 162 +++++++++++++++++++++----- 2 files changed, 131 insertions(+), 257 deletions(-) delete mode 100644 source4/libcli/util/ntlmssp_sign.c (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/ntlmssp_sign.c b/source4/libcli/util/ntlmssp_sign.c deleted file mode 100644 index bd6d64d842..0000000000 --- a/source4/libcli/util/ntlmssp_sign.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * Version 3.0 - * NTLMSSP Signing routines - * Copyright (C) Luke Kenneth Casson Leighton 1996-2001 - * Copyright (C) Andrew Bartlett 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 - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "includes.h" - -#define CLI_SIGN "session key to client-to-server signing key magic constant" -#define CLI_SEAL "session key to client-to-server sealing key magic constant" -#define SRV_SIGN "session key to server-to-client signing key magic constant" -#define SRV_SEAL "session key to server-to-client sealing key magic constant" - -static void NTLMSSPcalc_ap( unsigned char *hash, unsigned char *data, int len) -{ - unsigned char index_i = hash[256]; - unsigned char index_j = hash[257]; - int ind; - - for (ind = 0; ind < len; ind++) - { - unsigned char tc; - unsigned char t; - - index_i++; - index_j += hash[index_i]; - - tc = hash[index_i]; - hash[index_i] = hash[index_j]; - hash[index_j] = tc; - - t = hash[index_i] + hash[index_j]; - data[ind] = data[ind] ^ hash[t]; - } - - hash[256] = index_i; - hash[257] = index_j; -} - -static void calc_hash(unsigned char *hash, const char *k2, int k2l) -{ - unsigned char j = 0; - int ind; - - for (ind = 0; ind < 256; ind++) - { - hash[ind] = (unsigned char)ind; - } - - for (ind = 0; ind < 256; ind++) - { - unsigned char tc; - - j += (hash[ind] + k2[ind%k2l]); - - tc = hash[ind]; - hash[ind] = hash[j]; - hash[j] = tc; - } - - hash[256] = 0; - hash[257] = 0; -} - -static void calc_ntlmv2_hash(unsigned char hash[16], char digest[16], - const char encrypted_response[16], - const char *constant) -{ - struct MD5Context ctx3; - - MD5Init(&ctx3); - MD5Update(&ctx3, encrypted_response, 5); - MD5Update(&ctx3, constant, strlen(constant)); - MD5Final(digest, &ctx3); - - calc_hash(hash, digest, 16); -} - -enum ntlmssp_direction { - NTLMSSP_SEND, - NTLMSSP_RECEIVE -}; - -static NTSTATUS ntlmssp_make_packet_signiture(NTLMSSP_CLIENT_STATE *ntlmssp_state, - const uchar *data, size_t length, - enum ntlmssp_direction direction, - DATA_BLOB *sig) -{ - if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) { - HMACMD5Context ctx; - char seq_num[4]; - uchar digest[16]; - SIVAL(seq_num, 0, ntlmssp_state->ntlmssp_seq_num); - - hmac_md5_init_limK_to_64(ntlmssp_state->cli_sign_const, 16, &ctx); - hmac_md5_update(seq_num, 4, &ctx); - hmac_md5_update(data, length, &ctx); - hmac_md5_final(digest, &ctx); - - if (!msrpc_gen(sig, "Bd", digest, sizeof(digest), ntlmssp_state->ntlmssp_seq_num)) { - return NT_STATUS_NO_MEMORY; - } - switch (direction) { - case NTLMSSP_SEND: - NTLMSSPcalc_ap(ntlmssp_state->cli_sign_hash, sig->data, sig->length); - break; - case NTLMSSP_RECEIVE: - NTLMSSPcalc_ap(ntlmssp_state->srv_sign_hash, sig->data, sig->length); - break; - } - } else { - uint32 crc; - crc = crc32_buffer(data, length); - if (!msrpc_gen(sig, "ddd", 0, crc, ntlmssp_state->ntlmssp_seq_num)) { - return NT_STATUS_NO_MEMORY; - } - - NTLMSSPcalc_ap(ntlmssp_state->ntlmssp_hash, sig->data, sig->length); - } - return NT_STATUS_OK; -} - -NTSTATUS ntlmssp_client_sign_packet(NTLMSSP_CLIENT_STATE *ntlmssp_state, - const uchar *data, size_t length, - DATA_BLOB *sig) -{ - ntlmssp_state->ntlmssp_seq_num++; - return ntlmssp_make_packet_signiture(ntlmssp_state, data, length, NTLMSSP_SEND, sig); -} - -/** - * Check the signature of an incoming packet - * @note caller *must* check that the signature is the size it expects - * - */ - -NTSTATUS ntlmssp_client_check_packet(NTLMSSP_CLIENT_STATE *ntlmssp_state, - const uchar *data, size_t length, - const DATA_BLOB *sig) -{ - DATA_BLOB local_sig; - NTSTATUS nt_status; - - if (sig->length < 8) { - DEBUG(0, ("NTLMSSP packet check failed due to short signiture (%u bytes)!\n", - sig->length)); - } - - nt_status = ntlmssp_make_packet_signiture(ntlmssp_state, data, - length, NTLMSSP_RECEIVE, &local_sig); - - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(0, ("NTLMSSP packet check failed with %s\n", nt_errstr(nt_status))); - return nt_status; - } - - if (memcmp(sig->data, local_sig.data, MIN(sig->length, local_sig.length)) == 0) { - return NT_STATUS_OK; - } else { - DEBUG(5, ("BAD SIG: wanted signature of\n")); - dump_data(5, local_sig.data, local_sig.length); - - DEBUG(5, ("BAD SIG: got signature of\n")); - dump_data(5, sig->data, sig->length); - - DEBUG(0, ("NTLMSSP packet check failed due to invalid signiture!\n")); - return NT_STATUS_ACCESS_DENIED; - } -} - -/** - Initialise the state for NTLMSSP signing. -*/ -NTSTATUS ntlmssp_client_sign_init(NTLMSSP_CLIENT_STATE *ntlmssp_state) -{ - unsigned char p24[24]; - unsigned char lm_hash[16]; - - if (!ntlmssp_state->lm_resp.data) { - /* can't sign or check signitures yet */ - return NT_STATUS_UNSUCCESSFUL; - } - - E_deshash(ntlmssp_state->password, lm_hash); - - NTLMSSPOWFencrypt(lm_hash, ntlmssp_state->lm_resp.data, p24); - - if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) - { - calc_ntlmv2_hash(ntlmssp_state->cli_sign_hash, ntlmssp_state->cli_sign_const, p24, CLI_SIGN); - calc_ntlmv2_hash(ntlmssp_state->cli_seal_hash, ntlmssp_state->cli_seal_const, p24, CLI_SEAL); - calc_ntlmv2_hash(ntlmssp_state->srv_sign_hash, ntlmssp_state->srv_sign_const, p24, SRV_SIGN); - calc_ntlmv2_hash(ntlmssp_state->srv_seal_hash, ntlmssp_state->srv_seal_const, p24, SRV_SEAL); - } - else - { - char k2[8]; - memcpy(k2, p24, 5); - k2[5] = 0xe5; - k2[6] = 0x38; - k2[7] = 0xb0; - - calc_hash(ntlmssp_state->ntlmssp_hash, k2, 8); - } - - ntlmssp_state->ntlmssp_seq_num = 0; - - ZERO_STRUCT(lm_hash); - return NT_STATUS_OK; -} diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 00c2b58146..39f3803ade 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -76,13 +76,12 @@ void E_deshash(const char *passwd, uchar p16[16]) { fstring dospwd; ZERO_STRUCT(dospwd); - ZERO_STRUCTP(p16); /* Password must be converted to DOS charset - null terminated, uppercase. */ - push_ascii(dospwd, (const char *)passwd, sizeof(dospwd), STR_UPPER|STR_TERMINATE); + push_ascii(dospwd, passwd, sizeof(dospwd), STR_UPPER|STR_TERMINATE); /* Only the fisrt 14 chars are considered, password need not be null terminated. */ - E_P16(dospwd, p16); + E_P16((const unsigned char *)dospwd, p16); ZERO_STRUCT(dospwd); } @@ -248,23 +247,23 @@ BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[ return True; } -/* Does the md5 encryption from the NT hash for NTLMv2. */ +/* Does the md5 encryption from the Key Response for NTLMv2. */ void SMBOWFencrypt_ntv2(const uchar kr[16], - const DATA_BLOB srv_chal, - const DATA_BLOB cli_chal, + const DATA_BLOB *srv_chal, + const DATA_BLOB *cli_chal, uchar resp_buf[16]) { HMACMD5Context ctx; hmac_md5_init_limK_to_64(kr, 16, &ctx); - hmac_md5_update(srv_chal.data, srv_chal.length, &ctx); - hmac_md5_update(cli_chal.data, cli_chal.length, &ctx); + hmac_md5_update(srv_chal->data, srv_chal->length, &ctx); + hmac_md5_update(cli_chal->data, cli_chal->length, &ctx); hmac_md5_final(resp_buf, &ctx); #ifdef DEBUG_PASSWORD DEBUG(100, ("SMBOWFencrypt_ntv2: srv_chal, cli_chal, resp_buf\n")); - dump_data(100, srv_chal.data, srv_chal.length); - dump_data(100, cli_chal.data, cli_chal.length); + dump_data(100, srv_chal->data, srv_chal->length); + dump_data(100, cli_chal->data, cli_chal->length); dump_data(100, resp_buf, 16); #endif } @@ -272,6 +271,8 @@ void SMBOWFencrypt_ntv2(const uchar kr[16], void SMBsesskeygen_ntv2(const uchar kr[16], const uchar * nt_resp, uint8 sess_key[16]) { + /* a very nice, 128 bit, variable session key */ + HMACMD5Context ctx; hmac_md5_init_limK_to_64(kr, 16, &ctx); @@ -287,6 +288,9 @@ void SMBsesskeygen_ntv2(const uchar kr[16], void SMBsesskeygen_ntv1(const uchar kr[16], const uchar * nt_resp, uint8 sess_key[16]) { + /* yes, this session key does not change - yes, this + is a problem - but it is 128 bits */ + mdfour((unsigned char *)sess_key, kr, 16); #ifdef DEBUG_PASSWORD @@ -295,36 +299,125 @@ void SMBsesskeygen_ntv1(const uchar kr[16], #endif } -DATA_BLOB NTLMv2_generate_response(uchar ntlm_v2_hash[16], - DATA_BLOB server_chal, size_t client_chal_length) +void SMBsesskeygen_lmv1(const uchar lm_hash[16], + const uchar lm_resp[24], /* only uses 8 */ + uint8 sess_key[16]) +{ + /* Calculate the LM session key (effective length 40 bits, + but changes with each session) */ + + uchar p24[24]; + uchar partial_lm_hash[16]; + + memcpy(partial_lm_hash, lm_hash, 8); + memset(partial_lm_hash + 8, 0xbd, 8); + + SMBOWFencrypt(lm_hash, lm_resp, p24); + + memcpy(sess_key, p24, 16); + sess_key[5] = 0xe5; + sess_key[6] = 0x38; + sess_key[7] = 0xb0; + +#ifdef DEBUG_PASSWORD + DEBUG(100, ("SMBsesskeygen_lmv1:\n")); + dump_data(100, sess_key, 16); +#endif +} + +DATA_BLOB NTLMv2_generate_names_blob(const char *hostname, + const char *domain) +{ + DATA_BLOB names_blob = data_blob(NULL, 0); + + msrpc_gen(&names_blob, "aaa", + True, NTLMSSP_NAME_TYPE_DOMAIN, domain, + True, NTLMSSP_NAME_TYPE_SERVER, hostname, + True, 0, ""); + return names_blob; +} + +static DATA_BLOB NTLMv2_generate_client_data(const DATA_BLOB *names_blob) +{ + uchar client_chal[8]; + DATA_BLOB response = data_blob(NULL, 0); + char long_date[8]; + + generate_random_buffer(client_chal, sizeof(client_chal), False); + + put_long_date(long_date, time(NULL)); + + /* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */ + + msrpc_gen(&response, "ddbbdb", + 0x00000101, /* Header */ + 0, /* 'Reserved' */ + long_date, 8, /* Timestamp */ + client_chal, 8, /* client challenge */ + 0, /* Unknown */ + names_blob->data, names_blob->length); /* End of name list */ + + return response; +} + +static DATA_BLOB NTLMv2_generate_response(const uchar ntlm_v2_hash[16], + const DATA_BLOB *server_chal, + const DATA_BLOB *names_blob) { uchar ntlmv2_response[16]; DATA_BLOB ntlmv2_client_data; DATA_BLOB final_response; /* NTLMv2 */ + /* generate some data to pass into the response function - including + the hostname and domain name of the server */ + ntlmv2_client_data = NTLMv2_generate_client_data(names_blob); - /* We also get to specify some random data */ - ntlmv2_client_data = data_blob(NULL, client_chal_length); - generate_random_buffer(ntlmv2_client_data.data, ntlmv2_client_data.length, False); - /* Given that data, and the challenge from the server, generate a response */ - SMBOWFencrypt_ntv2(ntlm_v2_hash, server_chal, ntlmv2_client_data, ntlmv2_response); + SMBOWFencrypt_ntv2(ntlm_v2_hash, server_chal, &ntlmv2_client_data, ntlmv2_response); - /* put it into nt_response, for the code below to put into the packet */ - final_response = data_blob(NULL, ntlmv2_client_data.length + sizeof(ntlmv2_response)); + final_response = data_blob(NULL, sizeof(ntlmv2_response) + ntlmv2_client_data.length); + memcpy(final_response.data, ntlmv2_response, sizeof(ntlmv2_response)); - /* after the first 16 bytes is the random data we generated above, so the server can verify us with it */ - memcpy(final_response.data + sizeof(ntlmv2_response), ntlmv2_client_data.data, ntlmv2_client_data.length); + + memcpy(final_response.data+sizeof(ntlmv2_response), + ntlmv2_client_data.data, ntlmv2_client_data.length); + data_blob_free(&ntlmv2_client_data); return final_response; } +static DATA_BLOB LMv2_generate_response(const uchar ntlm_v2_hash[16], + const DATA_BLOB *server_chal) +{ + uchar lmv2_response[16]; + DATA_BLOB lmv2_client_data = data_blob(NULL, 8); + DATA_BLOB final_response = data_blob(NULL, 24); + + /* LMv2 */ + /* client-supplied random data */ + generate_random_buffer(lmv2_client_data.data, lmv2_client_data.length, False); + + /* Given that data, and the challenge from the server, generate a response */ + SMBOWFencrypt_ntv2(ntlm_v2_hash, server_chal, &lmv2_client_data, lmv2_response); + memcpy(final_response.data, lmv2_response, sizeof(lmv2_response)); + + /* after the first 16 bytes is the random data we generated above, + so the server can verify us with it */ + memcpy(final_response.data+sizeof(lmv2_response), + lmv2_client_data.data, lmv2_client_data.length); + + data_blob_free(&lmv2_client_data); + + return final_response; +} + BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password, - const DATA_BLOB server_chal, + const DATA_BLOB *server_chal, + const DATA_BLOB *names_blob, DATA_BLOB *lm_response, DATA_BLOB *nt_response, - DATA_BLOB *session_key) + DATA_BLOB *nt_session_key) { uchar nt_hash[16]; uchar ntlm_v2_hash[16]; @@ -338,18 +431,24 @@ BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password return False; } - *nt_response = NTLMv2_generate_response(ntlm_v2_hash, server_chal, 64 /* pick a number, > 8 */); + if (nt_response) { + *nt_response = NTLMv2_generate_response(ntlm_v2_hash, server_chal, + names_blob); + if (nt_session_key) { + *nt_session_key = data_blob(NULL, 16); + + /* The NTLMv2 calculations also provide a session key, for signing etc later */ + /* use only the first 16 bytes of nt_response for session key */ + SMBsesskeygen_ntv2(ntlm_v2_hash, nt_response->data, nt_session_key->data); + } + } /* LMv2 */ - *lm_response = NTLMv2_generate_response(ntlm_v2_hash, server_chal, 8); - - *session_key = data_blob(NULL, 16); + if (lm_response) { + *lm_response = LMv2_generate_response(ntlm_v2_hash, server_chal); + } - /* The NTLMv2 calculations also provide a session key, for signing etc later */ - /* use only the first 16 bytes of nt_response for session key */ - SMBsesskeygen_ntv2(ntlm_v2_hash, nt_response->data, session_key->data); - return True; } @@ -416,3 +515,4 @@ BOOL decode_pw_buffer(char in_buffer[516], char *new_pwrd, return True; } + -- cgit From 7602aa50fd591e63393def79d55302a22e77c387 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Dec 2003 00:17:30 +0000 Subject: * got rid of UNISTR2 and everything that depends on it * removed a bunch of code that needs to be rewritten using the new interfaces (This used to be commit 9b02b486ef5906516f8cad79dbff5e3dd54cde66) --- source4/libcli/util/credentials.c | 194 -------------------------------------- 1 file changed, 194 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/credentials.c b/source4/libcli/util/credentials.c index 0d521bae8a..2c8f7e7423 100644 --- a/source4/libcli/util/credentials.c +++ b/source4/libcli/util/credentials.c @@ -19,197 +19,3 @@ */ #include "includes.h" - -/**************************************************************************** -represent a credential as a string -****************************************************************************/ -char *credstr(const uchar *cred) -{ - static fstring buf; - slprintf(buf, sizeof(buf) - 1, "%02X%02X%02X%02X%02X%02X%02X%02X", - cred[0], cred[1], cred[2], cred[3], - cred[4], cred[5], cred[6], cred[7]); - return buf; -} - - -/**************************************************************************** - setup the session key. -Input: 8 byte challenge block - 8 byte server challenge block - 16 byte md4 encrypted password -Output: - 8 byte session key -****************************************************************************/ -void cred_session_key(const DOM_CHAL *clnt_chal, const DOM_CHAL *srv_chal, const uchar *pass, - uchar session_key[8]) -{ - uint32 sum[2]; - unsigned char sum2[8]; - - sum[0] = IVAL(clnt_chal->data, 0) + IVAL(srv_chal->data, 0); - sum[1] = IVAL(clnt_chal->data, 4) + IVAL(srv_chal->data, 4); - - SIVAL(sum2,0,sum[0]); - SIVAL(sum2,4,sum[1]); - - cred_hash1(session_key, sum2, pass); - - /* debug output */ - DEBUG(4,("cred_session_key\n")); - - DEBUG(5,(" clnt_chal: %s\n", credstr(clnt_chal->data))); - DEBUG(5,(" srv_chal : %s\n", credstr(srv_chal->data))); - DEBUG(5,(" clnt+srv : %s\n", credstr(sum2))); - DEBUG(5,(" sess_key : %s\n", credstr(session_key))); -} - - -/**************************************************************************** -create a credential - -Input: - 8 byte sesssion key - 8 byte stored credential - 4 byte timestamp - -Output: - 8 byte credential -****************************************************************************/ -void cred_create(uchar session_key[8], DOM_CHAL *stor_cred, UTIME timestamp, - DOM_CHAL *cred) -{ - DOM_CHAL time_cred; - - SIVAL(time_cred.data, 0, IVAL(stor_cred->data, 0) + timestamp.time); - SIVAL(time_cred.data, 4, IVAL(stor_cred->data, 4)); - - cred_hash2(cred->data, time_cred.data, session_key); - - /* debug output*/ - DEBUG(4,("cred_create\n")); - - DEBUG(5,(" sess_key : %s\n", credstr(session_key))); - DEBUG(5,(" stor_cred: %s\n", credstr(stor_cred->data))); - DEBUG(5,(" timestamp: %x\n" , timestamp.time)); - DEBUG(5,(" timecred : %s\n", credstr(time_cred.data))); - DEBUG(5,(" calc_cred: %s\n", credstr(cred->data))); -} - - -/**************************************************************************** - check a supplied credential - -Input: - 8 byte received credential - 8 byte sesssion key - 8 byte stored credential - 4 byte timestamp - -Output: - returns 1 if computed credential matches received credential - returns 0 otherwise -****************************************************************************/ -int cred_assert(DOM_CHAL *cred, uchar session_key[8], DOM_CHAL *stored_cred, - UTIME timestamp) -{ - DOM_CHAL cred2; - - cred_create(session_key, stored_cred, timestamp, &cred2); - - /* debug output*/ - DEBUG(4,("cred_assert\n")); - - DEBUG(5,(" challenge : %s\n", credstr(cred->data))); - DEBUG(5,(" calculated: %s\n", credstr(cred2.data))); - - if (memcmp(cred->data, cred2.data, 8) == 0) - { - DEBUG(5, ("credentials check ok\n")); - return True; - } - else - { - DEBUG(5, ("credentials check wrong\n")); - return False; - } -} - - -/**************************************************************************** - checks credentials; generates next step in the credential chain -****************************************************************************/ -BOOL clnt_deal_with_creds(uchar sess_key[8], - DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_srv_cred) -{ - UTIME new_clnt_time; - uint32 new_cred; - - DEBUG(5,("clnt_deal_with_creds: %d\n", __LINE__)); - - /* increment client time by one second */ - new_clnt_time.time = sto_clnt_cred->timestamp.time + 1; - - /* check that the received server credentials are valid */ - if (!cred_assert(&rcv_srv_cred->challenge, sess_key, - &sto_clnt_cred->challenge, new_clnt_time)) - { - return False; - } - - /* first 4 bytes of the new seed is old client 4 bytes + clnt time + 1 */ - new_cred = IVAL(sto_clnt_cred->challenge.data, 0); - new_cred += new_clnt_time.time; - - /* store new seed in client credentials */ - SIVAL(sto_clnt_cred->challenge.data, 0, new_cred); - - DEBUG(5,(" new clnt cred: %s\n", credstr(sto_clnt_cred->challenge.data))); - return True; -} - - -/**************************************************************************** - checks credentials; generates next step in the credential chain -****************************************************************************/ -BOOL deal_with_creds(uchar sess_key[8], - DOM_CRED *sto_clnt_cred, - DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred) -{ - UTIME new_clnt_time; - uint32 new_cred; - - DEBUG(5,("deal_with_creds: %d\n", __LINE__)); - - /* check that the received client credentials are valid */ - if (!cred_assert(&rcv_clnt_cred->challenge, sess_key, - &sto_clnt_cred->challenge, rcv_clnt_cred->timestamp)) - { - return False; - } - - /* increment client time by one second */ - new_clnt_time.time = rcv_clnt_cred->timestamp.time + 1; - - /* first 4 bytes of the new seed is old client 4 bytes + clnt time + 1 */ - new_cred = IVAL(sto_clnt_cred->challenge.data, 0); - new_cred += new_clnt_time.time; - - DEBUG(5,("deal_with_creds: new_cred[0]=%x\n", new_cred)); - - /* doesn't matter that server time is 0 */ - rtn_srv_cred->timestamp.time = 0; - - DEBUG(5,("deal_with_creds: new_clnt_time=%x\n", new_clnt_time.time)); - - /* create return credentials for inclusion in the reply */ - cred_create(sess_key, &sto_clnt_cred->challenge, new_clnt_time, - &rtn_srv_cred->challenge); - - DEBUG(5,("deal_with_creds: clnt_cred=%s\n", credstr(sto_clnt_cred->challenge.data))); - - /* store new seed in client credentials */ - SIVAL(sto_clnt_cred->challenge.data, 0, new_cred); - - return True; -} -- cgit From b4b0177fdb5f1704a7347552e48b2ab647a03d14 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Dec 2003 04:13:43 +0000 Subject: added netr_ServerAuthenticate() and test code I would like the netlogon test suite to eventually do a new domain join using a fake workstation name, then remove itself afterwards, but for now I'm assuming we are already joined to the domain when the testsuite runs. This means you need to use the Samba3 net command to do a join before running RPC-NETLOGON (This used to be commit 8c7a9446a0892a4f7722cced5019667f7a9fafdd) --- source4/libcli/util/credentials.c | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 source4/libcli/util/credentials.c (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/credentials.c b/source4/libcli/util/credentials.c deleted file mode 100644 index 2c8f7e7423..0000000000 --- a/source4/libcli/util/credentials.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - Unix SMB/CIFS implementation. - code to manipulate domain credentials - Copyright (C) Andrew Tridgell 1997-1998 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -- cgit From 8b30b0071cb7668f49b2ea5951d1180bf90371e3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Dec 2003 22:13:11 +0000 Subject: * another small API change in the credentials code * don't use static variables in the smbdes code (This used to be commit e6e09064646c347169852fa162c72fc0542c6d5c) --- source4/libcli/util/smbdes.c | 82 +++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 42 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index cde77f94a3..e5c4c6f3f1 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -306,7 +306,7 @@ static void smbhash(unsigned char *out, const unsigned char *in, const unsigned void E_P16(const unsigned char *p14,unsigned char *p16) { - unsigned char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; + unsigned const char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; smbhash(p16, sp8, p14, 1); smbhash(p16+8, sp8, p14+7, 1); } @@ -341,8 +341,8 @@ void cred_hash1(unsigned char *out, const unsigned char *in, const unsigned char void cred_hash2(unsigned char *out, const unsigned char *in, const unsigned char *key) { unsigned char buf[8]; - static unsigned char key2[8]; - + unsigned char key2[8]; + ZERO_STRUCT(key2); smbhash(buf, in, key, 1); key2[0] = key[7]; smbhash(out, buf, key2, 1); @@ -350,8 +350,8 @@ void cred_hash2(unsigned char *out, const unsigned char *in, const unsigned char void cred_hash3(unsigned char *out, unsigned char *in, const unsigned char *key, int forw) { - static unsigned char key2[8]; - + unsigned char key2[8]; + ZERO_STRUCT(key2); smbhash(out, in, key, forw); key2[0] = key[7]; smbhash(out + 8, in + 8, key2, forw); @@ -359,48 +359,46 @@ void cred_hash3(unsigned char *out, unsigned char *in, const unsigned char *key, void SamOEMhash( unsigned char *data, const unsigned char *key, int val) { - unsigned char s_box[256]; - unsigned char index_i = 0; - unsigned char index_j = 0; - unsigned char j = 0; - int ind; - - for (ind = 0; ind < 256; ind++) - { - s_box[ind] = (unsigned char)ind; - } - - for( ind = 0; ind < 256; ind++) - { - unsigned char tc; - - j += (s_box[ind] + key[ind%16]); - - tc = s_box[ind]; - s_box[ind] = s_box[j]; - s_box[j] = tc; - } - for( ind = 0; ind < val; ind++) - { - unsigned char tc; - unsigned char t; - - index_i++; - index_j += s_box[index_i]; - - tc = s_box[index_i]; - s_box[index_i] = s_box[index_j]; - s_box[index_j] = tc; - - t = s_box[index_i] + s_box[index_j]; - data[ind] = data[ind] ^ s_box[t]; - } + unsigned char s_box[256]; + unsigned char index_i = 0; + unsigned char index_j = 0; + unsigned char j = 0; + int ind; + + for (ind = 0; ind < 256; ind++) { + s_box[ind] = (unsigned char)ind; + } + + for( ind = 0; ind < 256; ind++) { + unsigned char tc; + + j += (s_box[ind] + key[ind%16]); + + tc = s_box[ind]; + s_box[ind] = s_box[j]; + s_box[j] = tc; + } + + for (ind = 0; ind < val; ind++){ + unsigned char tc; + unsigned char t; + + index_i++; + index_j += s_box[index_i]; + + tc = s_box[index_i]; + s_box[index_i] = s_box[index_j]; + s_box[index_j] = tc; + + t = s_box[index_i] + s_box[index_j]; + data[ind] = data[ind] ^ s_box[t]; + } } + /* Decode a sam password hash into a password. The password hash is the same method used to store passwords in the NT registry. The DES key used is based on the RID of the user. */ - void sam_pwd_hash(unsigned int rid, const uchar *in, uchar *out, int forw) { uchar s[14]; -- cgit From 4639eb5a58f8c0906afdc8e8f8f67f82e9547f75 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 8 Feb 2004 00:51:07 +0000 Subject: Convert libcli routines to use cli_tree instead of cli_state. Port smbtorture to use the new interface. Part 2 will be to eliminate cli_state from smbtorture as this is now the only place where it is used. (This used to be commit db1cc96af62ea42837d60592877fc3f93cef143b) --- source4/libcli/util/clierror.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clierror.c b/source4/libcli/util/clierror.c index 4fa1daa3be..97436d2106 100644 --- a/source4/libcli/util/clierror.c +++ b/source4/libcli/util/clierror.c @@ -25,14 +25,15 @@ /*************************************************************************** Return an error message from the last response ****************************************************************************/ -const char *cli_errstr(struct cli_state *cli) +const char *cli_errstr(struct cli_tree *tree) { - switch (cli->transport->error.etype) { + switch (tree->session->transport->error.etype) { case ETYPE_DOS: - return dos_errstr(cli->transport->error.e.dos.eclass, - cli->transport->error.e.dos.ecode); + return dos_errstr( + tree->session->transport->error.e.dos.eclass, + tree->session->transport->error.e.dos.ecode); case ETYPE_NT: - return nt_errstr(cli->transport->error.e.nt_status); + return nt_errstr(tree->session->transport->error.e.nt_status); case ETYPE_SOCKET: return "socket_error"; @@ -48,15 +49,16 @@ const char *cli_errstr(struct cli_state *cli) /* Return the 32-bit NT status code from the last packet */ -NTSTATUS cli_nt_error(struct cli_state *cli) +NTSTATUS cli_nt_error(struct cli_tree *tree) { - switch (cli->transport->error.etype) { + switch (tree->session->transport->error.etype) { case ETYPE_NT: - return cli->transport->error.e.nt_status; + return tree->session->transport->error.e.nt_status; case ETYPE_DOS: - return dos_to_ntstatus(cli->transport->error.e.dos.eclass, - cli->transport->error.e.dos.ecode); + return dos_to_ntstatus( + tree->session->transport->error.e.dos.eclass, + tree->session->transport->error.e.dos.ecode); case ETYPE_SOCKET: return NT_STATUS_UNSUCCESSFUL; @@ -87,13 +89,13 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) /* Return true if the last packet was an error */ -BOOL cli_is_error(struct cli_state *cli) +BOOL cli_is_error(struct cli_tree *tree) { - return NT_STATUS_IS_ERR(cli_nt_error(cli)); + return NT_STATUS_IS_ERR(cli_nt_error(tree)); } /* 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_tree *tree) { - return cli->transport->error.etype == ETYPE_DOS; + return tree->session->transport->error.etype == ETYPE_DOS; } -- cgit From b087ed482115520a6c18e9a1c02accce0014d80f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 5 Apr 2004 08:44:08 +0000 Subject: r23: get rid of def_finfo (This used to be commit 25b7ec390aec3e324c4c7ad8edbc90fc8896b230) --- source4/libcli/util/cliutil.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/cliutil.c b/source4/libcli/util/cliutil.c index 13b3dad0bf..56dee7381a 100644 --- a/source4/libcli/util/cliutil.c +++ b/source4/libcli/util/cliutil.c @@ -24,9 +24,6 @@ Functions nicked from lib/util.c needed by client. *******************************************************************/ -/* a default finfo structure to ensure all fields are sensible */ -file_info def_finfo = {-1,0,0,0,0,0,0,"",""}; - /******************************************************************* A wrapper that handles case sensitivity and the special handling of the ".." name. -- cgit From 984bfce2d9de9eb73e09887b720d219566242398 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 7 Apr 2004 07:20:53 +0000 Subject: r101: added lsa_SetSecret() and lsa_QuerySecret() this required some crypto infrastructure and some sid utilities (This used to be commit 37d0efa9c2af8532536bea88412f0dd3ed39ecfc) --- source4/libcli/util/dom_sid.c | 90 +++++++++++++++++++++++++++++++++++++++++++ source4/libcli/util/smbdes.c | 2 +- 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 source4/libcli/util/dom_sid.c (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/dom_sid.c b/source4/libcli/util/dom_sid.c new file mode 100644 index 0000000000..652f17a6b6 --- /dev/null +++ b/source4/libcli/util/dom_sid.c @@ -0,0 +1,90 @@ +/* + Unix SMB/CIFS implementation. + + routines to manipulate a "struct dom_sid" + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* + convert a string to a dom_sid, returning a talloc'd dom_sid +*/ +struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) +{ + struct dom_sid *ret; + unsigned int rev, ia, num_sub_auths, i; + char *p; + + if (strncasecmp(sidstr, "S-", 2)) { + return NULL; + } + + sidstr += 2; + + rev = strtol(sidstr, &p, 10); + if (*p != '-') { + return NULL; + } + sidstr = p+1; + + ia = strtol(sidstr, &p, 10); + if (*p != '-') { + return NULL; + } + sidstr = p+1; + + num_sub_auths = 0; + for (i=0;sidstr[i];i++) { + if (sidstr[i] == '-') num_sub_auths++; + } + + ret = talloc_p(mem_ctx, struct dom_sid); + if (!ret) { + return NULL; + } + + ret->sub_auths = talloc_array_p(mem_ctx, uint32, num_sub_auths); + if (!ret->sub_auths) { + return NULL; + } + + ret->sid_rev_num = rev; + ret->id_auth[0] = 0; + ret->id_auth[0] = 0; + ret->id_auth[1] = 0; + ret->id_auth[2] = ia >> 24; + ret->id_auth[3] = ia >> 16; + ret->id_auth[4] = ia >> 8; + ret->id_auth[5] = ia; + ret->num_auths = num_sub_auths; + + for (i=0;isub_auths[i] = strtol(sidstr, &p, 10); + if (p == sidstr) { + return NULL; + } + if (*p != '-' && i < num_sub_auths-1) { + return NULL; + } + sidstr = p+1; + } + + return ret; +} + diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index e5c4c6f3f1..d282b0135a 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -276,7 +276,7 @@ static void str_to_key(const unsigned char *str,unsigned char *key) } -static void smbhash(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw) +void smbhash(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw) { int i; char outb[64]; -- cgit From ac193579e7db00c7a2ea0aadaaf0d34c10dcf1a5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 10 Apr 2004 20:18:22 +0000 Subject: r152: a quick airport commit .... added ldbedit, a _really_ useful command added ldbadd, ldbdel, ldbsearch and ldbmodify to build solved lots of timezone issues, we now pass the torture tests with client and server in different zones fixed several build issues I know this breaks the no-LDAP build. Wait till I arrive in San Jose for that fix. (This used to be commit af34710d4da1841653624fe304b1c8d812c0fdd9) --- source4/libcli/util/smbencrypt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 39f3803ade..fc3449d767 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -342,10 +342,13 @@ static DATA_BLOB NTLMv2_generate_client_data(const DATA_BLOB *names_blob) uchar client_chal[8]; DATA_BLOB response = data_blob(NULL, 0); char long_date[8]; + NTTIME nttime; + + unix_to_nt_time(&nttime, time(NULL)); generate_random_buffer(client_chal, sizeof(client_chal), False); - put_long_date(long_date, time(NULL)); + push_nttime(long_date, 0, &nttime); /* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */ -- cgit From b9411f8aca7d3619551adaa09cd632cb507a6c7c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 18 Apr 2004 03:57:09 +0000 Subject: r265: fixed a bug in the string to sid conversion code (This used to be commit 117aa5cab7783ea741d4840ea5ced00cf34868a3) --- source4/libcli/util/dom_sid.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/dom_sid.c b/source4/libcli/util/dom_sid.c index 652f17a6b6..dbc9c20155 100644 --- a/source4/libcli/util/dom_sid.c +++ b/source4/libcli/util/dom_sid.c @@ -44,10 +44,10 @@ struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) sidstr = p+1; ia = strtol(sidstr, &p, 10); - if (*p != '-') { + if (p == sidstr) { return NULL; } - sidstr = p+1; + sidstr = p; num_sub_auths = 0; for (i=0;sidstr[i];i++) { @@ -75,14 +75,15 @@ struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) ret->num_auths = num_sub_auths; for (i=0;isub_auths[i] = strtol(sidstr, &p, 10); - if (p == sidstr) { + if (sidstr[0] != '-') { return NULL; } - if (*p != '-' && i < num_sub_auths-1) { + sidstr++; + ret->sub_auths[i] = strtol(sidstr, &p, 10); + if (p == sidstr) { return NULL; } - sidstr = p+1; + sidstr = p; } return ret; -- cgit From 8fce9e3c549bcf1433119333ddbbf0a3dc4af8d9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 19 Apr 2004 05:48:03 +0000 Subject: r275: added IDL and test code for samr_QueryDisplayInfo3(), samr_AddMultipleMembersToAlias(), samr_RemoveMultipleMembersFromAlias(), samr_OemChangePasswordUser2(), and samr_ChangePasswordUser2() The password change functions don't actually work yet (but should soon). At this stage I have just completed the IDL for them. Next step is to get the hash verifiers right and the torture test should be able to do password changes. (This used to be commit 849d0d314a2add80f2b2be6b503fea05973f998e) --- source4/libcli/util/smbencrypt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index fc3449d767..13d56e1e78 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -217,7 +217,9 @@ void SMBNTencrypt(const char *passwd, uchar *c8, uchar *p24) #endif } -BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode) +BOOL make_oem_passwd_hash(char data[516], const char *passwd, + const uchar old_pw_hash[16], + BOOL unicode) { int new_pw_len = strlen(passwd) * (unicode ? 2 : 1); @@ -242,7 +244,9 @@ BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[ DEBUG(100,("make_oem_passwd_hash\n")); dump_data(100, data, 516); #endif - SamOEMhash( (unsigned char *)data, (unsigned char *)old_pw_hash, 516); + SamOEMhash((unsigned char *)data, + (const unsigned char *)old_pw_hash, + 516); return True; } -- cgit From 5f545543f0bfb9d97d6401576906c0ba9e596cd1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 21 Apr 2004 05:01:31 +0000 Subject: r305: - added IDL and test code for samr_RidToSid() - completed the IDL and test code for the various set user password mechanisms in samr. Three password mechanisms are now working, the UserInfo24 method, the OemChangePasswordUser2() method (which only sets the LM password) and the ChangePasswordUser2() method which sets both the LM and NT passwords. - updated some crypto routines to support the password change tests (This used to be commit 051efa2abf9d1fbbf783df411c02f2714027f813) --- source4/libcli/util/smbdes.c | 30 ++++++++++++++++++++++-------- source4/libcli/util/smbencrypt.c | 21 ++++++++++++++------- 2 files changed, 36 insertions(+), 15 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index d282b0135a..80b938b460 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -357,7 +357,8 @@ void cred_hash3(unsigned char *out, unsigned char *in, const unsigned char *key, smbhash(out + 8, in + 8, key2, forw); } -void SamOEMhash( unsigned char *data, const unsigned char *key, int val) + +void SamOEMhashBlob(unsigned char *data, int len, const DATA_BLOB *key) { unsigned char s_box[256]; unsigned char index_i = 0; @@ -369,23 +370,22 @@ void SamOEMhash( unsigned char *data, const unsigned char *key, int val) s_box[ind] = (unsigned char)ind; } - for( ind = 0; ind < 256; ind++) { + for (ind = 0; ind < 256; ind++) { unsigned char tc; - - j += (s_box[ind] + key[ind%16]); - + + j += (s_box[ind] + key->data[ind%key->length]); + tc = s_box[ind]; s_box[ind] = s_box[j]; s_box[j] = tc; } - - for (ind = 0; ind < val; ind++){ + for (ind = 0; ind < len; ind++) { unsigned char tc; unsigned char t; index_i++; index_j += s_box[index_i]; - + tc = s_box[index_i]; s_box[index_i] = s_box[index_j]; s_box[index_j] = tc; @@ -395,6 +395,20 @@ void SamOEMhash( unsigned char *data, const unsigned char *key, int val) } } +/* + a varient that assumes a 16 byte key. This should be removed + when the last user is gone +*/ +void SamOEMhash(unsigned char *data, const unsigned char keystr[16], int len) +{ + DATA_BLOB key; + + key.length = 16; + key.data = keystr; + + SamOEMhashBlob(data, len, &key); +} + /* Decode a sam password hash into a password. The password hash is the same method used to store passwords in the NT registry. The DES key diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 13d56e1e78..a1c026a27d 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -460,21 +460,28 @@ BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password } /*********************************************************** - encode a password buffer. The caller gets to figure out - what to put in it. + encode a password buffer with a unicode password. The buffer + is filled with random data to make it harder to attack. ************************************************************/ -BOOL encode_pw_buffer(char buffer[516], char *new_pw, int new_pw_length) +BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) { - generate_random_buffer((unsigned char *)buffer, 516, True); + uchar new_pw[512]; + size_t new_pw_len; - memcpy(&buffer[512 - new_pw_length], new_pw, new_pw_length); + new_pw_len = push_string(NULL, new_pw, + password, + sizeof(new_pw), string_flags); + + memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len); + + generate_random_buffer((unsigned char *)buffer, 512 - new_pw_len, True); /* * The length of the new password is in the last 4 bytes of * the data buffer. */ - SIVAL(buffer, 512, new_pw_length); - + SIVAL(buffer, 512, new_pw_len); + ZERO_STRUCT(new_pw); return True; } -- cgit From 2b9fb9618ad8b2b468b0f9961f35a2b0db9d53b5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Apr 2004 06:18:40 +0000 Subject: r324: - don't reseed on every password generate - check for overflow (very unlikely) in random buffer generation (This used to be commit 548ec1efefa6f337a362cbadae74f177774e9e29) --- source4/libcli/util/smbencrypt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index a1c026a27d..a091805345 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -471,10 +471,13 @@ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) new_pw_len = push_string(NULL, new_pw, password, sizeof(new_pw), string_flags); + if (new_pw_len > 512) { + return False; + } memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len); - generate_random_buffer((unsigned char *)buffer, 512 - new_pw_len, True); + generate_random_buffer((unsigned char *)buffer, 512 - new_pw_len, False); /* * The length of the new password is in the last 4 bytes of @@ -485,6 +488,7 @@ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) return True; } + /*********************************************************** decode a password buffer *new_pw_len is the length in bytes of the possibly mulitbyte -- cgit From 9f084101dd392ceb85f141f55ee56bed344626ef Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 2 May 2004 08:45:00 +0000 Subject: r443: Update Samba4 to the auth and NTLMSSP code from Samba3. Not all the auth code is merged - only those parts that are actually being used in Samba4. There is a lot more work to do in the NTLMSSP area, and I hope to develop that work here. There is a start on this here - splitting NTLMSSP into two parts that my operate in an async fashion (before and after the actual authentication) Andrew Bartlett (This used to be commit 5876c78806e6a6c44613a1354e8d564b427d0c9f) --- source4/libcli/util/smbencrypt.c | 121 ++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 59 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index a091805345..4b2c753637 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -28,13 +28,17 @@ /* This implements the X/Open SMB password encryption It takes a password ('unix' string), a 8 byte "crypt key" - and puts 24 bytes of encrypted password into p24 */ -void SMBencrypt(const char *passwd, const uchar *c8, uchar p24[24]) + and puts 24 bytes of encrypted password into p24 + + Returns False if password must have been truncated to create LM hash +*/ +BOOL SMBencrypt(const char *passwd, const uchar *c8, uchar p24[24]) { + BOOL ret; uchar p21[21]; memset(p21,'\0',21); - E_deshash(passwd, p21); + ret = E_deshash(passwd, p21); SMBOWFencrypt(p21, c8, p24); @@ -44,6 +48,8 @@ void SMBencrypt(const char *passwd, const uchar *c8, uchar p24[24]) dump_data(100, (const char *)c8, 8); dump_data(100, (char *)p24, 24); #endif + + return ret; } /** @@ -70,20 +76,29 @@ void E_md4hash(const char *passwd, uchar p16[16]) * Creates the DES forward-only Hash of the users password in DOS ASCII charset * @param passwd password in 'unix' charset. * @param p16 return password hashed with DES, caller allocated 16 byte buffer + * @return False if password was > 14 characters, and therefore may be incorrect, otherwise True + * @note p16 is filled in regardless */ -void E_deshash(const char *passwd, uchar p16[16]) +BOOL E_deshash(const char *passwd, uchar p16[16]) { + BOOL ret = True; fstring dospwd; ZERO_STRUCT(dospwd); /* Password must be converted to DOS charset - null terminated, uppercase. */ push_ascii(dospwd, passwd, sizeof(dospwd), STR_UPPER|STR_TERMINATE); - + /* Only the fisrt 14 chars are considered, password need not be null terminated. */ E_P16((const unsigned char *)dospwd, p16); + if (strlen(dospwd) > 14) { + ret = False; + } + ZERO_STRUCT(dospwd); + + return ret; } /** @@ -118,7 +133,9 @@ void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar p16[16]) /* Does both the NTLMv2 owfs of a user's password */ BOOL ntv2_owf_gen(const uchar owf[16], - const char *user_in, const char *domain_in, uchar kr_buf[16]) + const char *user_in, const char *domain_in, + BOOL upper_case_domain, /* Transform the domain into UPPER case */ + uchar kr_buf[16]) { smb_ucs2_t *user; smb_ucs2_t *domain; @@ -141,7 +158,9 @@ BOOL ntv2_owf_gen(const uchar owf[16], } strupper_w(user); - strupper_w(domain); + + if (upper_case_domain) + strupper_w(domain); SMB_ASSERT(user_byte_len >= 2); SMB_ASSERT(domain_byte_len >= 2); @@ -217,40 +236,6 @@ void SMBNTencrypt(const char *passwd, uchar *c8, uchar *p24) #endif } -BOOL make_oem_passwd_hash(char data[516], const char *passwd, - const uchar old_pw_hash[16], - BOOL unicode) -{ - int new_pw_len = strlen(passwd) * (unicode ? 2 : 1); - - if (new_pw_len > 512) - { - DEBUG(0,("make_oem_passwd_hash: new password is too long.\n")); - return False; - } - - /* - * Now setup the data area. - * We need to generate a random fill - * for this area to make it harder to - * decrypt. JRA. - */ - generate_random_buffer((unsigned char *)data, 516, False); - push_string(NULL, &data[512 - new_pw_len], passwd, new_pw_len, - STR_NOALIGN | (unicode?STR_UNICODE:STR_ASCII)); - SIVAL(data, 512, new_pw_len); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("make_oem_passwd_hash\n")); - dump_data(100, data, 516); -#endif - SamOEMhash((unsigned char *)data, - (const unsigned char *)old_pw_hash, - 516); - - return True; -} - /* Does the md5 encryption from the Key Response for NTLMv2. */ void SMBOWFencrypt_ntv2(const uchar kr[16], const DATA_BLOB *srv_chal, @@ -329,15 +314,35 @@ void SMBsesskeygen_lmv1(const uchar lm_hash[16], #endif } +void SMBsesskeygen_lm_sess_key(const uchar lm_hash[16], + const uchar lm_resp[24], /* only uses 8 */ + uint8 sess_key[16]) +{ + uchar p24[24]; + uchar partial_lm_hash[16]; + + memcpy(partial_lm_hash, lm_hash, 8); + memset(partial_lm_hash + 8, 0xbd, 8); + + SMBOWFencrypt(partial_lm_hash, lm_resp, p24); + + memcpy(sess_key, p24, 16); + +#ifdef DEBUG_PASSWORD + DEBUG(100, ("SMBsesskeygen_lmv1_jerry:\n")); + dump_data(100, sess_key, 16); +#endif +} + DATA_BLOB NTLMv2_generate_names_blob(const char *hostname, const char *domain) { DATA_BLOB names_blob = data_blob(NULL, 0); msrpc_gen(&names_blob, "aaa", - True, NTLMSSP_NAME_TYPE_DOMAIN, domain, - True, NTLMSSP_NAME_TYPE_SERVER, hostname, - True, 0, ""); + NTLMSSP_NAME_TYPE_DOMAIN, domain, + NTLMSSP_NAME_TYPE_SERVER, hostname, + 0, ""); return names_blob; } @@ -424,7 +429,7 @@ BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password const DATA_BLOB *server_chal, const DATA_BLOB *names_blob, DATA_BLOB *lm_response, DATA_BLOB *nt_response, - DATA_BLOB *nt_session_key) + DATA_BLOB *user_session_key) { uchar nt_hash[16]; uchar ntlm_v2_hash[16]; @@ -434,19 +439,19 @@ BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password the username and domain. This prevents username swapping during the auth exchange */ - if (!ntv2_owf_gen(nt_hash, user, domain, ntlm_v2_hash)) { + if (!ntv2_owf_gen(nt_hash, user, domain, True, ntlm_v2_hash)) { return False; } if (nt_response) { *nt_response = NTLMv2_generate_response(ntlm_v2_hash, server_chal, names_blob); - if (nt_session_key) { - *nt_session_key = data_blob(NULL, 16); + if (user_session_key) { + *user_session_key = data_blob(NULL, 16); /* The NTLMv2 calculations also provide a session key, for signing etc later */ /* use only the first 16 bytes of nt_response for session key */ - SMBsesskeygen_ntv2(ntlm_v2_hash, nt_response->data, nt_session_key->data); + SMBsesskeygen_ntv2(ntlm_v2_hash, nt_response->data, user_session_key->data); } } @@ -471,9 +476,6 @@ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) new_pw_len = push_string(NULL, new_pw, password, sizeof(new_pw), string_flags); - if (new_pw_len > 512) { - return False; - } memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len); @@ -495,13 +497,14 @@ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) returned password including termination. ************************************************************/ BOOL decode_pw_buffer(char in_buffer[516], char *new_pwrd, - int new_pwrd_size, uint32 *new_pw_len) + int new_pwrd_size, uint32 *new_pw_len, + int string_flags) { int byte_len=0; /* Warning !!! : This function is called from some rpc call. - The password IN the buffer is a UNICODE string. + The password IN the buffer may be a UNICODE string. The password IN new_pwrd is an ASCII string If you reuse that code somewhere else check first. */ @@ -514,15 +517,16 @@ BOOL decode_pw_buffer(char in_buffer[516], char *new_pwrd, dump_data(100, in_buffer, 516); #endif - /* Password cannot be longer than 128 characters */ - if ( (byte_len < 0) || (byte_len > new_pwrd_size - 1)) { + /* Password cannot be longer than the size of the password buffer */ + if ( (byte_len < 0) || (byte_len > 512)) { DEBUG(0, ("decode_pw_buffer: incorrect password length (%d).\n", byte_len)); DEBUG(0, ("decode_pw_buffer: check that 'encrypt passwords = yes'\n")); return False; } - /* decode into the return buffer. Buffer must be a pstring */ - *new_pw_len = pull_string(NULL, new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, byte_len, STR_UNICODE); + /* decode into the return buffer. Buffer length supplied */ + *new_pw_len = pull_string(NULL, new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, + byte_len, string_flags); #ifdef DEBUG_PASSWORD DEBUG(100,("decode_pw_buffer: new_pwrd: ")); @@ -533,4 +537,3 @@ BOOL decode_pw_buffer(char in_buffer[516], char *new_pwrd, return True; } - -- cgit From d8bb3d81a6396c4051be00de0808c60839b6945e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 2 May 2004 12:42:01 +0000 Subject: r451: More NTLMSSP work. The work here is trying to get the LM_KEY option for NLTMSSP operating, however until that functions properly, it is now controlled by some new smb.conf options, defaulting off. Andrew Bartlett (This used to be commit c63eb35b45c6db6e4c5302d1832bb5cef49a14f6) --- source4/libcli/util/smbencrypt.c | 62 +++++++--------------------------------- 1 file changed, 10 insertions(+), 52 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 4b2c753637..cefd01bf1c 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -198,25 +198,6 @@ void SMBOWFencrypt(const uchar passwd[16], const uchar *c8, uchar p24[24]) E_P24(p21, c8, p24); } -/* Does the des encryption from the FIRST 8 BYTES of the NT or LM MD4 hash. */ -void NTLMSSPOWFencrypt(const uchar passwd[8], const uchar *ntlmchalresp, uchar p24[24]) -{ - uchar p21[21]; - - memset(p21,'\0',21); - memcpy(p21, passwd, 8); - memset(p21 + 8, 0xbd, 8); - - E_P24(p21, ntlmchalresp, p24); -#ifdef DEBUG_PASSWORD - DEBUG(100,("NTLMSSPOWFencrypt: p21, c8, p24\n")); - dump_data(100, (char *)p21, 21); - dump_data(100, (const char *)ntlmchalresp, 8); - dump_data(100, (char *)p24, 24); -#endif -} - - /* Does the NT MD4 hash then des encryption. */ void SMBNTencrypt(const char *passwd, uchar *c8, uchar *p24) @@ -288,48 +269,25 @@ void SMBsesskeygen_ntv1(const uchar kr[16], #endif } -void SMBsesskeygen_lmv1(const uchar lm_hash[16], - const uchar lm_resp[24], /* only uses 8 */ - uint8 sess_key[16]) +void SMBsesskeygen_lm_sess_key(const uchar lm_hash[16], + const uchar lm_resp[24], /* only uses 8 */ + uint8 sess_key[16]) { /* Calculate the LM session key (effective length 40 bits, but changes with each session) */ - uchar p24[24]; - uchar partial_lm_hash[16]; - - memcpy(partial_lm_hash, lm_hash, 8); - memset(partial_lm_hash + 8, 0xbd, 8); - - SMBOWFencrypt(lm_hash, lm_resp, p24); - - memcpy(sess_key, p24, 16); - sess_key[5] = 0xe5; - sess_key[6] = 0x38; - sess_key[7] = 0xb0; - -#ifdef DEBUG_PASSWORD - DEBUG(100, ("SMBsesskeygen_lmv1:\n")); - dump_data(100, sess_key, 16); -#endif -} + uchar p21[21]; + + memset(p21,'\0',21); + memcpy(p21, lm_hash, 8); + memset(p21 + 8, 0xbd, 8); -void SMBsesskeygen_lm_sess_key(const uchar lm_hash[16], - const uchar lm_resp[24], /* only uses 8 */ - uint8 sess_key[16]) -{ - uchar p24[24]; - uchar partial_lm_hash[16]; - - memcpy(partial_lm_hash, lm_hash, 8); - memset(partial_lm_hash + 8, 0xbd, 8); + E_P24(p21, lm_resp, p24); - SMBOWFencrypt(partial_lm_hash, lm_resp, p24); - memcpy(sess_key, p24, 16); #ifdef DEBUG_PASSWORD - DEBUG(100, ("SMBsesskeygen_lmv1_jerry:\n")); + DEBUG(100, ("SMBsesskeygen_lm_sess_key: \n")); dump_data(100, sess_key, 16); #endif } -- cgit From dce84ffd379012812170f68f7de8aab73123f0b3 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 9 May 2004 12:42:18 +0000 Subject: r610: - Merge the Samba3 'ntlm_auth --diagnostics' testsuite to Samba4. - This required using NETLOGON_NEG_AUTH2_FLAGS for the SetupCredentials2 negotiation flags, which is what Samba3 does, because otherwise the server uses different crypto. - This tests the returned session keys, which we decrypt. - Update the Samba4 notion of a 'session key' to be a DATA_BLOB in most places. - Fix session key code to return NT_STATUS_NO_SESSION_KEY if none is available. - Remove a useless argument to SMBsesskeygen_ntv1 - move netr_CredentialState from the .idl to the new credentials.h Andrew Bartlett (This used to be commit 44f8b5b53e6abd4de8a676f78d729988fadff320) --- source4/libcli/util/smbdes.c | 13 ++++++------- source4/libcli/util/smbencrypt.c | 3 +-- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index 80b938b460..22bafcb449 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -338,14 +338,14 @@ void cred_hash1(unsigned char *out, const unsigned char *in, const unsigned char smbhash(out, buf, key+9, 1); } -void cred_hash2(unsigned char *out, const unsigned char *in, const unsigned char *key) +void cred_hash2(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw) { unsigned char buf[8]; unsigned char key2[8]; ZERO_STRUCT(key2); - smbhash(buf, in, key, 1); + smbhash(buf, in, key, forw); key2[0] = key[7]; - smbhash(out, buf, key2, 1); + smbhash(out, buf, key2, forw); } void cred_hash3(unsigned char *out, unsigned char *in, const unsigned char *key, int forw) @@ -401,12 +401,11 @@ void SamOEMhashBlob(unsigned char *data, int len, const DATA_BLOB *key) */ void SamOEMhash(unsigned char *data, const unsigned char keystr[16], int len) { - DATA_BLOB key; - - key.length = 16; - key.data = keystr; + DATA_BLOB key = data_blob(keystr, 16); SamOEMhashBlob(data, len, &key); + + data_blob_free(&key); } diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index cefd01bf1c..5468bdbebe 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -255,8 +255,7 @@ void SMBsesskeygen_ntv2(const uchar kr[16], #endif } -void SMBsesskeygen_ntv1(const uchar kr[16], - const uchar * nt_resp, uint8 sess_key[16]) +void SMBsesskeygen_ntv1(const uchar kr[16], uint8 sess_key[16]) { /* yes, this session key does not change - yes, this is a problem - but it is 128 bits */ -- cgit From 5767c107735f83bd564a30abf8f374b326667966 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 14 May 2004 04:02:22 +0000 Subject: r718: removed some more unused code, and two source files (This used to be commit a9768c25fd32e76514c837f343f2b52bf0f0824d) --- source4/libcli/util/pwd_cache.c | 72 ----------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 source4/libcli/util/pwd_cache.c (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/pwd_cache.c b/source4/libcli/util/pwd_cache.c deleted file mode 100644 index 0d84f04ee3..0000000000 --- a/source4/libcli/util/pwd_cache.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Password cacheing. obfuscation is planned - Copyright (C) Luke Kenneth Casson Leighton 1996-1998 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" - -/**************************************************************************** - Initialises a password structure. -****************************************************************************/ - -static void pwd_init(struct pwd_info *pwd) -{ - memset((char *)pwd->password , '\0', sizeof(pwd->password )); - memset((char *)pwd->smb_lm_pwd, '\0', sizeof(pwd->smb_lm_pwd)); - memset((char *)pwd->smb_nt_pwd, '\0', sizeof(pwd->smb_nt_pwd)); - memset((char *)pwd->smb_lm_owf, '\0', sizeof(pwd->smb_lm_owf)); - memset((char *)pwd->smb_nt_owf, '\0', sizeof(pwd->smb_nt_owf)); - - pwd->null_pwd = True; /* safest option... */ - pwd->cleartext = False; - pwd->crypted = False; -} - -/**************************************************************************** - Makes lm and nt hashed passwords. -****************************************************************************/ - -static void pwd_make_lm_nt_16(struct pwd_info *pwd, const char *clr) -{ - pstring dos_passwd; - - pwd_init(pwd); - - push_ascii_pstring(dos_passwd, clr); - - nt_lm_owf_gen(dos_passwd, pwd->smb_nt_pwd, pwd->smb_lm_pwd); - pwd->null_pwd = False; - pwd->cleartext = False; - pwd->crypted = False; -} - -/**************************************************************************** - Stores a cleartext password. -****************************************************************************/ - -void pwd_set_cleartext(struct pwd_info *pwd, const char *clr) -{ - pwd_init(pwd); - push_ascii_fstring(pwd->password, clr); - pwd->cleartext = True; - pwd->null_pwd = False; - pwd->crypted = False; - pwd_make_lm_nt_16(pwd, clr); -} - - -- cgit From 579c13da43d5b40ac6d6c1436399fbc1d8dfd054 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 25 May 2004 13:57:39 +0000 Subject: r873: converted samba4 to use real 64 bit integers instead of structures. This was suggested by metze recently. I checked on the build farm and all the machines we have support 64 bit ints, and support the LL suffix for 64 bit constants. I suspect some won't support strtoll() and related functions, so we will probably need replacements for those. (This used to be commit 9a9244a1c66654c12abe4379661cba83a73c4c21) --- source4/libcli/util/asn1.c | 12 ++++++------ source4/libcli/util/smbencrypt.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 09d4fbb6c9..07c692f700 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -315,17 +315,17 @@ int asn1_tag_remaining(ASN1_DATA *data) BOOL asn1_read_OID(ASN1_DATA *data, char **OID) { uint8 b; - pstring oid; + pstring aoid; fstring el; if (!asn1_start_tag(data, ASN1_OID)) return False; asn1_read_uint8(data, &b); - oid[0] = 0; + aoid[0] = 0; snprintf(el, sizeof(el), "%u", b/40); - pstrcat(oid, el); + pstrcat(aoid, el); snprintf(el, sizeof(el), " %u", b%40); - pstrcat(oid, el); + pstrcat(aoid, el); while (asn1_tag_remaining(data) > 0) { unsigned v = 0; @@ -334,12 +334,12 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) v = (v<<7) | (b&0x7f); } while (!data->has_error && b & 0x80); snprintf(el, sizeof(el), " %u", v); - pstrcat(oid, el); + pstrcat(aoid, el); } asn1_end_tag(data); - *OID = strdup(oid); + *OID = strdup(aoid); return !data->has_error; } diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 5468bdbebe..013f00d5fa 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -314,7 +314,7 @@ static DATA_BLOB NTLMv2_generate_client_data(const DATA_BLOB *names_blob) generate_random_buffer(client_chal, sizeof(client_chal), False); - push_nttime(long_date, 0, &nttime); + push_nttime(long_date, 0, nttime); /* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */ -- cgit From 5b0ab386cb0fb74d78e6c68abe1b047ab515b7b3 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 25 May 2004 14:06:28 +0000 Subject: r874: This patch is a pile of work on NTLMSSP: Samba's NTLMSSP code is now fully talloc based, which should go a long way to cleaning up the memory leaks in this code. This also avoids a lot of extra copies of data, as we now allocate the 'return' blobs on a caller-supplied context. I have also been doing a lot of work towards NTLM2 signing and sealing. I have this working for sealing, but not for the verifier (MD5 integrity check on the stream) which is still incorrect. (I can aim a rpcecho sinkdata from a Win2k3 box to my server, and the data arrives intact, but the signature check fails. It does however match the test values I have...). The new torture test is cludged in - when we get a unit test suite back, I'll happliy put it in the 'right' place.... Andrew Bartlett (This used to be commit 399e2e2b1149b8d1c070aa7f0d5131c0b577d2b9) --- source4/libcli/util/smbencrypt.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 013f00d5fa..edf1526d2e 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -291,19 +291,20 @@ void SMBsesskeygen_lm_sess_key(const uchar lm_hash[16], #endif } -DATA_BLOB NTLMv2_generate_names_blob(const char *hostname, +DATA_BLOB NTLMv2_generate_names_blob(TALLOC_CTX *mem_ctx, + const char *hostname, const char *domain) { - DATA_BLOB names_blob = data_blob(NULL, 0); + DATA_BLOB names_blob = data_blob_talloc(mem_ctx, NULL, 0); - msrpc_gen(&names_blob, "aaa", + msrpc_gen(mem_ctx, &names_blob, "aaa", NTLMSSP_NAME_TYPE_DOMAIN, domain, NTLMSSP_NAME_TYPE_SERVER, hostname, 0, ""); return names_blob; } -static DATA_BLOB NTLMv2_generate_client_data(const DATA_BLOB *names_blob) +static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLOB *names_blob) { uchar client_chal[8]; DATA_BLOB response = data_blob(NULL, 0); @@ -318,7 +319,7 @@ static DATA_BLOB NTLMv2_generate_client_data(const DATA_BLOB *names_blob) /* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */ - msrpc_gen(&response, "ddbbdb", + msrpc_gen(mem_ctx, &response, "ddbbdb", 0x00000101, /* Header */ 0, /* 'Reserved' */ long_date, 8, /* Timestamp */ @@ -337,10 +338,16 @@ static DATA_BLOB NTLMv2_generate_response(const uchar ntlm_v2_hash[16], DATA_BLOB ntlmv2_client_data; DATA_BLOB final_response; + TALLOC_CTX *mem_ctx = talloc_init("NTLMv2_generate_response internal context"); + + if (!mem_ctx) { + return data_blob(NULL, 0); + } + /* NTLMv2 */ /* generate some data to pass into the response function - including the hostname and domain name of the server */ - ntlmv2_client_data = NTLMv2_generate_client_data(names_blob); + ntlmv2_client_data = NTLMv2_generate_client_data(mem_ctx, names_blob); /* Given that data, and the challenge from the server, generate a response */ SMBOWFencrypt_ntv2(ntlm_v2_hash, server_chal, &ntlmv2_client_data, ntlmv2_response); @@ -352,7 +359,7 @@ static DATA_BLOB NTLMv2_generate_response(const uchar ntlm_v2_hash[16], memcpy(final_response.data+sizeof(ntlmv2_response), ntlmv2_client_data.data, ntlmv2_client_data.length); - data_blob_free(&ntlmv2_client_data); + talloc_destroy(mem_ctx); return final_response; } -- cgit From f9d8f8843dc0ab8c9d59abde7222e0f118b86b5d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 May 2004 16:24:13 +0000 Subject: r884: convert samba4 to use [u]int32_t instead of [u]int32 metze (This used to be commit 0e5517d937a2eb7cf707991d1c7498c1ab456095) --- source4/libcli/util/clierror.c | 2 +- source4/libcli/util/dom_sid.c | 2 +- source4/libcli/util/errormap.c | 8 ++++---- source4/libcli/util/smbencrypt.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clierror.c b/source4/libcli/util/clierror.c index 97436d2106..7b78d191dd 100644 --- a/source4/libcli/util/clierror.c +++ b/source4/libcli/util/clierror.c @@ -75,7 +75,7 @@ NTSTATUS cli_nt_error(struct cli_tree *tree) /* 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) +void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32_t *ecode) { if (cli->transport->error.etype == ETYPE_DOS) { ntstatus_to_dos(cli->transport->error.e.nt_status, diff --git a/source4/libcli/util/dom_sid.c b/source4/libcli/util/dom_sid.c index dbc9c20155..88ece25a8e 100644 --- a/source4/libcli/util/dom_sid.c +++ b/source4/libcli/util/dom_sid.c @@ -59,7 +59,7 @@ struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) return NULL; } - ret->sub_auths = talloc_array_p(mem_ctx, uint32, num_sub_auths); + ret->sub_auths = talloc_array_p(mem_ctx, uint32_t, num_sub_auths); if (!ret->sub_auths) { return NULL; } diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index a257c2d0ea..11a07d45c7 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -47,7 +47,7 @@ /* NT status -> dos error map */ static const struct { uint8 dos_class; - uint32 dos_code; + uint32_t dos_code; NTSTATUS ntstatus; } ntstatus_to_dos_map[] = { {ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, @@ -613,7 +613,7 @@ static const struct { /* dos -> nt status error map */ static const struct { uint8 dos_class; - uint32 dos_code; + uint32_t dos_code; NTSTATUS ntstatus; } dos_to_ntstatus_map[] = { {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, @@ -1410,7 +1410,7 @@ static const struct { /***************************************************************************** convert a dos eclas/ecode to a NT status32 code *****************************************************************************/ -NTSTATUS dos_to_ntstatus(uint8 eclass, uint32 ecode) +NTSTATUS dos_to_ntstatus(uint8 eclass, uint32_t ecode) { int i; if (eclass == 0 && ecode == 0) return NT_STATUS_OK; @@ -1427,7 +1427,7 @@ NTSTATUS dos_to_ntstatus(uint8 eclass, uint32 ecode) /***************************************************************************** convert a NT status code to a dos class/code *****************************************************************************/ -void ntstatus_to_dos(NTSTATUS ntstatus, uint8 *eclass, uint32 *ecode) +void ntstatus_to_dos(NTSTATUS ntstatus, uint8 *eclass, uint32_t *ecode) { int i; if (NT_STATUS_IS_OK(ntstatus)) { diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index edf1526d2e..b31f62c727 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -461,7 +461,7 @@ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) returned password including termination. ************************************************************/ BOOL decode_pw_buffer(char in_buffer[516], char *new_pwrd, - int new_pwrd_size, uint32 *new_pw_len, + int new_pwrd_size, uint32_t *new_pw_len, int string_flags) { int byte_len=0; -- cgit From f88bf54c7f6d1c2ef833047eb8327953c304b5ff Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 May 2004 17:24:24 +0000 Subject: r889: convert samba4 to use [u]int16_t instead of [u]int16 metze (This used to be commit af6f1f8a01bebbecd99bc8c066519e89966e65e3) --- source4/libcli/util/smbencrypt.c | 2 +- source4/libcli/util/smberr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index b31f62c727..fa29059585 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -66,7 +66,7 @@ void E_md4hash(const char *passwd, uchar p16[16]) /* Password must be converted to NT unicode - null terminated. */ push_ucs2(NULL, wpwd, (const char *)passwd, 256, STR_UNICODE|STR_NOALIGN|STR_TERMINATE); /* Calculate length in bytes */ - len = strlen_w(wpwd) * sizeof(int16); + len = strlen_w(wpwd) * sizeof(int16_t); mdfour(p16, (unsigned char *)wpwd, len); ZERO_STRUCT(wpwd); diff --git a/source4/libcli/util/smberr.c b/source4/libcli/util/smberr.c index d6eabcfbce..577308a7c0 100644 --- a/source4/libcli/util/smberr.c +++ b/source4/libcli/util/smberr.c @@ -145,7 +145,7 @@ static const struct { /* return a dos error string given a error class and error code */ -const char *dos_errstr(uint8 class, uint16 code) +const char *dos_errstr(uint8 class, uint16_t code) { static char *msg; int i, j; -- cgit From fcd718c7d8a6850ae8719f23ed044b06b57501cd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 May 2004 17:50:17 +0000 Subject: r890: convert samba4 to use [u]int8_t instead of [u]int8 metze (This used to be commit 2986c5f08c8f0c26a2ea7b6ce20aae025183109f) --- source4/libcli/util/asn1.c | 26 +++++++++++++------------- source4/libcli/util/clierror.c | 2 +- source4/libcli/util/errormap.c | 8 ++++---- source4/libcli/util/smbencrypt.c | 6 +++--- source4/libcli/util/smberr.c | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 07c692f700..b44c62bc50 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -31,7 +31,7 @@ BOOL asn1_write(ASN1_DATA *data, const void *p, int len) { if (data->has_error) return False; if (data->length < data->ofs+len) { - uint8 *newp; + uint8_t *newp; newp = Realloc(data->data, data->ofs+len); if (!newp) { SAFE_FREE(data->data); @@ -46,14 +46,14 @@ BOOL asn1_write(ASN1_DATA *data, const void *p, int len) return True; } -/* useful fn for writing a uint8 */ -BOOL asn1_write_uint8(ASN1_DATA *data, uint8 v) +/* useful fn for writing a uint8_t */ +BOOL asn1_write_uint8(ASN1_DATA *data, uint8_t v) { return asn1_write(data, &v, 1); } /* push a tag onto the asn1 data buffer. Used for nested structures */ -BOOL asn1_push_tag(ASN1_DATA *data, uint8 tag) +BOOL asn1_push_tag(ASN1_DATA *data, uint8_t tag) { struct nesting *nesting; @@ -187,7 +187,7 @@ BOOL asn1_write_BOOLEAN2(ASN1_DATA *data, BOOL v) /* check a BOOLEAN */ BOOL asn1_check_BOOLEAN(ASN1_DATA *data, BOOL v) { - uint8 b = 0; + uint8_t b = 0; asn1_read_uint8(data, &b); if (b != ASN1_BOOLEAN) { @@ -228,16 +228,16 @@ BOOL asn1_read(ASN1_DATA *data, void *p, int len) return True; } -/* read a uint8 from a ASN1 buffer */ -BOOL asn1_read_uint8(ASN1_DATA *data, uint8 *v) +/* read a uint8_t from a ASN1 buffer */ +BOOL asn1_read_uint8(ASN1_DATA *data, uint8_t *v) { return asn1_read(data, v, 1); } /* start reading a nested asn1 structure */ -BOOL asn1_start_tag(ASN1_DATA *data, uint8 tag) +BOOL asn1_start_tag(ASN1_DATA *data, uint8_t tag) { - uint8 b; + uint8_t b; struct nesting *nesting; if (!asn1_read_uint8(data, &b)) @@ -314,7 +314,7 @@ int asn1_tag_remaining(ASN1_DATA *data) /* read an object ID from a ASN1 buffer */ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) { - uint8 b; + uint8_t b; pstring aoid; fstring el; @@ -392,7 +392,7 @@ BOOL asn1_read_OctetString(ASN1_DATA *data, DATA_BLOB *blob) /* read an interger */ BOOL asn1_read_Integer(ASN1_DATA *data, int *i) { - uint8 b; + uint8_t b; *i = 0; if (!asn1_start_tag(data, ASN1_INTEGER)) return False; @@ -407,7 +407,7 @@ BOOL asn1_read_Integer(ASN1_DATA *data, int *i) /* check a enumarted value is correct */ BOOL asn1_check_enumerated(ASN1_DATA *data, int v) { - uint8 b; + uint8_t b; if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False; asn1_read_uint8(data, &b); asn1_end_tag(data); @@ -419,7 +419,7 @@ BOOL asn1_check_enumerated(ASN1_DATA *data, int v) } /* write an enumarted value to the stream */ -BOOL asn1_write_enumerated(ASN1_DATA *data, uint8 v) +BOOL asn1_write_enumerated(ASN1_DATA *data, uint8_t v) { if (!asn1_push_tag(data, ASN1_ENUMERATED)) return False; asn1_write_uint8(data, v); diff --git a/source4/libcli/util/clierror.c b/source4/libcli/util/clierror.c index 7b78d191dd..d852cd0d21 100644 --- a/source4/libcli/util/clierror.c +++ b/source4/libcli/util/clierror.c @@ -75,7 +75,7 @@ NTSTATUS cli_nt_error(struct cli_tree *tree) /* 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_t *ecode) +void cli_dos_error(struct cli_state *cli, uint8_t *eclass, uint32_t *ecode) { if (cli->transport->error.etype == ETYPE_DOS) { ntstatus_to_dos(cli->transport->error.e.nt_status, diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 11a07d45c7..46290baa7c 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -46,7 +46,7 @@ /* NT status -> dos error map */ static const struct { - uint8 dos_class; + uint8_t dos_class; uint32_t dos_code; NTSTATUS ntstatus; } ntstatus_to_dos_map[] = { @@ -612,7 +612,7 @@ static const struct { /* dos -> nt status error map */ static const struct { - uint8 dos_class; + uint8_t dos_class; uint32_t dos_code; NTSTATUS ntstatus; } dos_to_ntstatus_map[] = { @@ -1410,7 +1410,7 @@ static const struct { /***************************************************************************** convert a dos eclas/ecode to a NT status32 code *****************************************************************************/ -NTSTATUS dos_to_ntstatus(uint8 eclass, uint32_t ecode) +NTSTATUS dos_to_ntstatus(uint8_t eclass, uint32_t ecode) { int i; if (eclass == 0 && ecode == 0) return NT_STATUS_OK; @@ -1427,7 +1427,7 @@ NTSTATUS dos_to_ntstatus(uint8 eclass, uint32_t ecode) /***************************************************************************** convert a NT status code to a dos class/code *****************************************************************************/ -void ntstatus_to_dos(NTSTATUS ntstatus, uint8 *eclass, uint32_t *ecode) +void ntstatus_to_dos(NTSTATUS ntstatus, uint8_t *eclass, uint32_t *ecode) { int i; if (NT_STATUS_IS_OK(ntstatus)) { diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index fa29059585..5b210394c1 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -239,7 +239,7 @@ void SMBOWFencrypt_ntv2(const uchar kr[16], } void SMBsesskeygen_ntv2(const uchar kr[16], - const uchar * nt_resp, uint8 sess_key[16]) + const uchar * nt_resp, uint8_t sess_key[16]) { /* a very nice, 128 bit, variable session key */ @@ -255,7 +255,7 @@ void SMBsesskeygen_ntv2(const uchar kr[16], #endif } -void SMBsesskeygen_ntv1(const uchar kr[16], uint8 sess_key[16]) +void SMBsesskeygen_ntv1(const uchar kr[16], uint8_t sess_key[16]) { /* yes, this session key does not change - yes, this is a problem - but it is 128 bits */ @@ -270,7 +270,7 @@ void SMBsesskeygen_ntv1(const uchar kr[16], uint8 sess_key[16]) void SMBsesskeygen_lm_sess_key(const uchar lm_hash[16], const uchar lm_resp[24], /* only uses 8 */ - uint8 sess_key[16]) + uint8_t sess_key[16]) { /* Calculate the LM session key (effective length 40 bits, but changes with each session) */ diff --git a/source4/libcli/util/smberr.c b/source4/libcli/util/smberr.c index 577308a7c0..87cc601b8d 100644 --- a/source4/libcli/util/smberr.c +++ b/source4/libcli/util/smberr.c @@ -128,7 +128,7 @@ static const struct err_code_struct hard_msgs[] = { static const struct { - uint8 class; + uint8_t class; const char *class_name; const struct err_code_struct *err_msgs; } err_classes[] = { @@ -145,7 +145,7 @@ static const struct { /* return a dos error string given a error class and error code */ -const char *dos_errstr(uint8 class, uint16_t code) +const char *dos_errstr(uint8_t class, uint16_t code) { static char *msg; int i, j; -- cgit From 8b3f08cefcd41e6f8005de84a2cc865c1011194d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 26 May 2004 05:40:33 +0000 Subject: r898: - remove some unused macros - remove unused lib/smbpasswd.c - don't set the pkt size twice when doing SMB signing (This used to be commit 69a2942f7987647a32d43c71f41ac1a82a82ccda) --- source4/libcli/util/errormap.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 46290baa7c..e2aeded65d 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1486,6 +1486,13 @@ WERROR ntstatus_to_werror(NTSTATUS error) /* Mapping between Unix, DOS and NT error numbers */ +struct unix_error_map { + int unix_error; + int dos_class; + int dos_code; + NTSTATUS nt_error; +}; + const struct unix_error_map unix_dos_nt_errmap[] = { { EPERM, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, -- cgit From 45e93c19ef95978f908f5b14962770510634cd3b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 29 May 2004 08:11:46 +0000 Subject: r943: change samba4 to use 'uint8_t' instead of 'unsigned char' metze (This used to be commit b5378803fdcb3b3afe7c2932a38828e83470f61a) --- source4/libcli/util/smbdes.c | 48 ++++++++++++++++++++-------------------- source4/libcli/util/smbencrypt.c | 14 ++++++------ 2 files changed, 31 insertions(+), 31 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index 22bafcb449..b0efdec157 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -258,7 +258,7 @@ static void dohash(char *out, char *in, char *key, int forw) permute(out, rl, perm6, 64); } -static void str_to_key(const unsigned char *str,unsigned char *key) +static void str_to_key(const uint8_t *str,uint8_t *key) { int i; @@ -276,13 +276,13 @@ static void str_to_key(const unsigned char *str,unsigned char *key) } -void smbhash(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw) +void smbhash(uint8_t *out, const uint8_t *in, const uint8_t *key, int forw) { int i; char outb[64]; char inb[64]; char keyb[64]; - unsigned char key2[8]; + uint8_t key2[8]; str_to_key(key, key2); @@ -304,53 +304,53 @@ void smbhash(unsigned char *out, const unsigned char *in, const unsigned char *k } } -void E_P16(const unsigned char *p14,unsigned char *p16) +void E_P16(const uint8_t *p14,uint8_t *p16) { unsigned const char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; smbhash(p16, sp8, p14, 1); smbhash(p16+8, sp8, p14+7, 1); } -void E_P24(const unsigned char *p21, const unsigned char *c8, unsigned char *p24) +void E_P24(const uint8_t *p21, const uint8_t *c8, uint8_t *p24) { smbhash(p24, c8, p21, 1); smbhash(p24+8, c8, p21+7, 1); smbhash(p24+16, c8, p21+14, 1); } -void D_P16(const unsigned char *p14, const unsigned char *in, unsigned char *out) +void D_P16(const uint8_t *p14, const uint8_t *in, uint8_t *out) { smbhash(out, in, p14, 0); smbhash(out+8, in+8, p14+7, 0); } -void E_old_pw_hash( unsigned char *p14, const unsigned char *in, unsigned char *out) +void E_old_pw_hash( uint8_t *p14, const uint8_t *in, uint8_t *out) { smbhash(out, in, p14, 1); smbhash(out+8, in+8, p14+7, 1); } -void cred_hash1(unsigned char *out, const unsigned char *in, const unsigned char *key) +void cred_hash1(uint8_t *out, const uint8_t *in, const uint8_t *key) { - unsigned char buf[8]; + uint8_t buf[8]; smbhash(buf, in, key, 1); smbhash(out, buf, key+9, 1); } -void cred_hash2(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw) +void cred_hash2(uint8_t *out, const uint8_t *in, const uint8_t *key, int forw) { - unsigned char buf[8]; - unsigned char key2[8]; + uint8_t buf[8]; + uint8_t key2[8]; ZERO_STRUCT(key2); smbhash(buf, in, key, forw); key2[0] = key[7]; smbhash(out, buf, key2, forw); } -void cred_hash3(unsigned char *out, unsigned char *in, const unsigned char *key, int forw) +void cred_hash3(uint8_t *out, uint8_t *in, const uint8_t *key, int forw) { - unsigned char key2[8]; + uint8_t key2[8]; ZERO_STRUCT(key2); smbhash(out, in, key, forw); key2[0] = key[7]; @@ -358,20 +358,20 @@ void cred_hash3(unsigned char *out, unsigned char *in, const unsigned char *key, } -void SamOEMhashBlob(unsigned char *data, int len, const DATA_BLOB *key) +void SamOEMhashBlob(uint8_t *data, int len, const DATA_BLOB *key) { - unsigned char s_box[256]; - unsigned char index_i = 0; - unsigned char index_j = 0; - unsigned char j = 0; + uint8_t s_box[256]; + uint8_t index_i = 0; + uint8_t index_j = 0; + uint8_t j = 0; int ind; for (ind = 0; ind < 256; ind++) { - s_box[ind] = (unsigned char)ind; + s_box[ind] = (uint8_t)ind; } for (ind = 0; ind < 256; ind++) { - unsigned char tc; + uint8_t tc; j += (s_box[ind] + key->data[ind%key->length]); @@ -380,8 +380,8 @@ void SamOEMhashBlob(unsigned char *data, int len, const DATA_BLOB *key) s_box[j] = tc; } for (ind = 0; ind < len; ind++) { - unsigned char tc; - unsigned char t; + uint8_t tc; + uint8_t t; index_i++; index_j += s_box[index_i]; @@ -399,7 +399,7 @@ void SamOEMhashBlob(unsigned char *data, int len, const DATA_BLOB *key) a varient that assumes a 16 byte key. This should be removed when the last user is gone */ -void SamOEMhash(unsigned char *data, const unsigned char keystr[16], int len) +void SamOEMhash(uint8_t *data, const uint8_t keystr[16], int len) { DATA_BLOB key = data_blob(keystr, 16); diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 5b210394c1..d52d24e1e1 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -68,7 +68,7 @@ void E_md4hash(const char *passwd, uchar p16[16]) /* Calculate length in bytes */ len = strlen_w(wpwd) * sizeof(int16_t); - mdfour(p16, (unsigned char *)wpwd, len); + mdfour(p16, (uint8_t *)wpwd, len); ZERO_STRUCT(wpwd); } @@ -90,7 +90,7 @@ BOOL E_deshash(const char *passwd, uchar p16[16]) push_ascii(dospwd, passwd, sizeof(dospwd), STR_UPPER|STR_TERMINATE); /* Only the fisrt 14 chars are considered, password need not be null terminated. */ - E_P16((const unsigned char *)dospwd, p16); + E_P16((const uint8_t *)dospwd, p16); if (strlen(dospwd) > 14) { ret = False; @@ -170,8 +170,8 @@ BOOL ntv2_owf_gen(const uchar owf[16], domain_byte_len = domain_byte_len - 2; hmac_md5_init_limK_to_64(owf, 16, &ctx); - hmac_md5_update((const unsigned char *)user, user_byte_len, &ctx); - hmac_md5_update((const unsigned char *)domain, domain_byte_len, &ctx); + hmac_md5_update((const uint8_t *)user, user_byte_len, &ctx); + hmac_md5_update((const uint8_t *)domain, domain_byte_len, &ctx); hmac_md5_final(kr_buf, &ctx); #ifdef DEBUG_PASSWORD @@ -247,7 +247,7 @@ void SMBsesskeygen_ntv2(const uchar kr[16], hmac_md5_init_limK_to_64(kr, 16, &ctx); hmac_md5_update(nt_resp, 16, &ctx); - hmac_md5_final((unsigned char *)sess_key, &ctx); + hmac_md5_final((uint8_t *)sess_key, &ctx); #ifdef DEBUG_PASSWORD DEBUG(100, ("SMBsesskeygen_ntv2:\n")); @@ -260,7 +260,7 @@ void SMBsesskeygen_ntv1(const uchar kr[16], uint8_t sess_key[16]) /* yes, this session key does not change - yes, this is a problem - but it is 128 bits */ - mdfour((unsigned char *)sess_key, kr, 16); + mdfour((uint8_t *)sess_key, kr, 16); #ifdef DEBUG_PASSWORD DEBUG(100, ("SMBsesskeygen_ntv1:\n")); @@ -443,7 +443,7 @@ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len); - generate_random_buffer((unsigned char *)buffer, 512 - new_pw_len, False); + generate_random_buffer((uint8_t *)buffer, 512 - new_pw_len, False); /* * The length of the new password is in the last 4 bytes of -- cgit From fa2e9ec311b99dee2fbff5ee5fa2c743298dacad Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Jun 2004 08:12:45 +0000 Subject: r960: convert 'unsigned int' to uint_t in the most places metze (This used to be commit 18062d2ed9fc9224c43143c10efbf2f6f1f5bbe0) --- source4/libcli/util/dom_sid.c | 2 +- source4/libcli/util/smbdes.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/dom_sid.c b/source4/libcli/util/dom_sid.c index 88ece25a8e..cdf89ccf96 100644 --- a/source4/libcli/util/dom_sid.c +++ b/source4/libcli/util/dom_sid.c @@ -28,7 +28,7 @@ struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) { struct dom_sid *ret; - unsigned int rev, ia, num_sub_auths, i; + uint_t rev, ia, num_sub_auths, i; char *p; if (strncasecmp(sidstr, "S-", 2)) { diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index b0efdec157..b2e46e759d 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -412,7 +412,7 @@ void SamOEMhash(uint8_t *data, const uint8_t keystr[16], int len) /* Decode a sam password hash into a password. The password hash is the same method used to store passwords in the NT registry. The DES key used is based on the RID of the user. */ -void sam_pwd_hash(unsigned int rid, const uchar *in, uchar *out, int forw) +void sam_pwd_hash(uint_t rid, const uchar *in, uchar *out, int forw) { uchar s[14]; -- cgit From 98d291423ff581786a369ce373c861f94c654aa0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Jun 2004 08:30:34 +0000 Subject: r961: convert 'uchar' to 'uint8_t' metze (This used to be commit 9f914e4af99e18b469d4cf9d8b1514a2bd28ddec) --- source4/libcli/util/smbdes.c | 32 +++++++++++----------- source4/libcli/util/smbencrypt.c | 58 ++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 45 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index b2e46e759d..90724cb778 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -46,9 +46,9 @@ */ -#define uchar unsigned char +#define uint8_t unsigned char -static const uchar perm1[56] = {57, 49, 41, 33, 25, 17, 9, +static const uint8_t perm1[56] = {57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, @@ -57,7 +57,7 @@ static const uchar perm1[56] = {57, 49, 41, 33, 25, 17, 9, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4}; -static const uchar perm2[48] = {14, 17, 11, 24, 1, 5, +static const uint8_t perm2[48] = {14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, @@ -66,7 +66,7 @@ static const uchar perm2[48] = {14, 17, 11, 24, 1, 5, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32}; -static const uchar perm3[64] = {58, 50, 42, 34, 26, 18, 10, 2, +static const uint8_t perm3[64] = {58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, @@ -75,7 +75,7 @@ static const uchar perm3[64] = {58, 50, 42, 34, 26, 18, 10, 2, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7}; -static const uchar perm4[48] = { 32, 1, 2, 3, 4, 5, +static const uint8_t perm4[48] = { 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, @@ -84,7 +84,7 @@ static const uchar perm4[48] = { 32, 1, 2, 3, 4, 5, 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1}; -static const uchar perm5[32] = { 16, 7, 20, 21, +static const uint8_t perm5[32] = { 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, @@ -94,7 +94,7 @@ static const uchar perm5[32] = { 16, 7, 20, 21, 22, 11, 4, 25}; -static const uchar perm6[64] ={ 40, 8, 48, 16, 56, 24, 64, 32, +static const uint8_t perm6[64] ={ 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, @@ -104,9 +104,9 @@ static const uchar perm6[64] ={ 40, 8, 48, 16, 56, 24, 64, 32, 33, 1, 41, 9, 49, 17, 57, 25}; -static const uchar sc[16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1}; +static const uint8_t sc[16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1}; -static const uchar sbox[8][4][16] = { +static const uint8_t sbox[8][4][16] = { {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7}, {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8}, {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0}, @@ -147,7 +147,7 @@ static const uchar sbox[8][4][16] = { {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8}, {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}}}; -static void permute(char *out, const char *in, const uchar *p, int n) +static void permute(char *out, const char *in, const uint8_t *p, int n) { int i; for (i=0;i> 8) & 0xFF); - s[2] = s[6] = s[10] = (uchar)((rid >> 16) & 0xFF); - s[3] = s[7] = s[11] = (uchar)((rid >> 24) & 0xFF); + s[0] = s[4] = s[8] = s[12] = (uint8_t)(rid & 0xFF); + s[1] = s[5] = s[9] = s[13] = (uint8_t)((rid >> 8) & 0xFF); + s[2] = s[6] = s[10] = (uint8_t)((rid >> 16) & 0xFF); + s[3] = s[7] = s[11] = (uint8_t)((rid >> 24) & 0xFF); smbhash(out, in, s, forw); smbhash(out+8, in+8, s+7, forw); diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index d52d24e1e1..fdd5838798 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -32,10 +32,10 @@ Returns False if password must have been truncated to create LM hash */ -BOOL SMBencrypt(const char *passwd, const uchar *c8, uchar p24[24]) +BOOL SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24]) { BOOL ret; - uchar p21[21]; + uint8_t p21[21]; memset(p21,'\0',21); ret = E_deshash(passwd, p21); @@ -58,7 +58,7 @@ BOOL SMBencrypt(const char *passwd, const uchar *c8, uchar p24[24]) * @param p16 return password hashed with md4, caller allocated 16 byte buffer */ -void E_md4hash(const char *passwd, uchar p16[16]) +void E_md4hash(const char *passwd, uint8_t p16[16]) { int len; smb_ucs2_t wpwd[129]; @@ -80,7 +80,7 @@ void E_md4hash(const char *passwd, uchar p16[16]) * @note p16 is filled in regardless */ -BOOL E_deshash(const char *passwd, uchar p16[16]) +BOOL E_deshash(const char *passwd, uint8_t p16[16]) { BOOL ret = True; fstring dospwd; @@ -110,7 +110,7 @@ BOOL E_deshash(const char *passwd, uchar p16[16]) */ /* Does both the NT and LM owfs of a user's password */ -void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar p16[16]) +void nt_lm_owf_gen(const char *pwd, uint8_t nt_p16[16], uint8_t p16[16]) { /* Calculate the MD4 hash (NT compatible) of the password */ memset(nt_p16, '\0', 16); @@ -122,7 +122,7 @@ void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar p16[16]) dump_data(100, (char *)nt_p16, 16); #endif - E_deshash(pwd, (uchar *)p16); + E_deshash(pwd, (uint8_t *)p16); #ifdef DEBUG_PASSWORD DEBUG(100,("nt_lm_owf_gen: pwd, lm#\n")); @@ -132,10 +132,10 @@ void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar p16[16]) } /* Does both the NTLMv2 owfs of a user's password */ -BOOL ntv2_owf_gen(const uchar owf[16], +BOOL ntv2_owf_gen(const uint8_t owf[16], const char *user_in, const char *domain_in, BOOL upper_case_domain, /* Transform the domain into UPPER case */ - uchar kr_buf[16]) + uint8_t kr_buf[16]) { smb_ucs2_t *user; smb_ucs2_t *domain; @@ -188,9 +188,9 @@ BOOL ntv2_owf_gen(const uchar owf[16], } /* Does the des encryption from the NT or LM MD4 hash. */ -void SMBOWFencrypt(const uchar passwd[16], const uchar *c8, uchar p24[24]) +void SMBOWFencrypt(const uint8_t passwd[16], const uint8_t *c8, uint8_t p24[24]) { - uchar p21[21]; + uint8_t p21[21]; ZERO_STRUCT(p21); @@ -200,9 +200,9 @@ void SMBOWFencrypt(const uchar passwd[16], const uchar *c8, uchar p24[24]) /* Does the NT MD4 hash then des encryption. */ -void SMBNTencrypt(const char *passwd, uchar *c8, uchar *p24) +void SMBNTencrypt(const char *passwd, uint8_t *c8, uint8_t *p24) { - uchar p21[21]; + uint8_t p21[21]; memset(p21,'\0',21); @@ -218,10 +218,10 @@ void SMBNTencrypt(const char *passwd, uchar *c8, uchar *p24) } /* Does the md5 encryption from the Key Response for NTLMv2. */ -void SMBOWFencrypt_ntv2(const uchar kr[16], +void SMBOWFencrypt_ntv2(const uint8_t kr[16], const DATA_BLOB *srv_chal, const DATA_BLOB *cli_chal, - uchar resp_buf[16]) + uint8_t resp_buf[16]) { HMACMD5Context ctx; @@ -238,8 +238,8 @@ void SMBOWFencrypt_ntv2(const uchar kr[16], #endif } -void SMBsesskeygen_ntv2(const uchar kr[16], - const uchar * nt_resp, uint8_t sess_key[16]) +void SMBsesskeygen_ntv2(const uint8_t kr[16], + const uint8_t * nt_resp, uint8_t sess_key[16]) { /* a very nice, 128 bit, variable session key */ @@ -255,7 +255,7 @@ void SMBsesskeygen_ntv2(const uchar kr[16], #endif } -void SMBsesskeygen_ntv1(const uchar kr[16], uint8_t sess_key[16]) +void SMBsesskeygen_ntv1(const uint8_t kr[16], uint8_t sess_key[16]) { /* yes, this session key does not change - yes, this is a problem - but it is 128 bits */ @@ -268,14 +268,14 @@ void SMBsesskeygen_ntv1(const uchar kr[16], uint8_t sess_key[16]) #endif } -void SMBsesskeygen_lm_sess_key(const uchar lm_hash[16], - const uchar lm_resp[24], /* only uses 8 */ +void SMBsesskeygen_lm_sess_key(const uint8_t lm_hash[16], + const uint8_t lm_resp[24], /* only uses 8 */ uint8_t sess_key[16]) { /* Calculate the LM session key (effective length 40 bits, but changes with each session) */ - uchar p24[24]; - uchar p21[21]; + uint8_t p24[24]; + uint8_t p21[21]; memset(p21,'\0',21); memcpy(p21, lm_hash, 8); @@ -306,7 +306,7 @@ DATA_BLOB NTLMv2_generate_names_blob(TALLOC_CTX *mem_ctx, static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLOB *names_blob) { - uchar client_chal[8]; + uint8_t client_chal[8]; DATA_BLOB response = data_blob(NULL, 0); char long_date[8]; NTTIME nttime; @@ -330,11 +330,11 @@ static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLO return response; } -static DATA_BLOB NTLMv2_generate_response(const uchar ntlm_v2_hash[16], +static DATA_BLOB NTLMv2_generate_response(const uint8_t ntlm_v2_hash[16], const DATA_BLOB *server_chal, const DATA_BLOB *names_blob) { - uchar ntlmv2_response[16]; + uint8_t ntlmv2_response[16]; DATA_BLOB ntlmv2_client_data; DATA_BLOB final_response; @@ -364,10 +364,10 @@ static DATA_BLOB NTLMv2_generate_response(const uchar ntlm_v2_hash[16], return final_response; } -static DATA_BLOB LMv2_generate_response(const uchar ntlm_v2_hash[16], +static DATA_BLOB LMv2_generate_response(const uint8_t ntlm_v2_hash[16], const DATA_BLOB *server_chal) { - uchar lmv2_response[16]; + uint8_t lmv2_response[16]; DATA_BLOB lmv2_client_data = data_blob(NULL, 8); DATA_BLOB final_response = data_blob(NULL, 24); @@ -395,8 +395,8 @@ BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password DATA_BLOB *lm_response, DATA_BLOB *nt_response, DATA_BLOB *user_session_key) { - uchar nt_hash[16]; - uchar ntlm_v2_hash[16]; + uint8_t nt_hash[16]; + uint8_t ntlm_v2_hash[16]; E_md4hash(password, nt_hash); /* We don't use the NT# directly. Instead we use it mashed up with @@ -434,7 +434,7 @@ BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password ************************************************************/ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) { - uchar new_pw[512]; + uint8_t new_pw[512]; size_t new_pw_len; new_pw_len = push_string(NULL, new_pw, -- cgit From 770e3307ce3da928762e15a136c562df86a9c799 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Jun 2004 10:12:52 +0000 Subject: r962: convert 'unsigned' and 'unsigned int' to uint_t metze (This used to be commit 57151e80eb1090281401930c8fe25b20a8cf3a38) --- source4/libcli/util/asn1.c | 4 ++-- source4/libcli/util/smbdes.c | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index b44c62bc50..ddefe0baa6 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -122,7 +122,7 @@ BOOL asn1_write_Integer(ASN1_DATA *data, int i) /* write an object ID to a ASN1 buffer */ BOOL asn1_write_OID(ASN1_DATA *data, const char *OID) { - unsigned v, v2; + uint_t v, v2; const char *p = (const char *)OID; char *newp; @@ -328,7 +328,7 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) pstrcat(aoid, el); while (asn1_tag_remaining(data) > 0) { - unsigned v = 0; + uint_t v = 0; do { asn1_read_uint8(data, &b); v = (v<<7) | (b&0x7f); diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index 90724cb778..967d0ffb82 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -46,8 +46,6 @@ */ -#define uint8_t unsigned char - static const uint8_t perm1[56] = {57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, @@ -306,7 +304,7 @@ void smbhash(uint8_t *out, const uint8_t *in, const uint8_t *key, int forw) void E_P16(const uint8_t *p14,uint8_t *p16) { - unsigned const char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; + const uint8_t sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; smbhash(p16, sp8, p14, 1); smbhash(p16+8, sp8, p14+7, 1); } -- cgit From dfbf6201297a39f339a179fbc8444b3748bf5012 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 2 Jun 2004 08:31:47 +0000 Subject: r975: slight improvemet to nt_errstr(), still needs to be fixed properly (getting rid of the static buffer) (This used to be commit 86a6236c2ad14fe94f5d7c488bfdbfb329d2a0bb) --- source4/libcli/util/nterr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 6c4b7c8417..c71dc2247b 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -646,8 +646,6 @@ const char *nt_errstr(NTSTATUS nt_code) static pstring msg; int idx = 0; - slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code)); - while (nt_errs[idx].nt_errstr != NULL) { if (NT_STATUS_V(nt_errs[idx].nt_errcode) == NT_STATUS_V(nt_code)) { @@ -656,6 +654,8 @@ const char *nt_errstr(NTSTATUS nt_code) idx++; } + slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code)); + return msg; } -- cgit From 8087d844ef59a82617be51f7c887b9bafe362f80 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 3 Jun 2004 23:15:16 +0000 Subject: r995: - renamed many of our crypto routines to use the industry standard names rather than our crazy naming scheme. So DES is now called des_crypt() rather than smbhash() - added the code from the solution of the ADS crypto challenge that allows Samba to correctly handle a 128 bit session key in all of the netr_ServerAuthenticateX() varients. A huge thanks to Luke Howard from PADL for solving this one! - restructured the server side rpc authentication to allow for other than NTLMSSP sign and seal. This commit just adds the structure, the next commit will add schannel server side support. - added 128 bit session key support to our client side code, and testing against w2k3 with smbtorture. Works well. (This used to be commit 729b2f41c924a0b435d44a14209e6dacc2304cee) --- source4/libcli/util/smbdes.c | 69 +++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 29 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index 967d0ffb82..2492f9a1ba 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -273,8 +273,10 @@ static void str_to_key(const uint8_t *str,uint8_t *key) } } - -void smbhash(uint8_t *out, const uint8_t *in, const uint8_t *key, int forw) +/* + basic des crypt using a 56 bit (7 byte) key +*/ +void des_crypt56(uint8_t out[8], const uint8_t in[8], const uint8_t key[7], int forw) { int i; char outb[64]; @@ -305,58 +307,67 @@ void smbhash(uint8_t *out, const uint8_t *in, const uint8_t *key, int forw) void E_P16(const uint8_t *p14,uint8_t *p16) { const uint8_t sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; - smbhash(p16, sp8, p14, 1); - smbhash(p16+8, sp8, p14+7, 1); + des_crypt56(p16, sp8, p14, 1); + des_crypt56(p16+8, sp8, p14+7, 1); } void E_P24(const uint8_t *p21, const uint8_t *c8, uint8_t *p24) { - smbhash(p24, c8, p21, 1); - smbhash(p24+8, c8, p21+7, 1); - smbhash(p24+16, c8, p21+14, 1); + des_crypt56(p24, c8, p21, 1); + des_crypt56(p24+8, c8, p21+7, 1); + des_crypt56(p24+16, c8, p21+14, 1); } void D_P16(const uint8_t *p14, const uint8_t *in, uint8_t *out) { - smbhash(out, in, p14, 0); - smbhash(out+8, in+8, p14+7, 0); + des_crypt56(out, in, p14, 0); + des_crypt56(out+8, in+8, p14+7, 0); } void E_old_pw_hash( uint8_t *p14, const uint8_t *in, uint8_t *out) { - smbhash(out, in, p14, 1); - smbhash(out+8, in+8, p14+7, 1); + des_crypt56(out, in, p14, 1); + des_crypt56(out+8, in+8, p14+7, 1); } -void cred_hash1(uint8_t *out, const uint8_t *in, const uint8_t *key) +/* des encryption with a 128 bit key */ +void des_crypt128(uint8_t out[8], const uint8_t in[8], const uint8_t key[16]) { uint8_t buf[8]; - - smbhash(buf, in, key, 1); - smbhash(out, buf, key+9, 1); + des_crypt56(buf, in, key, 1); + des_crypt56(out, buf, key+9, 1); } -void cred_hash2(uint8_t *out, const uint8_t *in, const uint8_t *key, int forw) +/* des encryption with a 64 bit key */ +void des_crypt64(uint8_t out[8], const uint8_t in[8], const uint8_t key[8], int forw) { uint8_t buf[8]; uint8_t key2[8]; ZERO_STRUCT(key2); - smbhash(buf, in, key, forw); + des_crypt56(buf, in, key, forw); key2[0] = key[7]; - smbhash(out, buf, key2, forw); + des_crypt56(out, buf, key2, forw); } -void cred_hash3(uint8_t *out, uint8_t *in, const uint8_t *key, int forw) +/* des encryption with a 112 bit (14 byte) key */ +void des_crypt112(uint8_t out[8], const uint8_t in[8], const uint8_t key[14], int forw) { - uint8_t key2[8]; - ZERO_STRUCT(key2); - smbhash(out, in, key, forw); - key2[0] = key[7]; - smbhash(out + 8, in + 8, key2, forw); + uint8_t buf[8]; + des_crypt56(buf, in, key, forw); + des_crypt56(out, buf, key+7, forw); } +/* des encryption of a 16 byte lump of data with a 112 bit key */ +void des_crypt112_16(uint8_t out[16], uint8_t in[16], const uint8_t key[14], int forw) +{ + des_crypt56(out, in, key, forw); + des_crypt56(out + 8, in + 8, key+7, forw); +} -void SamOEMhashBlob(uint8_t *data, int len, const DATA_BLOB *key) +/* + arcfour encryption with a blob key +*/ +void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key) { uint8_t s_box[256]; uint8_t index_i = 0; @@ -397,11 +408,11 @@ void SamOEMhashBlob(uint8_t *data, int len, const DATA_BLOB *key) a varient that assumes a 16 byte key. This should be removed when the last user is gone */ -void SamOEMhash(uint8_t *data, const uint8_t keystr[16], int len) +void arcfour_crypt(uint8_t *data, const uint8_t keystr[16], int len) { DATA_BLOB key = data_blob(keystr, 16); - SamOEMhashBlob(data, len, &key); + arcfour_crypt_blob(data, len, &key); data_blob_free(&key); } @@ -419,6 +430,6 @@ void sam_pwd_hash(uint_t rid, const uint8_t *in, uint8_t *out, int forw) s[2] = s[6] = s[10] = (uint8_t)((rid >> 16) & 0xFF); s[3] = s[7] = s[11] = (uint8_t)((rid >> 24) & 0xFF); - smbhash(out, in, s, forw); - smbhash(out+8, in+8, s+7, forw); + des_crypt56(out, in, s, forw); + des_crypt56(out+8, in+8, s+7, forw); } -- cgit From 46c88d561f9a5cbaf2b70e937fbc20dff6d31703 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 7 Jun 2004 08:54:49 +0000 Subject: r1061: The start of the SamLogon call for the NETLOGON pipe. Changes: - Check for a valid 'pipe_state' in netr_ServerAuthenticate3 before we dereference it - removes the expansionroom[7] in the netr_SamInfo* structs to 7 individual elements. - renames netr_SamInfo -> netr_SamInfo2 netr_SamInfo2 -> netr_SamInfo3 - Having the thing we always called an 'info3' being 'netr_SamInfo2' was just too confusing. - Expand and fill in extra details about users from the SAM, into the server_info, for processing into the SamLogon reply. - Add a dum_sid_dup() function to duplicate a struct dom_sid The SamLogon code currently does not return supplementary groups, and is only tested with Samba4 smbtorture. Andrew Bartlett (This used to be commit 6c92563b7961f15fc74b02601e105d5e1d04f04d) --- source4/libcli/util/dom_sid.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/dom_sid.c b/source4/libcli/util/dom_sid.c index cdf89ccf96..9b8b45e302 100644 --- a/source4/libcli/util/dom_sid.c +++ b/source4/libcli/util/dom_sid.c @@ -89,3 +89,36 @@ struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) return ret; } +/* + convert a string to a dom_sid, returning a talloc'd dom_sid +*/ +struct dom_sid *dom_sid_dup(TALLOC_CTX *mem_ctx, struct dom_sid *dom_sid) +{ + struct dom_sid *ret; + int i; + ret = talloc_p(mem_ctx, struct dom_sid); + if (!ret) { + return NULL; + } + + ret->sub_auths = talloc_array_p(mem_ctx, uint32_t, dom_sid->num_auths); + if (!ret->sub_auths) { + return NULL; + } + + ret->sid_rev_num = dom_sid->sid_rev_num; + ret->id_auth[0] = dom_sid->id_auth[0]; + ret->id_auth[1] = dom_sid->id_auth[1]; + ret->id_auth[2] = dom_sid->id_auth[2]; + ret->id_auth[3] = dom_sid->id_auth[3]; + ret->id_auth[4] = dom_sid->id_auth[4]; + ret->id_auth[5] = dom_sid->id_auth[5]; + ret->num_auths = dom_sid->num_auths; + + for (i=0;inum_auths;i++) { + ret->sub_auths[i] = dom_sid->sub_auths[i]; + } + + return ret; +} + -- cgit From 9f38798509616199d2c53dcd386ea1bc3e21df8f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 14 Jun 2004 06:49:18 +0000 Subject: r1129: Remove unused function. Andrew Bartlett (This used to be commit 4d23b9e039872273f3ef433d94d24759bcb87c30) --- source4/libcli/util/smbencrypt.c | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index fdd5838798..72c6589097 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -101,36 +101,6 @@ BOOL E_deshash(const char *passwd, uint8_t p16[16]) return ret; } -/** - * Creates the MD4 and DES (LM) Hash of the users password. - * MD4 is of the NT Unicode, DES is of the DOS UPPERCASE password. - * @param passwd password in 'unix' charset. - * @param nt_p16 return password hashed with md4, caller allocated 16 byte buffer - * @param p16 return password hashed with des, caller allocated 16 byte buffer - */ - -/* Does both the NT and LM owfs of a user's password */ -void nt_lm_owf_gen(const char *pwd, uint8_t nt_p16[16], uint8_t p16[16]) -{ - /* Calculate the MD4 hash (NT compatible) of the password */ - memset(nt_p16, '\0', 16); - E_md4hash(pwd, nt_p16); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("nt_lm_owf_gen: pwd, nt#\n")); - dump_data(120, pwd, strlen(pwd)); - dump_data(100, (char *)nt_p16, 16); -#endif - - E_deshash(pwd, (uint8_t *)p16); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("nt_lm_owf_gen: pwd, lm#\n")); - dump_data(120, pwd, strlen(pwd)); - dump_data(100, (char *)p16, 16); -#endif -} - /* Does both the NTLMv2 owfs of a user's password */ BOOL ntv2_owf_gen(const uint8_t owf[16], const char *user_in, const char *domain_in, -- cgit From bf598954f75bfd924b9aa22649975b372c74a49e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 19 Jun 2004 08:15:41 +0000 Subject: r1198: Merge the Samba 3.0 ntlm_auth, including the kerberos and SPENGO parts. I have moved the SPNEGO and Kerberos code into libcli/auth, and intend to refactor them into the same format as NTLMSSP. Andrew Bartlett (This used to be commit 58da78a7460d5d0a4abee7d7b84799c228e6bc0b) --- source4/libcli/util/asn1.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index ddefe0baa6..05bc5eace8 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -219,6 +219,11 @@ BOOL asn1_load(ASN1_DATA *data, DATA_BLOB blob) /* read from a ASN1 buffer, advancing the buffer pointer */ BOOL asn1_read(ASN1_DATA *data, void *p, int len) { + if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len) { + data->has_error = True; + return False; + } + if (data->ofs + len > data->length) { data->has_error = True; return False; @@ -315,17 +320,17 @@ int asn1_tag_remaining(ASN1_DATA *data) BOOL asn1_read_OID(ASN1_DATA *data, char **OID) { uint8_t b; - pstring aoid; - fstring el; + char *oid = NULL; + TALLOC_CTX *mem_ctx = talloc_init("asn1_read_OID"); + if (!mem_ctx) { + return False; + } if (!asn1_start_tag(data, ASN1_OID)) return False; asn1_read_uint8(data, &b); - aoid[0] = 0; - snprintf(el, sizeof(el), "%u", b/40); - pstrcat(aoid, el); - snprintf(el, sizeof(el), " %u", b%40); - pstrcat(aoid, el); + oid = talloc_asprintf_append(mem_ctx, oid, "%u", b/40); + oid = talloc_asprintf_append(mem_ctx, oid, " %u", b%40); while (asn1_tag_remaining(data) > 0) { uint_t v = 0; @@ -333,15 +338,15 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) asn1_read_uint8(data, &b); v = (v<<7) | (b&0x7f); } while (!data->has_error && b & 0x80); - snprintf(el, sizeof(el), " %u", v); - pstrcat(aoid, el); + oid = talloc_asprintf_append(mem_ctx, oid, " %u", v); } asn1_end_tag(data); - *OID = strdup(aoid); + *OID = strdup(oid); + talloc_destroy(mem_ctx); - return !data->has_error; + return (*OID && !data->has_error); } /* check that the next object ID is correct */ @@ -365,6 +370,10 @@ BOOL asn1_read_GeneralString(ASN1_DATA *data, char **s) int len; if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False; len = asn1_tag_remaining(data); + if (len < 0) { + data->has_error = True; + return False; + } *s = malloc(len+1); if (! *s) { data->has_error = True; @@ -383,6 +392,10 @@ BOOL asn1_read_OctetString(ASN1_DATA *data, DATA_BLOB *blob) ZERO_STRUCTP(blob); if (!asn1_start_tag(data, ASN1_OCTET_STRING)) return False; len = asn1_tag_remaining(data); + if (len < 0) { + data->has_error = True; + return False; + } *blob = data_blob(NULL, len); asn1_read(data, blob->data, len); asn1_end_tag(data); -- cgit From be081037e09bb78c0308cd6c7a5d7ae563678b7c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 20 Jun 2004 00:58:09 +0000 Subject: r1200: Add 'gensec', our generic security layer. This layer is used for DCERPC security, as well as ntlm_auth at this time. It expect things like SASL and the CIFS layer to use it as well. The particular purpose of this layer is to introduce SPENGO, which needs generic access to the actual implementation mechanisms. Schannel, due to it's 'interesting' setup properties is in GENSEC, but is only in the RPC code. Andrew Bartlett (This used to be commit 902af49006fb8cfecaadd3cc0c10e2e542083fb1) --- source4/libcli/util/asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 05bc5eace8..943ce4d1c1 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -329,7 +329,7 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) if (!asn1_start_tag(data, ASN1_OID)) return False; asn1_read_uint8(data, &b); - oid = talloc_asprintf_append(mem_ctx, oid, "%u", b/40); + oid = talloc_asprintf(mem_ctx, "%u", b/40); oid = talloc_asprintf_append(mem_ctx, oid, " %u", b%40); while (asn1_tag_remaining(data) > 0) { -- cgit From 81db9ef4425ed0d3397767f722b9f156b334867c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 24 Jun 2004 17:07:19 +0000 Subject: r1239: move the old msrpc_() functions to ndr__format_blob() simular to ndr__struct_blob() metze (This used to be commit b25dd341e0febd550a2936ca484b6fecce2ff8c2) --- source4/libcli/util/smbencrypt.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 72c6589097..e2fb033279 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -267,10 +267,12 @@ DATA_BLOB NTLMv2_generate_names_blob(TALLOC_CTX *mem_ctx, { DATA_BLOB names_blob = data_blob_talloc(mem_ctx, NULL, 0); - msrpc_gen(mem_ctx, &names_blob, "aaa", - NTLMSSP_NAME_TYPE_DOMAIN, domain, - NTLMSSP_NAME_TYPE_SERVER, hostname, - 0, ""); + ndr_push_format_blob(&names_blob ,mem_ctx, + "aaa", + NTLMSSP_NAME_TYPE_DOMAIN, domain, + NTLMSSP_NAME_TYPE_SERVER, hostname, + 0, ""); + return names_blob; } @@ -289,13 +291,14 @@ static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLO /* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */ - msrpc_gen(mem_ctx, &response, "ddbbdb", - 0x00000101, /* Header */ - 0, /* 'Reserved' */ - long_date, 8, /* Timestamp */ - client_chal, 8, /* client challenge */ - 0, /* Unknown */ - names_blob->data, names_blob->length); /* End of name list */ + ndr_push_format_blob(&response, mem_ctx, + "ddbbdb", + 0x00000101, /* Header */ + 0, /* 'Reserved' */ + long_date, 8, /* Timestamp */ + client_chal, 8, /* client challenge */ + 0, /* Unknown */ + names_blob->data, names_blob->length); /* End of name list */ return response; } -- cgit From 37fcf2236433bc5e74f19d2afac3d1d0055dcd01 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 27 Jun 2004 11:06:10 +0000 Subject: r1268: varient -> variant (This used to be commit de5984c95602ca67e8ac3139c3aa4330b74266e0) --- source4/libcli/util/smbdes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index 2492f9a1ba..99c2c00977 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -405,7 +405,7 @@ void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key) } /* - a varient that assumes a 16 byte key. This should be removed + a variant that assumes a 16 byte key. This should be removed when the last user is gone */ void arcfour_crypt(uint8_t *data, const uint8_t keystr[16], int len) -- cgit From 25bf685da5c037d1875f96e7e7127106dee2865d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Jun 2004 06:46:27 +0000 Subject: r1274: revert -r 1239 as discussed with abartlet metze (This used to be commit 52e2d038252bd745d53c687d266ad3ad62efa6fc) --- source4/libcli/util/smbencrypt.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index e2fb033279..72c6589097 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -267,12 +267,10 @@ DATA_BLOB NTLMv2_generate_names_blob(TALLOC_CTX *mem_ctx, { DATA_BLOB names_blob = data_blob_talloc(mem_ctx, NULL, 0); - ndr_push_format_blob(&names_blob ,mem_ctx, - "aaa", - NTLMSSP_NAME_TYPE_DOMAIN, domain, - NTLMSSP_NAME_TYPE_SERVER, hostname, - 0, ""); - + msrpc_gen(mem_ctx, &names_blob, "aaa", + NTLMSSP_NAME_TYPE_DOMAIN, domain, + NTLMSSP_NAME_TYPE_SERVER, hostname, + 0, ""); return names_blob; } @@ -291,14 +289,13 @@ static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLO /* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */ - ndr_push_format_blob(&response, mem_ctx, - "ddbbdb", - 0x00000101, /* Header */ - 0, /* 'Reserved' */ - long_date, 8, /* Timestamp */ - client_chal, 8, /* client challenge */ - 0, /* Unknown */ - names_blob->data, names_blob->length); /* End of name list */ + msrpc_gen(mem_ctx, &response, "ddbbdb", + 0x00000101, /* Header */ + 0, /* 'Reserved' */ + long_date, 8, /* Timestamp */ + client_chal, 8, /* client challenge */ + 0, /* Unknown */ + names_blob->data, names_blob->length); /* End of name list */ return response; } -- cgit From 0fa0eaa3837551bb04fd850d78633cc08a3dbdcc Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 5 Jul 2004 20:33:17 +0000 Subject: r1342: When fixing _lsa_lookupsids in samba3 I wanted to find out the number of SIDs w2k3 can handle in a single request. With the samba3 client rpc libs I can do about 21000 SIDs in a single request. test_many_LookupSIDs with 10000 SIDs fails on the subsequent request with a NET_WRITE_FAULT. Maybe the Samba4 DCE people want to take a look at this -- I don't see the problem. Bug fix: SID components should be treated as unsigned when parsing Volker (This used to be commit 8c997a2ad2e89a640f854b556ef76a3d52c15963) --- source4/libcli/util/dom_sid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/dom_sid.c b/source4/libcli/util/dom_sid.c index 9b8b45e302..0ca4cd731f 100644 --- a/source4/libcli/util/dom_sid.c +++ b/source4/libcli/util/dom_sid.c @@ -79,7 +79,7 @@ struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) return NULL; } sidstr++; - ret->sub_auths[i] = strtol(sidstr, &p, 10); + ret->sub_auths[i] = strtoul(sidstr, &p, 10); if (p == sidstr) { return NULL; } -- cgit From b359f5d89301882bbec657084b99c8d3e93dc3f2 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 6 Jul 2004 01:28:12 +0000 Subject: r1352: Add a 'peek' function to our ASN1 code, so we can safely perform the various switches without looking one byte past te end of the buffer. (This used to be commit 5bce188d429b4166f3d0314922ae40204de182a7) --- source4/libcli/util/asn1.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 943ce4d1c1..da51340774 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -239,6 +239,28 @@ BOOL asn1_read_uint8(ASN1_DATA *data, uint8_t *v) return asn1_read(data, v, 1); } +/* read from a ASN1 buffer, advancing the buffer pointer */ +BOOL asn1_peek(ASN1_DATA *data, void *p, int len) +{ + if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len) { + data->has_error = True; + return False; + } + + if (data->ofs + len > data->length) { + data->has_error = True; + return False; + } + memcpy(p, data->data + data->ofs, len); + return True; +} + +/* read a uint8_t from a ASN1 buffer */ +BOOL asn1_peek_uint8(ASN1_DATA *data, uint8_t *v) +{ + return asn1_peek(data, v, 1); +} + /* start reading a nested asn1 structure */ BOOL asn1_start_tag(ASN1_DATA *data, uint8_t tag) { -- cgit From f607197054436a8195e3d0a695fe31574b418059 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 14 Jul 2004 12:14:07 +0000 Subject: r1498: (merge from 3.0) Rework our random number generation system. On systems with /dev/urandom, this avoids a change to secrets.tdb for every fork(). For other systems, we now only re-seed after a fork, and on startup. No need to do it per-operation. This removes the 'need_reseed' parameter from generate_random_buffer(). This also requires that we start the secrets subsystem, as that is where the reseed value is stored, for systems without /dev/urandom. In order to aviod identical streams in forked children, the random state is re-initialised after the fork(), at the same point were we do that to the tdbs. Andrew Bartlett (This used to be commit b97d3cb2efd68310b1aea8a3ac40a64979c8cdae) --- source4/libcli/util/smbencrypt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 72c6589097..a02fdaa38b 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -283,7 +283,7 @@ static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLO unix_to_nt_time(&nttime, time(NULL)); - generate_random_buffer(client_chal, sizeof(client_chal), False); + generate_random_buffer(client_chal, sizeof(client_chal)); push_nttime(long_date, 0, nttime); @@ -343,7 +343,7 @@ static DATA_BLOB LMv2_generate_response(const uint8_t ntlm_v2_hash[16], /* LMv2 */ /* client-supplied random data */ - generate_random_buffer(lmv2_client_data.data, lmv2_client_data.length, False); + generate_random_buffer(lmv2_client_data.data, lmv2_client_data.length); /* Given that data, and the challenge from the server, generate a response */ SMBOWFencrypt_ntv2(ntlm_v2_hash, server_chal, &lmv2_client_data, lmv2_response); @@ -413,7 +413,7 @@ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len); - generate_random_buffer((uint8_t *)buffer, 512 - new_pw_len, False); + generate_random_buffer((uint8_t *)buffer, 512 - new_pw_len); /* * The length of the new password is in the last 4 bytes of -- cgit From c5fbb6f23c2d399c7510bc552cdb1a27b1ef66a8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 4 Aug 2004 13:23:35 +0000 Subject: r1654: rename cli_ -> smbcli_ rename CLI_ -> SMBCLI_ metze (This used to be commit 8441750fd9427dd6fe477f27e603821b4026f038) --- source4/libcli/util/clierror.c | 12 ++++++------ source4/libcli/util/cliutil.c | 2 +- source4/libcli/util/smbencrypt.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clierror.c b/source4/libcli/util/clierror.c index d852cd0d21..e7e413bbcb 100644 --- a/source4/libcli/util/clierror.c +++ b/source4/libcli/util/clierror.c @@ -25,7 +25,7 @@ /*************************************************************************** Return an error message from the last response ****************************************************************************/ -const char *cli_errstr(struct cli_tree *tree) +const char *smbcli_errstr(struct smbcli_tree *tree) { switch (tree->session->transport->error.etype) { case ETYPE_DOS: @@ -49,7 +49,7 @@ const char *cli_errstr(struct cli_tree *tree) /* Return the 32-bit NT status code from the last packet */ -NTSTATUS cli_nt_error(struct cli_tree *tree) +NTSTATUS smbcli_nt_error(struct smbcli_tree *tree) { switch (tree->session->transport->error.etype) { case ETYPE_NT: @@ -75,7 +75,7 @@ NTSTATUS cli_nt_error(struct cli_tree *tree) /* Return the DOS error from the last packet - an error class and an error code. */ -void cli_dos_error(struct cli_state *cli, uint8_t *eclass, uint32_t *ecode) +void smbcli_dos_error(struct smbcli_state *cli, uint8_t *eclass, uint32_t *ecode) { if (cli->transport->error.etype == ETYPE_DOS) { ntstatus_to_dos(cli->transport->error.e.nt_status, @@ -89,13 +89,13 @@ void cli_dos_error(struct cli_state *cli, uint8_t *eclass, uint32_t *ecode) /* Return true if the last packet was an error */ -BOOL cli_is_error(struct cli_tree *tree) +BOOL smbcli_is_error(struct smbcli_tree *tree) { - return NT_STATUS_IS_ERR(cli_nt_error(tree)); + return NT_STATUS_IS_ERR(smbcli_nt_error(tree)); } /* Return true if the last error was a DOS error */ -BOOL cli_is_dos_error(struct cli_tree *tree) +BOOL smbcli_is_dos_error(struct smbcli_tree *tree) { return tree->session->transport->error.etype == ETYPE_DOS; } diff --git a/source4/libcli/util/cliutil.c b/source4/libcli/util/cliutil.c index 56dee7381a..3efa1dbbc9 100644 --- a/source4/libcli/util/cliutil.c +++ b/source4/libcli/util/cliutil.c @@ -29,7 +29,7 @@ of the ".." name. *******************************************************************/ -BOOL mask_match(struct cli_state *cli, const char *string, char *pattern, BOOL is_case_sensitive) +BOOL mask_match(struct smbcli_state *cli, const char *string, char *pattern, BOOL is_case_sensitive) { fstring p2, s2; diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index a02fdaa38b..a50b4edc88 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -190,20 +190,20 @@ void SMBNTencrypt(const char *passwd, uint8_t *c8, uint8_t *p24) /* Does the md5 encryption from the Key Response for NTLMv2. */ void SMBOWFencrypt_ntv2(const uint8_t kr[16], const DATA_BLOB *srv_chal, - const DATA_BLOB *cli_chal, + const DATA_BLOB *smbcli_chal, uint8_t resp_buf[16]) { HMACMD5Context ctx; hmac_md5_init_limK_to_64(kr, 16, &ctx); hmac_md5_update(srv_chal->data, srv_chal->length, &ctx); - hmac_md5_update(cli_chal->data, cli_chal->length, &ctx); + hmac_md5_update(smbcli_chal->data, smbcli_chal->length, &ctx); hmac_md5_final(resp_buf, &ctx); #ifdef DEBUG_PASSWORD - DEBUG(100, ("SMBOWFencrypt_ntv2: srv_chal, cli_chal, resp_buf\n")); + DEBUG(100, ("SMBOWFencrypt_ntv2: srv_chal, smbcli_chal, resp_buf\n")); dump_data(100, srv_chal->data, srv_chal->length); - dump_data(100, cli_chal->data, cli_chal->length); + dump_data(100, smbcli_chal->data, smbcli_chal->length); dump_data(100, resp_buf, 16); #endif } -- cgit From 8ed563cfbbe3921a7a07479a50de85fcf71cd41a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 11 Aug 2004 16:09:54 +0000 Subject: r1723: Make sure we bail out on error in reading a OID. Andrew Bartlett (This used to be commit 6da7b65851aa4932aab56d1ab0f8fc67ccb62cdf) --- source4/libcli/util/asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index da51340774..dcafb261ee 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -354,7 +354,7 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) oid = talloc_asprintf(mem_ctx, "%u", b/40); oid = talloc_asprintf_append(mem_ctx, oid, " %u", b%40); - while (asn1_tag_remaining(data) > 0) { + while (!data->has_error && asn1_tag_remaining(data) > 0) { uint_t v = 0; do { asn1_read_uint8(data, &b); -- cgit From fa8d37adae70a5f479262b722e47aa7fc21aaf5c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 12 Aug 2004 04:55:59 +0000 Subject: r1756: merge volkers ldap client lib to samba4 for simo to start with the ldap server code it's not compiled in yet... metze (This used to be commit 48939adca1332ff90f9287311c0e9ff3e2e5917a) --- source4/libcli/util/asn1.c | 160 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 133 insertions(+), 27 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index dcafb261ee..6ddce7882c 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -184,6 +184,14 @@ BOOL asn1_write_BOOLEAN2(ASN1_DATA *data, BOOL v) return !data->has_error; } +BOOL asn1_read_BOOLEAN2(ASN1_DATA *data, BOOL *v) +{ + asn1_start_tag(data, ASN1_BOOLEAN); + asn1_read_uint8(data, (uint8 *)v); + asn1_end_tag(data); + return !data->has_error; +} + /* check a BOOLEAN */ BOOL asn1_check_BOOLEAN(ASN1_DATA *data, BOOL v) { @@ -216,51 +224,52 @@ BOOL asn1_load(ASN1_DATA *data, DATA_BLOB blob) return True; } -/* read from a ASN1 buffer, advancing the buffer pointer */ -BOOL asn1_read(ASN1_DATA *data, void *p, int len) +/* Peek into an ASN1 buffer, not advancing the pointer */ +BOOL asn1_peek(ASN1_DATA *data, void *p, int len) { - if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len) { - data->has_error = True; + if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len) return False; - } - if (data->ofs + len > data->length) { - data->has_error = True; + if (data->ofs + len > data->length) return False; - } + memcpy(p, data->data + data->ofs, len); - data->ofs += len; return True; } -/* read a uint8_t from a ASN1 buffer */ -BOOL asn1_read_uint8(ASN1_DATA *data, uint8_t *v) -{ - return asn1_read(data, v, 1); -} - /* read from a ASN1 buffer, advancing the buffer pointer */ -BOOL asn1_peek(ASN1_DATA *data, void *p, int len) +BOOL asn1_read(ASN1_DATA *data, void *p, int len) { - if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len) { + if (!asn1_peek(data, p, len)) { data->has_error = True; return False; } - if (data->ofs + len > data->length) { - data->has_error = True; - return False; - } - memcpy(p, data->data + data->ofs, len); + data->ofs += len; return True; } /* read a uint8_t from a ASN1 buffer */ +BOOL asn1_read_uint8(ASN1_DATA *data, uint8_t *v) +{ + return asn1_read(data, v, 1); +} + BOOL asn1_peek_uint8(ASN1_DATA *data, uint8_t *v) { return asn1_peek(data, v, 1); } +BOOL asn1_peek_tag(ASN1_DATA *data, uint8_t tag) +{ + uint8_t b; + + if (!asn1_peek(data, &b, sizeof(b))) + return False; + + return (b == tag); +} + /* start reading a nested asn1 structure */ BOOL asn1_start_tag(ASN1_DATA *data, uint8_t tag) { @@ -304,6 +313,89 @@ BOOL asn1_start_tag(ASN1_DATA *data, uint8_t tag) return !data->has_error; } +#if 0 +static BOOL read_one_uint8(int sock, uint8_t *result, ASN1_DATA *data, + const struct timeval *endtime) +{ + if (read_data_until(sock, result, 1, endtime) != 1) + return False; + + return asn1_write(data, result, 1); +} + +/* Read a complete ASN sequence (ie LDAP result) from a socket */ +BOOL asn1_read_sequence_until(int sock, ASN1_DATA *data, + const struct timeval *endtime) +{ + uint8_t b; + size_t len; + char *buf; + + ZERO_STRUCTP(data); + + if (!read_one_uint8(sock, &b, data, endtime)) + return False; + + if (b != 0x30) { + data->has_error = True; + return False; + } + + if (!read_one_uint8(sock, &b, data, endtime)) + return False; + + if (b & 0x80) { + int n = b & 0x7f; + if (!read_one_uint8(sock, &b, data, endtime)) + return False; + len = b; + while (n > 1) { + if (!read_one_uint8(sock, &b, data, endtime)) + return False; + len = (len<<8) | b; + n--; + } + } else { + len = b; + } + + buf = malloc(len); + if (buf == NULL) + return False; + + if (read_data_until(sock, buf, len, endtime) != len) + return False; + + if (!asn1_write(data, buf, len)) + return False; + + free(buf); + + data->ofs = 0; + + return True; +} +#endif + +/* Get the length to be expected in buf */ +BOOL asn1_object_length(uint8_t *buf, size_t buf_length, + uint8_t tag, size_t *result) +{ + ASN1_DATA data; + + /* Fake the asn1_load to avoid the memdup, this is just to be able to + * re-use the length-reading in asn1_start_tag */ + ZERO_STRUCT(data); + data.data = buf; + data.length = buf_length; + if (!asn1_start_tag(&data, tag)) + return False; + *result = asn1_tag_remaining(&data)+data.ofs; + /* We can't use asn1_end_tag here, as we did not consume the complete + * tag, so asn1_end_tag would flag an error and not free nesting */ + free(data.nesting); + return True; +} /* stop reading a tag */ BOOL asn1_end_tag(ASN1_DATA *data) @@ -342,7 +434,7 @@ int asn1_tag_remaining(ASN1_DATA *data) BOOL asn1_read_OID(ASN1_DATA *data, char **OID) { uint8_t b; - char *oid = NULL; + char *tmp_oid = NULL; TALLOC_CTX *mem_ctx = talloc_init("asn1_read_OID"); if (!mem_ctx) { return False; @@ -351,8 +443,8 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) if (!asn1_start_tag(data, ASN1_OID)) return False; asn1_read_uint8(data, &b); - oid = talloc_asprintf(mem_ctx, "%u", b/40); - oid = talloc_asprintf_append(mem_ctx, oid, " %u", b%40); + tmp_oid = talloc_asprintf(mem_ctx, "%u", b/40); + tmp_oid = talloc_asprintf_append(mem_ctx, tmp_oid, " %u", b%40); while (!data->has_error && asn1_tag_remaining(data) > 0) { uint_t v = 0; @@ -360,12 +452,12 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) asn1_read_uint8(data, &b); v = (v<<7) | (b&0x7f); } while (!data->has_error && b & 0x80); - oid = talloc_asprintf_append(mem_ctx, oid, " %u", v); + tmp_oid = talloc_asprintf_append(mem_ctx, tmp_oid, " %u", v); } asn1_end_tag(data); - *OID = strdup(oid); + *OID = strdup(tmp_oid); talloc_destroy(mem_ctx); return (*OID && !data->has_error); @@ -439,6 +531,20 @@ BOOL asn1_read_Integer(ASN1_DATA *data, int *i) } +/* read an interger */ +BOOL asn1_read_enumerated(ASN1_DATA *data, int *v) +{ + *v = 0; + + if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False; + while (asn1_tag_remaining(data)>0) { + uint8_t b; + asn1_read_uint8(data, &b); + *v = (*v << 8) + b; + } + return asn1_end_tag(data); +} + /* check a enumarted value is correct */ BOOL asn1_check_enumerated(ASN1_DATA *data, int v) { -- cgit From 2e28edd233964f54b46fde10217f93f571ed1d6d Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 12 Aug 2004 08:00:45 +0000 Subject: r1771: OK Let's add tests for ldap. Thanks to Metze and Volker for their unvaluable support :) (This used to be commit e6a6c0737ab94d58930c0d4e1ef0bb4d99510833) --- source4/libcli/util/asn1.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 6ddce7882c..6dc459d59d 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -313,7 +313,6 @@ BOOL asn1_start_tag(ASN1_DATA *data, uint8_t tag) return !data->has_error; } -#if 0 static BOOL read_one_uint8(int sock, uint8_t *result, ASN1_DATA *data, const struct timeval *endtime) { @@ -375,7 +374,6 @@ BOOL asn1_read_sequence_until(int sock, ASN1_DATA *data, return True; } -#endif /* Get the length to be expected in buf */ BOOL asn1_object_length(uint8_t *buf, size_t buf_length, -- cgit From 69d643535837bc23d8f7274ce476cf803b45969b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 17 Aug 2004 10:04:25 +0000 Subject: r1851: if we try to peek a subtag, check if the parent tag has remaining data metze (This used to be commit 01626ed381bdc9cab3e94e80220c916bb61acf30) --- source4/libcli/util/asn1.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 6dc459d59d..e7c38b2803 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -264,6 +264,10 @@ BOOL asn1_peek_tag(ASN1_DATA *data, uint8_t tag) { uint8_t b; + if (asn1_tag_remaining(data) <= 0) { + return False; + } + if (!asn1_peek(data, &b, sizeof(b))) return False; -- cgit From c074e30e2eacaacebb95efd755ad7de74a0970e8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 17 Aug 2004 11:22:44 +0000 Subject: r1856: - move asn1 functions to asn1.c - merge some stuff from trunk metze (This used to be commit 267edf1c0bb1ed73f1ba19148e6412b9a1c41979) --- source4/libcli/util/asn1.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index e7c38b2803..1f04e1fe46 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -166,6 +166,14 @@ BOOL asn1_write_GeneralString(ASN1_DATA *data, const char *s) return !data->has_error; } +BOOL asn1_write_ContextSimple(ASN1_DATA *data, uint8_t num, DATA_BLOB *blob) +{ + asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(num)); + asn1_write(data, blob->data, blob->length); + asn1_pop_tag(data); + return !data->has_error; +} + /* write a BOOLEAN */ BOOL asn1_write_BOOLEAN(ASN1_DATA *data, BOOL v) { @@ -518,6 +526,22 @@ BOOL asn1_read_OctetString(ASN1_DATA *data, DATA_BLOB *blob) return !data->has_error; } +BOOL asn1_read_ContextSimple(ASN1_DATA *data, uint8_t num, DATA_BLOB *blob) +{ + int len; + ZERO_STRUCTP(blob); + if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(num))) return False; + len = asn1_tag_remaining(data); + if (len < 0) { + data->has_error = True; + return False; + } + *blob = data_blob(NULL, len); + asn1_read(data, blob->data, len); + asn1_end_tag(data); + return !data->has_error; +} + /* read an interger */ BOOL asn1_read_Integer(ASN1_DATA *data, int *i) { -- cgit From dcd43a4cbef3bee948bdbd65212361b6043aa4bd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 22 Aug 2004 05:33:07 +0000 Subject: r1990: Fix breakage caused by the recent talloc changes. (Failure to process an SPNEGO login from WinXP at least). talloc_asprintf_append() lost an argument, but because TALLOC_CTX is now a void*, this was not picked up by the compiler. I've tested the login (asn1), but not the registry/gtk changes. Andrew Bartlett (This used to be commit 4294be44057124568fe1d176702056bb62ad3214) --- source4/libcli/util/asn1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 1f04e1fe46..293213a2d0 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -454,7 +454,7 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) asn1_read_uint8(data, &b); tmp_oid = talloc_asprintf(mem_ctx, "%u", b/40); - tmp_oid = talloc_asprintf_append(mem_ctx, tmp_oid, " %u", b%40); + tmp_oid = talloc_asprintf_append(tmp_oid, " %u", b%40); while (!data->has_error && asn1_tag_remaining(data) > 0) { uint_t v = 0; @@ -462,7 +462,7 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) asn1_read_uint8(data, &b); v = (v<<7) | (b&0x7f); } while (!data->has_error && b & 0x80); - tmp_oid = talloc_asprintf_append(mem_ctx, tmp_oid, " %u", v); + tmp_oid = talloc_asprintf_append(tmp_oid, " %u", v); } asn1_end_tag(data); -- cgit From 35d65298d5892ad2709d9c5a628179ba48fd46ba Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 25 Aug 2004 02:05:02 +0000 Subject: r2037: switched the asn.1 code to use talloc (This used to be commit c0862278cab106a441d1049c1da945fa11353f9f) --- source4/libcli/util/asn1.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 293213a2d0..6f613f398b 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -23,7 +23,7 @@ /* free an asn1 structure */ void asn1_free(ASN1_DATA *data) { - SAFE_FREE(data->data); + talloc_free(data->data); } /* write to the ASN1 buffer, advancing the buffer pointer */ @@ -32,9 +32,9 @@ BOOL asn1_write(ASN1_DATA *data, const void *p, int len) if (data->has_error) return False; if (data->length < data->ofs+len) { uint8_t *newp; - newp = Realloc(data->data, data->ofs+len); + newp = talloc_realloc(data->data, data->ofs+len); if (!newp) { - SAFE_FREE(data->data); + asn1_free(data); data->has_error = True; return False; } @@ -58,7 +58,7 @@ BOOL asn1_push_tag(ASN1_DATA *data, uint8_t tag) struct nesting *nesting; asn1_write_uint8(data, tag); - nesting = (struct nesting *)malloc(sizeof(struct nesting)); + nesting = talloc_p(NULL, struct nesting); if (!nesting) { data->has_error = True; return False; @@ -103,7 +103,7 @@ BOOL asn1_pop_tag(ASN1_DATA *data) } data->nesting = nesting->next; - free(nesting); + talloc_free(nesting); return True; } @@ -223,7 +223,7 @@ BOOL asn1_check_BOOLEAN(ASN1_DATA *data, BOOL v) BOOL asn1_load(ASN1_DATA *data, DATA_BLOB blob) { ZERO_STRUCTP(data); - data->data = memdup(blob.data, blob.length); + data->data = talloc_memdup(NULL, blob.data, blob.length); if (!data->data) { data->has_error = True; return False; @@ -295,7 +295,7 @@ BOOL asn1_start_tag(ASN1_DATA *data, uint8_t tag) data->has_error = True; return False; } - nesting = (struct nesting *)malloc(sizeof(struct nesting)); + nesting = talloc_p(NULL, struct nesting); if (!nesting) { data->has_error = True; return False; @@ -370,7 +370,7 @@ BOOL asn1_read_sequence_until(int sock, ASN1_DATA *data, len = b; } - buf = malloc(len); + buf = talloc(NULL, len); if (buf == NULL) return False; @@ -380,7 +380,7 @@ BOOL asn1_read_sequence_until(int sock, ASN1_DATA *data, if (!asn1_write(data, buf, len)) return False; - free(buf); + talloc_free(buf); data->ofs = 0; @@ -403,7 +403,7 @@ BOOL asn1_object_length(uint8_t *buf, size_t buf_length, *result = asn1_tag_remaining(&data)+data.ofs; /* We can't use asn1_end_tag here, as we did not consume the complete * tag, so asn1_end_tag would flag an error and not free nesting */ - free(data.nesting); + talloc_free(data.nesting); return True; } @@ -426,7 +426,7 @@ BOOL asn1_end_tag(ASN1_DATA *data) } data->nesting = nesting->next; - free(nesting); + talloc_free(nesting); return True; } @@ -445,15 +445,11 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) { uint8_t b; char *tmp_oid = NULL; - TALLOC_CTX *mem_ctx = talloc_init("asn1_read_OID"); - if (!mem_ctx) { - return False; - } if (!asn1_start_tag(data, ASN1_OID)) return False; asn1_read_uint8(data, &b); - tmp_oid = talloc_asprintf(mem_ctx, "%u", b/40); + tmp_oid = talloc_asprintf(NULL, "%u", b/40); tmp_oid = talloc_asprintf_append(tmp_oid, " %u", b%40); while (!data->has_error && asn1_tag_remaining(data) > 0) { @@ -467,8 +463,8 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) asn1_end_tag(data); - *OID = strdup(tmp_oid); - talloc_destroy(mem_ctx); + *OID = talloc_strdup(NULL, tmp_oid); + talloc_free(tmp_oid); return (*OID && !data->has_error); } @@ -484,7 +480,7 @@ BOOL asn1_check_OID(ASN1_DATA *data, const char *OID) data->has_error = True; return False; } - free(id); + talloc_free(id); return True; } @@ -498,7 +494,7 @@ BOOL asn1_read_GeneralString(ASN1_DATA *data, char **s) data->has_error = True; return False; } - *s = malloc(len+1); + *s = talloc(NULL, len+1); if (! *s) { data->has_error = True; return False; -- cgit From 18bbab726884725ccf2f3264223866194855f320 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 30 Aug 2004 01:34:01 +0000 Subject: r2099: Get rid of another private ARCFOUR implementation from the codebase. Andrew Bartlett (This used to be commit 0237389ce765cbb6825b79de1b0727da0969efeb) --- source4/libcli/util/smbdes.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index 99c2c00977..a7c8f760ea 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -364,30 +364,36 @@ void des_crypt112_16(uint8_t out[16], uint8_t in[16], const uint8_t key[14], int des_crypt56(out + 8, in + 8, key+7, forw); } -/* - arcfour encryption with a blob key -*/ -void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key) +/* initialise the arcfour sbox with key */ +void arcfour_init(uint8_t s_box[256], const DATA_BLOB *key) { - uint8_t s_box[256]; - uint8_t index_i = 0; - uint8_t index_j = 0; - uint8_t j = 0; int ind; - + uint8_t j = 0; for (ind = 0; ind < 256; ind++) { s_box[ind] = (uint8_t)ind; } - + for (ind = 0; ind < 256; ind++) { uint8_t tc; - + j += (s_box[ind] + key->data[ind%key->length]); - + tc = s_box[ind]; s_box[ind] = s_box[j]; s_box[j] = tc; } + s_box[256] = 0; /* i */ + s_box[257] = 0; /* j */ + +} + +/* crypt the data with arcfour */ +void arcfour_crypt_sbox(uint8_t s_box[258], uint8_t *data, int len) +{ + uint8_t index_i = s_box[256]; + uint8_t index_j = s_box[257]; + int ind; + for (ind = 0; ind < len; ind++) { uint8_t tc; uint8_t t; @@ -402,6 +408,18 @@ void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key) t = s_box[index_i] + s_box[index_j]; data[ind] = data[ind] ^ s_box[t]; } + s_box[256] = index_i; + s_box[257] = index_j; +} + +/* + arcfour encryption with a blob key +*/ +void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key) +{ + uint8_t s_box[258]; + arcfour_init(s_box, key); + arcfour_crypt_sbox(s_box, data, len); } /* -- cgit From f3d946646975cc04c5abd6b41adaf547175d6aab Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 30 Aug 2004 05:33:49 +0000 Subject: r2102: fixed a race condition when handling dos errors that are in our table. Should get rid of the static buffer completely at some point. (This used to be commit e0bda611121ed1f4afc2bfe83853e5521c494164) --- source4/libcli/util/doserr.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index c4ec869961..b8605864fc 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -22,13 +22,12 @@ #include "includes.h" -typedef const struct -{ +struct werror_code_struct { const char *dos_errstr; WERROR werror; -} werror_code_struct; +}; -werror_code_struct dos_errs[] = +static const struct werror_code_struct dos_errs[] = { { "WERR_OK", WERR_OK }, { "WERR_BADFILE", WERR_BADFILE }, @@ -79,8 +78,6 @@ const char *win_errstr(WERROR werror) static pstring msg; int idx = 0; - slprintf(msg, sizeof(msg), "DOS code 0x%08x", W_ERROR_V(werror)); - while (dos_errs[idx].dos_errstr != NULL) { if (W_ERROR_V(dos_errs[idx].werror) == W_ERROR_V(werror)) @@ -88,5 +85,7 @@ const char *win_errstr(WERROR werror) idx++; } + slprintf(msg, sizeof(msg), "DOS code 0x%08x", W_ERROR_V(werror)); + return msg; } -- cgit From 776d90d801ee253157f9de90416a93bfc7bfd55e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 31 Aug 2004 06:21:14 +0000 Subject: r2122: merge from trunk (-r 2120): Fix bug found by Love H?\195?\182rnquist ?\195?\133strand: asn1_write_Integer needs to push stuff little endian. (This used to be commit 79bee828fbb70e71ad3fbd45758bcc7775ea977b) --- source4/libcli/util/asn1.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 6f613f398b..756a33f77d 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -107,15 +107,23 @@ BOOL asn1_pop_tag(ASN1_DATA *data) return True; } +static void push_int_littleendian(ASN1_DATA *data, int i) +{ + uint8_t lowest = i & 0xFF; + + i = i >> 8; + if (i != 0) + push_int_littleendian(data, i); + + asn1_write_uint8(data, lowest); +} + /* write an integer */ BOOL asn1_write_Integer(ASN1_DATA *data, int i) { if (!asn1_push_tag(data, ASN1_INTEGER)) return False; - do { - asn1_write_uint8(data, i); - i = i >> 8; - } while (i); + push_int_littleendian(data, i); return asn1_pop_tag(data); } -- cgit From 0575d5e0d2d1548ce2f6d133ccebe65a0b6b7745 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 31 Aug 2004 07:14:34 +0000 Subject: r2124: merge from trunk (-r 2123): Argl. I could never get the naming right. Having the most significant byte at the lowest memory address is big endian, at least according to the google search for 'big endian'.... Volker (This used to be commit bc4c188362901423cc900fd4bdfa4a9ed6838f2b) --- source4/libcli/util/asn1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 756a33f77d..7025808a1e 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -107,13 +107,13 @@ BOOL asn1_pop_tag(ASN1_DATA *data) return True; } -static void push_int_littleendian(ASN1_DATA *data, int i) +static void push_int_bigendian(ASN1_DATA *data, int i) { uint8_t lowest = i & 0xFF; i = i >> 8; if (i != 0) - push_int_littleendian(data, i); + push_int_bigendian(data, i); asn1_write_uint8(data, lowest); } @@ -123,7 +123,7 @@ static void push_int_littleendian(ASN1_DATA *data, int i) BOOL asn1_write_Integer(ASN1_DATA *data, int i) { if (!asn1_push_tag(data, ASN1_INTEGER)) return False; - push_int_littleendian(data, i); + push_int_bigendian(data, i); return asn1_pop_tag(data); } -- cgit From deb288d82e92644dcc2431806e214dfeac7b0e84 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 1 Sep 2004 07:29:02 +0000 Subject: r2166: sync the asn1 stuff with trunk metze (This used to be commit 46762c9ee011e5c37f3d94a1b80ed7d679c55434) --- source4/libcli/util/asn1.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 7025808a1e..7e313bcd4a 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -107,23 +107,59 @@ BOOL asn1_pop_tag(ASN1_DATA *data) return True; } -static void push_int_bigendian(ASN1_DATA *data, int i) +/* "i" is the one's complement representation, as is the normal result of an + * implicit signed->unsigned conversion */ + +static void push_int_bigendian(ASN1_DATA *data, unsigned int i, BOOL negative) { uint8_t lowest = i & 0xFF; i = i >> 8; if (i != 0) - push_int_bigendian(data, i); + push_int_bigendian(data, i, negative); + + if (data->nesting->start+1 == data->ofs) { + + /* We did not write anything yet, looking at the highest + * valued byte */ + + if (negative) { + /* Don't write leading 0xff's */ + if (lowest == 0xFF) + return; + + if ((lowest & 0x80) == 0) { + /* The only exception for a leading 0xff is if + * the highest bit is 0, which would indicate + * a positive value */ + asn1_write_uint8(data, 0xff); + } + } else { + if (lowest & 0x80) { + /* The highest bit of a positive integer is 1, + * this would indicate a negative number. Push + * a 0 to indicate a positive one */ + asn1_write_uint8(data, 0); + } + } + } asn1_write_uint8(data, lowest); } - /* write an integer */ BOOL asn1_write_Integer(ASN1_DATA *data, int i) { if (!asn1_push_tag(data, ASN1_INTEGER)) return False; - push_int_bigendian(data, i); + if (i == -1) { + /* -1 is special as it consists of all-0xff bytes. In + push_int_bigendian this is the only case that is not + properly handled, as all 0xff bytes would be handled as + leading ones to be ignored. */ + asn1_write_uint8(data, 0xff); + } else { + push_int_bigendian(data, i, i<0); + } return asn1_pop_tag(data); } -- cgit From 3e454a5891b73c9b021406bdb662127e1a3180dc Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 1 Sep 2004 14:49:43 +0000 Subject: r2173: Fix asn1 BOOLEANs. Thanks to Love Hornquist-Astrand. Volker (This used to be commit 53f58c053b643c8b45d2f9394faf8cfdd5005f6d) --- source4/libcli/util/asn1.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 7e313bcd4a..b5db9b157e 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -220,23 +220,14 @@ BOOL asn1_write_ContextSimple(ASN1_DATA *data, uint8_t num, DATA_BLOB *blob) /* write a BOOLEAN */ BOOL asn1_write_BOOLEAN(ASN1_DATA *data, BOOL v) -{ - asn1_write_uint8(data, ASN1_BOOLEAN); - asn1_write_uint8(data, v); - return !data->has_error; -} - -/* write a BOOLEAN - hmm, I suspect this one is the correct one, and the - above boolean is bogus. Need to check */ -BOOL asn1_write_BOOLEAN2(ASN1_DATA *data, BOOL v) { asn1_push_tag(data, ASN1_BOOLEAN); - asn1_write_uint8(data, v); + asn1_write_uint8(data, v ? 0xFF : 0); asn1_pop_tag(data); return !data->has_error; } -BOOL asn1_read_BOOLEAN2(ASN1_DATA *data, BOOL *v) +BOOL asn1_read_BOOLEAN(ASN1_DATA *data, BOOL *v) { asn1_start_tag(data, ASN1_BOOLEAN); asn1_read_uint8(data, (uint8 *)v); -- cgit From d9d634ce97b2fd7d49410d26271eacd98660bbc4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 15 Sep 2004 13:29:59 +0000 Subject: r2347: merge LDAP ASN.1 fixes from trunk metze (This used to be commit 492a00d909d6f3ff8305f102551f60d91d988ccd) --- source4/libcli/util/asn1.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index b5db9b157e..ca62a0b574 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -110,13 +110,14 @@ BOOL asn1_pop_tag(ASN1_DATA *data) /* "i" is the one's complement representation, as is the normal result of an * implicit signed->unsigned conversion */ -static void push_int_bigendian(ASN1_DATA *data, unsigned int i, BOOL negative) +static BOOL push_int_bigendian(ASN1_DATA *data, unsigned int i, BOOL negative) { uint8_t lowest = i & 0xFF; i = i >> 8; if (i != 0) - push_int_bigendian(data, i, negative); + if (!push_int_bigendian(data, i, negative)) + return False; if (data->nesting->start+1 == data->ofs) { @@ -126,40 +127,51 @@ static void push_int_bigendian(ASN1_DATA *data, unsigned int i, BOOL negative) if (negative) { /* Don't write leading 0xff's */ if (lowest == 0xFF) - return; + return True; if ((lowest & 0x80) == 0) { /* The only exception for a leading 0xff is if * the highest bit is 0, which would indicate * a positive value */ - asn1_write_uint8(data, 0xff); + if (!asn1_write_uint8(data, 0xff)) + return False; } } else { if (lowest & 0x80) { /* The highest bit of a positive integer is 1, * this would indicate a negative number. Push * a 0 to indicate a positive one */ - asn1_write_uint8(data, 0); + if (!asn1_write_uint8(data, 0)) + return False; } } } - asn1_write_uint8(data, lowest); + return asn1_write_uint8(data, lowest); } -/* write an integer */ -BOOL asn1_write_Integer(ASN1_DATA *data, int i) +/* write an Integer without the tag framing. Needed for example for the LDAP + * Abandon Operation */ + +BOOL asn1_write_implicit_Integer(ASN1_DATA *data, int i) { - if (!asn1_push_tag(data, ASN1_INTEGER)) return False; if (i == -1) { /* -1 is special as it consists of all-0xff bytes. In push_int_bigendian this is the only case that is not properly handled, as all 0xff bytes would be handled as leading ones to be ignored. */ - asn1_write_uint8(data, 0xff); + return asn1_write_uint8(data, 0xff); } else { - push_int_bigendian(data, i, i<0); + return push_int_bigendian(data, i, i<0); } +} + + +/* write an integer */ +BOOL asn1_write_Integer(ASN1_DATA *data, int i) +{ + if (!asn1_push_tag(data, ASN1_INTEGER)) return False; + if (!asn1_write_implicit_Integer(data, i)) return False; return asn1_pop_tag(data); } -- cgit From 2e55ba2018a25aac33cec76ee16c2e9754421448 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 22 Sep 2004 05:14:59 +0000 Subject: r2498: added STATUS_NO_MORE_FILES to nt status codes that we can map to a string (This used to be commit b7191999634cf3817dc69dd3743d185ae41dbdc3) --- source4/libcli/util/nterr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index c71dc2247b..563e27ddbf 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -31,6 +31,7 @@ typedef struct static const nt_err_code_struct nt_errs[] = { { "NT_STATUS_OK", NT_STATUS_OK }, + { "STATUS_NO_MORE_FILES", STATUS_NO_MORE_FILES }, { "NT_STATUS_UNSUCCESSFUL", NT_STATUS_UNSUCCESSFUL }, { "NT_STATUS_NOT_IMPLEMENTED", NT_STATUS_NOT_IMPLEMENTED }, { "NT_STATUS_INVALID_INFO_CLASS", NT_STATUS_INVALID_INFO_CLASS }, -- cgit From 211d3cff2f6d5669af71699c74e6d40c4206249a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 22 Sep 2004 10:42:09 +0000 Subject: r2507: Allow a case-insensitive lookup when converting strings into NTSTATUS values. Andrew Bartlett (This used to be commit 59e361f7cca1bbaeba5d5952173b90665a76ab2d) --- source4/libcli/util/nterr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 563e27ddbf..2adb561222 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -707,7 +707,7 @@ NTSTATUS nt_status_string_to_code(char *nt_status_str) int idx = 0; while (nt_errs[idx].nt_errstr != NULL) { - if (strcmp(nt_errs[idx].nt_errstr, nt_status_str) == 0) { + if (strcasecmp(nt_errs[idx].nt_errstr, nt_status_str) == 0) { return nt_errs[idx].nt_errcode; } idx++; -- cgit From bc8ef3d1b6bfdf279d65783869b9a247c1da38aa Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 22 Sep 2004 12:25:53 +0000 Subject: r2516: Remove duplicate line. (This used to be commit dff6262e4f9d48ed753e00faf081e52c03c7129c) --- source4/libcli/util/dom_sid.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/dom_sid.c b/source4/libcli/util/dom_sid.c index 0ca4cd731f..c2d188abec 100644 --- a/source4/libcli/util/dom_sid.c +++ b/source4/libcli/util/dom_sid.c @@ -66,7 +66,6 @@ struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) ret->sid_rev_num = rev; ret->id_auth[0] = 0; - ret->id_auth[0] = 0; ret->id_auth[1] = 0; ret->id_auth[2] = ia >> 24; ret->id_auth[3] = ia >> 16; -- cgit From ca60193f24bb2540e65c8c272ca2bead3850b456 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 22 Sep 2004 12:38:19 +0000 Subject: r2520: - finished implementing the server side of the old style search requests (This used to be commit 4e4859c06b9de5fe60ebd17cfb09eed480b79ec1) --- source4/libcli/util/errormap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index e2aeded65d..482743b03b 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -50,6 +50,7 @@ static const struct { uint32_t dos_code; NTSTATUS ntstatus; } ntstatus_to_dos_map[] = { + {ERRDOS, ERRnofiles, STATUS_NO_MORE_FILES}, {ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, {ERRDOS, 87, NT_STATUS_INVALID_INFO_CLASS}, @@ -616,6 +617,7 @@ static const struct { uint32_t dos_code; NTSTATUS ntstatus; } dos_to_ntstatus_map[] = { + {ERRDOS, ERRnofiles, STATUS_NO_MORE_FILES}, {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, {ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, @@ -628,7 +630,6 @@ static const struct { {ERRDOS, 14, NT_STATUS_SECTION_NOT_EXTENDED}, {ERRDOS, ERRremcd, NT_STATUS_DIRECTORY_NOT_EMPTY}, {ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE}, - {ERRDOS, ERRnofiles, NT_STATUS(0x80000006)}, {ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED}, {ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE}, {ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE}, -- cgit From 5e7259a6977078b95008856a3f8986fbb99e7a1b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 22 Sep 2004 21:50:49 +0000 Subject: r2535: Make certain, that even if we have invalid ASN.1 here, and the caller does not check the return value, that we don't return uninitialised memory here. Andrew Bartlett (This used to be commit 0e081ecb9d752067b99305b3b62477c3eed9ac24) --- source4/libcli/util/asn1.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index ca62a0b574..3dc5abc09a 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -566,7 +566,13 @@ BOOL asn1_read_OctetString(ASN1_DATA *data, DATA_BLOB *blob) *blob = data_blob(NULL, len); asn1_read(data, blob->data, len); asn1_end_tag(data); - return !data->has_error; + + if (data->has_error) { + data_blob_free(blob); + *blob = data_blob(NULL, 0); + return False; + } + return True; } BOOL asn1_read_ContextSimple(ASN1_DATA *data, uint8_t num, DATA_BLOB *blob) -- cgit From 9a9dcc7250ccd4544cb797c15b3bc3dfbb760be0 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 23 Sep 2004 00:51:45 +0000 Subject: r2552: Character set conversion and string handling updates. The intial motivation for this commit was to merge in some of the bugfixes present in Samba3's chrcnv and string handling code into Samba4. However, along the way I found a lot of unused functions, and decided to do a bit more... The strlen_m code now does not use a fixed buffer, but more work is needed to finish off other functions in str_util.c. These fixed length buffers hav caused very nasty, hard to chase down bugs at some sites. The strupper_m() function has a strupper_talloc() to replace it (we need to go around and fix more uses, but it's a start). Use of these new functions will avoid bugs where the upper or lowercase version of a string is a different length. I have removed the push_*_allocate functions, which are replaced by calls to push_*_talloc. Likewise, pstring and other 'fixed length' wrappers are removed, where possible. I have removed the first ('base pointer') argument, used by push_ucs2, as the Samba4 way of doing things ensures that this is always on an even boundary anyway. (It was used in only one place, in any case). (This used to be commit dfecb0150627b500cb026b8a4932fe87902ca392) --- source4/libcli/util/smbencrypt.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index a50b4edc88..f0dba16a5a 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -61,15 +61,17 @@ BOOL SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24]) void E_md4hash(const char *passwd, uint8_t p16[16]) { int len; - smb_ucs2_t wpwd[129]; + smb_ucs2_t *wpwd; - /* Password must be converted to NT unicode - null terminated. */ - push_ucs2(NULL, wpwd, (const char *)passwd, 256, STR_UNICODE|STR_NOALIGN|STR_TERMINATE); - /* Calculate length in bytes */ - len = strlen_w(wpwd) * sizeof(int16_t); + TALLOC_CTX *mem_ctx = talloc_init("E_md4hash"); + SMB_ASSERT(mem_ctx); + len = push_ucs2_talloc(mem_ctx, &wpwd, passwd); + SMB_ASSERT(len >= 2); + + len -= 2; mdfour(p16, (uint8_t *)wpwd, len); - ZERO_STRUCT(wpwd); + talloc_free(mem_ctx); } /** @@ -114,16 +116,22 @@ BOOL ntv2_owf_gen(const uint8_t owf[16], size_t domain_byte_len; HMACMD5Context ctx; + TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in); + if (!mem_ctx) { + return False; + } - user_byte_len = push_ucs2_allocate(&user, user_in); - if (user_byte_len == (size_t)-1) { - DEBUG(0, ("push_uss2_allocate() for user returned -1 (probably malloc() failure)\n")); + user_byte_len = push_ucs2_talloc(mem_ctx, &user, user_in); + if (user_byte_len == (ssize_t)-1) { + DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n")); + talloc_free(mem_ctx); return False; } - domain_byte_len = push_ucs2_allocate(&domain, domain_in); - if (domain_byte_len == (size_t)-1) { - DEBUG(0, ("push_uss2_allocate() for domain returned -1 (probably malloc() failure)\n")); + domain_byte_len = push_ucs2_talloc(mem_ctx, &domain, domain_in); + if (domain_byte_len == (ssize_t)-1) { + DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n")); + talloc_free(mem_ctx); return False; } @@ -152,8 +160,7 @@ BOOL ntv2_owf_gen(const uint8_t owf[16], dump_data(100, kr_buf, 16); #endif - SAFE_FREE(user); - SAFE_FREE(domain); + talloc_free(mem_ctx); return True; } @@ -407,7 +414,7 @@ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) uint8_t new_pw[512]; size_t new_pw_len; - new_pw_len = push_string(NULL, new_pw, + new_pw_len = push_string(new_pw, password, sizeof(new_pw), string_flags); @@ -459,7 +466,7 @@ BOOL decode_pw_buffer(char in_buffer[516], char *new_pwrd, } /* decode into the return buffer. Buffer length supplied */ - *new_pw_len = pull_string(NULL, new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, + *new_pw_len = pull_string(new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, byte_len, string_flags); #ifdef DEBUG_PASSWORD -- cgit From 5b44130afad1bb1764d986de3ef0e8e04b0e7357 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Sep 2004 01:36:19 +0000 Subject: r2671: we're getting too many errors caused by the talloc_realloc() API not taking a context (so when you pass a NULL pointer you end up with memory in a top level context). Fixed it by changing the API to take a context. The context is only used if the pointer you are reallocing is NULL. (This used to be commit 8dc23821c9f54b2f13049b5e608a0cafb81aa540) --- source4/libcli/util/asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 3dc5abc09a..4ff335399a 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -32,7 +32,7 @@ BOOL asn1_write(ASN1_DATA *data, const void *p, int len) if (data->has_error) return False; if (data->length < data->ofs+len) { uint8_t *newp; - newp = talloc_realloc(data->data, data->ofs+len); + newp = talloc_realloc(NULL, data->data, data->ofs+len); if (!newp) { asn1_free(data); data->has_error = True; -- cgit From e54cc10f1680a965c058dcb9c32c3cd1750ae13d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 29 Sep 2004 12:40:30 +0000 Subject: r2749: add asn1_read_implicit_Integer() metze (This used to be commit a62fbcb30f63245d9dfb48c83a5f449965bb1ca7) --- source4/libcli/util/asn1.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 4ff335399a..138ae930e3 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -591,17 +591,27 @@ BOOL asn1_read_ContextSimple(ASN1_DATA *data, uint8_t num, DATA_BLOB *blob) return !data->has_error; } -/* read an interger */ -BOOL asn1_read_Integer(ASN1_DATA *data, int *i) +/* read an interger without tag*/ +BOOL asn1_read_implicit_Integer(ASN1_DATA *data, int *i) { uint8_t b; *i = 0; - - if (!asn1_start_tag(data, ASN1_INTEGER)) return False; + while (asn1_tag_remaining(data)>0) { - asn1_read_uint8(data, &b); + if (!asn1_read_uint8(data, &b)) return False; *i = (*i << 8) + b; } + return !data->has_error; + +} + +/* read an interger */ +BOOL asn1_read_Integer(ASN1_DATA *data, int *i) +{ + *i = 0; + + if (!asn1_start_tag(data, ASN1_INTEGER)) return False; + if (!asn1_read_implicit_Integer(data, i)) return False; return asn1_end_tag(data); } -- cgit From 7d32679e9683c81aca538f0267684332a28a286f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 8 Oct 2004 08:13:00 +0000 Subject: r2857: this commit gets rid of smb_ucs2_t, wpstring and fpstring, plus lots of associated functions. The motivation for this change was to avoid having to convert to/from ucs2 strings for so many operations. Doing that was slow, used many static buffers, and was also incorrect as it didn't cope properly with unicode codepoints above 65536 (which could not be represented correctly as smb_ucs2_t chars) The two core functions that allowed this change are next_codepoint() and push_codepoint(). These functions allow you to correctly walk a arbitrary multi-byte string a character at a time without converting the whole string to ucs2. While doing this cleanup I also fixed several ucs2 string handling bugs. See the commit for details. The following code (which counts the number of occuraces of 'c' in a string) shows how to use the new interface: size_t count_chars(const char *s, char c) { size_t count = 0; while (*s) { size_t size; codepoint_t c2 = next_codepoint(s, &size); if (c2 == c) count++; s += size; } return count; } (This used to be commit 814881f0e50019196b3aa9fbe4aeadbb98172040) --- source4/libcli/util/smbencrypt.c | 44 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index f0dba16a5a..1089c3a4cf 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -61,17 +61,15 @@ BOOL SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24]) void E_md4hash(const char *passwd, uint8_t p16[16]) { int len; - smb_ucs2_t *wpwd; - - TALLOC_CTX *mem_ctx = talloc_init("E_md4hash"); - SMB_ASSERT(mem_ctx); + void *wpwd; - len = push_ucs2_talloc(mem_ctx, &wpwd, passwd); + len = push_ucs2_talloc(NULL, &wpwd, passwd); SMB_ASSERT(len >= 2); len -= 2; - mdfour(p16, (uint8_t *)wpwd, len); - talloc_free(mem_ctx); + mdfour(p16, wpwd, len); + + talloc_free(wpwd); } /** @@ -109,9 +107,8 @@ BOOL ntv2_owf_gen(const uint8_t owf[16], BOOL upper_case_domain, /* Transform the domain into UPPER case */ uint8_t kr_buf[16]) { - smb_ucs2_t *user; - smb_ucs2_t *domain; - + void *user; + void *domain; size_t user_byte_len; size_t domain_byte_len; @@ -121,6 +118,20 @@ BOOL ntv2_owf_gen(const uint8_t owf[16], return False; } + user_in = strupper_talloc(mem_ctx, user_in); + if (user_in == NULL) { + talloc_free(mem_ctx); + return False; + } + + if (upper_case_domain) { + domain_in = strupper_talloc(mem_ctx, domain_in); + if (domain_in == NULL) { + talloc_free(mem_ctx); + return False; + } + } + user_byte_len = push_ucs2_talloc(mem_ctx, &user, user_in); if (user_byte_len == (ssize_t)-1) { DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n")); @@ -135,11 +146,6 @@ BOOL ntv2_owf_gen(const uint8_t owf[16], return False; } - strupper_w(user); - - if (upper_case_domain) - strupper_w(domain); - SMB_ASSERT(user_byte_len >= 2); SMB_ASSERT(domain_byte_len >= 2); @@ -148,14 +154,14 @@ BOOL ntv2_owf_gen(const uint8_t owf[16], domain_byte_len = domain_byte_len - 2; hmac_md5_init_limK_to_64(owf, 16, &ctx); - hmac_md5_update((const uint8_t *)user, user_byte_len, &ctx); - hmac_md5_update((const uint8_t *)domain, domain_byte_len, &ctx); + hmac_md5_update(user, user_byte_len, &ctx); + hmac_md5_update(domain, domain_byte_len, &ctx); hmac_md5_final(kr_buf, &ctx); #ifdef DEBUG_PASSWORD DEBUG(100, ("ntv2_owf_gen: user, domain, owfkey, kr\n")); - dump_data(100, (const char *)user, user_byte_len); - dump_data(100, (const char *)domain, domain_byte_len); + dump_data(100, user, user_byte_len); + dump_data(100, domain, domain_byte_len); dump_data(100, owf, 16); dump_data(100, kr_buf, 16); #endif -- cgit From 9d26f044a34bbc53a7621c7343cdcbbc752f99ac Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 9 Oct 2004 23:58:11 +0000 Subject: r2883: set BOOL to the internal values not the wire ones metze (This used to be commit ad7b0385cfdb989d69a5c42c21fdaf8cd816999e) --- source4/libcli/util/asn1.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 138ae930e3..15d9243acd 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -241,8 +241,14 @@ BOOL asn1_write_BOOLEAN(ASN1_DATA *data, BOOL v) BOOL asn1_read_BOOLEAN(ASN1_DATA *data, BOOL *v) { + uint8_t tmp = 0; asn1_start_tag(data, ASN1_BOOLEAN); - asn1_read_uint8(data, (uint8 *)v); + asn1_read_uint8(data, &tmp); + if (tmp == 0xFF) { + *v = True; + } else { + *v = False; + } asn1_end_tag(data); return !data->has_error; } -- cgit From d78ae0b646028916b59c2beeeefe9c62c1d97517 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 18 Oct 2004 15:26:16 +0000 Subject: r3044: resolve the error code for WERR_DS_OBJ_NOT_FOUND to the name metze (This used to be commit c79bbe54b400f8e088401e1d59a626cb2a37ee34) --- source4/libcli/util/doserr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index b8605864fc..c8e0e89078 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -67,6 +67,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DFS_CANT_CREATE_JUNCT", WERR_DFS_CANT_CREATE_JUNCT }, { "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR }, { "WERR_INVALID_OWNER", WERR_INVALID_OWNER }, + { "WERR_DS_OBJ_NOT_FOUND", WERR_DS_OBJ_NOT_FOUND }, { NULL, W_ERROR(0) } }; -- cgit From 651f3903f0a380a951bfe5bf80322f1ab2330705 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Oct 2004 06:49:27 +0000 Subject: r3131: - make map_nt_error_from_unix() return NT_STATUS_UNSUCCESSFUL if errno is 0 - more consistent checking for system call return values in simple backend (This used to be commit 375a9a1347abf0b917cf94ea0cabcdea37d60e98) --- source4/libcli/util/errormap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 482743b03b..650dc55e50 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1534,13 +1534,13 @@ const struct unix_error_map unix_dos_nt_errmap[] = { /********************************************************************* Map an NT error code from a Unix error code. *********************************************************************/ - NTSTATUS map_nt_error_from_unix(int unix_error) { int i = 0; - if (unix_error == 0) - return NT_STATUS_OK; + if (unix_error == 0) { + return NT_STATUS_UNSUCCESSFUL; + } /* Look through list */ while(unix_dos_nt_errmap[i].unix_error != 0) { -- cgit From 6b2fc6e2d431261ea0877afa27a70ec15d504f37 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 25 Oct 2004 06:22:29 +0000 Subject: r3197: fixed error code mapping for ENOTDIR (This used to be commit 2c852539ed089b584b721a31cd411667bb5669c7) --- source4/libcli/util/errormap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 650dc55e50..ce7832eaac 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1498,7 +1498,7 @@ const struct unix_error_map unix_dos_nt_errmap[] = { { EPERM, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND }, - { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND }, + { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_NOT_A_DIRECTORY }, { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR }, { EBADF, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE }, { EINVAL, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE }, -- cgit From e1c43f243a7dea8c8a7ae235252091d1e18c2fb4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 25 Oct 2004 07:56:48 +0000 Subject: r3206: - added the reverse map for ERRbaduid to NT_STATUS_INVALID_HANDLE - force disable spnego in the RAW-CONTEXT test (it breaks the test) (This used to be commit 3f247ec21c59af92b420a3e550552b5a1f1f08e2) --- source4/libcli/util/errormap.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index ce7832eaac..91ebddc181 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -747,6 +747,7 @@ static const struct { {ERRSRV, ERRnoroom, NT_STATUS_DISK_FULL}, {ERRSRV, ERRnoresource, NT_STATUS_REQUEST_NOT_ACCEPTED}, {ERRSRV, ERRtoomanyuids, NT_STATUS_TOO_MANY_SESSIONS}, + {ERRSRV, ERRbaduid, NT_STATUS_INVALID_HANDLE}, {ERRSRV, 123, NT_STATUS_OBJECT_NAME_INVALID}, {ERRSRV, 206, NT_STATUS_OBJECT_NAME_INVALID}, {ERRHRD, 1, NT_STATUS_NOT_IMPLEMENTED}, -- cgit From 9d055846f225bea4953822f40fab1d2f1a2e2d07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 27 Oct 2004 03:15:42 +0000 Subject: r3278: - rewrote the client side rpc connection code to use lib/socket/ rather than doing everything itself. This greatly simplifies the code, although I really don't like the socket_recv() interface (it always allocates memory for you, which means an extra memcpy in this code) - fixed several bugs in the socket_ipv4.c code, in particular client side code used a non-blocking connect but didn't handle EINPROGRESS, so it had no chance of working. Also fixed the error codes, using map_nt_error_from_unix() - cleaned up and expanded map_nt_error_from_unix() - changed interpret_addr2() to not take a mem_ctx. It makes absolutely no sense to allocate a fixed size 4 byte structure like this. Dozens of places in the code were also using interpret_addr2() incorrectly (precisely because the allocation made no sense) (This used to be commit 7f2c771b0e0e98c5c9e5cf662592d64d34ff1205) --- source4/libcli/util/errormap.c | 73 ++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 91ebddc181..46e4831f89 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1490,66 +1490,69 @@ WERROR ntstatus_to_werror(NTSTATUS error) struct unix_error_map { int unix_error; - int dos_class; - int dos_code; NTSTATUS nt_error; }; -const struct unix_error_map unix_dos_nt_errmap[] = { - { EPERM, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, - { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, - { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND }, - { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_NOT_A_DIRECTORY }, - { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR }, - { EBADF, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE }, - { EINVAL, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE }, - { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION}, - { ENFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES }, - { EMFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES }, - { ENOSPC, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, - { EISDIR, ERRDOS, ERRbadpath, NT_STATUS_FILE_IS_A_DIRECTORY }, +const struct unix_error_map unix_nt_errmap[] = { + { EAGAIN, STATUS_MORE_ENTRIES }, + { EINTR, STATUS_MORE_ENTRIES }, + { EINPROGRESS, STATUS_MORE_ENTRIES }, + { EPERM, NT_STATUS_ACCESS_DENIED }, + { EACCES, NT_STATUS_ACCESS_DENIED }, + { ENOENT, NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { ENOTDIR, NT_STATUS_NOT_A_DIRECTORY }, + { EIO, NT_STATUS_IO_DEVICE_ERROR }, + { EBADF, NT_STATUS_INVALID_HANDLE }, + { EINVAL, NT_STATUS_INVALID_PARAMETER }, + { EEXIST, NT_STATUS_OBJECT_NAME_COLLISION}, + { ENFILE, NT_STATUS_TOO_MANY_OPENED_FILES }, + { EMFILE, NT_STATUS_TOO_MANY_OPENED_FILES }, + { ENOSPC, NT_STATUS_DISK_FULL }, + { EISDIR, NT_STATUS_FILE_IS_A_DIRECTORY }, + { ENOTSOCK, NT_STATUS_INVALID_HANDLE }, + { EFAULT, NT_STATUS_INVALID_PARAMETER }, + { EMSGSIZE, NT_STATUS_INVALID_BUFFER_SIZE }, + { ENOBUFS, NT_STATUS_NO_MEMORY }, + { ENOMEM, NT_STATUS_NO_MEMORY }, + { EPIPE, NT_STATUS_CONNECTION_DISCONNECTED }, + { ECONNREFUSED, NT_STATUS_CONNECTION_REFUSED }, + { EBUSY, NT_STATUS_SHARING_VIOLATION }, #ifdef EDQUOT - { EDQUOT, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, + { EDQUOT, NT_STATUS_QUOTA_EXCEEDED }, #endif #ifdef ENOTEMPTY - { ENOTEMPTY, ERRDOS, ERRnoaccess, NT_STATUS_DIRECTORY_NOT_EMPTY }, + { ENOTEMPTY, NT_STATUS_DIRECTORY_NOT_EMPTY }, #endif #ifdef EXDEV - { EXDEV, ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE }, + { EXDEV, NT_STATUS_NOT_SAME_DEVICE }, #endif #ifdef EROFS - { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED }, + { EROFS, NT_STATUS_MEDIA_WRITE_PROTECTED }, #endif #ifdef ENAMETOOLONG - { ENAMETOOLONG, ERRDOS, 206, NT_STATUS_OBJECT_NAME_INVALID }, + { ENAMETOOLONG, NT_STATUS_NAME_TOO_LONG }, #endif #ifdef EFBIG - { EFBIG, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, + { EFBIG, NT_STATUS_DISK_FULL }, #endif -#ifdef EFBIG - { EBUSY, ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION }, -#endif - { 0, 0, 0, NT_STATUS_OK } + { 0, NT_STATUS_UNSUCCESSFUL } }; + /********************************************************************* Map an NT error code from a Unix error code. *********************************************************************/ NTSTATUS map_nt_error_from_unix(int unix_error) { - int i = 0; - - if (unix_error == 0) { - return NT_STATUS_UNSUCCESSFUL; - } + int i; /* Look through list */ - while(unix_dos_nt_errmap[i].unix_error != 0) { - if (unix_dos_nt_errmap[i].unix_error == unix_error) - return unix_dos_nt_errmap[i].nt_error; - i++; + for (i=0;i Date: Thu, 28 Oct 2004 12:46:59 +0000 Subject: r3322: fixed a bunch of warnings in the build, including one case where it was a real bug (This used to be commit 02d5d0f685e44bd66aff4a007f0bf34c8f915574) --- source4/libcli/util/asn1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 15d9243acd..e03b1d5f39 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -494,7 +494,7 @@ int asn1_tag_remaining(ASN1_DATA *data) } /* read an object ID from a ASN1 buffer */ -BOOL asn1_read_OID(ASN1_DATA *data, char **OID) +BOOL asn1_read_OID(ASN1_DATA *data, const char **OID) { uint8_t b; char *tmp_oid = NULL; @@ -525,7 +525,7 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID) /* check that the next object ID is correct */ BOOL asn1_check_OID(ASN1_DATA *data, const char *OID) { - char *id; + const char *id; if (!asn1_read_OID(data, &id)) return False; -- cgit From 1331667abf1b45abe40353ce70978294314d1a63 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 28 Oct 2004 21:00:38 +0000 Subject: r3331: Add string descriptions for a couple more WERROR's (This used to be commit 1d374cdeb09b856449287cf12a77b23296c82a1d) --- source4/libcli/util/doserr.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index c8e0e89078..8f997cf092 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -68,9 +68,19 @@ static const struct werror_code_struct dos_errs[] = { "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR }, { "WERR_INVALID_OWNER", WERR_INVALID_OWNER }, { "WERR_DS_OBJ_NOT_FOUND", WERR_DS_OBJ_NOT_FOUND }, + { "WERR_GENERAL_FAILURE", WERR_GENERAL_FAILURE }, + { "WERR_PRINTQ_FULL", WERR_PRINTQ_FULL }, + { "WERR_NO_SPOOL_SPACE", WERR_NO_SPOOL_SPACE }, + { "WERR_CAN_NOT_COMPLETE", WERR_CAN_NOT_COMPLETE }, + { "WERR_SERVER_UNAVAILABLE", WERR_SERVER_UNAVAILABLE }, { NULL, W_ERROR(0) } }; + + + +/* DFS errors */ + /***************************************************************************** returns a windows error message. not amazingly helpful, but better than a number. *****************************************************************************/ -- cgit From 659332794871c64470fd23b5a15e1f45fcb78a84 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Oct 2004 08:31:27 +0000 Subject: r3358: Try to put all the basic struct dom_sid manipulation functions in one place. (I always have trouble finding one half or the other). Andrew Bartlett (This used to be commit 224b59edba7c00ad515b4c5e3e9a886700247ad4) --- source4/libcli/util/dom_sid.c | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/dom_sid.c b/source4/libcli/util/dom_sid.c index c2d188abec..1faf3debab 100644 --- a/source4/libcli/util/dom_sid.c +++ b/source4/libcli/util/dom_sid.c @@ -22,6 +22,39 @@ #include "includes.h" +/* + convert a dom_sid to a string +*/ +char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid) +{ + int i, ofs, maxlen; + uint32_t ia; + char *ret; + + if (!sid) { + return talloc_strdup(mem_ctx, "(NULL SID)"); + } + + maxlen = sid->num_auths * 11 + 25; + ret = talloc(mem_ctx, maxlen); + if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)"); + + ia = (sid->id_auth[5]) + + (sid->id_auth[4] << 8 ) + + (sid->id_auth[3] << 16) + + (sid->id_auth[2] << 24); + + ofs = snprintf(ret, maxlen, "S-%u-%lu", + (uint_t)sid->sid_rev_num, (unsigned long)ia); + + for (i = 0; i < sid->num_auths; i++) { + ofs += snprintf(ret + ofs, maxlen - ofs, "-%lu", (unsigned long)sid->sub_auths[i]); + } + + return ret; +} + + /* convert a string to a dom_sid, returning a talloc'd dom_sid */ @@ -121,3 +154,27 @@ struct dom_sid *dom_sid_dup(TALLOC_CTX *mem_ctx, struct dom_sid *dom_sid) return ret; } +/* + add a rid to a domain dom_sid to make a full dom_sid +*/ +struct dom_sid *dom_sid_add_rid(TALLOC_CTX *mem_ctx, + const struct dom_sid *domain_sid, + uint32_t rid) +{ + struct dom_sid *sid; + + sid = talloc_p(mem_ctx, struct dom_sid); + if (!sid) return NULL; + + *sid = *domain_sid; + /*TODO: use realloc! */ + sid->sub_auths = talloc_array_p(mem_ctx, uint32_t, sid->num_auths+1); + if (!sid->sub_auths) { + return NULL; + } + memcpy(sid->sub_auths, domain_sid->sub_auths, sid->num_auths*sizeof(uint32_t)); + sid->sub_auths[sid->num_auths] = rid; + sid->num_auths++; + return sid; +} + -- cgit From 9f1210a243654fd6d94acdef83f468a33c1b3b3f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Nov 2004 01:03:22 +0000 Subject: r3419: moved the libcli/raw structures into libcli/raw/libcliraw.h and made them private (This used to be commit 386ac565c452ede1d74e06acb401ca9db99d3ff3) --- source4/libcli/util/clierror.c | 1 + source4/libcli/util/cliutil.c | 2 ++ 2 files changed, 3 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clierror.c b/source4/libcli/util/clierror.c index e7e413bbcb..1c82958ce2 100644 --- a/source4/libcli/util/clierror.c +++ b/source4/libcli/util/clierror.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "libcli/raw/libcliraw.h" /*************************************************************************** diff --git a/source4/libcli/util/cliutil.c b/source4/libcli/util/cliutil.c index 3efa1dbbc9..ead09c4b41 100644 --- a/source4/libcli/util/cliutil.c +++ b/source4/libcli/util/cliutil.c @@ -20,6 +20,8 @@ */ #include "includes.h" +#include "libcli/raw/libcliraw.h" + /******************************************************************* Functions nicked from lib/util.c needed by client. *******************************************************************/ -- cgit From 652b8b34f8b326f79771b03e039cfa3c6ba3427e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Nov 2004 20:21:54 +0000 Subject: r3441: some include file cleanups and general housekeeping (This used to be commit 73ea8ee6c268371d05cf74160f2ad451dd2ae699) --- source4/libcli/util/cliutil.c | 109 ------------------------------------------ 1 file changed, 109 deletions(-) delete mode 100644 source4/libcli/util/cliutil.c (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/cliutil.c b/source4/libcli/util/cliutil.c deleted file mode 100644 index ead09c4b41..0000000000 --- a/source4/libcli/util/cliutil.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - Unix SMB/CIFS implementation. - client utility routines - Copyright (C) Andrew Tridgell 2001 - Copyright (C) James Myers 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "libcli/raw/libcliraw.h" - -/******************************************************************* - Functions nicked from lib/util.c needed by client. -*******************************************************************/ - -/******************************************************************* - A wrapper that handles case sensitivity and the special handling - of the ".." name. -*******************************************************************/ - -BOOL mask_match(struct smbcli_state *cli, const char *string, char *pattern, BOOL is_case_sensitive) -{ - fstring p2, s2; - - if (strcmp(string,"..") == 0) - string = "."; - if (strcmp(pattern,".") == 0) - return False; - - if (is_case_sensitive) - return ms_fnmatch(pattern, string, - cli->transport->negotiate.protocol) == 0; - - fstrcpy(p2, pattern); - fstrcpy(s2, string); - strlower(p2); - strlower(s2); - return ms_fnmatch(p2, s2, cli->transport->negotiate.protocol) == 0; -} - -/**************************************************************************** - Put up a yes/no prompt. -****************************************************************************/ - -BOOL yesno(char *p) -{ - pstring ans; - printf("%s",p); - - if (!fgets(ans,sizeof(ans)-1,stdin)) - return(False); - - if (*ans == 'y' || *ans == 'Y') - return(True); - - return(False); -} - -/******************************************************************* - A readdir wrapper which just returns the file name. - ********************************************************************/ - -const char *readdirname(DIR *p) -{ - struct smb_dirent *ptr; - char *dname; - - if (!p) - return(NULL); - - ptr = (struct smb_dirent *)sys_readdir(p); - if (!ptr) - return(NULL); - - dname = ptr->d_name; - -#ifdef NEXT2 - if (telldir(p) < 0) - return(NULL); -#endif - -#ifdef HAVE_BROKEN_READDIR - /* using /usr/ucb/cc is BAD */ - dname = dname - 2; -#endif - - { - static pstring buf; - int len = NAMLEN(ptr); - memcpy(buf, dname, len); - buf[len] = 0; - dname = buf; - } - - return(dname); -} -- cgit From ead3508ac81ff3ed2a48753f3b5e23537ba6ec73 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 00:24:21 +0000 Subject: r3447: more include/system/XXX.h include files (This used to be commit 264ce9181089922547e8f6f67116f2d7277a5105) --- source4/libcli/util/smbencrypt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 1089c3a4cf..1cf0890ba8 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -23,6 +23,7 @@ */ #include "includes.h" +#include "system/time.h" #include "byteorder.h" /* -- cgit From edbfc0f6e70150e321822365bf0eead2821551bd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 02:57:18 +0000 Subject: r3453: - split out the auth and popt includes - tidied up some of the system includes - moved a few more structures back from misc.idl to netlogon.idl and samr.idl now that pidl knows about inter-IDL dependencies (This used to be commit 7b7477ac42d96faac1b0ff361525d2c63cedfc64) --- source4/libcli/util/smbencrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 1cf0890ba8..1e911f094b 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -24,7 +24,7 @@ #include "includes.h" #include "system/time.h" -#include "byteorder.h" +#include "auth/auth.h" /* This implements the X/Open SMB password encryption -- cgit From a1d0b97ed40fe6985bb45b1715309638e7faaffc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 06:14:15 +0000 Subject: r3462: separate out the crypto includes (This used to be commit 3f75117db921e493bb77a5dc14b8ce91a6288f30) --- source4/libcli/util/smbencrypt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 1e911f094b..6034c0e327 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -25,6 +25,7 @@ #include "includes.h" #include "system/time.h" #include "auth/auth.h" +#include "lib/crypto/crypto.h" /* This implements the X/Open SMB password encryption -- cgit From 3643fb11092e28a9538ef32cedce8ff21ad86a28 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 06:42:15 +0000 Subject: r3463: separated out some more headers (asn_1.h, messages.h, dlinklist.h and ioctl.h) (This used to be commit b97e395c814762024336c1cf4d7c25be8da5813a) --- source4/libcli/util/asn1.c | 77 +++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 38 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index e03b1d5f39..15858f4f75 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -19,15 +19,16 @@ */ #include "includes.h" +#include "asn_1.h" /* free an asn1 structure */ -void asn1_free(ASN1_DATA *data) +void asn1_free(struct asn1_data *data) { talloc_free(data->data); } /* write to the ASN1 buffer, advancing the buffer pointer */ -BOOL asn1_write(ASN1_DATA *data, const void *p, int len) +BOOL asn1_write(struct asn1_data *data, const void *p, int len) { if (data->has_error) return False; if (data->length < data->ofs+len) { @@ -47,13 +48,13 @@ BOOL asn1_write(ASN1_DATA *data, const void *p, int len) } /* useful fn for writing a uint8_t */ -BOOL asn1_write_uint8(ASN1_DATA *data, uint8_t v) +BOOL asn1_write_uint8(struct asn1_data *data, uint8_t v) { return asn1_write(data, &v, 1); } /* push a tag onto the asn1 data buffer. Used for nested structures */ -BOOL asn1_push_tag(ASN1_DATA *data, uint8_t tag) +BOOL asn1_push_tag(struct asn1_data *data, uint8_t tag) { struct nesting *nesting; @@ -71,7 +72,7 @@ BOOL asn1_push_tag(ASN1_DATA *data, uint8_t tag) } /* pop a tag */ -BOOL asn1_pop_tag(ASN1_DATA *data) +BOOL asn1_pop_tag(struct asn1_data *data) { struct nesting *nesting; size_t len; @@ -110,7 +111,7 @@ BOOL asn1_pop_tag(ASN1_DATA *data) /* "i" is the one's complement representation, as is the normal result of an * implicit signed->unsigned conversion */ -static BOOL push_int_bigendian(ASN1_DATA *data, unsigned int i, BOOL negative) +static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL negative) { uint8_t lowest = i & 0xFF; @@ -153,7 +154,7 @@ static BOOL push_int_bigendian(ASN1_DATA *data, unsigned int i, BOOL negative) /* write an Integer without the tag framing. Needed for example for the LDAP * Abandon Operation */ -BOOL asn1_write_implicit_Integer(ASN1_DATA *data, int i) +BOOL asn1_write_implicit_Integer(struct asn1_data *data, int i) { if (i == -1) { /* -1 is special as it consists of all-0xff bytes. In @@ -168,7 +169,7 @@ BOOL asn1_write_implicit_Integer(ASN1_DATA *data, int i) /* write an integer */ -BOOL asn1_write_Integer(ASN1_DATA *data, int i) +BOOL asn1_write_Integer(struct asn1_data *data, int i) { if (!asn1_push_tag(data, ASN1_INTEGER)) return False; if (!asn1_write_implicit_Integer(data, i)) return False; @@ -176,7 +177,7 @@ BOOL asn1_write_Integer(ASN1_DATA *data, int i) } /* write an object ID to a ASN1 buffer */ -BOOL asn1_write_OID(ASN1_DATA *data, const char *OID) +BOOL asn1_write_OID(struct asn1_data *data, const char *OID) { uint_t v, v2; const char *p = (const char *)OID; @@ -205,7 +206,7 @@ BOOL asn1_write_OID(ASN1_DATA *data, const char *OID) } /* write an octet string */ -BOOL asn1_write_OctetString(ASN1_DATA *data, const void *p, size_t length) +BOOL asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length) { asn1_push_tag(data, ASN1_OCTET_STRING); asn1_write(data, p, length); @@ -214,7 +215,7 @@ BOOL asn1_write_OctetString(ASN1_DATA *data, const void *p, size_t length) } /* write a general string */ -BOOL asn1_write_GeneralString(ASN1_DATA *data, const char *s) +BOOL asn1_write_GeneralString(struct asn1_data *data, const char *s) { asn1_push_tag(data, ASN1_GENERAL_STRING); asn1_write(data, s, strlen(s)); @@ -222,7 +223,7 @@ BOOL asn1_write_GeneralString(ASN1_DATA *data, const char *s) return !data->has_error; } -BOOL asn1_write_ContextSimple(ASN1_DATA *data, uint8_t num, DATA_BLOB *blob) +BOOL asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob) { asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(num)); asn1_write(data, blob->data, blob->length); @@ -231,7 +232,7 @@ BOOL asn1_write_ContextSimple(ASN1_DATA *data, uint8_t num, DATA_BLOB *blob) } /* write a BOOLEAN */ -BOOL asn1_write_BOOLEAN(ASN1_DATA *data, BOOL v) +BOOL asn1_write_BOOLEAN(struct asn1_data *data, BOOL v) { asn1_push_tag(data, ASN1_BOOLEAN); asn1_write_uint8(data, v ? 0xFF : 0); @@ -239,7 +240,7 @@ BOOL asn1_write_BOOLEAN(ASN1_DATA *data, BOOL v) return !data->has_error; } -BOOL asn1_read_BOOLEAN(ASN1_DATA *data, BOOL *v) +BOOL asn1_read_BOOLEAN(struct asn1_data *data, BOOL *v) { uint8_t tmp = 0; asn1_start_tag(data, ASN1_BOOLEAN); @@ -254,7 +255,7 @@ BOOL asn1_read_BOOLEAN(ASN1_DATA *data, BOOL *v) } /* check a BOOLEAN */ -BOOL asn1_check_BOOLEAN(ASN1_DATA *data, BOOL v) +BOOL asn1_check_BOOLEAN(struct asn1_data *data, BOOL v) { uint8_t b = 0; @@ -272,8 +273,8 @@ BOOL asn1_check_BOOLEAN(ASN1_DATA *data, BOOL v) } -/* load a ASN1_DATA structure with a lump of data, ready to be parsed */ -BOOL asn1_load(ASN1_DATA *data, DATA_BLOB blob) +/* load a struct asn1_data structure with a lump of data, ready to be parsed */ +BOOL asn1_load(struct asn1_data *data, DATA_BLOB blob) { ZERO_STRUCTP(data); data->data = talloc_memdup(NULL, blob.data, blob.length); @@ -286,7 +287,7 @@ BOOL asn1_load(ASN1_DATA *data, DATA_BLOB blob) } /* Peek into an ASN1 buffer, not advancing the pointer */ -BOOL asn1_peek(ASN1_DATA *data, void *p, int len) +BOOL asn1_peek(struct asn1_data *data, void *p, int len) { if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len) return False; @@ -299,7 +300,7 @@ BOOL asn1_peek(ASN1_DATA *data, void *p, int len) } /* read from a ASN1 buffer, advancing the buffer pointer */ -BOOL asn1_read(ASN1_DATA *data, void *p, int len) +BOOL asn1_read(struct asn1_data *data, void *p, int len) { if (!asn1_peek(data, p, len)) { data->has_error = True; @@ -311,17 +312,17 @@ BOOL asn1_read(ASN1_DATA *data, void *p, int len) } /* read a uint8_t from a ASN1 buffer */ -BOOL asn1_read_uint8(ASN1_DATA *data, uint8_t *v) +BOOL asn1_read_uint8(struct asn1_data *data, uint8_t *v) { return asn1_read(data, v, 1); } -BOOL asn1_peek_uint8(ASN1_DATA *data, uint8_t *v) +BOOL asn1_peek_uint8(struct asn1_data *data, uint8_t *v) { return asn1_peek(data, v, 1); } -BOOL asn1_peek_tag(ASN1_DATA *data, uint8_t tag) +BOOL asn1_peek_tag(struct asn1_data *data, uint8_t tag) { uint8_t b; @@ -336,7 +337,7 @@ BOOL asn1_peek_tag(ASN1_DATA *data, uint8_t tag) } /* start reading a nested asn1 structure */ -BOOL asn1_start_tag(ASN1_DATA *data, uint8_t tag) +BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag) { uint8_t b; struct nesting *nesting; @@ -378,7 +379,7 @@ BOOL asn1_start_tag(ASN1_DATA *data, uint8_t tag) return !data->has_error; } -static BOOL read_one_uint8(int sock, uint8_t *result, ASN1_DATA *data, +static BOOL read_one_uint8(int sock, uint8_t *result, struct asn1_data *data, const struct timeval *endtime) { if (read_data_until(sock, result, 1, endtime) != 1) @@ -388,7 +389,7 @@ static BOOL read_one_uint8(int sock, uint8_t *result, ASN1_DATA *data, } /* Read a complete ASN sequence (ie LDAP result) from a socket */ -BOOL asn1_read_sequence_until(int sock, ASN1_DATA *data, +BOOL asn1_read_sequence_until(int sock, struct asn1_data *data, const struct timeval *endtime) { uint8_t b; @@ -444,7 +445,7 @@ BOOL asn1_read_sequence_until(int sock, ASN1_DATA *data, BOOL asn1_object_length(uint8_t *buf, size_t buf_length, uint8_t tag, size_t *result) { - ASN1_DATA data; + struct asn1_data data; /* Fake the asn1_load to avoid the memdup, this is just to be able to * re-use the length-reading in asn1_start_tag */ @@ -461,7 +462,7 @@ BOOL asn1_object_length(uint8_t *buf, size_t buf_length, } /* stop reading a tag */ -BOOL asn1_end_tag(ASN1_DATA *data) +BOOL asn1_end_tag(struct asn1_data *data) { struct nesting *nesting; @@ -484,7 +485,7 @@ BOOL asn1_end_tag(ASN1_DATA *data) } /* work out how many bytes are left in this nested tag */ -int asn1_tag_remaining(ASN1_DATA *data) +int asn1_tag_remaining(struct asn1_data *data) { if (!data->nesting) { data->has_error = True; @@ -494,7 +495,7 @@ int asn1_tag_remaining(ASN1_DATA *data) } /* read an object ID from a ASN1 buffer */ -BOOL asn1_read_OID(ASN1_DATA *data, const char **OID) +BOOL asn1_read_OID(struct asn1_data *data, const char **OID) { uint8_t b; char *tmp_oid = NULL; @@ -523,7 +524,7 @@ BOOL asn1_read_OID(ASN1_DATA *data, const char **OID) } /* check that the next object ID is correct */ -BOOL asn1_check_OID(ASN1_DATA *data, const char *OID) +BOOL asn1_check_OID(struct asn1_data *data, const char *OID) { const char *id; @@ -538,7 +539,7 @@ BOOL asn1_check_OID(ASN1_DATA *data, const char *OID) } /* read a GeneralString from a ASN1 buffer */ -BOOL asn1_read_GeneralString(ASN1_DATA *data, char **s) +BOOL asn1_read_GeneralString(struct asn1_data *data, char **s) { int len; if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False; @@ -559,7 +560,7 @@ BOOL asn1_read_GeneralString(ASN1_DATA *data, char **s) } /* read a octet string blob */ -BOOL asn1_read_OctetString(ASN1_DATA *data, DATA_BLOB *blob) +BOOL asn1_read_OctetString(struct asn1_data *data, DATA_BLOB *blob) { int len; ZERO_STRUCTP(blob); @@ -581,7 +582,7 @@ BOOL asn1_read_OctetString(ASN1_DATA *data, DATA_BLOB *blob) return True; } -BOOL asn1_read_ContextSimple(ASN1_DATA *data, uint8_t num, DATA_BLOB *blob) +BOOL asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob) { int len; ZERO_STRUCTP(blob); @@ -598,7 +599,7 @@ BOOL asn1_read_ContextSimple(ASN1_DATA *data, uint8_t num, DATA_BLOB *blob) } /* read an interger without tag*/ -BOOL asn1_read_implicit_Integer(ASN1_DATA *data, int *i) +BOOL asn1_read_implicit_Integer(struct asn1_data *data, int *i) { uint8_t b; *i = 0; @@ -612,7 +613,7 @@ BOOL asn1_read_implicit_Integer(ASN1_DATA *data, int *i) } /* read an interger */ -BOOL asn1_read_Integer(ASN1_DATA *data, int *i) +BOOL asn1_read_Integer(struct asn1_data *data, int *i) { *i = 0; @@ -623,7 +624,7 @@ BOOL asn1_read_Integer(ASN1_DATA *data, int *i) } /* read an interger */ -BOOL asn1_read_enumerated(ASN1_DATA *data, int *v) +BOOL asn1_read_enumerated(struct asn1_data *data, int *v) { *v = 0; @@ -637,7 +638,7 @@ BOOL asn1_read_enumerated(ASN1_DATA *data, int *v) } /* check a enumarted value is correct */ -BOOL asn1_check_enumerated(ASN1_DATA *data, int v) +BOOL asn1_check_enumerated(struct asn1_data *data, int v) { uint8_t b; if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False; @@ -651,7 +652,7 @@ BOOL asn1_check_enumerated(ASN1_DATA *data, int v) } /* write an enumarted value to the stream */ -BOOL asn1_write_enumerated(ASN1_DATA *data, uint8_t v) +BOOL asn1_write_enumerated(struct asn1_data *data, uint8_t v) { if (!asn1_push_tag(data, ASN1_ENUMERATED)) return False; asn1_write_uint8(data, v); -- cgit From acc9f59c7f3bdaa5be20f7c46e9e1a9eaa21192a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 11:17:06 +0000 Subject: r3476: fixed some const warnings (This used to be commit 7dc58dc01e19b342df76dcc14ee28ff37a8f9ace) --- source4/libcli/util/asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 15858f4f75..2bf29f9161 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -534,7 +534,7 @@ BOOL asn1_check_OID(struct asn1_data *data, const char *OID) data->has_error = True; return False; } - talloc_free(id); + talloc_free(discard_const(id)); return True; } -- cgit From 9fe5fa11d637252f1fbe79c7baf778e2d3cdade2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 5 Nov 2004 07:29:02 +0000 Subject: r3545: initial support for using extended attributes to hold extended dos attributes of files. I decided to use IDL/NDR to encode the attribute, as it gives us a simple way to describe and extend the saved attributes. The xattr code needs to hook into quite a few more places in the pvfs code, but this at least gets the basics done. I will start encoding alternate data streams streams, DOS EAs etc soon using the same basic mechanism. I'll probably stick to "version 1" for the xattr.idl for quite a while even though it will be changing, as I don't expect anyone to be deploying this in production just yet. Once we have production users we will need to keep compatibility by supporting all the old version numbers in xattr.idl. (This used to be commit c54253ed1b7dce1d14f43e747da61089aea87094) --- source4/libcli/util/errormap.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 46e4831f89..417f4571a7 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1517,6 +1517,13 @@ const struct unix_error_map unix_nt_errmap[] = { { EPIPE, NT_STATUS_CONNECTION_DISCONNECTED }, { ECONNREFUSED, NT_STATUS_CONNECTION_REFUSED }, { EBUSY, NT_STATUS_SHARING_VIOLATION }, + { ENOTSUP, NT_STATUS_NOT_SUPPORTED}, +#ifdef ENOATTR + { ENOATTR, NT_STATUS_NOT_FOUND }, +#endif +#ifdef ENODATA + { ENODATA, NT_STATUS_NOT_FOUND }, +#endif #ifdef EDQUOT { EDQUOT, NT_STATUS_QUOTA_EXCEEDED }, #endif -- cgit From 5805c780dc6d78c2cc4a86d07155db807a80bac7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 10 Nov 2004 10:58:15 +0000 Subject: r3655: As required by the new torture test, add the LM session key output parameter to SMBNTLMv2encrypt(). Andrew Bartlett (This used to be commit 75ff351faf0a3231e17f000b006beb9cb545d905) --- source4/libcli/util/smbencrypt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 6034c0e327..d327b53f9d 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -378,7 +378,7 @@ BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password const DATA_BLOB *server_chal, const DATA_BLOB *names_blob, DATA_BLOB *lm_response, DATA_BLOB *nt_response, - DATA_BLOB *user_session_key) + DATA_BLOB *lm_session_key, DATA_BLOB *user_session_key) { uint8_t nt_hash[16]; uint8_t ntlm_v2_hash[16]; @@ -408,6 +408,13 @@ BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password if (lm_response) { *lm_response = LMv2_generate_response(ntlm_v2_hash, server_chal); + if (lm_session_key) { + *lm_session_key = data_blob(NULL, 16); + + /* The NTLMv2 calculations also provide a session key, for signing etc later */ + /* use only the first 16 bytes of lm_response for session key */ + SMBsesskeygen_ntv2(ntlm_v2_hash, lm_response->data, lm_session_key->data); + } } return True; -- cgit From fd5135a63b4c81688c4e2d729380ca954f22286d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 11 Nov 2004 23:24:30 +0000 Subject: r3686: The results of some work on the NETLOGON pipe: Break out the samsync tests from RPC-NETLOGON into a new RPC-SAMSYNC, that will cross-verify all the values. Add support for the way netlogon credentials are shared between the pipe that sets up schannel and the pipe that is encrypted with it. Test this support, by calling both NETLOGON and SAMR operations in the RPC-SCHANNEL test. Move some of the Netlogon NEG flags into the .idl, now we have an idea what a few of them really are. Rename the sam_pwd_hash into a name that has meaning (all other crypto functions were renamed in Samba4 ages ago). Break out NTLMv2 functionality for operation on the NT hash - I intend to do NTLMv2 logins in the samsync test in future, and naturally I only have the hash. Andrew Bartlett (This used to be commit 6e6cc6fb9842113a1b0c7f6904dac709b320a6e5) --- source4/libcli/util/smbdes.c | 2 +- source4/libcli/util/smbencrypt.c | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index a7c8f760ea..4e4222b9e6 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -439,7 +439,7 @@ void arcfour_crypt(uint8_t *data, const uint8_t keystr[16], int len) /* Decode a sam password hash into a password. The password hash is the same method used to store passwords in the NT registry. The DES key used is based on the RID of the user. */ -void sam_pwd_hash(uint_t rid, const uint8_t *in, uint8_t *out, int forw) +void sam_rid_crypt(uint_t rid, const uint8_t *in, uint8_t *out, int forw) { uint8_t s[14]; diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index d327b53f9d..dac8674f03 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -374,15 +374,13 @@ static DATA_BLOB LMv2_generate_response(const uint8_t ntlm_v2_hash[16], return final_response; } -BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password, - const DATA_BLOB *server_chal, - const DATA_BLOB *names_blob, - DATA_BLOB *lm_response, DATA_BLOB *nt_response, - DATA_BLOB *lm_session_key, DATA_BLOB *user_session_key) +BOOL SMBNTLMv2encrypt_hash(const char *user, const char *domain, const char nt_hash[16], + const DATA_BLOB *server_chal, + const DATA_BLOB *names_blob, + DATA_BLOB *lm_response, DATA_BLOB *nt_response, + DATA_BLOB *lm_session_key, DATA_BLOB *user_session_key) { - uint8_t nt_hash[16]; uint8_t ntlm_v2_hash[16]; - E_md4hash(password, nt_hash); /* We don't use the NT# directly. Instead we use it mashed up with the username and domain. @@ -420,6 +418,19 @@ BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password return True; } +BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password, + const DATA_BLOB *server_chal, + const DATA_BLOB *names_blob, + DATA_BLOB *lm_response, DATA_BLOB *nt_response, + DATA_BLOB *lm_session_key, DATA_BLOB *user_session_key) +{ + uint8_t nt_hash[16]; + E_md4hash(password, nt_hash); + + return SMBNTLMv2encrypt_hash(user, domain, nt_hash, server_chal, names_blob, + lm_response, nt_response, lm_session_key, user_session_key); +} + /*********************************************************** encode a password buffer with a unicode password. The buffer is filled with random data to make it harder to attack. -- cgit From 285db3339931c47a569f49e8e18760d6185aac54 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 17 Nov 2004 00:31:56 +0000 Subject: r3792: improved the posix -> nt error mapping, so we get things like NT_STATUS_HOST_UNREACHABLE instead of NT_STATUS_UNSUCCESSFUL (This used to be commit f2a488e5668ab5d262269f1bab1b33a63265cbe9) --- source4/libcli/util/errormap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 417f4571a7..6849d7d0cd 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1518,6 +1518,18 @@ const struct unix_error_map unix_nt_errmap[] = { { ECONNREFUSED, NT_STATUS_CONNECTION_REFUSED }, { EBUSY, NT_STATUS_SHARING_VIOLATION }, { ENOTSUP, NT_STATUS_NOT_SUPPORTED}, +#ifdef EHOSTUNREACH + { EHOSTUNREACH, NT_STATUS_HOST_UNREACHABLE }, +#endif +#ifdef ENETUNREACH + { ENETUNREACH, NT_STATUS_NETWORK_UNREACHABLE }, +#endif +#ifdef ETIMEDOUT + { ETIMEDOUT, NT_STATUS_IO_TIMEOUT }, +#endif +#ifdef EADDRINUSE + { EADDRINUSE, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED }, +#endif #ifdef ENOATTR { ENOATTR, NT_STATUS_NOT_FOUND }, #endif -- cgit From 856ee665374071c89f5ecf540dcc3d68ccf2ff16 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Nov 2004 14:35:29 +0000 Subject: r3810: create a LIB_SECURITY subsystem - move dom_sid, security_descriptor, security_* funtions to one place and rename some of them metze (This used to be commit b620bdd672cfdf0e009492e648b0709e6b6d8596) --- source4/libcli/util/dom_sid.c | 180 ------------------------------------------ 1 file changed, 180 deletions(-) delete mode 100644 source4/libcli/util/dom_sid.c (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/dom_sid.c b/source4/libcli/util/dom_sid.c deleted file mode 100644 index 1faf3debab..0000000000 --- a/source4/libcli/util/dom_sid.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - routines to manipulate a "struct dom_sid" - - Copyright (C) Andrew Tridgell 2004 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" - -/* - convert a dom_sid to a string -*/ -char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid) -{ - int i, ofs, maxlen; - uint32_t ia; - char *ret; - - if (!sid) { - return talloc_strdup(mem_ctx, "(NULL SID)"); - } - - maxlen = sid->num_auths * 11 + 25; - ret = talloc(mem_ctx, maxlen); - if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)"); - - ia = (sid->id_auth[5]) + - (sid->id_auth[4] << 8 ) + - (sid->id_auth[3] << 16) + - (sid->id_auth[2] << 24); - - ofs = snprintf(ret, maxlen, "S-%u-%lu", - (uint_t)sid->sid_rev_num, (unsigned long)ia); - - for (i = 0; i < sid->num_auths; i++) { - ofs += snprintf(ret + ofs, maxlen - ofs, "-%lu", (unsigned long)sid->sub_auths[i]); - } - - return ret; -} - - -/* - convert a string to a dom_sid, returning a talloc'd dom_sid -*/ -struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) -{ - struct dom_sid *ret; - uint_t rev, ia, num_sub_auths, i; - char *p; - - if (strncasecmp(sidstr, "S-", 2)) { - return NULL; - } - - sidstr += 2; - - rev = strtol(sidstr, &p, 10); - if (*p != '-') { - return NULL; - } - sidstr = p+1; - - ia = strtol(sidstr, &p, 10); - if (p == sidstr) { - return NULL; - } - sidstr = p; - - num_sub_auths = 0; - for (i=0;sidstr[i];i++) { - if (sidstr[i] == '-') num_sub_auths++; - } - - ret = talloc_p(mem_ctx, struct dom_sid); - if (!ret) { - return NULL; - } - - ret->sub_auths = talloc_array_p(mem_ctx, uint32_t, num_sub_auths); - if (!ret->sub_auths) { - return NULL; - } - - ret->sid_rev_num = rev; - ret->id_auth[0] = 0; - ret->id_auth[1] = 0; - ret->id_auth[2] = ia >> 24; - ret->id_auth[3] = ia >> 16; - ret->id_auth[4] = ia >> 8; - ret->id_auth[5] = ia; - ret->num_auths = num_sub_auths; - - for (i=0;isub_auths[i] = strtoul(sidstr, &p, 10); - if (p == sidstr) { - return NULL; - } - sidstr = p; - } - - return ret; -} - -/* - convert a string to a dom_sid, returning a talloc'd dom_sid -*/ -struct dom_sid *dom_sid_dup(TALLOC_CTX *mem_ctx, struct dom_sid *dom_sid) -{ - struct dom_sid *ret; - int i; - ret = talloc_p(mem_ctx, struct dom_sid); - if (!ret) { - return NULL; - } - - ret->sub_auths = talloc_array_p(mem_ctx, uint32_t, dom_sid->num_auths); - if (!ret->sub_auths) { - return NULL; - } - - ret->sid_rev_num = dom_sid->sid_rev_num; - ret->id_auth[0] = dom_sid->id_auth[0]; - ret->id_auth[1] = dom_sid->id_auth[1]; - ret->id_auth[2] = dom_sid->id_auth[2]; - ret->id_auth[3] = dom_sid->id_auth[3]; - ret->id_auth[4] = dom_sid->id_auth[4]; - ret->id_auth[5] = dom_sid->id_auth[5]; - ret->num_auths = dom_sid->num_auths; - - for (i=0;inum_auths;i++) { - ret->sub_auths[i] = dom_sid->sub_auths[i]; - } - - return ret; -} - -/* - add a rid to a domain dom_sid to make a full dom_sid -*/ -struct dom_sid *dom_sid_add_rid(TALLOC_CTX *mem_ctx, - const struct dom_sid *domain_sid, - uint32_t rid) -{ - struct dom_sid *sid; - - sid = talloc_p(mem_ctx, struct dom_sid); - if (!sid) return NULL; - - *sid = *domain_sid; - /*TODO: use realloc! */ - sid->sub_auths = talloc_array_p(mem_ctx, uint32_t, sid->num_auths+1); - if (!sid->sub_auths) { - return NULL; - } - memcpy(sid->sub_auths, domain_sid->sub_auths, sid->num_auths*sizeof(uint32_t)); - sid->sub_auths[sid->num_auths] = rid; - sid->num_auths++; - return sid; -} - -- cgit From 5f868bc1acc9bdaed32ae70fb9906334663ccfff Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 17 Nov 2004 22:00:15 +0000 Subject: r3826: - added testing of ea lists in NTTRANS CREATE - fixed push/pull of chained ea lists - fixed a bug in the nttrans wire encoding (This used to be commit fcd09224076508f9c10095bf2e2c394232a4d297) --- source4/libcli/util/nterr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 2adb561222..eac7989800 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -32,6 +32,7 @@ static const nt_err_code_struct nt_errs[] = { { "NT_STATUS_OK", NT_STATUS_OK }, { "STATUS_NO_MORE_FILES", STATUS_NO_MORE_FILES }, + { "STATUS_EA_LIST_INCONSISTENT", STATUS_EA_LIST_INCONSISTENT }, { "NT_STATUS_UNSUCCESSFUL", NT_STATUS_UNSUCCESSFUL }, { "NT_STATUS_NOT_IMPLEMENTED", NT_STATUS_NOT_IMPLEMENTED }, { "NT_STATUS_INVALID_INFO_CLASS", NT_STATUS_INVALID_INFO_CLASS }, -- cgit From cc368fa69e6a205516c64712aee701fe0cf6d20b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Nov 2004 17:47:09 +0000 Subject: r3898: Work towards local/server DCOM support, start working on Simple example server side implementation (This used to be commit 98afb504d95ccca4d6ec48273e10b52ccfa26ad0) --- source4/libcli/util/smbencrypt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index dac8674f03..1218de1fe7 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -46,9 +46,9 @@ BOOL SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24]) #ifdef DEBUG_PASSWORD DEBUG(100,("SMBencrypt: lm#, challenge, response\n")); - dump_data(100, (char *)p21, 16); - dump_data(100, (const char *)c8, 8); - dump_data(100, (char *)p24, 24); + dump_data(100, p21, 16); + dump_data(100, c8, 8); + dump_data(100, p24, 24); #endif return ret; @@ -196,9 +196,9 @@ void SMBNTencrypt(const char *passwd, uint8_t *c8, uint8_t *p24) #ifdef DEBUG_PASSWORD DEBUG(100,("SMBNTencrypt: nt#, challenge, response\n")); - dump_data(100, (char *)p21, 16); - dump_data(100, (char *)c8, 8); - dump_data(100, (char *)p24, 24); + dump_data(100, p21, 16); + dump_data(100, c8, 8); + dump_data(100, p24, 24); #endif } -- cgit From 2877f415ae1da30e5971840c124f6ca60813b93d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 22 Nov 2004 07:54:16 +0000 Subject: r3899: fix compiler warnings metze (This used to be commit b1b47bda0177c42687b9c291e4e28ae123fb4eac) --- source4/libcli/util/smbencrypt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 1218de1fe7..ba89000c6c 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -435,7 +435,7 @@ BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password encode a password buffer with a unicode password. The buffer is filled with random data to make it harder to attack. ************************************************************/ -BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) +BOOL encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flags) { uint8_t new_pw[512]; size_t new_pw_len; @@ -446,7 +446,7 @@ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len); - generate_random_buffer((uint8_t *)buffer, 512 - new_pw_len); + generate_random_buffer(buffer, 512 - new_pw_len); /* * The length of the new password is in the last 4 bytes of -- cgit From ac40a16d6ac3a639f9fdd2437340eb07bb8a98ef Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 22 Nov 2004 07:56:13 +0000 Subject: r3900: fix compiler warning metze (This used to be commit f2ff50dfc40f7bf329ab83eefcc2cff9e575a84e) --- source4/libcli/util/smbencrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index ba89000c6c..f0ff3ee08d 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -374,7 +374,7 @@ static DATA_BLOB LMv2_generate_response(const uint8_t ntlm_v2_hash[16], return final_response; } -BOOL SMBNTLMv2encrypt_hash(const char *user, const char *domain, const char nt_hash[16], +BOOL SMBNTLMv2encrypt_hash(const char *user, const char *domain, const uint8_t nt_hash[16], const DATA_BLOB *server_chal, const DATA_BLOB *names_blob, DATA_BLOB *lm_response, DATA_BLOB *nt_response, -- cgit From 243b314a231f0044ceee81728a0a1deb71c58283 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 22 Nov 2004 07:59:14 +0000 Subject: r3901: fix compiler warnings metze (This used to be commit efe840c8b0dd599d205068a4946ef587d542f2a5) --- source4/libcli/util/smbencrypt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index f0ff3ee08d..9e8a4cd02d 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -463,7 +463,7 @@ BOOL encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flag *new_pw_len is the length in bytes of the possibly mulitbyte returned password including termination. ************************************************************/ -BOOL decode_pw_buffer(char in_buffer[516], char *new_pwrd, +BOOL decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd, int new_pwrd_size, uint32_t *new_pw_len, int string_flags) { @@ -497,7 +497,7 @@ BOOL decode_pw_buffer(char in_buffer[516], char *new_pwrd, #ifdef DEBUG_PASSWORD DEBUG(100,("decode_pw_buffer: new_pwrd: ")); - dump_data(100, (char *)new_pwrd, *new_pw_len); + dump_data(100, (const uint8_t *)new_pwrd, *new_pw_len); DEBUG(100,("multibyte len:%d\n", *new_pw_len)); DEBUG(100,("original char len:%d\n", byte_len/2)); #endif -- cgit From 3129264308c7c68bfe94228dcb7af99876d93dff Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 22 Nov 2004 14:28:09 +0000 Subject: r3910: add some error codes metze (This used to be commit 64570b7a4734ec1cc56a07e6bd9b20a155a876c0) --- source4/libcli/util/doserr.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 8f997cf092..0e2270d8f6 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -67,6 +67,12 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DFS_CANT_CREATE_JUNCT", WERR_DFS_CANT_CREATE_JUNCT }, { "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR }, { "WERR_INVALID_OWNER", WERR_INVALID_OWNER }, + { "WERR_INVALID_DOMAINNAME", WERR_INVALID_DOMAINNAME }, + { "WERR_NO_SUCH_USER", WERR_NO_SUCH_USER }, + { "WERR_NO_SUCH_DOMAIN", WERR_NO_SUCH_DOMAIN }, + { "WERR_DS_SERVICE_BUSY", WERR_DS_SERVICE_BUSY }, + { "WERR_DS_SERVICE_UNAVAILABLE", WERR_DS_SERVICE_UNAVAILABLE }, + { "WERR_DS_NO_SUCH_OBJECT", WERR_DS_NO_SUCH_OBJECT }, { "WERR_DS_OBJ_NOT_FOUND", WERR_DS_OBJ_NOT_FOUND }, { "WERR_GENERAL_FAILURE", WERR_GENERAL_FAILURE }, { "WERR_PRINTQ_FULL", WERR_PRINTQ_FULL }, -- cgit From 9112a632f6791ffc3c3c1aadd214cbaba8fe816e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 4 Dec 2004 13:56:25 +0000 Subject: r4063: - change char * -> uint8_t in struct request_buffer - change smbcli_read/write to take void * for the buffers to match read(2)/write(2) all this fixes a lot of gcc-4 warnings metze (This used to be commit b94f92bc6637f748d6f7049f4f9a30b0b8d18a7a) --- source4/libcli/util/smbencrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index 9e8a4cd02d..ee423fbbba 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -293,7 +293,7 @@ static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLO { uint8_t client_chal[8]; DATA_BLOB response = data_blob(NULL, 0); - char long_date[8]; + uint8_t long_date[8]; NTTIME nttime; unix_to_nt_time(&nttime, time(NULL)); -- cgit From 41999d67c1980e0631c4f357d3825cfda9b9fc1a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 5 Dec 2004 07:43:38 +0000 Subject: r4065: fixed ntstatus->dos error code for NT_STATUS_NO_SUCH_FILE (This used to be commit 19efd83b863a8c94f509d6a933a7d5de43aa95e9) --- source4/libcli/util/errormap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 6849d7d0cd..cc3b960082 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -65,7 +65,7 @@ static const struct { {ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED}, {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER}, {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE}, - {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, + {ERRDOS, ERRnofiles, NT_STATUS_NO_SUCH_FILE}, {ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST}, {ERRDOS, 38, NT_STATUS_END_OF_FILE}, {ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, -- cgit From 14c65343b052be4766fc27e17488f95fb201cb4f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 5 Dec 2004 07:53:57 +0000 Subject: r4066: add a mapping for NT_STATUS_NO_MORE_ENTRIES (This used to be commit 335b1c6a52b2e437e7f16a84ba547e5387ef64d1) --- source4/libcli/util/errormap.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index cc3b960082..4a57e436c7 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -51,6 +51,7 @@ static const struct { NTSTATUS ntstatus; } ntstatus_to_dos_map[] = { {ERRDOS, ERRnofiles, STATUS_NO_MORE_FILES}, + {ERRDOS, ERRnofiles, NT_STATUS_NO_MORE_ENTRIES}, {ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, {ERRDOS, 87, NT_STATUS_INVALID_INFO_CLASS}, -- cgit From ad3ee0a81c4b2bf2ae67ba461e936f7777584345 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 6 Dec 2004 07:12:38 +0000 Subject: r4073: - added a set of lsa helper routines to make lsa lookups that are related to filesharing. For example, in order to manipulate ACLs properly its important to be able to call LookupSids, and to be able to lookup what privileges a SID has. - added 3 new commands to smbclient "lookupname", "lookupsid" and "privileges" (This used to be commit 8780c40f0539da72652d17455e98fcaee6d197d1) --- source4/libcli/util/clilsa.c | 299 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 source4/libcli/util/clilsa.c (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c new file mode 100644 index 0000000000..c3c7f8cc77 --- /dev/null +++ b/source4/libcli/util/clilsa.c @@ -0,0 +1,299 @@ +/* + Unix SMB/CIFS implementation. + + lsa calls for file sharing connections + + Copyright (C) Andrew Tridgell 2004 + + 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. +*/ + +/* + when dealing with ACLs the file sharing client code needs to + sometimes make LSA RPC calls. This code provides an easy interface + for doing those calls. +*/ + +#include "includes.h" +#include "libcli/raw/libcliraw.h" +#include "librpc/gen_ndr/ndr_lsa.h" + +struct smblsa_state { + struct dcerpc_pipe *pipe; + struct smbcli_tree *ipc_tree; + struct policy_handle handle; +}; + +/* + establish the lsa pipe connection +*/ +static NTSTATUS smblsa_connect(struct smbcli_state *cli) +{ + struct smblsa_state *lsa; + NTSTATUS status; + struct lsa_OpenPolicy r; + uint16_t system_name = '\\'; + union smb_tcon tcon; + struct lsa_ObjectAttribute attr; + struct lsa_QosInfo qos; + + if (cli->lsa != NULL) { + return NT_STATUS_OK; + } + + lsa = talloc_p(cli, struct smblsa_state); + if (lsa == NULL) { + return NT_STATUS_NO_MEMORY; + } + + lsa->ipc_tree = smbcli_tree_init(cli->session); + if (lsa->ipc_tree == NULL) { + return NT_STATUS_NO_MEMORY; + } + + /* connect to IPC$ */ + tcon.generic.level = RAW_TCON_TCONX; + tcon.tconx.in.flags = 0; + tcon.tconx.in.password = data_blob(NULL, 0); + tcon.tconx.in.path = "ipc$"; + tcon.tconx.in.device = "IPC"; + status = smb_tree_connect(lsa->ipc_tree, lsa, &tcon); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(lsa); + return status; + } + lsa->ipc_tree->tid = tcon.tconx.out.cnum; + + /* open the LSA pipe */ + status = dcerpc_pipe_open_smb(&lsa->pipe, lsa->ipc_tree, DCERPC_LSARPC_NAME); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(lsa); + return status; + } + + /* bind to the LSA pipe */ + status = dcerpc_bind_auth_none(lsa->pipe, DCERPC_LSARPC_UUID, DCERPC_LSARPC_VERSION); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(lsa); + return status; + } + + + /* open a lsa policy handle */ + qos.len = 0; + qos.impersonation_level = 2; + qos.context_mode = 1; + qos.effective_only = 0; + + attr.len = 0; + attr.root_dir = NULL; + attr.object_name = NULL; + attr.attributes = 0; + attr.sec_desc = NULL; + attr.sec_qos = &qos; + + r.in.system_name = &system_name; + r.in.attr = &attr; + r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + r.out.handle = &lsa->handle; + + status = dcerpc_lsa_OpenPolicy(lsa->pipe, lsa, &r); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(lsa); + return status; + } + + cli->lsa = lsa; + + return NT_STATUS_OK; +} + + +/* + return the set of privileges for the given sid +*/ +NTSTATUS smblsa_sid_privileges(struct smbcli_state *cli, struct dom_sid *sid, + TALLOC_CTX *mem_ctx, + struct lsa_RightSet *rights) +{ + NTSTATUS status; + struct lsa_EnumAccountRights r; + + status = smblsa_connect(cli); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + r.in.handle = &cli->lsa->handle; + r.in.sid = sid; + r.out.rights = rights; + + return dcerpc_lsa_EnumAccountRights(cli->lsa->pipe, mem_ctx, &r); +} + + +/* + check if a named sid has a particular named privilege +*/ +NTSTATUS smblsa_sid_check_privilege(struct smbcli_state *cli, + const char *sid_str, + const char *privilege) +{ + struct lsa_RightSet rights; + NTSTATUS status; + TALLOC_CTX *mem_ctx = talloc(cli, 0); + struct dom_sid *sid; + unsigned i; + + sid = dom_sid_parse_talloc(mem_ctx, sid_str); + if (sid == NULL) { + talloc_free(mem_ctx); + return NT_STATUS_INVALID_SID; + } + + status = smblsa_sid_privileges(cli, sid, mem_ctx, &rights); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return status; + } + + for (i=0;ilsa->handle; + r.in.sids = &sids; + r.in.names = &names; + r.in.level = 1; + r.in.count = &count; + r.out.count = &count; + r.out.names = &names; + + status = dcerpc_lsa_LookupSids(cli->lsa->pipe, mem_ctx2, &r); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx2); + return status; + } + if (names.count != 1) { + talloc_free(mem_ctx2); + return NT_STATUS_UNSUCCESSFUL; + } + + (*name) = talloc_asprintf(mem_ctx, "%s\\%s", + r.out.domains->domains[0].name.string, + names.names[0].name.string); + + talloc_free(mem_ctx2); + + return NT_STATUS_OK; +} + +/* + lookup a name, returning its sid +*/ +NTSTATUS smblsa_lookup_name(struct smbcli_state *cli, + const char *name, + TALLOC_CTX *mem_ctx, + const char **sid_str) +{ + struct lsa_LookupNames r; + struct lsa_TransSidArray sids; + struct lsa_String names; + uint32_t count = 1; + NTSTATUS status; + struct dom_sid *sid; + TALLOC_CTX *mem_ctx2 = talloc(mem_ctx, 0); + uint32_t rid; + + status = smblsa_connect(cli); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + sids.count = 0; + sids.sids = NULL; + + names.string = name; + + r.in.handle = &cli->lsa->handle; + r.in.num_names = 1; + r.in.names = &names; + r.in.sids = &sids; + r.in.level = 1; + r.in.count = &count; + r.out.count = &count; + r.out.sids = &sids; + + status = dcerpc_lsa_LookupNames(cli->lsa->pipe, mem_ctx2, &r); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx2); + return status; + } + if (sids.count != 1) { + talloc_free(mem_ctx2); + return NT_STATUS_UNSUCCESSFUL; + } + + sid = r.out.domains->domains[0].sid; + rid = sids.sids[0].rid; + + (*sid_str) = talloc_asprintf(mem_ctx, "%s-%u", + dom_sid_string(mem_ctx2, sid), rid); + + talloc_free(mem_ctx2); + + return NT_STATUS_OK; +} -- cgit From 4b7960a091916613ad89e9ef9e4de857b08c8e24 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 7 Dec 2004 09:18:56 +0000 Subject: r4084: add some more error codes metze (This used to be commit e5db58526825476fd6d8d80c8ee6c3bca0e23c84) --- source4/libcli/util/doserr.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 0e2270d8f6..d81280bff6 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -74,6 +74,8 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DS_SERVICE_UNAVAILABLE", WERR_DS_SERVICE_UNAVAILABLE }, { "WERR_DS_NO_SUCH_OBJECT", WERR_DS_NO_SUCH_OBJECT }, { "WERR_DS_OBJ_NOT_FOUND", WERR_DS_OBJ_NOT_FOUND }, + { "WERR_DS_DRA_DB_ERROR", WERR_DS_DRA_DB_ERROR }, + { "WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX", WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX }, { "WERR_GENERAL_FAILURE", WERR_GENERAL_FAILURE }, { "WERR_PRINTQ_FULL", WERR_PRINTQ_FULL }, { "WERR_NO_SPOOL_SPACE", WERR_NO_SPOOL_SPACE }, -- cgit From a7c70d4c5e11c515f1d09b88a83fb79baaf47e15 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 13 Dec 2004 11:37:47 +0000 Subject: r4177: add some more error codes metze (This used to be commit e624bb52886db80a3600b79494ad1150592efebe) --- source4/libcli/util/doserr.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index d81280bff6..ee2ca25435 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -74,7 +74,10 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DS_SERVICE_UNAVAILABLE", WERR_DS_SERVICE_UNAVAILABLE }, { "WERR_DS_NO_SUCH_OBJECT", WERR_DS_NO_SUCH_OBJECT }, { "WERR_DS_OBJ_NOT_FOUND", WERR_DS_OBJ_NOT_FOUND }, + { "WERR_DS_DRA_BAD_DN", WERR_DS_DRA_BAD_DN }, + { "WERR_DS_DRA_BAD_NC", WERR_DS_DRA_BAD_NC }, { "WERR_DS_DRA_DB_ERROR", WERR_DS_DRA_DB_ERROR }, + { "WERR_DS_DRA_NO_REPLICA", WERR_DS_DRA_NO_REPLICA }, { "WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX", WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX }, { "WERR_GENERAL_FAILURE", WERR_GENERAL_FAILURE }, { "WERR_PRINTQ_FULL", WERR_PRINTQ_FULL }, -- cgit From 4d545e09c899dd63dfc055d05dd871c7df8638a5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 14 Dec 2004 06:31:20 +0000 Subject: r4202: added smbclient commands "addprivileges" and "delprivileges" for easily adding/removing privileges from users (This used to be commit 8764909c05c4829d1e4f7eaf8c18e8ef1e53645f) --- source4/libcli/util/clilsa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index c3c7f8cc77..4204adcc07 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -297,3 +297,49 @@ NTSTATUS smblsa_lookup_name(struct smbcli_state *cli, return NT_STATUS_OK; } + + +/* + add a set of privileges to the given sid +*/ +NTSTATUS smblsa_sid_add_privileges(struct smbcli_state *cli, struct dom_sid *sid, + TALLOC_CTX *mem_ctx, + struct lsa_RightSet *rights) +{ + NTSTATUS status; + struct lsa_AddAccountRights r; + + status = smblsa_connect(cli); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + r.in.handle = &cli->lsa->handle; + r.in.sid = sid; + r.in.rights = rights; + + return dcerpc_lsa_AddAccountRights(cli->lsa->pipe, mem_ctx, &r); +} + +/* + remove a set of privileges from the given sid +*/ +NTSTATUS smblsa_sid_del_privileges(struct smbcli_state *cli, struct dom_sid *sid, + TALLOC_CTX *mem_ctx, + struct lsa_RightSet *rights) +{ + NTSTATUS status; + struct lsa_RemoveAccountRights r; + + status = smblsa_connect(cli); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + r.in.handle = &cli->lsa->handle; + r.in.sid = sid; + r.in.unknown = 0; + r.in.rights = rights; + + return dcerpc_lsa_RemoveAccountRights(cli->lsa->pipe, mem_ctx, &r); +} -- cgit From cb25806d8dcdbf45f6de3b1a86e1c40ee3711fee Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 31 Dec 2004 04:45:13 +0000 Subject: r4431: add WERR_NET_NAME_NOT_FOUND metze (This used to be commit 74e65680fa9a6b8f04c6ae62ec1da49659879fb5) --- source4/libcli/util/doserr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index ee2ca25435..aff46bc8bf 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -59,7 +59,8 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DEST_NOT_FOUND", WERR_DEST_NOT_FOUND }, { "WERR_NOT_LOCAL_DOMAIN", WERR_NOT_LOCAL_DOMAIN }, { "WERR_PRINTER_DRIVER_IN_USE", WERR_PRINTER_DRIVER_IN_USE }, - { "WERR_STATUS_MORE_ENTRIES ", WERR_STATUS_MORE_ENTRIES }, + { "WERR_STATUS_MORE_ENTRIES", WERR_STATUS_MORE_ENTRIES }, + { "WERR_NET_NAME_NOT_FOUND", WERR_NET_NAME_NOT_FOUND }, { "WERR_DFS_NO_SUCH_VOL", WERR_DFS_NO_SUCH_VOL }, { "WERR_DFS_NO_SUCH_SHARE", WERR_DFS_NO_SUCH_SHARE }, { "WERR_DFS_NO_SUCH_SERVER", WERR_DFS_NO_SUCH_SERVER }, -- cgit From 7ac62a7b133cac8915fe10272c1045d7aa4dc7fa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 31 Dec 2004 07:21:31 +0000 Subject: r4435: add another error code metze (This used to be commit 02861f63052c48fc85c6694ad8164cc6cc5443d4) --- source4/libcli/util/doserr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index aff46bc8bf..a9acb7335c 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -61,6 +61,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_PRINTER_DRIVER_IN_USE", WERR_PRINTER_DRIVER_IN_USE }, { "WERR_STATUS_MORE_ENTRIES", WERR_STATUS_MORE_ENTRIES }, { "WERR_NET_NAME_NOT_FOUND", WERR_NET_NAME_NOT_FOUND }, + { "WERR_DEVICE_NOT_SHARED", WERR_DEVICE_NOT_SHARED }, { "WERR_DFS_NO_SUCH_VOL", WERR_DFS_NO_SUCH_VOL }, { "WERR_DFS_NO_SUCH_SHARE", WERR_DFS_NO_SUCH_SHARE }, { "WERR_DFS_NO_SUCH_SERVER", WERR_DFS_NO_SUCH_SERVER }, -- cgit From cc55aef7c116d03ba2817625b0ba9edb378525e3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Jan 2005 02:32:43 +0000 Subject: r4547: - added talloc_new(ctx) macro that is a neater form of the common talloc(ctx, 0) call. - cleaned up some talloc usage in various files I'd like to get to the point that we have no calls to talloc(), at which point we will rename talloc_p() to talloc(), to encourage everyone to use the typesafe functions. (This used to be commit e6c81d7c9f8a6938947d3c1c8a971a0d6d50b67a) --- source4/libcli/util/clilsa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 4204adcc07..843d45607b 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -153,7 +153,7 @@ NTSTATUS smblsa_sid_check_privilege(struct smbcli_state *cli, { struct lsa_RightSet rights; NTSTATUS status; - TALLOC_CTX *mem_ctx = talloc(cli, 0); + TALLOC_CTX *mem_ctx = talloc_new(cli); struct dom_sid *sid; unsigned i; @@ -195,7 +195,7 @@ NTSTATUS smblsa_lookup_sid(struct smbcli_state *cli, uint32_t count = 1; NTSTATUS status; struct dom_sid *sid; - TALLOC_CTX *mem_ctx2 = talloc(mem_ctx, 0); + TALLOC_CTX *mem_ctx2 = talloc_new(mem_ctx); status = smblsa_connect(cli); if (!NT_STATUS_IS_OK(status)) { @@ -255,7 +255,7 @@ NTSTATUS smblsa_lookup_name(struct smbcli_state *cli, uint32_t count = 1; NTSTATUS status; struct dom_sid *sid; - TALLOC_CTX *mem_ctx2 = talloc(mem_ctx, 0); + TALLOC_CTX *mem_ctx2 = talloc_new(mem_ctx); uint32_t rid; status = smblsa_connect(cli); -- cgit From ddc10d4d37984246a6547e34a32d629c689c40d1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Jan 2005 03:06:58 +0000 Subject: r4549: got rid of a lot more uses of plain talloc(), instead using talloc_size() or talloc_array_p() where appropriate. also fixed a memory leak in pvfs_copy_file() (failed to free a memory context) (This used to be commit 89b74b53546e1570b11b3702f40bee58aed8c503) --- source4/libcli/util/asn1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 2bf29f9161..52ba0225c9 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -424,7 +424,7 @@ BOOL asn1_read_sequence_until(int sock, struct asn1_data *data, len = b; } - buf = talloc(NULL, len); + buf = talloc_size(NULL, len); if (buf == NULL) return False; @@ -548,7 +548,7 @@ BOOL asn1_read_GeneralString(struct asn1_data *data, char **s) data->has_error = True; return False; } - *s = talloc(NULL, len+1); + *s = talloc_size(NULL, len+1); if (! *s) { data->has_error = True; return False; -- cgit From 9278473ea456bd7f45f1465e7112540f611c177c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 Jan 2005 03:43:59 +0000 Subject: r4589: forgot to commit the new NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED error code (This used to be commit f4337c988c15dc84e3cfd77b628e92a0996717ea) --- source4/libcli/util/nterr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index eac7989800..d2d87eeb1c 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -536,6 +536,7 @@ static const nt_err_code_struct nt_errs[] = { "NT_STATUS_QUOTA_LIST_INCONSISTENT", NT_STATUS_QUOTA_LIST_INCONSISTENT }, { "NT_STATUS_FILE_IS_OFFLINE", NT_STATUS_FILE_IS_OFFLINE }, { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES }, + { "NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED", NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED }, { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES }, { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED }, { NULL, NT_STATUS(0) } -- cgit From 11ce2cfd70df264c5c91b4daaa9a01c5abc673b0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 Jan 2005 04:39:16 +0000 Subject: r4591: - converted the other _p talloc functions to not need _p - added #if TALLOC_DEPRECATED around the _p functions - fixes the code that broke from the above while doing this I fixed quite a number of places that were incorrectly using the non type-safe talloc functions to use the type safe ones. Some were even doing multiplies for array allocation, which is potentially unsafe. (This used to be commit 6e7754abd0c225527fb38363996a6e241b87b37e) --- source4/libcli/util/asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 52ba0225c9..de14eb0e57 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -33,7 +33,7 @@ BOOL asn1_write(struct asn1_data *data, const void *p, int len) if (data->has_error) return False; if (data->length < data->ofs+len) { uint8_t *newp; - newp = talloc_realloc(NULL, data->data, data->ofs+len); + newp = talloc_realloc(NULL, data->data, uint8_t, data->ofs+len); if (!newp) { asn1_free(data); data->has_error = True; -- cgit From 6836f5d0b167027908da9a08b9b219520997b563 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 9 Jan 2005 08:34:05 +0000 Subject: r4616: the first phase in the addition of proper support for dcerpc_alter_context and multiple context_ids in the dcerpc client library. This stage does the following: - split "struct dcerpc_pipe" into two parts, the main part being "struct dcerpc_connection", which contains all the parts not dependent on the context, and "struct dcerpc_pipe" which has the context dependent part. This is similar to the layering in libcli_*() for SMB - disable the current dcerpc_alter code. I've used a #warning until i get the 2nd phase finished. I don't know how portable #warning is, but it won't be long before I add full alter context support anyway, so it won't last long - cleanup the allocation of dcerpc_pipe structures. The previous code was quite awkward. (This used to be commit 4004c69937be7e5dae56f9567ca607f982d395d3) --- source4/libcli/util/clilsa.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 843d45607b..c032af0abc 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -76,8 +76,14 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) } lsa->ipc_tree->tid = tcon.tconx.out.cnum; + lsa->pipe = dcerpc_pipe_init(lsa); + if (lsa->pipe == NULL) { + talloc_free(lsa); + return NT_STATUS_NO_MEMORY; + } + /* open the LSA pipe */ - status = dcerpc_pipe_open_smb(&lsa->pipe, lsa->ipc_tree, DCERPC_LSARPC_NAME); + status = dcerpc_pipe_open_smb(lsa->pipe->conn, lsa->ipc_tree, DCERPC_LSARPC_NAME); if (!NT_STATUS_IS_OK(status)) { talloc_free(lsa); return status; -- cgit From e74b3ed6f195e66cb5fa0f387cea0f59fb66711b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 9 Jan 2005 11:32:12 +0000 Subject: r4618: - tidied up the alter_context client code a bit - there is no alter_nak or alter_ack packet, its all done in an alter_response - auto-allocated the contex_ids - tried to fix up the dcom code to work again with alter_context. Jelmer, please take a look :) (This used to be commit dd1c54add8884376601f2f8a56c01bfb8add030c) --- source4/libcli/util/nterr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index d2d87eeb1c..9317f0e37a 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -537,6 +537,7 @@ static const nt_err_code_struct nt_errs[] = { "NT_STATUS_FILE_IS_OFFLINE", NT_STATUS_FILE_IS_OFFLINE }, { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES }, { "NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED", NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED }, + { "NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX", NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX }, { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES }, { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED }, { NULL, NT_STATUS(0) } -- cgit From 28236430f4b0114d9539967fa9c10bfd69c38774 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 10 Jan 2005 22:53:52 +0000 Subject: r4658: (grr, commited wrong file last time). We really should have a seperate structure for this (the ARCFOUR sbox), but for now, get the declaration right. Andrew Bartlett (This used to be commit 2e16f3a8d31954fdfe4a8832637fcd9191ecab96) --- source4/libcli/util/smbdes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index 4e4222b9e6..016bd59501 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -365,7 +365,7 @@ void des_crypt112_16(uint8_t out[16], uint8_t in[16], const uint8_t key[14], int } /* initialise the arcfour sbox with key */ -void arcfour_init(uint8_t s_box[256], const DATA_BLOB *key) +void arcfour_init(uint8_t s_box[258], const DATA_BLOB *key) { int ind; uint8_t j = 0; -- cgit From fef48c0cc8b58536ed2f3338fc7c790a846f305d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 12 Jan 2005 07:19:15 +0000 Subject: r4701: remove debugs metze (This used to be commit 9db0d19413beb4a0a0b48f4223600ff8dff33728) --- source4/libcli/util/smbencrypt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index ee423fbbba..bd2aae3db1 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -486,8 +486,6 @@ BOOL decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd, /* Password cannot be longer than the size of the password buffer */ if ( (byte_len < 0) || (byte_len > 512)) { - DEBUG(0, ("decode_pw_buffer: incorrect password length (%d).\n", byte_len)); - DEBUG(0, ("decode_pw_buffer: check that 'encrypt passwords = yes'\n")); return False; } -- cgit From 592fce7fb149ca5e82b14d9c8f13a4da1babe2b7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 13 Jan 2005 18:49:10 +0000 Subject: r4726: - use the name tcon and tid instead of conn and cnum - make use of talloc destructors metze (This used to be commit 8308da6ce4a95f8c10e22949ef00e9e64f2dbb85) --- source4/libcli/util/clilsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index c032af0abc..eac6984254 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -74,7 +74,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) talloc_free(lsa); return status; } - lsa->ipc_tree->tid = tcon.tconx.out.cnum; + lsa->ipc_tree->tid = tcon.tconx.out.tid; lsa->pipe = dcerpc_pipe_init(lsa); if (lsa->pipe == NULL) { -- cgit From e89fd49df7e63dcf37ee1aa7e2f50965851725c9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 15 Jan 2005 10:38:12 +0000 Subject: r4757: added the ability of the clisocket level of libcli to handle async socket connections. This was complicated by a few factors: - it meant moving the event context from clitransport to clisocket, so lots of structures changed - we need to asynchronously handle connection to lists of port numbers, not just one port number. The code internally tries each port in the list in turn, without ever blocking - the man page on how connect() is supposed to work asynchronously doesn't work in practice (now why doesn't this surprise me?). The getsockopt() for SOL_ERROR is supposed to retrieve the error, but in fact the next (unrelated) connect() call on the same socket also gets an error, though not the right error. To work around this I need to tear down the whole socket between each attempted port. I hate posix. Note that clisocket.c still does a blocking name resolution call in smbcli_sock_connect_byname(). That will be fixed when we add the async NBT resolution code. Also note that I arranged things so that every SMB connection is now async internally, so using plain smbclient or smbtorture tests all the async features of this new code. (This used to be commit 468f8ebbfdbdf37c757fdc4863626aa9946a8870) --- source4/libcli/util/errormap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 4a57e436c7..b99ab3d2fe 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1497,7 +1497,7 @@ struct unix_error_map { const struct unix_error_map unix_nt_errmap[] = { { EAGAIN, STATUS_MORE_ENTRIES }, { EINTR, STATUS_MORE_ENTRIES }, - { EINPROGRESS, STATUS_MORE_ENTRIES }, + { EINPROGRESS, NT_STATUS_MORE_PROCESSING_REQUIRED }, { EPERM, NT_STATUS_ACCESS_DENIED }, { EACCES, NT_STATUS_ACCESS_DENIED }, { ENOENT, NT_STATUS_OBJECT_NAME_NOT_FOUND }, -- cgit From 3e44c4a3ba6acd7d9bc997c012d1863377e9d873 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 24 Jan 2005 00:57:14 +0000 Subject: r4951: some of the code dealing with libcli was getting too complex trying to handle the inverted memory hierarchy that a normal session establishment gave. The inverted hierarchy came from that fact that you first establish a socket, then a transport, then a session and finally a tree. That leads to the socket being at the top of the memory hierarchy and the tree at the bottom, which makes no sense from the users point of view, as they want to be able to free the tree and have everything disappear. The core problem was that the libcli interface didn't distinguish between establishing a primary context and a secondary context. If you establish a 2nd session on a transport then you want the transport to be referenced by the session, whereas if you establish a primary session then you want the transport to be a child of the session. To fix this I have added "parent_ctx" and "primary" arguments to the libcli intialisation functions. This makes using the library much easier, and gives us a memory hierarchy that makes much more sense. I was prompted to do this by a bug in the cifs backend, which was caused by the socket not being properly torn down on a disconnect due to the inverted memory hierarchy. (This used to be commit 5e8fd5f70178992e249805c2e1ddafaf6840739b) --- source4/libcli/util/clilsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index eac6984254..40991a8855 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -58,7 +58,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) return NT_STATUS_NO_MEMORY; } - lsa->ipc_tree = smbcli_tree_init(cli->session); + lsa->ipc_tree = smbcli_tree_init(cli->session, lsa, False); if (lsa->ipc_tree == NULL) { return NT_STATUS_NO_MEMORY; } -- cgit From 759da3b915e2006d4c87b5ace47f399accd9ce91 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Jan 2005 07:08:20 +0000 Subject: r5037: got rid of all of the TALLOC_DEPRECATED stuff. My apologies for the large commit. I thought this was worthwhile to get done for consistency. (This used to be commit ec32b22ed5ec224f6324f5e069d15e92e38e15c0) --- source4/libcli/util/asn1.c | 4 ++-- source4/libcli/util/clilsa.c | 4 ++-- source4/libcli/util/smbencrypt.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index de14eb0e57..550450fea7 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -59,7 +59,7 @@ BOOL asn1_push_tag(struct asn1_data *data, uint8_t tag) struct nesting *nesting; asn1_write_uint8(data, tag); - nesting = talloc_p(NULL, struct nesting); + nesting = talloc(NULL, struct nesting); if (!nesting) { data->has_error = True; return False; @@ -349,7 +349,7 @@ BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag) data->has_error = True; return False; } - nesting = talloc_p(NULL, struct nesting); + nesting = talloc(NULL, struct nesting); if (!nesting) { data->has_error = True; return False; diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 40991a8855..0c0c64c0b4 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -53,7 +53,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) return NT_STATUS_OK; } - lsa = talloc_p(cli, struct smblsa_state); + lsa = talloc(cli, struct smblsa_state); if (lsa == NULL) { return NT_STATUS_NO_MEMORY; } @@ -217,7 +217,7 @@ NTSTATUS smblsa_lookup_sid(struct smbcli_state *cli, names.names = NULL; sids.num_sids = 1; - sids.sids = talloc_p(mem_ctx2, struct lsa_SidPtr); + sids.sids = talloc(mem_ctx2, struct lsa_SidPtr); sids.sids[0].sid = sid; r.in.handle = &cli->lsa->handle; diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index bd2aae3db1..7e2890272c 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -344,7 +344,7 @@ static DATA_BLOB NTLMv2_generate_response(const uint8_t ntlm_v2_hash[16], memcpy(final_response.data+sizeof(ntlmv2_response), ntlmv2_client_data.data, ntlmv2_client_data.length); - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); return final_response; } -- cgit From 99ecf2d95325e7b6143596760dbc2780ba246dc6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 28 Jan 2005 11:25:01 +0000 Subject: r5053: - fix up the library dependencies so that tools that need nbt don't need to pull in the whole dcerpc subsystem - moved smbencrypt.c code into libcli/auth/ (This used to be commit 3351c636af23ad88649e84f4cb88fc1167d5c654) --- source4/libcli/util/smbencrypt.c | 504 --------------------------------------- 1 file changed, 504 deletions(-) delete mode 100644 source4/libcli/util/smbencrypt.c (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c deleted file mode 100644 index 7e2890272c..0000000000 --- a/source4/libcli/util/smbencrypt.c +++ /dev/null @@ -1,504 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB parameters and setup - Copyright (C) Andrew Tridgell 1992-1998 - Modified by Jeremy Allison 1995. - Copyright (C) Jeremy Allison 1995-2000. - Copyright (C) Luke Kennethc Casson Leighton 1996-2000. - Copyright (C) Andrew Bartlett 2002-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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "system/time.h" -#include "auth/auth.h" -#include "lib/crypto/crypto.h" - -/* - This implements the X/Open SMB password encryption - It takes a password ('unix' string), a 8 byte "crypt key" - and puts 24 bytes of encrypted password into p24 - - Returns False if password must have been truncated to create LM hash -*/ -BOOL SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24]) -{ - BOOL ret; - uint8_t p21[21]; - - memset(p21,'\0',21); - ret = E_deshash(passwd, p21); - - SMBOWFencrypt(p21, c8, p24); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("SMBencrypt: lm#, challenge, response\n")); - dump_data(100, p21, 16); - dump_data(100, c8, 8); - dump_data(100, p24, 24); -#endif - - return ret; -} - -/** - * Creates the MD4 Hash of the users password in NT UNICODE. - * @param passwd password in 'unix' charset. - * @param p16 return password hashed with md4, caller allocated 16 byte buffer - */ - -void E_md4hash(const char *passwd, uint8_t p16[16]) -{ - int len; - void *wpwd; - - len = push_ucs2_talloc(NULL, &wpwd, passwd); - SMB_ASSERT(len >= 2); - - len -= 2; - mdfour(p16, wpwd, len); - - talloc_free(wpwd); -} - -/** - * Creates the DES forward-only Hash of the users password in DOS ASCII charset - * @param passwd password in 'unix' charset. - * @param p16 return password hashed with DES, caller allocated 16 byte buffer - * @return False if password was > 14 characters, and therefore may be incorrect, otherwise True - * @note p16 is filled in regardless - */ - -BOOL E_deshash(const char *passwd, uint8_t p16[16]) -{ - BOOL ret = True; - fstring dospwd; - ZERO_STRUCT(dospwd); - - /* Password must be converted to DOS charset - null terminated, uppercase. */ - push_ascii(dospwd, passwd, sizeof(dospwd), STR_UPPER|STR_TERMINATE); - - /* Only the fisrt 14 chars are considered, password need not be null terminated. */ - E_P16((const uint8_t *)dospwd, p16); - - if (strlen(dospwd) > 14) { - ret = False; - } - - ZERO_STRUCT(dospwd); - - return ret; -} - -/* Does both the NTLMv2 owfs of a user's password */ -BOOL ntv2_owf_gen(const uint8_t owf[16], - const char *user_in, const char *domain_in, - BOOL upper_case_domain, /* Transform the domain into UPPER case */ - uint8_t kr_buf[16]) -{ - void *user; - void *domain; - size_t user_byte_len; - size_t domain_byte_len; - - HMACMD5Context ctx; - TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in); - if (!mem_ctx) { - return False; - } - - user_in = strupper_talloc(mem_ctx, user_in); - if (user_in == NULL) { - talloc_free(mem_ctx); - return False; - } - - if (upper_case_domain) { - domain_in = strupper_talloc(mem_ctx, domain_in); - if (domain_in == NULL) { - talloc_free(mem_ctx); - return False; - } - } - - user_byte_len = push_ucs2_talloc(mem_ctx, &user, user_in); - if (user_byte_len == (ssize_t)-1) { - DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n")); - talloc_free(mem_ctx); - return False; - } - - domain_byte_len = push_ucs2_talloc(mem_ctx, &domain, domain_in); - if (domain_byte_len == (ssize_t)-1) { - DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n")); - talloc_free(mem_ctx); - return False; - } - - SMB_ASSERT(user_byte_len >= 2); - SMB_ASSERT(domain_byte_len >= 2); - - /* We don't want null termination */ - user_byte_len = user_byte_len - 2; - domain_byte_len = domain_byte_len - 2; - - hmac_md5_init_limK_to_64(owf, 16, &ctx); - hmac_md5_update(user, user_byte_len, &ctx); - hmac_md5_update(domain, domain_byte_len, &ctx); - hmac_md5_final(kr_buf, &ctx); - -#ifdef DEBUG_PASSWORD - DEBUG(100, ("ntv2_owf_gen: user, domain, owfkey, kr\n")); - dump_data(100, user, user_byte_len); - dump_data(100, domain, domain_byte_len); - dump_data(100, owf, 16); - dump_data(100, kr_buf, 16); -#endif - - talloc_free(mem_ctx); - return True; -} - -/* Does the des encryption from the NT or LM MD4 hash. */ -void SMBOWFencrypt(const uint8_t passwd[16], const uint8_t *c8, uint8_t p24[24]) -{ - uint8_t p21[21]; - - ZERO_STRUCT(p21); - - memcpy(p21, passwd, 16); - E_P24(p21, c8, p24); -} - -/* Does the NT MD4 hash then des encryption. */ - -void SMBNTencrypt(const char *passwd, uint8_t *c8, uint8_t *p24) -{ - uint8_t p21[21]; - - memset(p21,'\0',21); - - E_md4hash(passwd, p21); - SMBOWFencrypt(p21, c8, p24); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("SMBNTencrypt: nt#, challenge, response\n")); - dump_data(100, p21, 16); - dump_data(100, c8, 8); - dump_data(100, p24, 24); -#endif -} - -/* Does the md5 encryption from the Key Response for NTLMv2. */ -void SMBOWFencrypt_ntv2(const uint8_t kr[16], - const DATA_BLOB *srv_chal, - const DATA_BLOB *smbcli_chal, - uint8_t resp_buf[16]) -{ - HMACMD5Context ctx; - - hmac_md5_init_limK_to_64(kr, 16, &ctx); - hmac_md5_update(srv_chal->data, srv_chal->length, &ctx); - hmac_md5_update(smbcli_chal->data, smbcli_chal->length, &ctx); - hmac_md5_final(resp_buf, &ctx); - -#ifdef DEBUG_PASSWORD - DEBUG(100, ("SMBOWFencrypt_ntv2: srv_chal, smbcli_chal, resp_buf\n")); - dump_data(100, srv_chal->data, srv_chal->length); - dump_data(100, smbcli_chal->data, smbcli_chal->length); - dump_data(100, resp_buf, 16); -#endif -} - -void SMBsesskeygen_ntv2(const uint8_t kr[16], - const uint8_t * nt_resp, uint8_t sess_key[16]) -{ - /* a very nice, 128 bit, variable session key */ - - HMACMD5Context ctx; - - hmac_md5_init_limK_to_64(kr, 16, &ctx); - hmac_md5_update(nt_resp, 16, &ctx); - hmac_md5_final((uint8_t *)sess_key, &ctx); - -#ifdef DEBUG_PASSWORD - DEBUG(100, ("SMBsesskeygen_ntv2:\n")); - dump_data(100, sess_key, 16); -#endif -} - -void SMBsesskeygen_ntv1(const uint8_t kr[16], uint8_t sess_key[16]) -{ - /* yes, this session key does not change - yes, this - is a problem - but it is 128 bits */ - - mdfour((uint8_t *)sess_key, kr, 16); - -#ifdef DEBUG_PASSWORD - DEBUG(100, ("SMBsesskeygen_ntv1:\n")); - dump_data(100, sess_key, 16); -#endif -} - -void SMBsesskeygen_lm_sess_key(const uint8_t lm_hash[16], - const uint8_t lm_resp[24], /* only uses 8 */ - uint8_t sess_key[16]) -{ - /* Calculate the LM session key (effective length 40 bits, - but changes with each session) */ - uint8_t p24[24]; - uint8_t p21[21]; - - memset(p21,'\0',21); - memcpy(p21, lm_hash, 8); - memset(p21 + 8, 0xbd, 8); - - E_P24(p21, lm_resp, p24); - - memcpy(sess_key, p24, 16); - -#ifdef DEBUG_PASSWORD - DEBUG(100, ("SMBsesskeygen_lm_sess_key: \n")); - dump_data(100, sess_key, 16); -#endif -} - -DATA_BLOB NTLMv2_generate_names_blob(TALLOC_CTX *mem_ctx, - const char *hostname, - const char *domain) -{ - DATA_BLOB names_blob = data_blob_talloc(mem_ctx, NULL, 0); - - msrpc_gen(mem_ctx, &names_blob, "aaa", - NTLMSSP_NAME_TYPE_DOMAIN, domain, - NTLMSSP_NAME_TYPE_SERVER, hostname, - 0, ""); - return names_blob; -} - -static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLOB *names_blob) -{ - uint8_t client_chal[8]; - DATA_BLOB response = data_blob(NULL, 0); - uint8_t long_date[8]; - NTTIME nttime; - - unix_to_nt_time(&nttime, time(NULL)); - - generate_random_buffer(client_chal, sizeof(client_chal)); - - push_nttime(long_date, 0, nttime); - - /* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */ - - msrpc_gen(mem_ctx, &response, "ddbbdb", - 0x00000101, /* Header */ - 0, /* 'Reserved' */ - long_date, 8, /* Timestamp */ - client_chal, 8, /* client challenge */ - 0, /* Unknown */ - names_blob->data, names_blob->length); /* End of name list */ - - return response; -} - -static DATA_BLOB NTLMv2_generate_response(const uint8_t ntlm_v2_hash[16], - const DATA_BLOB *server_chal, - const DATA_BLOB *names_blob) -{ - uint8_t ntlmv2_response[16]; - DATA_BLOB ntlmv2_client_data; - DATA_BLOB final_response; - - TALLOC_CTX *mem_ctx = talloc_init("NTLMv2_generate_response internal context"); - - if (!mem_ctx) { - return data_blob(NULL, 0); - } - - /* NTLMv2 */ - /* generate some data to pass into the response function - including - the hostname and domain name of the server */ - ntlmv2_client_data = NTLMv2_generate_client_data(mem_ctx, names_blob); - - /* Given that data, and the challenge from the server, generate a response */ - SMBOWFencrypt_ntv2(ntlm_v2_hash, server_chal, &ntlmv2_client_data, ntlmv2_response); - - final_response = data_blob(NULL, sizeof(ntlmv2_response) + ntlmv2_client_data.length); - - memcpy(final_response.data, ntlmv2_response, sizeof(ntlmv2_response)); - - memcpy(final_response.data+sizeof(ntlmv2_response), - ntlmv2_client_data.data, ntlmv2_client_data.length); - - talloc_free(mem_ctx); - - return final_response; -} - -static DATA_BLOB LMv2_generate_response(const uint8_t ntlm_v2_hash[16], - const DATA_BLOB *server_chal) -{ - uint8_t lmv2_response[16]; - DATA_BLOB lmv2_client_data = data_blob(NULL, 8); - DATA_BLOB final_response = data_blob(NULL, 24); - - /* LMv2 */ - /* client-supplied random data */ - generate_random_buffer(lmv2_client_data.data, lmv2_client_data.length); - - /* Given that data, and the challenge from the server, generate a response */ - SMBOWFencrypt_ntv2(ntlm_v2_hash, server_chal, &lmv2_client_data, lmv2_response); - memcpy(final_response.data, lmv2_response, sizeof(lmv2_response)); - - /* after the first 16 bytes is the random data we generated above, - so the server can verify us with it */ - memcpy(final_response.data+sizeof(lmv2_response), - lmv2_client_data.data, lmv2_client_data.length); - - data_blob_free(&lmv2_client_data); - - return final_response; -} - -BOOL SMBNTLMv2encrypt_hash(const char *user, const char *domain, const uint8_t nt_hash[16], - const DATA_BLOB *server_chal, - const DATA_BLOB *names_blob, - DATA_BLOB *lm_response, DATA_BLOB *nt_response, - DATA_BLOB *lm_session_key, DATA_BLOB *user_session_key) -{ - uint8_t ntlm_v2_hash[16]; - - /* We don't use the NT# directly. Instead we use it mashed up with - the username and domain. - This prevents username swapping during the auth exchange - */ - if (!ntv2_owf_gen(nt_hash, user, domain, True, ntlm_v2_hash)) { - return False; - } - - if (nt_response) { - *nt_response = NTLMv2_generate_response(ntlm_v2_hash, server_chal, - names_blob); - if (user_session_key) { - *user_session_key = data_blob(NULL, 16); - - /* The NTLMv2 calculations also provide a session key, for signing etc later */ - /* use only the first 16 bytes of nt_response for session key */ - SMBsesskeygen_ntv2(ntlm_v2_hash, nt_response->data, user_session_key->data); - } - } - - /* LMv2 */ - - if (lm_response) { - *lm_response = LMv2_generate_response(ntlm_v2_hash, server_chal); - if (lm_session_key) { - *lm_session_key = data_blob(NULL, 16); - - /* The NTLMv2 calculations also provide a session key, for signing etc later */ - /* use only the first 16 bytes of lm_response for session key */ - SMBsesskeygen_ntv2(ntlm_v2_hash, lm_response->data, lm_session_key->data); - } - } - - return True; -} - -BOOL SMBNTLMv2encrypt(const char *user, const char *domain, const char *password, - const DATA_BLOB *server_chal, - const DATA_BLOB *names_blob, - DATA_BLOB *lm_response, DATA_BLOB *nt_response, - DATA_BLOB *lm_session_key, DATA_BLOB *user_session_key) -{ - uint8_t nt_hash[16]; - E_md4hash(password, nt_hash); - - return SMBNTLMv2encrypt_hash(user, domain, nt_hash, server_chal, names_blob, - lm_response, nt_response, lm_session_key, user_session_key); -} - -/*********************************************************** - encode a password buffer with a unicode password. The buffer - is filled with random data to make it harder to attack. -************************************************************/ -BOOL encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flags) -{ - uint8_t new_pw[512]; - size_t new_pw_len; - - new_pw_len = push_string(new_pw, - password, - sizeof(new_pw), string_flags); - - memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len); - - generate_random_buffer(buffer, 512 - new_pw_len); - - /* - * The length of the new password is in the last 4 bytes of - * the data buffer. - */ - SIVAL(buffer, 512, new_pw_len); - ZERO_STRUCT(new_pw); - return True; -} - - -/*********************************************************** - decode a password buffer - *new_pw_len is the length in bytes of the possibly mulitbyte - returned password including termination. -************************************************************/ -BOOL decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd, - int new_pwrd_size, uint32_t *new_pw_len, - int string_flags) -{ - int byte_len=0; - - /* - Warning !!! : This function is called from some rpc call. - The password IN the buffer may be a UNICODE string. - The password IN new_pwrd is an ASCII string - If you reuse that code somewhere else check first. - */ - - /* The length of the new password is in the last 4 bytes of the data buffer. */ - - byte_len = IVAL(in_buffer, 512); - -#ifdef DEBUG_PASSWORD - dump_data(100, in_buffer, 516); -#endif - - /* Password cannot be longer than the size of the password buffer */ - if ( (byte_len < 0) || (byte_len > 512)) { - return False; - } - - /* decode into the return buffer. Buffer length supplied */ - *new_pw_len = pull_string(new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, - byte_len, string_flags); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("decode_pw_buffer: new_pwrd: ")); - dump_data(100, (const uint8_t *)new_pwrd, *new_pw_len); - DEBUG(100,("multibyte len:%d\n", *new_pw_len)); - DEBUG(100,("original char len:%d\n", byte_len/2)); -#endif - - return True; -} -- cgit From a0ab1f7afda62964d480af9dc26e60a38d1350e0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 30 Jan 2005 07:22:16 +0000 Subject: r5107: moved the horrible ldap socket code, and the even worse asn1-tied-to-blocking-sockets code into the ldap client and torture suite, and out of the generic libs, so nobody else is tempted to use it for any new code. (This used to be commit 39d1ced21baeca40d1fca62ba65243ca8f15757e) --- source4/libcli/util/asn1.c | 61 ---------------------------------------------- 1 file changed, 61 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 550450fea7..1124cc1701 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -379,67 +379,6 @@ BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag) return !data->has_error; } -static BOOL read_one_uint8(int sock, uint8_t *result, struct asn1_data *data, - const struct timeval *endtime) -{ - if (read_data_until(sock, result, 1, endtime) != 1) - return False; - - return asn1_write(data, result, 1); -} - -/* Read a complete ASN sequence (ie LDAP result) from a socket */ -BOOL asn1_read_sequence_until(int sock, struct asn1_data *data, - const struct timeval *endtime) -{ - uint8_t b; - size_t len; - char *buf; - - ZERO_STRUCTP(data); - - if (!read_one_uint8(sock, &b, data, endtime)) - return False; - - if (b != 0x30) { - data->has_error = True; - return False; - } - - if (!read_one_uint8(sock, &b, data, endtime)) - return False; - - if (b & 0x80) { - int n = b & 0x7f; - if (!read_one_uint8(sock, &b, data, endtime)) - return False; - len = b; - while (n > 1) { - if (!read_one_uint8(sock, &b, data, endtime)) - return False; - len = (len<<8) | b; - n--; - } - } else { - len = b; - } - - buf = talloc_size(NULL, len); - if (buf == NULL) - return False; - - if (read_data_until(sock, buf, len, endtime) != len) - return False; - - if (!asn1_write(data, buf, len)) - return False; - - talloc_free(buf); - - data->ofs = 0; - - return True; -} /* Get the length to be expected in buf */ BOOL asn1_object_length(uint8_t *buf, size_t buf_length, -- cgit From 58a957035336119a3a023384fef205ae718fdf1b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 5 Feb 2005 14:40:47 +0000 Subject: r5237: Add error code for "class not registered" (This used to be commit b72a0ac654857273eaaf3c5e32d86abed0af3ceb) --- source4/libcli/util/doserr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index a9acb7335c..a584def829 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -86,6 +86,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_NO_SPOOL_SPACE", WERR_NO_SPOOL_SPACE }, { "WERR_CAN_NOT_COMPLETE", WERR_CAN_NOT_COMPLETE }, { "WERR_SERVER_UNAVAILABLE", WERR_SERVER_UNAVAILABLE }, + { "WERR_CLASS_NOT_REGISTERED", WERR_CLASS_NOT_REGISTERED }, { NULL, W_ERROR(0) } }; -- cgit From e82aad1ce39a6b7a2e51b9e2cb494d74ec70e158 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 05:09:35 +0000 Subject: r5298: - got rid of pstring.h from includes.h. This at least makes it a bit less likely that anyone will use pstring for new code - got rid of winbind_client.h from includes.h. This one triggered a huge change, as winbind_client.h was including system/filesys.h and defining the old uint32 and uint16 types, as well as its own pstring and fstring. (This used to be commit 9db6c79e902ec538108d6b7d3324039aabe1704f) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/nterr.c | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index a584def829..b346fea644 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -21,6 +21,7 @@ /* DOS error codes. please read doserr.h */ #include "includes.h" +#include "pstring.h" struct werror_code_struct { const char *dos_errstr; diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 9317f0e37a..d727cfe2a9 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -21,6 +21,7 @@ /* NT error codes. please read nterr.h */ #include "includes.h" +#include "pstring.h" typedef struct { -- cgit From 736797ef7fe3b9cf542fa69281272501f95bfa3f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 11 Mar 2005 10:33:01 +0000 Subject: r5737: add some error codes metze (This used to be commit f543eb4ede54ac361017878574b3f4b6ffc9f2d5) --- source4/libcli/util/doserr.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index b346fea644..83553448a3 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -77,10 +77,12 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DS_SERVICE_UNAVAILABLE", WERR_DS_SERVICE_UNAVAILABLE }, { "WERR_DS_NO_SUCH_OBJECT", WERR_DS_NO_SUCH_OBJECT }, { "WERR_DS_OBJ_NOT_FOUND", WERR_DS_OBJ_NOT_FOUND }, + { "WERR_DS_DRA_INVALID_PARAMETER", WERR_DS_DRA_INVALID_PARAMETER }, { "WERR_DS_DRA_BAD_DN", WERR_DS_DRA_BAD_DN }, { "WERR_DS_DRA_BAD_NC", WERR_DS_DRA_BAD_NC }, { "WERR_DS_DRA_DB_ERROR", WERR_DS_DRA_DB_ERROR }, { "WERR_DS_DRA_NO_REPLICA", WERR_DS_DRA_NO_REPLICA }, + { "WERR_DS_DNS_LOOKUP_FAILURE", WERR_DS_DNS_LOOKUP_FAILURE }, { "WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX", WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX }, { "WERR_GENERAL_FAILURE", WERR_GENERAL_FAILURE }, { "WERR_PRINTQ_FULL", WERR_PRINTQ_FULL }, -- cgit From ef213b02482194a8fed7f37123e08624072694b2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Mar 2005 20:28:01 +0000 Subject: r5866: Add InitShutdown IDL and torture test. Implement push side of NDR_LEN4|NDR_NOTERM strings (pull side was already present) (This used to be commit ea61ec1122841716ed5d90085ba79e7bf691bd6a) --- source4/libcli/util/doserr.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 83553448a3..577c004422 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -90,6 +90,8 @@ static const struct werror_code_struct dos_errs[] = { "WERR_CAN_NOT_COMPLETE", WERR_CAN_NOT_COMPLETE }, { "WERR_SERVER_UNAVAILABLE", WERR_SERVER_UNAVAILABLE }, { "WERR_CLASS_NOT_REGISTERED", WERR_CLASS_NOT_REGISTERED }, + { "WERR_NO_SHUTDOWN_IN_PROGRESS", WERR_NO_SHUTDOWN_IN_PROGRESS }, + { "WERR_SHUTDOWN_ALREADY_IN_PROGRESS", WERR_SHUTDOWN_ALREADY_IN_PROGRESS }, { NULL, W_ERROR(0) } }; -- cgit From 0501a440bedde5e867e461d266aafe666be53e54 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 25 Apr 2005 08:26:53 +0000 Subject: r6462: Move the arcfour sbox state into it's own structure, and allocate it with talloc() for the NTLMSSP system. Andrew Bartlett (This used to be commit 7a93ac49c28d433ccf0f077294f473fe728b9995) --- source4/libcli/util/smbdes.c | 48 ++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index 016bd59501..d214d4cfe4 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -22,6 +22,7 @@ */ #include "includes.h" +#include "lib/crypto/crypto.h" /* NOTES: @@ -365,51 +366,46 @@ void des_crypt112_16(uint8_t out[16], uint8_t in[16], const uint8_t key[14], int } /* initialise the arcfour sbox with key */ -void arcfour_init(uint8_t s_box[258], const DATA_BLOB *key) +void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key) { int ind; uint8_t j = 0; - for (ind = 0; ind < 256; ind++) { - s_box[ind] = (uint8_t)ind; + for (ind = 0; ind < sizeof(state->sbox); ind++) { + state->sbox[ind] = (uint8_t)ind; } - for (ind = 0; ind < 256; ind++) { + for (ind = 0; ind < sizeof(state->sbox); ind++) { uint8_t tc; - j += (s_box[ind] + key->data[ind%key->length]); + j += (state->sbox[ind] + key->data[ind%key->length]); - tc = s_box[ind]; - s_box[ind] = s_box[j]; - s_box[j] = tc; + tc = state->sbox[ind]; + state->sbox[ind] = state->sbox[j]; + state->sbox[j] = tc; } - s_box[256] = 0; /* i */ - s_box[257] = 0; /* j */ - + state->index_i = 0; + state->index_j = 0; } /* crypt the data with arcfour */ -void arcfour_crypt_sbox(uint8_t s_box[258], uint8_t *data, int len) +void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data, int len) { - uint8_t index_i = s_box[256]; - uint8_t index_j = s_box[257]; int ind; for (ind = 0; ind < len; ind++) { uint8_t tc; uint8_t t; - index_i++; - index_j += s_box[index_i]; + state->index_i++; + state->index_j += state->sbox[state->index_i]; - tc = s_box[index_i]; - s_box[index_i] = s_box[index_j]; - s_box[index_j] = tc; + tc = state->sbox[state->index_i]; + state->sbox[state->index_i] = state->sbox[state->index_j]; + state->sbox[state->index_j] = tc; - t = s_box[index_i] + s_box[index_j]; - data[ind] = data[ind] ^ s_box[t]; + t = state->sbox[state->index_i] + state->sbox[state->index_j]; + data[ind] = data[ind] ^ state->sbox[t]; } - s_box[256] = index_i; - s_box[257] = index_j; } /* @@ -417,9 +413,9 @@ void arcfour_crypt_sbox(uint8_t s_box[258], uint8_t *data, int len) */ void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key) { - uint8_t s_box[258]; - arcfour_init(s_box, key); - arcfour_crypt_sbox(s_box, data, len); + struct arcfour_state state; + arcfour_init(&state, key); + arcfour_crypt_sbox(&state, data, len); } /* -- cgit From 4b0e5bd75373ffa2d847706a71fd0349dfa15e71 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Jun 2005 09:10:17 +0000 Subject: r7527: - added a ldb_search_bytree() interface, which takes a ldb_parse_tree instead of a search expression. This allows our ldap server to pass its ASN.1 parsed search expressions straight to ldb, instead of going via strings. - updated all the ldb modules code to handle the new interface - got rid of the separate ldb_parse.h now that the ldb_parse structures are exposed externally - moved to C99 structure initialisation in ldb - switched ldap server to using ldb_search_bytree() (This used to be commit 96620ab2ee5d440bbbc51c1bc0cad9977770f897) --- source4/libcli/util/asn1.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 1124cc1701..dff31f6411 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -509,9 +509,11 @@ BOOL asn1_read_OctetString(struct asn1_data *data, DATA_BLOB *blob) data->has_error = True; return False; } - *blob = data_blob(NULL, len); + *blob = data_blob(NULL, len+1); asn1_read(data, blob->data, len); asn1_end_tag(data); + blob->length--; + blob->data[len] = 0; if (data->has_error) { data_blob_free(blob); -- cgit From 9d6b3e62c2dd27c7e8f72d6887888f686d868981 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 14 Jun 2005 03:52:27 +0000 Subject: r7566: added support for LDAPString types in the asn.1 library (This used to be commit 1a81d28456261ad77181fd12c0b4a9df6aa6a47d) --- source4/libcli/util/asn1.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index dff31f6411..510ffa37cf 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -214,11 +214,18 @@ BOOL asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length return !data->has_error; } +/* write a LDAP string */ +BOOL asn1_write_LDAPString(struct asn1_data *data, const char *s) +{ + asn1_write(data, s, strlen(s)); + return !data->has_error; +} + /* write a general string */ BOOL asn1_write_GeneralString(struct asn1_data *data, const char *s) { asn1_push_tag(data, ASN1_GENERAL_STRING); - asn1_write(data, s, strlen(s)); + asn1_write_LDAPString(data, s); asn1_pop_tag(data); return !data->has_error; } @@ -477,11 +484,10 @@ BOOL asn1_check_OID(struct asn1_data *data, const char *OID) return True; } -/* read a GeneralString from a ASN1 buffer */ -BOOL asn1_read_GeneralString(struct asn1_data *data, char **s) +/* read a LDAPString from a ASN1 buffer */ +BOOL asn1_read_LDAPString(struct asn1_data *data, char **s) { int len; - if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False; len = asn1_tag_remaining(data); if (len < 0) { data->has_error = True; @@ -494,10 +500,19 @@ BOOL asn1_read_GeneralString(struct asn1_data *data, char **s) } asn1_read(data, *s, len); (*s)[len] = 0; - asn1_end_tag(data); return !data->has_error; } + +/* read a GeneralString from a ASN1 buffer */ +BOOL asn1_read_GeneralString(struct asn1_data *data, char **s) +{ + if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False; + if (!asn1_read_LDAPString(data, s)) return False; + return asn1_end_tag(data); +} + + /* read a octet string blob */ BOOL asn1_read_OctetString(struct asn1_data *data, DATA_BLOB *blob) { -- cgit From bab977dad76e9204278c7afe0bb905cda064f488 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 05:39:40 +0000 Subject: r7626: a new ldap client library. Main features are: - hooked into events system, so requests can be truly async and won't interfere with other processing happening at the same time - uses NTSTATUS codes for errors (previously errors were mostly ignored). In a similar fashion to the DOS error handling, I have reserved a range of the NTSTATUS code 32 bit space for LDAP error codes, so a function can return a LDAP error code in a NTSTATUS - much cleaner packet handling (This used to be commit 2e3c660b2fc20e046d82bf1cc296422b6e7dfad0) --- source4/libcli/util/nterr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index d727cfe2a9..eca47572e3 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -648,7 +648,7 @@ static const nt_err_code_struct nt_err_desc[] = *****************************************************************************/ const char *nt_errstr(NTSTATUS nt_code) { - static pstring msg; + static fstring msg; int idx = 0; while (nt_errs[idx].nt_errstr != NULL) { @@ -659,7 +659,14 @@ const char *nt_errstr(NTSTATUS nt_code) idx++; } - slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code)); + if (NT_STATUS_IS_DOS(nt_code)) { + slprintf(msg, sizeof(msg), "DOS code %u:%u", + NT_STATUS_DOS_CLASS(nt_code), NT_STATUS_DOS_CODE(nt_code)); + } else if (NT_STATUS_IS_LDAP(nt_code)) { + slprintf(msg, sizeof(msg), "LDAP code %u", NT_STATUS_LDAP_CODE(nt_code)); + } else { + slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code)); + } return msg; } -- cgit From af237084ecd4f9928c6c282b9c5c73598d5c73d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 11:36:09 +0000 Subject: r7633: this patch started as an attempt to make the dcerpc code use a given event_context for the socket_connect() call, so that when things that use dcerpc are running alongside anything else it doesn't block the whole process during a connect. Then of course I needed to change any code that created a dcerpc connection (such as the auth code) to also take an event context, and anything that called that and so on .... thus the size of the patch. There were 3 places where I punted: - abartlet wanted me to add a gensec_set_event_context() call instead of adding it to the gensec init calls. Andrew, my apologies for not doing this. I didn't do it as adding a new parameter allowed me to catch all the callers with the compiler. Now that its done, we could go back and use gensec_set_event_context() - the ejs code calls auth initialisation, which means it should pass in the event context from the web server. I punted on that. Needs fixing. - I used a NULL event context in dcom_get_pipe(). This is equivalent to what we did already, but should be fixed to use a callers event context. Jelmer, can you think of a clean way to do that? I also cleaned up a couple of things: - libnet_context_destroy() makes no sense. I removed it. - removed some unused vars in various places (This used to be commit 3a3025485bdb8f600ab528c0b4b4eef0c65e3fc9) --- source4/libcli/util/clilsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 0c0c64c0b4..ad2006756b 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -76,7 +76,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) } lsa->ipc_tree->tid = tcon.tconx.out.tid; - lsa->pipe = dcerpc_pipe_init(lsa); + lsa->pipe = dcerpc_pipe_init(lsa, cli->transport->socket->event.ctx); if (lsa->pipe == NULL) { talloc_free(lsa); return NT_STATUS_NO_MEMORY; -- cgit From b4eee348c4d36e67ba83651c250366e84e7125dd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 18 Jun 2005 10:38:06 +0000 Subject: r7720: - simplify the asn1 decode of ldap_search() a lot, taking advantage of the fact that the ldap data structures now use ldb_message_element. - fixed null termination of elements in ildap (This used to be commit 09060994c1ed12073ae6e1131d7074db8fdc523c) --- source4/libcli/util/asn1.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 510ffa37cf..92f9a8c389 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -576,7 +576,6 @@ BOOL asn1_read_Integer(struct asn1_data *data, int *i) if (!asn1_start_tag(data, ASN1_INTEGER)) return False; if (!asn1_read_implicit_Integer(data, i)) return False; return asn1_end_tag(data); - } /* read an interger */ -- cgit From 68853a1c7be11ffaaef4ad2e3f78a97f0b401b68 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 19 Jun 2005 07:21:18 +0000 Subject: r7746: - added TLS support to our ldap server - this involved changing the buffer handling in the ldap server quite a lot, as it didn't handle partial packets at all - removed completely bogus asn1_object_length() function. You can't do that with BER/DER (This used to be commit fed6f4cc6ceaf83aacb581499aeaf6af4ee8ddd2) --- source4/libcli/util/asn1.c | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 92f9a8c389..10afd74273 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -387,26 +387,6 @@ BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag) } -/* Get the length to be expected in buf */ -BOOL asn1_object_length(uint8_t *buf, size_t buf_length, - uint8_t tag, size_t *result) -{ - struct asn1_data data; - - /* Fake the asn1_load to avoid the memdup, this is just to be able to - * re-use the length-reading in asn1_start_tag */ - ZERO_STRUCT(data); - data.data = buf; - data.length = buf_length; - if (!asn1_start_tag(&data, tag)) - return False; - *result = asn1_tag_remaining(&data)+data.ofs; - /* We can't use asn1_end_tag here, as we did not consume the complete - * tag, so asn1_end_tag would flag an error and not free nesting */ - talloc_free(data.nesting); - return True; -} - /* stop reading a tag */ BOOL asn1_end_tag(struct asn1_data *data) { -- cgit From 7267cb3312f148be8cd00eb76b8e137cd4b2a314 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 19 Jun 2005 10:37:45 +0000 Subject: r7749: some bug fixes from testing with socket:testnonblock - fixed some infinite loops in asn1.c - ensure asn1 callers know if an error is end of buffer or bad data - handle npending 0 in ldap server (This used to be commit f22c3b84c8912ccd36e676a782b58f1841be8875) --- source4/libcli/util/asn1.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 10afd74273..2a4c75d939 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -299,8 +299,12 @@ BOOL asn1_peek(struct asn1_data *data, void *p, int len) if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len) return False; - if (data->ofs + len > data->length) + if (data->ofs + len > data->length) { + /* we need to mark the buffer as consumed, so the caller knows + this was an out of data error, and not a decode error */ + data->ofs = data->length; return False; + } memcpy(p, data->data + data->ofs, len); return True; @@ -437,7 +441,7 @@ BOOL asn1_read_OID(struct asn1_data *data, const char **OID) do { asn1_read_uint8(data, &b); v = (v<<7) | (b&0x7f); - } while (!data->has_error && b & 0x80); + } while (!data->has_error && (b & 0x80)); tmp_oid = talloc_asprintf_append(tmp_oid, " %u", v); } @@ -540,7 +544,7 @@ BOOL asn1_read_implicit_Integer(struct asn1_data *data, int *i) uint8_t b; *i = 0; - while (asn1_tag_remaining(data)>0) { + while (!data->has_error && asn1_tag_remaining(data)>0) { if (!asn1_read_uint8(data, &b)) return False; *i = (*i << 8) + b; } @@ -564,7 +568,7 @@ BOOL asn1_read_enumerated(struct asn1_data *data, int *v) *v = 0; if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False; - while (asn1_tag_remaining(data)>0) { + while (!data->has_error && asn1_tag_remaining(data)>0) { uint8_t b; asn1_read_uint8(data, &b); *v = (*v << 8) + b; -- cgit From d6c1ad5c174f3b914927396cf3ec595543289109 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Jun 2005 07:02:39 +0000 Subject: r7941: fixed handling of ASN.1 objects bigger than 64k (This used to be commit f88a6018821163a52bdf384142c7d16f5011ab4e) --- source4/libcli/util/asn1.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 2a4c75d939..6ca2221b1a 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -87,7 +87,16 @@ BOOL asn1_pop_tag(struct asn1_data *data) /* yes, this is ugly. We don't know in advance how many bytes the length of a tag will take, so we assumed 1 byte. If we were wrong then we need to correct our mistake */ - if (len > 255) { + if (len > 0xFFFF) { + data->data[nesting->start] = 0x83; + if (!asn1_write_uint8(data, 0)) return False; + if (!asn1_write_uint8(data, 0)) return False; + if (!asn1_write_uint8(data, 0)) return False; + memmove(data->data+nesting->start+4, data->data+nesting->start+1, len); + data->data[nesting->start+1] = (len>>16) & 0xFF; + data->data[nesting->start+2] = (len>>8) & 0xFF; + data->data[nesting->start+3] = len&0xff; + } else if (len > 255) { data->data[nesting->start] = 0x82; if (!asn1_write_uint8(data, 0)) return False; if (!asn1_write_uint8(data, 0)) return False; -- cgit From e0d521ca79314b7c27512565262f614f67e20e64 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Jul 2005 01:23:38 +0000 Subject: r8104: - added support for our client library to not negotiate nt status codes, controlled with 'nt status support' option. - make nt_errstr() display nice strings for dos status codes encoded using NT_STATUS_DOS() - no longer map between dos and nt status codes in the client library, instead return using NT_STATUS_DOS() - fixed the RAW-CONTEXT test to look for NT_STATUS_DOS(ERRSRV, ERRbaduid) instead of NT_STATUS_INVALID_HANDLE (This used to be commit ff5549e87ffae9f062394f30d8fd1ae95b614735) --- source4/libcli/util/clierror.c | 33 ++------------------------------- source4/libcli/util/nterr.c | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 40 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clierror.c b/source4/libcli/util/clierror.c index 1c82958ce2..52607b1a47 100644 --- a/source4/libcli/util/clierror.c +++ b/source4/libcli/util/clierror.c @@ -29,11 +29,7 @@ const char *smbcli_errstr(struct smbcli_tree *tree) { switch (tree->session->transport->error.etype) { - case ETYPE_DOS: - return dos_errstr( - tree->session->transport->error.e.dos.eclass, - tree->session->transport->error.e.dos.ecode); - case ETYPE_NT: + case ETYPE_SMB: return nt_errstr(tree->session->transport->error.e.nt_status); case ETYPE_SOCKET: @@ -53,13 +49,9 @@ const char *smbcli_errstr(struct smbcli_tree *tree) NTSTATUS smbcli_nt_error(struct smbcli_tree *tree) { switch (tree->session->transport->error.etype) { - case ETYPE_NT: + case ETYPE_SMB: return tree->session->transport->error.e.nt_status; - case ETYPE_DOS: - return dos_to_ntstatus( - tree->session->transport->error.e.dos.eclass, - tree->session->transport->error.e.dos.ecode); case ETYPE_SOCKET: return NT_STATUS_UNSUCCESSFUL; @@ -74,29 +66,8 @@ NTSTATUS smbcli_nt_error(struct smbcli_tree *tree) } -/* Return the DOS error from the last packet - an error class and an error - code. */ -void smbcli_dos_error(struct smbcli_state *cli, uint8_t *eclass, uint32_t *ecode) -{ - if (cli->transport->error.etype == ETYPE_DOS) { - ntstatus_to_dos(cli->transport->error.e.nt_status, - eclass, ecode); - return; - } - - if (eclass) *eclass = cli->transport->error.e.dos.eclass; - if (ecode) *ecode = cli->transport->error.e.dos.ecode; -} - - /* Return true if the last packet was an error */ BOOL smbcli_is_error(struct smbcli_tree *tree) { return NT_STATUS_IS_ERR(smbcli_nt_error(tree)); } - -/* Return true if the last error was a DOS error */ -BOOL smbcli_is_dos_error(struct smbcli_tree *tree) -{ - return tree->session->transport->error.etype == ETYPE_DOS; -} diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index eca47572e3..a5ba1305e4 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -648,9 +648,17 @@ static const nt_err_code_struct nt_err_desc[] = *****************************************************************************/ const char *nt_errstr(NTSTATUS nt_code) { - static fstring msg; + static char msg[40]; int idx = 0; + if (NT_STATUS_IS_DOS(nt_code)) { + return dos_errstr(NT_STATUS_DOS_CLASS(nt_code), + NT_STATUS_DOS_CODE(nt_code)); + } else if (NT_STATUS_IS_LDAP(nt_code)) { + slprintf(msg, sizeof(msg), "LDAP code %u", NT_STATUS_LDAP_CODE(nt_code)); + return msg; + } + while (nt_errs[idx].nt_errstr != NULL) { if (NT_STATUS_V(nt_errs[idx].nt_errcode) == NT_STATUS_V(nt_code)) { @@ -659,14 +667,7 @@ const char *nt_errstr(NTSTATUS nt_code) idx++; } - if (NT_STATUS_IS_DOS(nt_code)) { - slprintf(msg, sizeof(msg), "DOS code %u:%u", - NT_STATUS_DOS_CLASS(nt_code), NT_STATUS_DOS_CODE(nt_code)); - } else if (NT_STATUS_IS_LDAP(nt_code)) { - slprintf(msg, sizeof(msg), "LDAP code %u", NT_STATUS_LDAP_CODE(nt_code)); - } else { - slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code)); - } + slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code)); return msg; } -- cgit From b3383236a27655227fd20b10252e156aac8e61c5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Jul 2005 01:45:52 +0000 Subject: r8106: the use of a static string for dos error codes was causing problems in the torture code. To fix this, get rid of dos_errstr() and instead move the strings into the nt_errstr() table, using cpp to generate the strings (This used to be commit 3136ad9634f0a5ab46e4f83e093df87fdd36484d) --- source4/libcli/util/nterr.c | 125 +++++++++++++++++++++++++++++- source4/libcli/util/smberr.c | 181 ------------------------------------------- 2 files changed, 121 insertions(+), 185 deletions(-) delete mode 100644 source4/libcli/util/smberr.c (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index a5ba1305e4..9bef2cf35c 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -29,6 +29,8 @@ typedef struct NTSTATUS nt_errcode; } nt_err_code_struct; +#define DOS_CODE(class, code) { #class ":" #code, NT_STATUS_DOS(class, code) } + static const nt_err_code_struct nt_errs[] = { { "NT_STATUS_OK", NT_STATUS_OK }, @@ -541,6 +543,124 @@ static const nt_err_code_struct nt_errs[] = { "NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX", NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX }, { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES }, { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED }, + + DOS_CODE(ERRDOS, ERRsuccess), + DOS_CODE(ERRDOS, ERRbadfunc), + DOS_CODE(ERRDOS, ERRbadfile), + DOS_CODE(ERRDOS, ERRbadpath), + DOS_CODE(ERRDOS, ERRnofids), + DOS_CODE(ERRDOS, ERRnoaccess), + DOS_CODE(ERRDOS, ERRbadfid), + DOS_CODE(ERRDOS, ERRbadmcb), + DOS_CODE(ERRDOS, ERRnomem), + DOS_CODE(ERRDOS, ERRbadmem), + DOS_CODE(ERRDOS, ERRbadenv), + DOS_CODE(ERRDOS, ERRbadaccess), + DOS_CODE(ERRDOS, ERRbaddata), + DOS_CODE(ERRDOS, ERRres), + DOS_CODE(ERRDOS, ERRbaddrive), + DOS_CODE(ERRDOS, ERRremcd), + DOS_CODE(ERRDOS, ERRdiffdevice), + DOS_CODE(ERRDOS, ERRnofiles), + DOS_CODE(ERRDOS, ERRgeneral), + DOS_CODE(ERRDOS, ERRbadshare), + DOS_CODE(ERRDOS, ERRlock), + DOS_CODE(ERRDOS, ERRunsup), + DOS_CODE(ERRDOS, ERRnetnamedel), + DOS_CODE(ERRDOS, ERRnosuchshare), + DOS_CODE(ERRDOS, ERRfilexists), + DOS_CODE(ERRDOS, ERRinvalidparam), + DOS_CODE(ERRDOS, ERRcannotopen), + DOS_CODE(ERRDOS, ERRinsufficientbuffer), + DOS_CODE(ERRDOS, ERRinvalidname), + DOS_CODE(ERRDOS, ERRunknownlevel), + DOS_CODE(ERRDOS, ERRnotlocked), + DOS_CODE(ERRDOS, ERRrename), + DOS_CODE(ERRDOS, ERRbadpipe), + DOS_CODE(ERRDOS, ERRpipebusy), + DOS_CODE(ERRDOS, ERRpipeclosing), + DOS_CODE(ERRDOS, ERRnotconnected), + DOS_CODE(ERRDOS, ERRmoredata), + DOS_CODE(ERRDOS, ERRnomoreitems), + DOS_CODE(ERRDOS, ERRbaddirectory), + DOS_CODE(ERRDOS, ERReasnotsupported), + DOS_CODE(ERRDOS, ERRlogonfailure), + DOS_CODE(ERRDOS, ERRbuftoosmall), + DOS_CODE(ERRDOS, ERRunknownipc), + DOS_CODE(ERRDOS, ERRnosuchprintjob), + DOS_CODE(ERRDOS, ERRinvgroup), + DOS_CODE(ERRDOS, ERRnoipc), + DOS_CODE(ERRDOS, ERRdriveralreadyinstalled), + DOS_CODE(ERRDOS, ERRunknownprinterport), + DOS_CODE(ERRDOS, ERRunknownprinterdriver), + DOS_CODE(ERRDOS, ERRunknownprintprocessor), + DOS_CODE(ERRDOS, ERRinvalidseparatorfile), + DOS_CODE(ERRDOS, ERRinvalidjobpriority), + DOS_CODE(ERRDOS, ERRinvalidprintername), + DOS_CODE(ERRDOS, ERRprinteralreadyexists), + DOS_CODE(ERRDOS, ERRinvalidprintercommand), + DOS_CODE(ERRDOS, ERRinvaliddatatype), + DOS_CODE(ERRDOS, ERRinvalidenvironment), + DOS_CODE(ERRDOS, ERRunknownprintmonitor), + DOS_CODE(ERRDOS, ERRprinterdriverinuse), + DOS_CODE(ERRDOS, ERRspoolfilenotfound), + DOS_CODE(ERRDOS, ERRnostartdoc), + DOS_CODE(ERRDOS, ERRnoaddjob), + DOS_CODE(ERRDOS, ERRprintprocessoralreadyinstalled), + DOS_CODE(ERRDOS, ERRprintmonitoralreadyinstalled), + DOS_CODE(ERRDOS, ERRinvalidprintmonitor), + DOS_CODE(ERRDOS, ERRprintmonitorinuse), + DOS_CODE(ERRDOS, ERRprinterhasjobsqueued), + + DOS_CODE(ERRSRV, ERRerror), + DOS_CODE(ERRSRV, ERRbadpw), + DOS_CODE(ERRSRV, ERRbadtype), + DOS_CODE(ERRSRV, ERRaccess), + DOS_CODE(ERRSRV, ERRinvnid), + DOS_CODE(ERRSRV, ERRinvnetname), + DOS_CODE(ERRSRV, ERRinvdevice), + DOS_CODE(ERRSRV, ERRqfull), + DOS_CODE(ERRSRV, ERRqtoobig), + DOS_CODE(ERRSRV, ERRinvpfid), + DOS_CODE(ERRSRV, ERRsmbcmd), + DOS_CODE(ERRSRV, ERRsrverror), + DOS_CODE(ERRSRV, ERRfilespecs), + DOS_CODE(ERRSRV, ERRbadlink), + DOS_CODE(ERRSRV, ERRbadpermits), + DOS_CODE(ERRSRV, ERRbadpid), + DOS_CODE(ERRSRV, ERRsetattrmode), + DOS_CODE(ERRSRV, ERRpaused), + DOS_CODE(ERRSRV, ERRmsgoff), + DOS_CODE(ERRSRV, ERRnoroom), + DOS_CODE(ERRSRV, ERRrmuns), + DOS_CODE(ERRSRV, ERRtimeout), + DOS_CODE(ERRSRV, ERRnoresource), + DOS_CODE(ERRSRV, ERRtoomanyuids), + DOS_CODE(ERRSRV, ERRbaduid), + DOS_CODE(ERRSRV, ERRuseMPX), + DOS_CODE(ERRSRV, ERRuseSTD), + DOS_CODE(ERRSRV, ERRcontMPX), + DOS_CODE(ERRSRV, ERRnosupport), + DOS_CODE(ERRSRV, ERRunknownsmb), + + DOS_CODE(ERRHRD, ERRnowrite), + DOS_CODE(ERRHRD, ERRbadunit), + DOS_CODE(ERRHRD, ERRnotready), + DOS_CODE(ERRHRD, ERRbadcmd), + DOS_CODE(ERRHRD, ERRdata), + DOS_CODE(ERRHRD, ERRbadreq), + DOS_CODE(ERRHRD, ERRseek), + DOS_CODE(ERRHRD, ERRbadmedia), + DOS_CODE(ERRHRD, ERRbadsector), + DOS_CODE(ERRHRD, ERRnopaper), + DOS_CODE(ERRHRD, ERRwrite), + DOS_CODE(ERRHRD, ERRread), + DOS_CODE(ERRHRD, ERRgeneral), + DOS_CODE(ERRHRD, ERRwrongdisk), + DOS_CODE(ERRHRD, ERRFCBunavail), + DOS_CODE(ERRHRD, ERRsharebufexc), + DOS_CODE(ERRHRD, ERRdiskfull), + { NULL, NT_STATUS(0) } }; @@ -651,10 +771,7 @@ const char *nt_errstr(NTSTATUS nt_code) static char msg[40]; int idx = 0; - if (NT_STATUS_IS_DOS(nt_code)) { - return dos_errstr(NT_STATUS_DOS_CLASS(nt_code), - NT_STATUS_DOS_CODE(nt_code)); - } else if (NT_STATUS_IS_LDAP(nt_code)) { + if (NT_STATUS_IS_LDAP(nt_code)) { slprintf(msg, sizeof(msg), "LDAP code %u", NT_STATUS_LDAP_CODE(nt_code)); return msg; } diff --git a/source4/libcli/util/smberr.c b/source4/libcli/util/smberr.c deleted file mode 100644 index 87cc601b8d..0000000000 --- a/source4/libcli/util/smberr.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Copyright (C) Andrew Tridgell 1998-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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" - -/* - error code stuff - put together by Merik Karman - merik@blackadder.dsh.oz.au -*/ - -struct err_code_struct { - const char *name; - int code; - const char *message; -}; - -/* Dos Error Messages */ -static const struct err_code_struct dos_msgs[] = { - {"ERRbadfunc",ERRbadfunc,"Invalid function."}, - {"ERRbadfile",ERRbadfile,"File not found."}, - {"ERRbadpath",ERRbadpath,"Directory invalid."}, - {"ERRnofids",ERRnofids,"No file descriptors available"}, - {"ERRnoaccess",ERRnoaccess,"Access denied."}, - {"ERRbadfid",ERRbadfid,"Invalid file handle."}, - {"ERRbadmcb",ERRbadmcb,"Memory control blocks destroyed."}, - {"ERRnomem",ERRnomem,"Insufficient server memory to perform the requested function."}, - {"ERRbadmem",ERRbadmem,"Invalid memory block address."}, - {"ERRbadenv",ERRbadenv,"Invalid environment."}, - {"ERRbadformat",11,"Invalid format."}, - {"ERRbadaccess",ERRbadaccess,"Invalid open mode."}, - {"ERRbaddata",ERRbaddata,"Invalid data."}, - {"ERRres",ERRres,"reserved."}, - {"ERRbaddrive",ERRbaddrive,"Invalid drive specified."}, - {"ERRremcd",ERRremcd,"A Delete Directory request attempted to remove the server's current directory."}, - {"ERRdiffdevice",ERRdiffdevice,"Not same device."}, - {"ERRnofiles",ERRnofiles,"A File Search command can find no more files matching the specified criteria."}, - {"ERRbadshare",ERRbadshare,"The sharing mode specified for an Open conflicts with existing FIDs on the file."}, - {"ERRlock",ERRlock,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."}, - {"ERRunsup", ERRunsup, "The operation is unsupported"}, - {"ERRnosuchshare", ERRnosuchshare, "You specified an invalid share name"}, - {"ERRfilexists",ERRfilexists,"The file named in a Create Directory, Make New File or Link request already exists."}, - {"ERRinvalidname",ERRinvalidname, "Invalid name"}, - {"ERRbadpipe",ERRbadpipe,"Pipe invalid."}, - {"ERRpipebusy",ERRpipebusy,"All instances of the requested pipe are busy."}, - {"ERRpipeclosing",ERRpipeclosing,"Pipe close in progress."}, - {"ERRnotconnected",ERRnotconnected,"No process on other end of pipe."}, - {"ERRmoredata",ERRmoredata,"There is more data to be returned."}, - {"ERRinvgroup",ERRinvgroup,"Invalid workgroup (try the -W option)"}, - {"ERRlogonfailure",ERRlogonfailure,"Logon failure"}, - {"ERRdiskfull",ERRdiskfull,"Disk full"}, - {"ERRgeneral",ERRgeneral, "General failure"}, - {"ERRunknownlevel",ERRunknownlevel, "Unknown info level"}, - {NULL,-1,NULL}}; - -/* Server Error Messages */ -static const struct err_code_struct server_msgs[] = { - {"ERRerror",1,"Non-specific error code."}, - {"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."}, - {"ERRbadtype",3,"reserved."}, - {"ERRaccess",4,"The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID."}, - {"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."}, - {"ERRinvnetname",6,"Invalid network name in tree connect."}, - {"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."}, - {"ERRqfull",49,"Print queue full (files) -- returned by open print file."}, - {"ERRqtoobig",50,"Print queue full -- no space."}, - {"ERRqeof",51,"EOF on print queue dump."}, - {"ERRinvpfid",52,"Invalid print file FID."}, - {"ERRsmbcmd",64,"The server did not recognize the command received."}, - {"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."}, - {"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."}, - {"ERRreserved",68,"reserved."}, - {"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."}, - {"ERRreserved",70,"reserved."}, - {"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."}, - {"ERRpaused",81,"Server is paused."}, - {"ERRmsgoff",82,"Not receiving messages."}, - {"ERRnoroom",83,"No room to buffer message."}, - {"ERRrmuns",87,"Too many remote user names."}, - {"ERRtimeout",88,"Operation timed out."}, - {"ERRnoresource",89,"No resources currently available for request."}, - {"ERRtoomanyuids",90,"Too many UIDs active on this session."}, - {"ERRbaduid",91,"The UID is not known as a valid ID on this session."}, - {"ERRusempx",250,"Temp unable to support Raw, use MPX mode."}, - {"ERRusestd",251,"Temp unable to support Raw, use standard read/write."}, - {"ERRcontmpx",252,"Continue in MPX mode."}, - {"ERRreserved",253,"reserved."}, - {"ERRreserved",254,"reserved."}, - {"ERRnosupport",0xFFFF,"Function not supported."}, - {NULL,-1,NULL}}; - -/* Hard Error Messages */ -static const struct err_code_struct hard_msgs[] = { - {"ERRnowrite",19,"Attempt to write on write-protected diskette."}, - {"ERRbadunit",20,"Unknown unit."}, - {"ERRnotready",21,"Drive not ready."}, - {"ERRbadcmd",22,"Unknown command."}, - {"ERRdata",23,"Data error (CRC)."}, - {"ERRbadreq",24,"Bad request structure length."}, - {"ERRseek",25 ,"Seek error."}, - {"ERRbadmedia",26,"Unknown media type."}, - {"ERRbadsector",27,"Sector not found."}, - {"ERRnopaper",28,"Printer out of paper."}, - {"ERRwrite",29,"Write fault."}, - {"ERRread",30,"Read fault."}, - {"ERRgeneral",31,"General failure."}, - {"ERRbadshare",32,"An open conflicts with an existing open."}, - {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."}, - {"ERRwrongdisk",34,"The wrong disk was found in a drive."}, - {"ERRFCBUnavail",35,"No FCBs are available to process request."}, - {"ERRsharebufexc",36,"A sharing buffer has been exceeded."}, - {NULL,-1,NULL}}; - - -static const struct { - uint8_t class; - const char *class_name; - const struct err_code_struct *err_msgs; -} err_classes[] = { - {0,"SUCCESS",NULL}, - {0x01,"ERRDOS",dos_msgs}, - {0x02,"ERRSRV",server_msgs}, - {0x03,"ERRHRD",hard_msgs}, - {0x04,"ERRXOS",NULL}, - {0xE1,"ERRRMX1",NULL}, - {0xE2,"ERRRMX2",NULL}, - {0xE3,"ERRRMX3",NULL}, - {0xFF,"ERRCMD",NULL}, - {-1,NULL,NULL}}; - - -/* return a dos error string given a error class and error code */ -const char *dos_errstr(uint8_t class, uint16_t code) -{ - static char *msg; - int i, j; - const struct err_code_struct *err_msgs; - - if (msg) { - free(msg); - msg = NULL; - } - - for (i=0;err_classes[i].class_name;i++) { - if (class == err_classes[i].class) break; - } - if (!err_classes[i].class_name) { - asprintf(&msg, "Unknown DOS error %d:%d\n", class, code); - return msg; - } - - err_msgs = err_classes[i].err_msgs; - - for (j=0;err_msgs && err_msgs[j].name;j++) { - if (err_msgs[j].code == code) { - asprintf(&msg, "%s:%s (%s)\n", - err_classes[i].class_name, - err_msgs[j].name, - err_msgs[j].message); - return msg; - } - } - - asprintf(&msg, "Unknown DOS error %s:%d\n", err_classes[i].class_name, code); - return msg; -} -- cgit From 950f6624842628b770bf58424f3b2ab9a7036263 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Jul 2005 02:54:32 +0000 Subject: r8111: fixed the client library to work against w2k3 with nt status codes disabled. The main change is to turn off spnego, which cannot work at all without nt status codes (w2k3 gives a ERRHRD:ERRgeneral error when you try) I also modified NT_STATUS_EQUAL() to allow for nt->dos code equality, but only when nt status codes are disabled in smb.conf. That keeps all the existing torture code working, while still allowing us to correctly catch the cases where forced dos error codes are needed The dos->ntstatus mapping table has been removed completely, as it doesn't really make sense, is impossible to get right, and with the new dos status handling isn't needed. When matching a nt status code to a dos status code it makes far more sense to map from the nt code to the dos code and compare, rather than the reverse, as the nt->dos mapping is what windows has to do internally, so there really is a valid mapping table. (This used to be commit f21274e07b361ef40fdc0fe23e96f1c9c63a091c) --- source4/libcli/util/errormap.c | 300 +++++------------------------------------ 1 file changed, 30 insertions(+), 270 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index b99ab3d2fe..76400c98a3 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -117,7 +117,7 @@ static const struct { {ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, {ERRDOS, ERRinvalidname, NT_STATUS_OBJECT_NAME_INVALID}, {ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, - {ERRDOS, 183, NT_STATUS_OBJECT_NAME_COLLISION}, + {ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION}, {ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, {ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED}, {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED}, @@ -612,262 +612,6 @@ static const struct { }; -/* dos -> nt status error map */ -static const struct { - uint8_t dos_class; - uint32_t dos_code; - NTSTATUS ntstatus; -} dos_to_ntstatus_map[] = { - {ERRDOS, ERRnofiles, STATUS_NO_MORE_FILES}, - {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, - {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, - {ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, - {ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES}, - {ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED}, - {ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, - {ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES}, - {ERRDOS, ERRbadaccess, NT_STATUS_INVALID_LOCK_SEQUENCE}, - {ERRDOS, ERRbaddata, NT_STATUS_DATA_ERROR}, - {ERRDOS, 14, NT_STATUS_SECTION_NOT_EXTENDED}, - {ERRDOS, ERRremcd, NT_STATUS_DIRECTORY_NOT_EMPTY}, - {ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE}, - {ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED}, - {ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE}, - {ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE}, - {ERRDOS, 23, NT_STATUS_DATA_ERROR}, - {ERRDOS, 24, NT_STATUS_DATA_ERROR}, - {ERRDOS, 26, NT_STATUS_DISK_CORRUPT_ERROR}, - {ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR}, - {ERRDOS, 28, NT_STATUS(0x8000000e)}, - {ERRDOS, 31, NT_STATUS_UNSUCCESSFUL}, - {ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, - {ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, - {ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, - {ERRDOS, 38, NT_STATUS_END_OF_FILE}, - {ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, - {ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING}, - {ERRDOS, 52, NT_STATUS_DUPLICATE_NAME}, - {ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH}, - {ERRDOS, 54, NT_STATUS_NETWORK_BUSY}, - {ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, - {ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS}, - {ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, - {ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, - {ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, - {ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, - {ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL}, - {ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE}, - {ERRDOS, 63, NT_STATUS_PRINT_CANCELLED}, - {ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED}, - {ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, - {ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE}, - {ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME}, - {ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, - {ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS}, - {ERRDOS, 70, NT_STATUS_SHARING_PAUSED}, - {ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, - {ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED}, - {ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION}, - {ERRDOS, 86, NT_STATUS_WRONG_PASSWORD}, - {ERRDOS, 87, NT_STATUS_INVALID_INFO_CLASS}, - {ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT}, - {ERRDOS, 109, NT_STATUS_PIPE_BROKEN}, - {ERRDOS, 111, STATUS_MORE_ENTRIES}, - {ERRDOS, 112, NT_STATUS_DISK_FULL}, - {ERRDOS, 121, NT_STATUS_IO_TIMEOUT}, - {ERRDOS, 122, NT_STATUS_BUFFER_TOO_SMALL}, - {ERRDOS, ERRinvalidname, NT_STATUS_OBJECT_NAME_INVALID}, - {ERRDOS, 124, NT_STATUS_INVALID_LEVEL}, - {ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND}, - {ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, - {ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, - {ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL}, - {ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, - {ERRDOS, 158, NT_STATUS_NOT_LOCKED}, - {ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID}, - {ERRDOS, 170, NT_STATUS(0x80000011)}, - {ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND}, - {ERRDOS, 183, NT_STATUS_OBJECT_NAME_COLLISION}, - {ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC}, - {ERRDOS, 203, NT_STATUS(0xc0000100)}, - {ERRDOS, 206, NT_STATUS_NAME_TOO_LONG}, - {ERRDOS, ERRbadpipe, NT_STATUS_INVALID_INFO_CLASS}, - {ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE}, - {ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING}, - {ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED}, - {ERRDOS, ERRmoredata, NT_STATUS_MORE_PROCESSING_REQUIRED}, - {ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, - {ERRDOS, 254, NT_STATUS(0x80000013)}, - {ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, - {ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED}, - {ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY}, - {ERRDOS, 275, NT_STATUS_EA_TOO_LARGE}, - {ERRDOS, 276, NT_STATUS_NONEXISTENT_EA_ENTRY}, - {ERRDOS, 277, NT_STATUS_NONEXISTENT_EA_ENTRY}, - {ERRDOS, 278, NT_STATUS_NONEXISTENT_EA_ENTRY}, - {ERRDOS, 282, NT_STATUS_EAS_NOT_SUPPORTED}, - {ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED}, - {ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, - {ERRDOS, 299, NT_STATUS(0x8000000d)}, - {ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, - {ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, - {ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES}, - {ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW}, - {ERRDOS, 535, NT_STATUS_PIPE_CONNECTED}, - {ERRDOS, 536, NT_STATUS_PIPE_LISTENING}, - {ERRDOS, 995, NT_STATUS_CANCELLED}, - {ERRDOS, 997, NT_STATUS(0x00000103)}, - {ERRDOS, 998, NT_STATUS_ACCESS_VIOLATION}, - {ERRDOS, 999, NT_STATUS_IN_PAGE_ERROR}, - {ERRDOS, 1001, NT_STATUS_BAD_INITIAL_STACK}, - {ERRDOS, 1005, NT_STATUS_UNRECOGNIZED_VOLUME}, - {ERRDOS, 1006, NT_STATUS_FILE_INVALID}, - {ERRDOS, 1007, NT_STATUS_FULLSCREEN_MODE}, - {ERRDOS, 1008, NT_STATUS_NO_TOKEN}, - {ERRDOS, 1009, NT_STATUS_REGISTRY_CORRUPT}, - {ERRDOS, 1016, NT_STATUS_REGISTRY_IO_FAILED}, - {ERRDOS, 1017, NT_STATUS_NOT_REGISTRY_FILE}, - {ERRDOS, 1018, NT_STATUS_KEY_DELETED}, - {ERRDOS, 1019, NT_STATUS_NO_LOG_SPACE}, - {ERRDOS, 1020, NT_STATUS_KEY_HAS_CHILDREN}, - {ERRDOS, 1021, NT_STATUS_CHILD_MUST_BE_VOLATILE}, - {ERRDOS, 1022, NT_STATUS(0x0000010c)}, - {ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD}, - {ERRSRV, ERRbadtype, NT_STATUS_BAD_DEVICE_TYPE}, - {ERRSRV, ERRaccess, NT_STATUS_NETWORK_ACCESS_DENIED}, - {ERRSRV, ERRinvnid, NT_STATUS_NETWORK_NAME_DELETED}, - {ERRSRV, ERRinvnetname, NT_STATUS_BAD_NETWORK_NAME}, - {ERRSRV, ERRinvdevice, NT_STATUS_BAD_DEVICE_TYPE}, - {ERRSRV, ERRqfull, NT_STATUS_PRINT_QUEUE_FULL}, - {ERRSRV, ERRqtoobig, NT_STATUS_NO_SPOOL_SPACE}, - {ERRSRV, ERRinvpfid, NT_STATUS_PRINT_CANCELLED}, - {ERRSRV, ERRsmbcmd, NT_STATUS_NOT_IMPLEMENTED}, - {ERRSRV, ERRbadpermits, NT_STATUS_NETWORK_ACCESS_DENIED}, - {ERRSRV, ERRpaused, NT_STATUS_SHARING_PAUSED}, - {ERRSRV, ERRmsgoff, NT_STATUS_REQUEST_NOT_ACCEPTED}, - {ERRSRV, ERRnoroom, NT_STATUS_DISK_FULL}, - {ERRSRV, ERRnoresource, NT_STATUS_REQUEST_NOT_ACCEPTED}, - {ERRSRV, ERRtoomanyuids, NT_STATUS_TOO_MANY_SESSIONS}, - {ERRSRV, ERRbaduid, NT_STATUS_INVALID_HANDLE}, - {ERRSRV, 123, NT_STATUS_OBJECT_NAME_INVALID}, - {ERRSRV, 206, NT_STATUS_OBJECT_NAME_INVALID}, - {ERRHRD, 1, NT_STATUS_NOT_IMPLEMENTED}, - {ERRHRD, 2, NT_STATUS_NO_SUCH_DEVICE}, - {ERRHRD, 3, NT_STATUS_OBJECT_PATH_NOT_FOUND}, - {ERRHRD, 4, NT_STATUS_TOO_MANY_OPENED_FILES}, - {ERRHRD, 5, NT_STATUS_INVALID_LOCK_SEQUENCE}, - {ERRHRD, 6, NT_STATUS_INVALID_HANDLE}, - {ERRHRD, 8, NT_STATUS_INSUFFICIENT_RESOURCES}, - {ERRHRD, 12, NT_STATUS_INVALID_LOCK_SEQUENCE}, - {ERRHRD, 13, NT_STATUS_DATA_ERROR}, - {ERRHRD, 14, NT_STATUS_SECTION_NOT_EXTENDED}, - {ERRHRD, 16, NT_STATUS_DIRECTORY_NOT_EMPTY}, - {ERRHRD, 17, NT_STATUS_NOT_SAME_DEVICE}, - {ERRHRD, 18, NT_STATUS(0x80000006)}, - {ERRHRD, ERRnowrite, NT_STATUS_MEDIA_WRITE_PROTECTED}, - {ERRHRD, ERRnotready, NT_STATUS_NO_MEDIA_IN_DEVICE}, - {ERRHRD, ERRbadcmd, NT_STATUS_INVALID_DEVICE_STATE}, - {ERRHRD, ERRdata, NT_STATUS_DATA_ERROR}, - {ERRHRD, ERRbadreq, NT_STATUS_DATA_ERROR}, - {ERRHRD, ERRbadmedia, NT_STATUS_DISK_CORRUPT_ERROR}, - {ERRHRD, ERRbadsector, NT_STATUS_NONEXISTENT_SECTOR}, - {ERRHRD, ERRnopaper, NT_STATUS(0x8000000e)}, - {ERRHRD, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, - {ERRHRD, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, - {ERRHRD, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, - {ERRHRD, ERRwrongdisk, NT_STATUS_WRONG_VOLUME}, - {ERRHRD, 38, NT_STATUS_END_OF_FILE}, - {ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL}, - {ERRHRD, 50, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, - {ERRHRD, 51, NT_STATUS_REMOTE_NOT_LISTENING}, - {ERRHRD, 52, NT_STATUS_DUPLICATE_NAME}, - {ERRHRD, 53, NT_STATUS_BAD_NETWORK_PATH}, - {ERRHRD, 54, NT_STATUS_NETWORK_BUSY}, - {ERRHRD, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, - {ERRHRD, 56, NT_STATUS_TOO_MANY_COMMANDS}, - {ERRHRD, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, - {ERRHRD, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, - {ERRHRD, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, - {ERRHRD, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, - {ERRHRD, 61, NT_STATUS_PRINT_QUEUE_FULL}, - {ERRHRD, 62, NT_STATUS_NO_SPOOL_SPACE}, - {ERRHRD, 63, NT_STATUS_PRINT_CANCELLED}, - {ERRHRD, 64, NT_STATUS_NETWORK_NAME_DELETED}, - {ERRHRD, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, - {ERRHRD, 66, NT_STATUS_BAD_DEVICE_TYPE}, - {ERRHRD, 67, NT_STATUS_BAD_NETWORK_NAME}, - {ERRHRD, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, - {ERRHRD, 69, NT_STATUS_TOO_MANY_SESSIONS}, - {ERRHRD, 70, NT_STATUS_SHARING_PAUSED}, - {ERRHRD, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, - {ERRHRD, 72, NT_STATUS_REDIRECTOR_PAUSED}, - {ERRHRD, 80, NT_STATUS_OBJECT_NAME_COLLISION}, - {ERRHRD, 86, NT_STATUS_WRONG_PASSWORD}, - {ERRHRD, 87, NT_STATUS_INVALID_INFO_CLASS}, - {ERRHRD, 88, NT_STATUS_NET_WRITE_FAULT}, - {ERRHRD, 109, NT_STATUS_PIPE_BROKEN}, - {ERRHRD, 111, STATUS_MORE_ENTRIES}, - {ERRHRD, 112, NT_STATUS_DISK_FULL}, - {ERRHRD, 121, NT_STATUS_IO_TIMEOUT}, - {ERRHRD, 122, NT_STATUS_BUFFER_TOO_SMALL}, - {ERRHRD, 123, NT_STATUS_OBJECT_NAME_INVALID}, - {ERRHRD, 124, NT_STATUS_INVALID_LEVEL}, - {ERRHRD, 126, NT_STATUS_DLL_NOT_FOUND}, - {ERRHRD, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, - {ERRHRD, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, - {ERRHRD, 154, NT_STATUS_INVALID_VOLUME_LABEL}, - {ERRHRD, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, - {ERRHRD, 158, NT_STATUS_NOT_LOCKED}, - {ERRHRD, 161, NT_STATUS_OBJECT_PATH_INVALID}, - {ERRHRD, 170, NT_STATUS(0x80000011)}, - {ERRHRD, 182, NT_STATUS_ORDINAL_NOT_FOUND}, - {ERRHRD, 183, NT_STATUS_OBJECT_NAME_COLLISION}, - {ERRHRD, 193, NT_STATUS_BAD_INITIAL_PC}, - {ERRHRD, 203, NT_STATUS(0xc0000100)}, - {ERRHRD, 206, NT_STATUS_NAME_TOO_LONG}, - {ERRHRD, 230, NT_STATUS_INVALID_INFO_CLASS}, - {ERRHRD, 231, NT_STATUS_INSTANCE_NOT_AVAILABLE}, - {ERRHRD, 232, NT_STATUS_PIPE_CLOSING}, - {ERRHRD, 233, NT_STATUS_PIPE_DISCONNECTED}, - {ERRHRD, 234, STATUS_MORE_ENTRIES}, - {ERRHRD, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, - {ERRHRD, 254, NT_STATUS(0x80000013)}, - {ERRHRD, 255, NT_STATUS_EA_TOO_LARGE}, - {ERRHRD, 259, NT_STATUS_GUIDS_EXHAUSTED}, - {ERRHRD, 267, NT_STATUS_NOT_A_DIRECTORY}, - {ERRHRD, 275, NT_STATUS_EA_TOO_LARGE}, - {ERRHRD, 276, NT_STATUS_NONEXISTENT_EA_ENTRY}, - {ERRHRD, 277, NT_STATUS_NONEXISTENT_EA_ENTRY}, - {ERRHRD, 278, NT_STATUS_NONEXISTENT_EA_ENTRY}, - {ERRHRD, 282, NT_STATUS_EAS_NOT_SUPPORTED}, - {ERRHRD, 288, NT_STATUS_MUTANT_NOT_OWNED}, - {ERRHRD, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, - {ERRHRD, 299, NT_STATUS(0x8000000d)}, - {ERRHRD, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, - {ERRHRD, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, - {ERRHRD, 487, NT_STATUS_CONFLICTING_ADDRESSES}, - {ERRHRD, 534, NT_STATUS_INTEGER_OVERFLOW}, - {ERRHRD, 535, NT_STATUS_PIPE_CONNECTED}, - {ERRHRD, 536, NT_STATUS_PIPE_LISTENING}, - {ERRHRD, 995, NT_STATUS_CANCELLED}, - {ERRHRD, 997, NT_STATUS(0x00000103)}, - {ERRHRD, 998, NT_STATUS_ACCESS_VIOLATION}, - {ERRHRD, 999, NT_STATUS_IN_PAGE_ERROR}, - {ERRHRD, 1001, NT_STATUS_BAD_INITIAL_STACK}, - {ERRHRD, 1005, NT_STATUS_UNRECOGNIZED_VOLUME}, - {ERRHRD, 1006, NT_STATUS_FILE_INVALID}, - {ERRHRD, 1007, NT_STATUS_FULLSCREEN_MODE}, - {ERRHRD, 1008, NT_STATUS_NO_TOKEN}, - {ERRHRD, 1009, NT_STATUS_REGISTRY_CORRUPT}, - {ERRHRD, 1016, NT_STATUS_REGISTRY_IO_FAILED}, - {ERRHRD, 1017, NT_STATUS_NOT_REGISTRY_FILE}, - {ERRHRD, 1018, NT_STATUS_KEY_DELETED}, - {ERRHRD, 1019, NT_STATUS_NO_LOG_SPACE}, - {ERRHRD, 1020, NT_STATUS_KEY_HAS_CHILDREN}, - {ERRHRD, 1021, NT_STATUS_CHILD_MUST_BE_VOLATILE}, - {ERRHRD, 1022, NT_STATUS(0x0000010c)}, -}; - /* errmap NTSTATUS->Win32 */ static const struct { NTSTATUS ntstatus; @@ -1410,22 +1154,38 @@ static const struct { {NT_STATUS_OK, WERR_OK}}; -/***************************************************************************** -convert a dos eclas/ecode to a NT status32 code - *****************************************************************************/ -NTSTATUS dos_to_ntstatus(uint8_t eclass, uint32_t ecode) +/* + check if a DOS encoded NTSTATUS code maps to the given NTSTATUS code +*/ +BOOL ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2) { - int i; - if (eclass == 0 && ecode == 0) return NT_STATUS_OK; - for (i=0; NT_STATUS_V(dos_to_ntstatus_map[i].ntstatus); i++) { - if (eclass == dos_to_ntstatus_map[i].dos_class && - ecode == dos_to_ntstatus_map[i].dos_code) { - return dos_to_ntstatus_map[i].ntstatus; - } + /* when we negotiate nt status support, we don't want to consider + the mapping of dos codes, as we want to catch the cases where + a forced dos code is needed + */ + if (lp_nt_status_support()) { + return NT_STATUS_V(status1) == NT_STATUS_V(status2); } - return NT_STATUS_UNSUCCESSFUL; -} + /* otherwise check if the mapping comes out right. Note that it is important + that we do the mapping only from ntstatus -> dos and not from dos -> ntstatus, + as that is the mapping that servers must do */ + if (!NT_STATUS_IS_DOS(status1) && NT_STATUS_IS_DOS(status2)) { + uint8_t eclass; + uint32_t ecode; + ntstatus_to_dos(status1, &eclass, &ecode); + return eclass == NT_STATUS_DOS_CLASS(status2) && + ecode == NT_STATUS_DOS_CODE(status2); + } + if (NT_STATUS_IS_DOS(status1) && !NT_STATUS_IS_DOS(status2)) { + uint8_t eclass; + uint32_t ecode; + ntstatus_to_dos(status2, &eclass, &ecode); + return eclass == NT_STATUS_DOS_CLASS(status1) && + ecode == NT_STATUS_DOS_CODE(status1); + } + return NT_STATUS_V(status1) == NT_STATUS_V(status2); +} /***************************************************************************** convert a NT status code to a dos class/code -- cgit From 934831686c2bde9bdd9fbb050ac10341b32c83fa Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Jul 2005 05:01:22 +0000 Subject: r8115: added support for 2 more dos error codes found during testing (This used to be commit 97cb70571377e3b4e5eb0b7ca516e4af349fdfea) --- source4/libcli/util/nterr.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 9bef2cf35c..65de6a72b4 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -575,6 +575,8 @@ static const nt_err_code_struct nt_errs[] = DOS_CODE(ERRDOS, ERRinvalidname), DOS_CODE(ERRDOS, ERRunknownlevel), DOS_CODE(ERRDOS, ERRnotlocked), + DOS_CODE(ERRDOS, ERRcancelviolation), + DOS_CODE(ERRDOS, ERRnoatomiclocks), DOS_CODE(ERRDOS, ERRrename), DOS_CODE(ERRDOS, ERRbadpipe), DOS_CODE(ERRDOS, ERRpipebusy), -- cgit From 65ae28dfa714d1f4b1006093f65ec3f9d904ebb9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Jul 2005 05:55:32 +0000 Subject: r8125: fixed an error code mapping based on the updated torture tests (This used to be commit a3b8a00d7f67da5bc1187ce271a8df1601411dbc) --- source4/libcli/util/errormap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 76400c98a3..808f5427c6 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -66,7 +66,7 @@ static const struct { {ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED}, {ERRDOS, 87, NT_STATUS_INVALID_PARAMETER}, {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE}, - {ERRDOS, ERRnofiles, NT_STATUS_NO_SUCH_FILE}, + {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, {ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST}, {ERRDOS, 38, NT_STATUS_END_OF_FILE}, {ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, -- cgit From 3de3d6a02dfb790af21f6c848a202064922ea780 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 6 Jul 2005 03:13:17 +0000 Subject: r8174: Check DOS error codes in torture chkpath test. Jeremy. (This used to be commit ff58ecad044dc7a3cdb4c010ea5cc1ea5e2e4b3b) --- source4/libcli/util/nterr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 65de6a72b4..b7e3bcabde 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -575,6 +575,7 @@ static const nt_err_code_struct nt_errs[] = DOS_CODE(ERRDOS, ERRinvalidname), DOS_CODE(ERRDOS, ERRunknownlevel), DOS_CODE(ERRDOS, ERRnotlocked), + DOS_CODE(ERRDOS, ERRinvalidpath), DOS_CODE(ERRDOS, ERRcancelviolation), DOS_CODE(ERRDOS, ERRnoatomiclocks), DOS_CODE(ERRDOS, ERRrename), -- cgit From 223262c11e94c1e67b8cdec1a264d7f93a9afdc4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Aug 2005 04:24:37 +0000 Subject: r9048: added a new DOS error code (thanks to EMC) (This used to be commit 1936c20939a6e1311665b44a71a31ab231ba7b28) --- source4/libcli/util/nterr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index b7e3bcabde..08cd844b3a 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -614,6 +614,7 @@ static const nt_err_code_struct nt_errs[] = DOS_CODE(ERRDOS, ERRinvalidprintmonitor), DOS_CODE(ERRDOS, ERRprintmonitorinuse), DOS_CODE(ERRDOS, ERRprinterhasjobsqueued), + DOS_CODE(ERRDOS, ERReainconsistent), DOS_CODE(ERRSRV, ERRerror), DOS_CODE(ERRSRV, ERRbadpw), -- cgit From 2fa50ab671ba4a7e552e001f0dfde3a7cc330f8e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 9 Aug 2005 03:09:47 +0000 Subject: r9222: Rename smb_tree_connect() to smb_raw_tcon() to match other raw function names. (This used to be commit 26b191b3c9529b2dae5d004819dab46657064408) --- source4/libcli/util/clilsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index ad2006756b..f5de5014e3 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -69,7 +69,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) tcon.tconx.in.password = data_blob(NULL, 0); tcon.tconx.in.path = "ipc$"; tcon.tconx.in.device = "IPC"; - status = smb_tree_connect(lsa->ipc_tree, lsa, &tcon); + status = smb_raw_tcon(lsa->ipc_tree, lsa, &tcon); if (!NT_STATUS_IS_OK(status)) { talloc_free(lsa); return status; -- cgit From 684c824e9ac51ee2d6b748973757697a8ead2634 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 20 Aug 2005 07:59:00 +0000 Subject: r9421: Move arcfour code into it's own file, in lib/crypto. Andrew Bartlett (This used to be commit ca6cf462708810637544d4b4bef0f404fb89a002) --- source4/libcli/util/smbdes.c | 67 -------------------------------------------- 1 file changed, 67 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index d214d4cfe4..d02cae602f 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -365,73 +365,6 @@ void des_crypt112_16(uint8_t out[16], uint8_t in[16], const uint8_t key[14], int des_crypt56(out + 8, in + 8, key+7, forw); } -/* initialise the arcfour sbox with key */ -void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key) -{ - int ind; - uint8_t j = 0; - for (ind = 0; ind < sizeof(state->sbox); ind++) { - state->sbox[ind] = (uint8_t)ind; - } - - for (ind = 0; ind < sizeof(state->sbox); ind++) { - uint8_t tc; - - j += (state->sbox[ind] + key->data[ind%key->length]); - - tc = state->sbox[ind]; - state->sbox[ind] = state->sbox[j]; - state->sbox[j] = tc; - } - state->index_i = 0; - state->index_j = 0; -} - -/* crypt the data with arcfour */ -void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data, int len) -{ - int ind; - - for (ind = 0; ind < len; ind++) { - uint8_t tc; - uint8_t t; - - state->index_i++; - state->index_j += state->sbox[state->index_i]; - - tc = state->sbox[state->index_i]; - state->sbox[state->index_i] = state->sbox[state->index_j]; - state->sbox[state->index_j] = tc; - - t = state->sbox[state->index_i] + state->sbox[state->index_j]; - data[ind] = data[ind] ^ state->sbox[t]; - } -} - -/* - arcfour encryption with a blob key -*/ -void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key) -{ - struct arcfour_state state; - arcfour_init(&state, key); - arcfour_crypt_sbox(&state, data, len); -} - -/* - a variant that assumes a 16 byte key. This should be removed - when the last user is gone -*/ -void arcfour_crypt(uint8_t *data, const uint8_t keystr[16], int len) -{ - DATA_BLOB key = data_blob(keystr, 16); - - arcfour_crypt_blob(data, len, &key); - - data_blob_free(&key); -} - - /* Decode a sam password hash into a password. The password hash is the same method used to store passwords in the NT registry. The DES key used is based on the RID of the user. */ -- cgit From 36dcb8425dfe861f74994d13a3b46ade323868d0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 23 Aug 2005 11:40:26 +0000 Subject: r9514: add some new error codes I was getting with DsGetNCChanges() and DsAddEntry() metze (This used to be commit 2cbbb8ace215f56e4e9affd54027bbd74309ae3a) --- source4/libcli/util/doserr.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 577c004422..4f977b7e75 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -69,6 +69,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DFS_INTERNAL_ERROR", WERR_DFS_INTERNAL_ERROR }, { "WERR_DFS_CANT_CREATE_JUNCT", WERR_DFS_CANT_CREATE_JUNCT }, { "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR }, + { "WERR_REVISION_MISMATCH", WERR_REVISION_MISMATCH }, { "WERR_INVALID_OWNER", WERR_INVALID_OWNER }, { "WERR_INVALID_DOMAINNAME", WERR_INVALID_DOMAINNAME }, { "WERR_NO_SUCH_USER", WERR_NO_SUCH_USER }, @@ -80,6 +81,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DS_DRA_INVALID_PARAMETER", WERR_DS_DRA_INVALID_PARAMETER }, { "WERR_DS_DRA_BAD_DN", WERR_DS_DRA_BAD_DN }, { "WERR_DS_DRA_BAD_NC", WERR_DS_DRA_BAD_NC }, + { "WERR_DS_SINGLE_VALUE_CONSTRAINT", WERR_DS_SINGLE_VALUE_CONSTRAINT }, { "WERR_DS_DRA_DB_ERROR", WERR_DS_DRA_DB_ERROR }, { "WERR_DS_DRA_NO_REPLICA", WERR_DS_DRA_NO_REPLICA }, { "WERR_DS_DNS_LOOKUP_FAILURE", WERR_DS_DNS_LOOKUP_FAILURE }, -- cgit From 81021aaa953661e711ba0030ab2644664587ad5b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 26 Aug 2005 08:42:29 +0000 Subject: r9638: add error code that you get when you call DsGetNCChanges() with a tmp_highest_usn which is higher than the real highest of the source dsa metze (This used to be commit e4424d2a6dc7a783e8b3af4a164f8dc801130e44) --- source4/libcli/util/doserr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 4f977b7e75..eecf923bac 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -81,6 +81,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DS_DRA_INVALID_PARAMETER", WERR_DS_DRA_INVALID_PARAMETER }, { "WERR_DS_DRA_BAD_DN", WERR_DS_DRA_BAD_DN }, { "WERR_DS_DRA_BAD_NC", WERR_DS_DRA_BAD_NC }, + { "WERR_DS_DRA_INTERNAL_ERROR", WERR_DS_DRA_INTERNAL_ERROR }, { "WERR_DS_SINGLE_VALUE_CONSTRAINT", WERR_DS_SINGLE_VALUE_CONSTRAINT }, { "WERR_DS_DRA_DB_ERROR", WERR_DS_DRA_DB_ERROR }, { "WERR_DS_DRA_NO_REPLICA", WERR_DS_DRA_NO_REPLICA }, -- cgit From 561a02d646b3a43014db7814f3af91d1f67110b2 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 9 Sep 2005 04:21:19 +0000 Subject: r10103: Put an #ifdef guard around ENOTSUP to fix systems that don't have it (OpenBSD 3.7). (This used to be commit cc24af6545b19ad7710c43399c396e1807f80eeb) --- source4/libcli/util/errormap.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 808f5427c6..95fac97428 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1278,7 +1278,9 @@ const struct unix_error_map unix_nt_errmap[] = { { EPIPE, NT_STATUS_CONNECTION_DISCONNECTED }, { ECONNREFUSED, NT_STATUS_CONNECTION_REFUSED }, { EBUSY, NT_STATUS_SHARING_VIOLATION }, +#ifdef ENOTSUP { ENOTSUP, NT_STATUS_NOT_SUPPORTED}, +#endif #ifdef EHOSTUNREACH { EHOSTUNREACH, NT_STATUS_HOST_UNREACHABLE }, #endif -- cgit From 49839f356f493d0de1b719c8c3bfdee4713c0728 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Sep 2005 16:57:08 +0000 Subject: r10513: Reduce some use of pstring. The main reason some parts of the code still use pstring is next_token() now. (This used to be commit a5b88bcd420eb7ae42283293541519e142be36e3) --- source4/libcli/util/nterr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 08cd844b3a..ca8605faea 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -835,7 +835,7 @@ const char *get_nt_error_c_code(NTSTATUS nt_code) /***************************************************************************** returns the NT_STATUS constant matching the string supplied (as an NTSTATUS) *****************************************************************************/ -NTSTATUS nt_status_string_to_code(char *nt_status_str) +NTSTATUS nt_status_string_to_code(const char *nt_status_str) { int idx = 0; -- cgit From 5880f79f4f314b875d8cb2b72562f6cdf716ba67 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 27 Sep 2005 16:20:17 +0000 Subject: r10545: map ECONNRESET to NT_STATUS_CONNECTION_RESET metze (This used to be commit e753114e863ff0ea32b35ef30a6f0056cfa7c902) --- source4/libcli/util/errormap.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 95fac97428..99154d2cb0 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1277,6 +1277,9 @@ const struct unix_error_map unix_nt_errmap[] = { { ENOMEM, NT_STATUS_NO_MEMORY }, { EPIPE, NT_STATUS_CONNECTION_DISCONNECTED }, { ECONNREFUSED, NT_STATUS_CONNECTION_REFUSED }, +#ifdef ECONNRESET + { ECONNRESET, NT_STATUS_CONNECTION_RESET }, +#endif { EBUSY, NT_STATUS_SHARING_VIOLATION }, #ifdef ENOTSUP { ENOTSUP, NT_STATUS_NOT_SUPPORTED}, -- cgit From b0e342e389d19377ad6c1b4236e60306d662ddab Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 10 Oct 2005 11:21:02 +0000 Subject: r10867: add WERR_UNKNOWN_REVISION errorcode metze (This used to be commit b436206c498ea166b8b9fa47638d5f8f6f4752bf) --- source4/libcli/util/doserr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index eecf923bac..a32da5a880 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -69,6 +69,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DFS_INTERNAL_ERROR", WERR_DFS_INTERNAL_ERROR }, { "WERR_DFS_CANT_CREATE_JUNCT", WERR_DFS_CANT_CREATE_JUNCT }, { "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR }, + { "WERR_UNKNOWN_REVISION", WERR_UNKNOWN_REVISION }, { "WERR_REVISION_MISMATCH", WERR_REVISION_MISMATCH }, { "WERR_INVALID_OWNER", WERR_INVALID_OWNER }, { "WERR_INVALID_DOMAINNAME", WERR_INVALID_DOMAINNAME }, -- cgit From b1d3d75c681d99f84aa2c60863597e32cdd24e66 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 31 Oct 2005 02:46:15 +0000 Subject: r11404: Another torture test and a new WERR. Andrew Bartlett (This used to be commit de83b8cd187b28ecb30550c44f9f84e373df692e) --- source4/libcli/util/doserr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index a32da5a880..e1ef9d930a 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -72,6 +72,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_UNKNOWN_REVISION", WERR_UNKNOWN_REVISION }, { "WERR_REVISION_MISMATCH", WERR_REVISION_MISMATCH }, { "WERR_INVALID_OWNER", WERR_INVALID_OWNER }, + { "WERR_INVALID_COMPUTERNAME", WERR_INVALID_COMPUTERNAME }, { "WERR_INVALID_DOMAINNAME", WERR_INVALID_DOMAINNAME }, { "WERR_NO_SUCH_USER", WERR_NO_SUCH_USER }, { "WERR_NO_SUCH_DOMAIN", WERR_NO_SUCH_DOMAIN }, -- cgit From c4a0e36143fed4ca2ba29ddc1b52dd6e22d713fb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 7 Nov 2005 11:44:08 +0000 Subject: r11546: add more errno ntstatus mappings, to get more usefull errors from socket_wrapper metze (This used to be commit 6375a9a95da1eb2d5fd60b265047d98b264ff93f) --- source4/libcli/util/errormap.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 99154d2cb0..526e9085c9 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1319,6 +1319,21 @@ const struct unix_error_map unix_nt_errmap[] = { #endif #ifdef EFBIG { EFBIG, NT_STATUS_DISK_FULL }, +#endif +#ifdef EADDRNOTAVAIL + { EADDRNOTAVAIL,NT_STATUS_ADDRESS_NOT_ASSOCIATED }, +#endif +#ifdef ESOCKTNOSUPPORT + { ESOCKTNOSUPPORT,NT_STATUS_INVALID_PARAMETER_MIX }, +#endif +#ifdef EAFNOSUPPORT + { EAFNOSUPPORT, NT_STATUS_INVALID_PARAMETER_MIX }, +#endif +#ifdef ENOPROTOOPT + { ENOPROTOOPT, NT_STATUS_INVALID_PARAMETER_MIX }, +#endif +#ifdef ENODEV + { ENODEV, NT_STATUS_NO_SUCH_DEVICE }, #endif { 0, NT_STATUS_UNSUCCESSFUL } }; -- cgit From 65baaafc34b2befac50541c5aef86e5d906d2797 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Nov 2005 00:28:02 +0000 Subject: r11620: switch the ldap client code over to using the generic packet code (This used to be commit 1d29ad2a27d89454e5e3c4a3cf05cc5edde0208c) --- source4/libcli/util/asn1.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 6ca2221b1a..0dceb1bba6 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -607,3 +607,30 @@ BOOL asn1_write_enumerated(struct asn1_data *data, uint8_t v) asn1_pop_tag(data); return !data->has_error; } + +/* + check if a ASN.1 blob is a full tag +*/ +NTSTATUS asn1_full_tag(DATA_BLOB blob, uint8_t tag, size_t *packet_size) +{ + struct asn1_data asn1; + int size; + + ZERO_STRUCT(asn1); + asn1.data = blob.data; + asn1.length = blob.length; + asn1_start_tag(&asn1, tag); + if (asn1.has_error) { + talloc_free(asn1.nesting); + return STATUS_MORE_ENTRIES; + } + size = asn1_tag_remaining(&asn1) + asn1.ofs; + talloc_free(asn1.nesting); + + if (size > blob.length) { + return STATUS_MORE_ENTRIES; + } + + *packet_size = size; + return NT_STATUS_OK; +} -- cgit From 43fa1b6dbd5e03251572fb6c2ee7c7f59f413c7d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 16 Nov 2005 10:16:14 +0000 Subject: r11740: add some EA error codes metze (This used to be commit b1afcced395812477365befad1ed37a7cdafa275) --- source4/libcli/util/nterr.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index ca8605faea..45d0181103 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -35,7 +35,10 @@ static const nt_err_code_struct nt_errs[] = { { "NT_STATUS_OK", NT_STATUS_OK }, { "STATUS_NO_MORE_FILES", STATUS_NO_MORE_FILES }, + { "STATUS_NO_MORE_EAS", STATUS_NO_MORE_EAS }, + { "STATUS_INVALID_EA_NAME", STATUS_INVALID_EA_NAME }, { "STATUS_EA_LIST_INCONSISTENT", STATUS_EA_LIST_INCONSISTENT }, + { "STATUS_INVALID_EA_FLAG", STATUS_INVALID_EA_FLAG }, { "NT_STATUS_UNSUCCESSFUL", NT_STATUS_UNSUCCESSFUL }, { "NT_STATUS_NOT_IMPLEMENTED", NT_STATUS_NOT_IMPLEMENTED }, { "NT_STATUS_INVALID_INFO_CLASS", NT_STATUS_INVALID_INFO_CLASS }, -- cgit From acd6a086b341096fcbea1775ce748587fcc8020a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Dec 2005 14:28:01 +0000 Subject: r12510: Change the DCE/RPC interfaces to take a pointer to a dcerpc_interface_table struct rather then a tuple of interface name, UUID and version. This removes the requirement for having a global list of DCE/RPC interfaces, except for these parts of the code that use that list explicitly (ndrdump and the scanner torture test). This should also allow us to remove the hack that put the authservice parameter in the dcerpc_binding struct as it can now be read directly from dcerpc_interface_table. I will now modify some of these functions to take a dcerpc_syntax_id structure rather then a full dcerpc_interface_table. (This used to be commit 8aae0f168e54c01d0866ad6e0da141dbd828574f) --- source4/libcli/util/clilsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index f5de5014e3..3c7850b7fd 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -90,7 +90,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) } /* bind to the LSA pipe */ - status = dcerpc_bind_auth_none(lsa->pipe, DCERPC_LSARPC_UUID, DCERPC_LSARPC_VERSION); + status = dcerpc_bind_auth_none(lsa->pipe, &dcerpc_table_lsarpc); if (!NT_STATUS_IS_OK(status)) { talloc_free(lsa); return status; -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/libcli/util/smbdes.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c index d02cae602f..d392109b1e 100644 --- a/source4/libcli/util/smbdes.c +++ b/source4/libcli/util/smbdes.c @@ -22,7 +22,6 @@ */ #include "includes.h" -#include "lib/crypto/crypto.h" /* NOTES: -- cgit From 78c50015bb8bd5a1d831a6e7ec796b3367c73145 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 3 Jan 2006 15:40:05 +0000 Subject: r12694: Move some headers to the directory of the subsystem they belong to. (This used to be commit c722f665c90103f3ed57621c460e32ad33e7a8a3) --- source4/libcli/util/asn1.c | 2 +- source4/libcli/util/asn_1.h | 53 ++++++++++++++++++++++++++++++++++++++++++++ source4/libcli/util/clilsa.c | 1 + 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 source4/libcli/util/asn_1.h (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 0dceb1bba6..db3f7823fa 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -19,7 +19,7 @@ */ #include "includes.h" -#include "asn_1.h" +#include "libcli/util/asn_1.h" /* free an asn1 structure */ void asn1_free(struct asn1_data *data) diff --git a/source4/libcli/util/asn_1.h b/source4/libcli/util/asn_1.h new file mode 100644 index 0000000000..2dc9bef06d --- /dev/null +++ b/source4/libcli/util/asn_1.h @@ -0,0 +1,53 @@ +/* + Unix SMB/CIFS implementation. + simple ASN1 code + Copyright (C) Andrew Tridgell 2001 + + 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. +*/ + +#ifndef _ASN_1_H +#define _ASN_1_H + +struct nesting { + off_t start; + size_t taglen; /* for parsing */ + struct nesting *next; +}; + +struct asn1_data { + uint8_t *data; + size_t length; + off_t ofs; + struct nesting *nesting; + BOOL has_error; +}; + +#define ASN1_APPLICATION(x) ((x)+0x60) +#define ASN1_APPLICATION_SIMPLE(x) ((x)+0x40) +#define ASN1_SEQUENCE(x) ((x)+0x30) +#define ASN1_CONTEXT(x) ((x)+0xa0) +#define ASN1_CONTEXT_SIMPLE(x) ((x)+0x80) +#define ASN1_GENERAL_STRING 0x1b +#define ASN1_OCTET_STRING 0x4 +#define ASN1_OID 0x6 +#define ASN1_BOOLEAN 0x1 +#define ASN1_INTEGER 0x2 +#define ASN1_ENUMERATED 0xa +#define ASN1_SET 0x31 + +#define ASN1_MAX_OIDS 20 + +#endif /* _ASN_1_H */ diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 3c7850b7fd..bf5048b02a 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -28,6 +28,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" +#include "libcli/libcli.h" #include "librpc/gen_ndr/ndr_lsa.h" struct smblsa_state { -- cgit From 23aa4becf20ae8a1384bad7d819745d7c38b211b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 13 Jan 2006 17:07:28 +0000 Subject: r12910: fix bug #3069 metze (This used to be commit 1768a698a461bfb8aeaa8f28efaab4ad300823a2) --- source4/libcli/util/errormap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 526e9085c9..bbaac629e4 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1284,14 +1284,17 @@ const struct unix_error_map unix_nt_errmap[] = { #ifdef ENOTSUP { ENOTSUP, NT_STATUS_NOT_SUPPORTED}, #endif +#ifdef EOPNOTSUPP + { EOPNOTSUPP, NT_STATUS_NOT_SUPPORTED}, +#endif #ifdef EHOSTUNREACH { EHOSTUNREACH, NT_STATUS_HOST_UNREACHABLE }, #endif #ifdef ENETUNREACH - { ENETUNREACH, NT_STATUS_NETWORK_UNREACHABLE }, + { ENETUNREACH, NT_STATUS_NETWORK_UNREACHABLE }, #endif #ifdef ETIMEDOUT - { ETIMEDOUT, NT_STATUS_IO_TIMEOUT }, + { ETIMEDOUT, NT_STATUS_IO_TIMEOUT }, #endif #ifdef EADDRINUSE { EADDRINUSE, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED }, -- cgit From 10d88a02d727ae16336eec8f696a94b76c1132cd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 23 Feb 2006 11:29:01 +0000 Subject: r13652: Move some more stuff out off include/ (This used to be commit 26bf2a393b90acc098be0b30886dbba34d348a01) --- source4/libcli/util/doserr.h | 266 ++++++++++++++++++++ source4/libcli/util/nterr.h | 587 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 853 insertions(+) create mode 100644 source4/libcli/util/doserr.h create mode 100644 source4/libcli/util/nterr.h (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h new file mode 100644 index 0000000000..5b8ff1dd3d --- /dev/null +++ b/source4/libcli/util/doserr.h @@ -0,0 +1,266 @@ +/* + Unix SMB/CIFS implementation. + DOS error code constants + Copyright (C) Andrew Tridgell 1992-2000 + Copyright (C) John H Terpstra 1996-2000 + Copyright (C) Luke Kenneth Casson Leighton 1996-2000 + Copyright (C) Paul Ashton 1998-2000 + + 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. +*/ + +#ifndef _DOSERR_H +#define _DOSERR_H + +/* Error classes */ + +#define ERRDOS 0x01 /* Error is from the core DOS operating system set. */ +#define ERRSRV 0x02 /* Error is generated by the server network file manager.*/ +#define ERRHRD 0x03 /* Error is an hardware error. */ +#define ERRCMD 0xFF /* Command was not in the "SMB" format. */ + +/* SMB X/Open error codes for the ERRDOS error class */ +#define ERRsuccess 0 /* No error */ +#define ERRbadfunc 1 /* Invalid function (or system call) */ +#define ERRbadfile 2 /* File not found (pathname error) */ +#define ERRbadpath 3 /* Directory not found */ +#define ERRnofids 4 /* Too many open files */ +#define ERRnoaccess 5 /* Access denied */ +#define ERRbadfid 6 /* Invalid fid */ +#define ERRbadmcb 7 /* Memory control blocks destroyed. */ +#define ERRnomem 8 /* Out of memory */ +#define ERRbadmem 9 /* Invalid memory block address */ +#define ERRbadenv 10 /* Invalid environment */ +#define ERRbadaccess 12 /* Invalid open mode */ +#define ERRbaddata 13 /* Invalid data (only from ioctl call) */ +#define ERRres 14 /* reserved */ +#define ERRbaddrive 15 /* Invalid drive */ +#define ERRremcd 16 /* Attempt to delete current directory */ +#define ERRdiffdevice 17 /* rename/move across different filesystems */ +#define ERRnofiles 18 /* no more files found in file search */ +#define ERRgeneral 31 /* General failure */ +#define ERRbadshare 32 /* Share mode on file conflict with open mode */ +#define ERRlock 33 /* Lock request conflicts with existing lock */ +#define ERRunsup 50 /* Request unsupported, returned by Win 95, RJS 20Jun98 */ +#define ERRnetnamedel 64 /* Network name deleted or not available */ +#define ERRnosuchshare 67 /* You specified an invalid share name */ +#define ERRfilexists 80 /* File in operation already exists */ +#define ERRinvalidparam 87 +#define ERRcannotopen 110 /* Cannot open the file specified */ +#define ERRinsufficientbuffer 122 +#define ERRinvalidname 123 /* Invalid name */ +#define ERRunknownlevel 124 +#define ERRnotlocked 158 /* This region is not locked by this locking context. */ +#define ERRinvalidpath 161 +#define ERRcancelviolation 173 +#define ERRnoatomiclocks 174 +#define ERRrename 183 +#define ERRbadpipe 230 /* Named pipe invalid */ +#define ERRpipebusy 231 /* All instances of pipe are busy */ +#define ERRpipeclosing 232 /* named pipe close in progress */ +#define ERRnotconnected 233 /* No process on other end of named pipe */ +#define ERRmoredata 234 /* More data to be returned */ +#define ERReainconsistent 255 /* from EMC */ +#define ERRnomoreitems 259 +#define ERRbaddirectory 267 /* Invalid directory name in a path. */ +#define ERReasnotsupported 282 /* Extended attributes */ +#define ERRlogonfailure 1326 /* Unknown username or bad password */ +#define ERRbuftoosmall 2123 +#define ERRunknownipc 2142 +#define ERRnosuchprintjob 2151 +#define ERRinvgroup 2455 + +/* here's a special one from observing NT */ +#define ERRnoipc 66 /* don't support ipc */ + +/* These errors seem to be only returned by the NT printer driver system */ +#define ERRdriveralreadyinstalled 1795 /* ERROR_PRINTER_DRIVER_ALREADY_INSTALLED */ +#define ERRunknownprinterport 1796 /* ERROR_UNKNOWN_PORT */ +#define ERRunknownprinterdriver 1797 /* ERROR_UNKNOWN_PRINTER_DRIVER */ +#define ERRunknownprintprocessor 1798 /* ERROR_UNKNOWN_PRINTPROCESSOR */ +#define ERRinvalidseparatorfile 1799 /* ERROR_INVALID_SEPARATOR_FILE */ +#define ERRinvalidjobpriority 1800 /* ERROR_INVALID_PRIORITY */ +#define ERRinvalidprintername 1801 /* ERROR_INVALID_PRINTER_NAME */ +#define ERRprinteralreadyexists 1802 /* ERROR_PRINTER_ALREADY_EXISTS */ +#define ERRinvalidprintercommand 1803 /* ERROR_INVALID_PRINTER_COMMAND */ +#define ERRinvaliddatatype 1804 /* ERROR_INVALID_DATATYPE */ +#define ERRinvalidenvironment 1805 /* ERROR_INVALID_ENVIRONMENT */ + +#define ERRunknownprintmonitor 3000 /* ERROR_UNKNOWN_PRINT_MONITOR */ +#define ERRprinterdriverinuse 3001 /* ERROR_PRINTER_DRIVER_IN_USE */ +#define ERRspoolfilenotfound 3002 /* ERROR_SPOOL_FILE_NOT_FOUND */ +#define ERRnostartdoc 3003 /* ERROR_SPL_NO_STARTDOC */ +#define ERRnoaddjob 3004 /* ERROR_SPL_NO_ADDJOB */ +#define ERRprintprocessoralreadyinstalled 3005 /* ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED */ +#define ERRprintmonitoralreadyinstalled 3006 /* ERROR_PRINT_MONITOR_ALREADY_INSTALLED */ +#define ERRinvalidprintmonitor 3007 /* ERROR_INVALID_PRINT_MONITOR */ +#define ERRprintmonitorinuse 3008 /* ERROR_PRINT_MONITOR_IN_USE */ +#define ERRprinterhasjobsqueued 3009 /* ERROR_PRINTER_HAS_JOBS_QUEUED */ + +/* Error codes for the ERRSRV class */ + +#define ERRerror 1 /* Non specific error code */ +#define ERRbadpw 2 /* Bad password */ +#define ERRbadtype 3 /* reserved */ +#define ERRaccess 4 /* No permissions to do the requested operation */ +#define ERRinvnid 5 /* tid invalid */ +#define ERRinvnetname 6 /* Invalid servername */ +#define ERRinvdevice 7 /* Invalid device */ +#define ERRqfull 49 /* Print queue full */ +#define ERRqtoobig 50 /* Queued item too big */ +#define ERRinvpfid 52 /* Invalid print file in smb_fid */ +#define ERRsmbcmd 64 /* Unrecognised command */ +#define ERRsrverror 65 /* smb server internal error */ +#define ERRfilespecs 67 /* fid and pathname invalid combination */ +#define ERRbadlink 68 /* reserved */ +#define ERRbadpermits 69 /* Access specified for a file is not valid */ +#define ERRbadpid 70 /* reserved */ +#define ERRsetattrmode 71 /* attribute mode invalid */ +#define ERRpaused 81 /* Message server paused */ +#define ERRmsgoff 82 /* Not receiving messages */ +#define ERRnoroom 83 /* No room for message */ +#define ERRrmuns 87 /* too many remote usernames */ +#define ERRtimeout 88 /* operation timed out */ +#define ERRnoresource 89 /* No resources currently available for request. */ +#define ERRtoomanyuids 90 /* too many userids */ +#define ERRbaduid 91 /* bad userid */ +#define ERRuseMPX 250 /* temporarily unable to use raw mode, use MPX mode */ +#define ERRuseSTD 251 /* temporarily unable to use raw mode, use standard mode */ +#define ERRcontMPX 252 /* resume MPX mode */ +#define ERRnosupport 0xFFFF +#define ERRunknownsmb 22 /* from NT 3.5 response */ + +/* Error codes for the ERRHRD class */ + +#define ERRnowrite 19 /* read only media */ +#define ERRbadunit 20 /* Unknown device */ +#define ERRnotready 21 /* Drive not ready */ +#define ERRbadcmd 22 /* Unknown command */ +#define ERRdata 23 /* Data (CRC) error */ +#define ERRbadreq 24 /* Bad request structure length */ +#define ERRseek 25 +#define ERRbadmedia 26 +#define ERRbadsector 27 +#define ERRnopaper 28 +#define ERRwrite 29 /* write fault */ +#define ERRread 30 /* read fault */ +#define ERRgeneral 31 /* General hardware failure */ +#define ERRwrongdisk 34 +#define ERRFCBunavail 35 +#define ERRsharebufexc 36 /* share buffer exceeded */ +#define ERRdiskfull 39 + + +/* these are win32 error codes. There are only a few places where + these matter for Samba, primarily in the NT printing code */ +#define WERR_OK W_ERROR(0) +#define WERR_BADFUNC W_ERROR(1) +#define WERR_BADFILE W_ERROR(2) +#define WERR_ACCESS_DENIED W_ERROR(5) +#define WERR_BADFID W_ERROR(6) +#define WERR_NOMEM W_ERROR(8) +#define WERR_GENERAL_FAILURE W_ERROR(31) +#define WERR_NOT_SUPPORTED W_ERROR(50) +#define WERR_BAD_NETPATH W_ERROR(53) +#define WERR_PRINTQ_FULL W_ERROR(61) +#define WERR_NO_SPOOL_SPACE W_ERROR(62) +#define WERR_NO_SUCH_SHARE W_ERROR(67) +#define WERR_ALREADY_EXISTS W_ERROR(80) +#define WERR_BAD_PASSWORD W_ERROR(86) +#define WERR_INVALID_PARAM W_ERROR(87) +#define WERR_INSUFFICIENT_BUFFER W_ERROR(122) +#define WERR_INVALID_NAME W_ERROR(123) +#define WERR_UNKNOWN_LEVEL W_ERROR(124) +#define WERR_OBJECT_PATH_INVALID W_ERROR(161) +#define WERR_NO_MORE_ITEMS W_ERROR(259) +#define WERR_MORE_DATA W_ERROR(234) +#define WERR_CAN_NOT_COMPLETE W_ERROR(1003) +#define WERR_INVALID_COMPUTERNAME W_ERROR(1210) +#define WERR_INVALID_DOMAINNAME W_ERROR(1212) +#define WERR_UNKNOWN_REVISION W_ERROR(1305) +#define WERR_REVISION_MISMATCH W_ERROR(1306) +#define WERR_INVALID_OWNER W_ERROR(1307) +#define WERR_NO_SUCH_USER W_ERROR(1317) +#define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338) +#define WERR_NO_SUCH_DOMAIN W_ERROR(1355) +#define WERR_SERVER_UNAVAILABLE W_ERROR(1722) +#define WERR_INVALID_FORM_NAME W_ERROR(1902) +#define WERR_INVALID_FORM_SIZE W_ERROR(1903) +#define WERR_BUF_TOO_SMALL W_ERROR(2123) +#define WERR_JOB_NOT_FOUND W_ERROR(2151) +#define WERR_DEST_NOT_FOUND W_ERROR(2152) +#define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320) +#define WERR_STATUS_MORE_ENTRIES W_ERROR(0x0105) + +#define WERR_PRINTER_DRIVER_ALREADY_INSTALLED W_ERROR(ERRdriveralreadyinstalled) +#define WERR_UNKNOWN_PORT W_ERROR(ERRunknownprinterport) +#define WERR_UNKNOWN_PRINTER_DRIVER W_ERROR(ERRunknownprinterdriver) +#define WERR_UNKNOWN_PRINTPROCESSOR W_ERROR(ERRunknownprintprocessor) +#define WERR_INVALID_SEPARATOR_FILE W_ERROR(ERRinvalidseparatorfile) +#define WERR_INVALID_PRIORITY W_ERROR(ERRinvalidjobpriority) +#define WERR_INVALID_PRINTER_NAME W_ERROR(ERRinvalidprintername) +#define WERR_PRINTER_ALREADY_EXISTS W_ERROR(ERRprinteralreadyexists) +#define WERR_INVALID_PRINTER_COMMAND W_ERROR(ERRinvalidprintercommand) +#define WERR_INVALID_DATATYPE W_ERROR(ERRinvaliddatatype) +#define WERR_INVALID_ENVIRONMENT W_ERROR(ERRinvalidenvironment) + +#define WERR_UNKNOWN_PRINT_MONITOR W_ERROR(ERRunknownprintmonitor) +#define WERR_PRINTER_DRIVER_IN_USE W_ERROR(ERRprinterdriverinuse) +#define WERR_SPOOL_FILE_NOT_FOUND W_ERROR(ERRspoolfilenotfound) +#define WERR_SPL_NO_STARTDOC W_ERROR(ERRnostartdoc) +#define WERR_SPL_NO_ADDJOB W_ERROR(ERRnoaddjob) +#define WERR_PRINT_PROCESSOR_ALREADY_INSTALLED W_ERROR(ERRprintprocessoralreadyinstalled) +#define WERR_PRINT_MONITOR_ALREADY_INSTALLED W_ERROR(ERRprintmonitoralreadyinstalled) +#define WERR_INVALID_PRINT_MONITOR W_ERROR(ERRinvalidprintmonitor) +#define WERR_PRINT_MONITOR_IN_USE W_ERROR(ERRprintmonitorinuse) +#define WERR_PRINTER_HAS_JOBS_QUEUED W_ERROR(ERRprinterhasjobsqueued) + +#define WERR_CLASS_NOT_REGISTERED W_ERROR(0x40154) +#define WERR_NO_SHUTDOWN_IN_PROGRESS W_ERROR(0x45c) +#define WERR_SHUTDOWN_ALREADY_IN_PROGRESS W_ERROR(0x45b) + + +#ifndef NERR_BASE +#define NERR_BASE (2100) +#endif + +#define WERR_NET_NAME_NOT_FOUND W_ERROR(NERR_BASE+210) +#define WERR_DEVICE_NOT_SHARED W_ERROR(NERR_BASE+211) + +/* DFS errors */ +#define WERR_DFS_NO_SUCH_VOL W_ERROR(NERR_BASE+562) +#define WERR_DFS_NO_SUCH_SHARE W_ERROR(NERR_BASE+565) +#define WERR_DFS_NO_SUCH_SERVER W_ERROR(NERR_BASE+573) +#define WERR_DFS_INTERNAL_ERROR W_ERROR(NERR_BASE+590) +#define WERR_DFS_CANT_CREATE_JUNCT W_ERROR(NERR_BASE+569) + +/* DS errors */ +#define WERR_DS_SERVICE_BUSY W_ERROR(0x0000200e) +#define WERR_DS_SERVICE_UNAVAILABLE W_ERROR(0x0000200f) +#define WERR_DS_NO_SUCH_OBJECT W_ERROR(0x00002030) +#define WERR_DS_OBJ_NOT_FOUND W_ERROR(0x0000208d) +#define WERR_DS_DRA_INVALID_PARAMETER W_ERROR(0x000020f5) +#define WERR_DS_DRA_BAD_DN W_ERROR(0x000020f7) +#define WERR_DS_DRA_BAD_NC W_ERROR(0x000020f8) +#define WERR_DS_DRA_INTERNAL_ERROR W_ERROR(0x000020fa) +#define WERR_DS_SINGLE_VALUE_CONSTRAINT W_ERROR(0x00002081) +#define WERR_DS_DRA_DB_ERROR W_ERROR(0x00002103) +#define WERR_DS_DRA_NO_REPLICA W_ERROR(0x00002104) +#define WERR_DS_DNS_LOOKUP_FAILURE W_ERROR(0x0000214c) +#define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX W_ERROR(0x00002150) + +#define WERR_FOOBAR WERR_GENERAL_FAILURE + +#endif /* _DOSERR_H */ diff --git a/source4/libcli/util/nterr.h b/source4/libcli/util/nterr.h new file mode 100644 index 0000000000..08e3fa2db0 --- /dev/null +++ b/source4/libcli/util/nterr.h @@ -0,0 +1,587 @@ +/* + Unix SMB/CIFS implementation. + NT error code constants + Copyright (C) Andrew Tridgell 1992-2000 + Copyright (C) John H Terpstra 1996-2000 + Copyright (C) Luke Kenneth Casson Leighton 1996-2000 + Copyright (C) Paul Ashton 1998-2000 + + 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. +*/ + +#ifndef _NTERR_H +#define _NTERR_H + +/* Win32 Status codes. */ + +#define STATUS_BUFFER_OVERFLOW NT_STATUS(0x80000005) +#define STATUS_NO_MORE_FILES NT_STATUS(0x80000006) +#define STATUS_NO_MORE_EAS NT_STATUS(0x80000012) +#define STATUS_INVALID_EA_NAME NT_STATUS(0x80000013) +#define STATUS_EA_LIST_INCONSISTENT NT_STATUS(0x80000014) +#define STATUS_INVALID_EA_FLAG NT_STATUS(0x80000015) +#define NT_STATUS_NO_MORE_ENTRIES NT_STATUS(0x8000001a) + +#define STATUS_PENDING NT_STATUS(0x0103) +#define STATUS_MORE_ENTRIES NT_STATUS(0x0105) +#define STATUS_SOME_UNMAPPED NT_STATUS(0x0107) +#define ERROR_INVALID_PARAMETER NT_STATUS(0x0057) +#define ERROR_INSUFFICIENT_BUFFER NT_STATUS(0x007a) +#define STATUS_NOTIFY_ENUM_DIR NT_STATUS(0x010c) +#define ERROR_INVALID_DATATYPE NT_STATUS(0x070c) + +/* Win32 Error codes extracted using a loop in smbclient then printing a + netmon sniff to a file. */ + +/* + -------------- + / \ + / REST \ + / IN \ + / PEACE \ + / \ + | NT_STATUS_NOPROBLEMO | + | | + | | + | 4 September | + | | + | 2001 | + *| * * * | * + _________)/\\_//(\/(/\)/\//\/\///|_)_______ +*/ + +#define NT_STATUS_OK NT_STATUS(0x0000) +#define NT_STATUS_UNSUCCESSFUL NT_STATUS(0xC0000000 | 0x0001) +#define NT_STATUS_NOT_IMPLEMENTED NT_STATUS(0xC0000000 | 0x0002) +#define NT_STATUS_INVALID_INFO_CLASS NT_STATUS(0xC0000000 | 0x0003) +#define NT_STATUS_INFO_LENGTH_MISMATCH NT_STATUS(0xC0000000 | 0x0004) +#define NT_STATUS_ACCESS_VIOLATION NT_STATUS(0xC0000000 | 0x0005) +#define NT_STATUS_IN_PAGE_ERROR NT_STATUS(0xC0000000 | 0x0006) +#define NT_STATUS_PAGEFILE_QUOTA NT_STATUS(0xC0000000 | 0x0007) +#define NT_STATUS_INVALID_HANDLE NT_STATUS(0xC0000000 | 0x0008) +#define NT_STATUS_BAD_INITIAL_STACK NT_STATUS(0xC0000000 | 0x0009) +#define NT_STATUS_BAD_INITIAL_PC NT_STATUS(0xC0000000 | 0x000a) +#define NT_STATUS_INVALID_CID NT_STATUS(0xC0000000 | 0x000b) +#define NT_STATUS_TIMER_NOT_CANCELED NT_STATUS(0xC0000000 | 0x000c) +#define NT_STATUS_INVALID_PARAMETER NT_STATUS(0xC0000000 | 0x000d) +#define NT_STATUS_NO_SUCH_DEVICE NT_STATUS(0xC0000000 | 0x000e) +#define NT_STATUS_NO_SUCH_FILE NT_STATUS(0xC0000000 | 0x000f) +#define NT_STATUS_INVALID_DEVICE_REQUEST NT_STATUS(0xC0000000 | 0x0010) +#define NT_STATUS_END_OF_FILE NT_STATUS(0xC0000000 | 0x0011) +#define NT_STATUS_WRONG_VOLUME NT_STATUS(0xC0000000 | 0x0012) +#define NT_STATUS_NO_MEDIA_IN_DEVICE NT_STATUS(0xC0000000 | 0x0013) +#define NT_STATUS_UNRECOGNIZED_MEDIA NT_STATUS(0xC0000000 | 0x0014) +#define NT_STATUS_NONEXISTENT_SECTOR NT_STATUS(0xC0000000 | 0x0015) +#define NT_STATUS_MORE_PROCESSING_REQUIRED NT_STATUS(0xC0000000 | 0x0016) +#if 0 +/* this demonstrates a little trick when tracking down error codes */ +#define NT_STATUS_NO_MEMORY (printf("no memory at %s\n", __location__), NT_STATUS(0xC0000000 | 0x0017)) +#else +#define NT_STATUS_NO_MEMORY NT_STATUS(0xC0000000 | 0x0017) +#endif +#define NT_STATUS_CONFLICTING_ADDRESSES NT_STATUS(0xC0000000 | 0x0018) +#define NT_STATUS_NOT_MAPPED_VIEW NT_STATUS(0xC0000000 | 0x0019) +#define NT_STATUS_UNABLE_TO_FREE_VM NT_STATUS(0xC0000000 | 0x001a) +#define NT_STATUS_UNABLE_TO_DELETE_SECTION NT_STATUS(0xC0000000 | 0x001b) +#define NT_STATUS_INVALID_SYSTEM_SERVICE NT_STATUS(0xC0000000 | 0x001c) +#define NT_STATUS_ILLEGAL_INSTRUCTION NT_STATUS(0xC0000000 | 0x001d) +#define NT_STATUS_INVALID_LOCK_SEQUENCE NT_STATUS(0xC0000000 | 0x001e) +#define NT_STATUS_INVALID_VIEW_SIZE NT_STATUS(0xC0000000 | 0x001f) +#define NT_STATUS_INVALID_FILE_FOR_SECTION NT_STATUS(0xC0000000 | 0x0020) +#define NT_STATUS_ALREADY_COMMITTED NT_STATUS(0xC0000000 | 0x0021) +#if 0 +/* this demonstrates a little trick when tracking down error codes */ +#define NT_STATUS_ACCESS_DENIED (printf("access denied at %s\n", __location__), NT_STATUS(0xC0000000 | 0x0022)) +#else +#define NT_STATUS_ACCESS_DENIED NT_STATUS(0xC0000000 | 0x0022) +#endif +#define NT_STATUS_BUFFER_TOO_SMALL NT_STATUS(0xC0000000 | 0x0023) +#define NT_STATUS_OBJECT_TYPE_MISMATCH NT_STATUS(0xC0000000 | 0x0024) +#define NT_STATUS_NONCONTINUABLE_EXCEPTION NT_STATUS(0xC0000000 | 0x0025) +#define NT_STATUS_INVALID_DISPOSITION NT_STATUS(0xC0000000 | 0x0026) +#define NT_STATUS_UNWIND NT_STATUS(0xC0000000 | 0x0027) +#define NT_STATUS_BAD_STACK NT_STATUS(0xC0000000 | 0x0028) +#define NT_STATUS_INVALID_UNWIND_TARGET NT_STATUS(0xC0000000 | 0x0029) +#define NT_STATUS_NOT_LOCKED NT_STATUS(0xC0000000 | 0x002a) +#define NT_STATUS_PARITY_ERROR NT_STATUS(0xC0000000 | 0x002b) +#define NT_STATUS_UNABLE_TO_DECOMMIT_VM NT_STATUS(0xC0000000 | 0x002c) +#define NT_STATUS_NOT_COMMITTED NT_STATUS(0xC0000000 | 0x002d) +#define NT_STATUS_INVALID_PORT_ATTRIBUTES NT_STATUS(0xC0000000 | 0x002e) +#define NT_STATUS_PORT_MESSAGE_TOO_LONG NT_STATUS(0xC0000000 | 0x002f) +#define NT_STATUS_INVALID_PARAMETER_MIX NT_STATUS(0xC0000000 | 0x0030) +#define NT_STATUS_INVALID_QUOTA_LOWER NT_STATUS(0xC0000000 | 0x0031) +#define NT_STATUS_DISK_CORRUPT_ERROR NT_STATUS(0xC0000000 | 0x0032) +#define NT_STATUS_OBJECT_NAME_INVALID NT_STATUS(0xC0000000 | 0x0033) +#define NT_STATUS_OBJECT_NAME_NOT_FOUND NT_STATUS(0xC0000000 | 0x0034) +#define NT_STATUS_OBJECT_NAME_COLLISION NT_STATUS(0xC0000000 | 0x0035) +#define NT_STATUS_HANDLE_NOT_WAITABLE NT_STATUS(0xC0000000 | 0x0036) +#define NT_STATUS_PORT_DISCONNECTED NT_STATUS(0xC0000000 | 0x0037) +#define NT_STATUS_DEVICE_ALREADY_ATTACHED NT_STATUS(0xC0000000 | 0x0038) +#define NT_STATUS_OBJECT_PATH_INVALID NT_STATUS(0xC0000000 | 0x0039) +#define NT_STATUS_OBJECT_PATH_NOT_FOUND NT_STATUS(0xC0000000 | 0x003a) +#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD NT_STATUS(0xC0000000 | 0x003b) +#define NT_STATUS_DATA_OVERRUN NT_STATUS(0xC0000000 | 0x003c) +#define NT_STATUS_DATA_LATE_ERROR NT_STATUS(0xC0000000 | 0x003d) +#define NT_STATUS_DATA_ERROR NT_STATUS(0xC0000000 | 0x003e) +#define NT_STATUS_CRC_ERROR NT_STATUS(0xC0000000 | 0x003f) +#define NT_STATUS_SECTION_TOO_BIG NT_STATUS(0xC0000000 | 0x0040) +#define NT_STATUS_PORT_CONNECTION_REFUSED NT_STATUS(0xC0000000 | 0x0041) +#define NT_STATUS_INVALID_PORT_HANDLE NT_STATUS(0xC0000000 | 0x0042) +#define NT_STATUS_SHARING_VIOLATION NT_STATUS(0xC0000000 | 0x0043) +#define NT_STATUS_QUOTA_EXCEEDED NT_STATUS(0xC0000000 | 0x0044) +#define NT_STATUS_INVALID_PAGE_PROTECTION NT_STATUS(0xC0000000 | 0x0045) +#define NT_STATUS_MUTANT_NOT_OWNED NT_STATUS(0xC0000000 | 0x0046) +#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED NT_STATUS(0xC0000000 | 0x0047) +#define NT_STATUS_PORT_ALREADY_SET NT_STATUS(0xC0000000 | 0x0048) +#define NT_STATUS_SECTION_NOT_IMAGE NT_STATUS(0xC0000000 | 0x0049) +#define NT_STATUS_SUSPEND_COUNT_EXCEEDED NT_STATUS(0xC0000000 | 0x004a) +#define NT_STATUS_THREAD_IS_TERMINATING NT_STATUS(0xC0000000 | 0x004b) +#define NT_STATUS_BAD_WORKING_SET_LIMIT NT_STATUS(0xC0000000 | 0x004c) +#define NT_STATUS_INCOMPATIBLE_FILE_MAP NT_STATUS(0xC0000000 | 0x004d) +#define NT_STATUS_SECTION_PROTECTION NT_STATUS(0xC0000000 | 0x004e) +#define NT_STATUS_EAS_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x004f) +#define NT_STATUS_EA_TOO_LARGE NT_STATUS(0xC0000000 | 0x0050) +#define NT_STATUS_NONEXISTENT_EA_ENTRY NT_STATUS(0xC0000000 | 0x0051) +#define NT_STATUS_NO_EAS_ON_FILE NT_STATUS(0xC0000000 | 0x0052) +#define NT_STATUS_EA_CORRUPT_ERROR NT_STATUS(0xC0000000 | 0x0053) +#define NT_STATUS_FILE_LOCK_CONFLICT NT_STATUS(0xC0000000 | 0x0054) +#define NT_STATUS_LOCK_NOT_GRANTED NT_STATUS(0xC0000000 | 0x0055) +#define NT_STATUS_DELETE_PENDING NT_STATUS(0xC0000000 | 0x0056) +#define NT_STATUS_CTL_FILE_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x0057) +#define NT_STATUS_UNKNOWN_REVISION NT_STATUS(0xC0000000 | 0x0058) +#define NT_STATUS_REVISION_MISMATCH NT_STATUS(0xC0000000 | 0x0059) +#define NT_STATUS_INVALID_OWNER NT_STATUS(0xC0000000 | 0x005a) +#define NT_STATUS_INVALID_PRIMARY_GROUP NT_STATUS(0xC0000000 | 0x005b) +#define NT_STATUS_NO_IMPERSONATION_TOKEN NT_STATUS(0xC0000000 | 0x005c) +#define NT_STATUS_CANT_DISABLE_MANDATORY NT_STATUS(0xC0000000 | 0x005d) +#define NT_STATUS_NO_LOGON_SERVERS NT_STATUS(0xC0000000 | 0x005e) +#define NT_STATUS_NO_SUCH_LOGON_SESSION NT_STATUS(0xC0000000 | 0x005f) +#define NT_STATUS_NO_SUCH_PRIVILEGE NT_STATUS(0xC0000000 | 0x0060) +#define NT_STATUS_PRIVILEGE_NOT_HELD NT_STATUS(0xC0000000 | 0x0061) +#define NT_STATUS_INVALID_ACCOUNT_NAME NT_STATUS(0xC0000000 | 0x0062) +#define NT_STATUS_USER_EXISTS NT_STATUS(0xC0000000 | 0x0063) +#define NT_STATUS_NO_SUCH_USER NT_STATUS(0xC0000000 | 0x0064) +#define NT_STATUS_GROUP_EXISTS NT_STATUS(0xC0000000 | 0x0065) +#define NT_STATUS_NO_SUCH_GROUP NT_STATUS(0xC0000000 | 0x0066) +#define NT_STATUS_MEMBER_IN_GROUP NT_STATUS(0xC0000000 | 0x0067) +#define NT_STATUS_MEMBER_NOT_IN_GROUP NT_STATUS(0xC0000000 | 0x0068) +#define NT_STATUS_LAST_ADMIN NT_STATUS(0xC0000000 | 0x0069) +#define NT_STATUS_WRONG_PASSWORD NT_STATUS(0xC0000000 | 0x006a) +#define NT_STATUS_ILL_FORMED_PASSWORD NT_STATUS(0xC0000000 | 0x006b) +#define NT_STATUS_PASSWORD_RESTRICTION NT_STATUS(0xC0000000 | 0x006c) +#define NT_STATUS_LOGON_FAILURE NT_STATUS(0xC0000000 | 0x006d) +#define NT_STATUS_ACCOUNT_RESTRICTION NT_STATUS(0xC0000000 | 0x006e) +#define NT_STATUS_INVALID_LOGON_HOURS NT_STATUS(0xC0000000 | 0x006f) +#define NT_STATUS_INVALID_WORKSTATION NT_STATUS(0xC0000000 | 0x0070) +#define NT_STATUS_PASSWORD_EXPIRED NT_STATUS(0xC0000000 | 0x0071) +#define NT_STATUS_ACCOUNT_DISABLED NT_STATUS(0xC0000000 | 0x0072) +#define NT_STATUS_NONE_MAPPED NT_STATUS(0xC0000000 | 0x0073) +#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED NT_STATUS(0xC0000000 | 0x0074) +#define NT_STATUS_LUIDS_EXHAUSTED NT_STATUS(0xC0000000 | 0x0075) +#define NT_STATUS_INVALID_SUB_AUTHORITY NT_STATUS(0xC0000000 | 0x0076) +#define NT_STATUS_INVALID_ACL NT_STATUS(0xC0000000 | 0x0077) +#define NT_STATUS_INVALID_SID NT_STATUS(0xC0000000 | 0x0078) +#define NT_STATUS_INVALID_SECURITY_DESCR NT_STATUS(0xC0000000 | 0x0079) +#define NT_STATUS_PROCEDURE_NOT_FOUND NT_STATUS(0xC0000000 | 0x007a) +#define NT_STATUS_INVALID_IMAGE_FORMAT NT_STATUS(0xC0000000 | 0x007b) +#define NT_STATUS_NO_TOKEN NT_STATUS(0xC0000000 | 0x007c) +#define NT_STATUS_BAD_INHERITANCE_ACL NT_STATUS(0xC0000000 | 0x007d) +#define NT_STATUS_RANGE_NOT_LOCKED NT_STATUS(0xC0000000 | 0x007e) +#define NT_STATUS_DISK_FULL NT_STATUS(0xC0000000 | 0x007f) +#define NT_STATUS_SERVER_DISABLED NT_STATUS(0xC0000000 | 0x0080) +#define NT_STATUS_SERVER_NOT_DISABLED NT_STATUS(0xC0000000 | 0x0081) +#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED NT_STATUS(0xC0000000 | 0x0082) +#define NT_STATUS_GUIDS_EXHAUSTED NT_STATUS(0xC0000000 | 0x0083) +#define NT_STATUS_INVALID_ID_AUTHORITY NT_STATUS(0xC0000000 | 0x0084) +#define NT_STATUS_AGENTS_EXHAUSTED NT_STATUS(0xC0000000 | 0x0085) +#define NT_STATUS_INVALID_VOLUME_LABEL NT_STATUS(0xC0000000 | 0x0086) +#define NT_STATUS_SECTION_NOT_EXTENDED NT_STATUS(0xC0000000 | 0x0087) +#define NT_STATUS_NOT_MAPPED_DATA NT_STATUS(0xC0000000 | 0x0088) +#define NT_STATUS_RESOURCE_DATA_NOT_FOUND NT_STATUS(0xC0000000 | 0x0089) +#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND NT_STATUS(0xC0000000 | 0x008a) +#define NT_STATUS_RESOURCE_NAME_NOT_FOUND NT_STATUS(0xC0000000 | 0x008b) +#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED NT_STATUS(0xC0000000 | 0x008c) +#define NT_STATUS_FLOAT_DENORMAL_OPERAND NT_STATUS(0xC0000000 | 0x008d) +#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO NT_STATUS(0xC0000000 | 0x008e) +#define NT_STATUS_FLOAT_INEXACT_RESULT NT_STATUS(0xC0000000 | 0x008f) +#define NT_STATUS_FLOAT_INVALID_OPERATION NT_STATUS(0xC0000000 | 0x0090) +#define NT_STATUS_FLOAT_OVERFLOW NT_STATUS(0xC0000000 | 0x0091) +#define NT_STATUS_FLOAT_STACK_CHECK NT_STATUS(0xC0000000 | 0x0092) +#define NT_STATUS_FLOAT_UNDERFLOW NT_STATUS(0xC0000000 | 0x0093) +#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO NT_STATUS(0xC0000000 | 0x0094) +#define NT_STATUS_INTEGER_OVERFLOW NT_STATUS(0xC0000000 | 0x0095) +#define NT_STATUS_PRIVILEGED_INSTRUCTION NT_STATUS(0xC0000000 | 0x0096) +#define NT_STATUS_TOO_MANY_PAGING_FILES NT_STATUS(0xC0000000 | 0x0097) +#define NT_STATUS_FILE_INVALID NT_STATUS(0xC0000000 | 0x0098) +#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED NT_STATUS(0xC0000000 | 0x0099) +#define NT_STATUS_INSUFFICIENT_RESOURCES NT_STATUS(0xC0000000 | 0x009a) +#define NT_STATUS_DFS_EXIT_PATH_FOUND NT_STATUS(0xC0000000 | 0x009b) +#define NT_STATUS_DEVICE_DATA_ERROR NT_STATUS(0xC0000000 | 0x009c) +#define NT_STATUS_DEVICE_NOT_CONNECTED NT_STATUS(0xC0000000 | 0x009d) +#define NT_STATUS_DEVICE_POWER_FAILURE NT_STATUS(0xC0000000 | 0x009e) +#define NT_STATUS_FREE_VM_NOT_AT_BASE NT_STATUS(0xC0000000 | 0x009f) +#define NT_STATUS_MEMORY_NOT_ALLOCATED NT_STATUS(0xC0000000 | 0x00a0) +#define NT_STATUS_WORKING_SET_QUOTA NT_STATUS(0xC0000000 | 0x00a1) +#define NT_STATUS_MEDIA_WRITE_PROTECTED NT_STATUS(0xC0000000 | 0x00a2) +#define NT_STATUS_DEVICE_NOT_READY NT_STATUS(0xC0000000 | 0x00a3) +#define NT_STATUS_INVALID_GROUP_ATTRIBUTES NT_STATUS(0xC0000000 | 0x00a4) +#define NT_STATUS_BAD_IMPERSONATION_LEVEL NT_STATUS(0xC0000000 | 0x00a5) +#define NT_STATUS_CANT_OPEN_ANONYMOUS NT_STATUS(0xC0000000 | 0x00a6) +#define NT_STATUS_BAD_VALIDATION_CLASS NT_STATUS(0xC0000000 | 0x00a7) +#define NT_STATUS_BAD_TOKEN_TYPE NT_STATUS(0xC0000000 | 0x00a8) +#define NT_STATUS_BAD_MASTER_BOOT_RECORD NT_STATUS(0xC0000000 | 0x00a9) +#define NT_STATUS_INSTRUCTION_MISALIGNMENT NT_STATUS(0xC0000000 | 0x00aa) +#define NT_STATUS_INSTANCE_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x00ab) +#define NT_STATUS_PIPE_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x00ac) +#define NT_STATUS_INVALID_PIPE_STATE NT_STATUS(0xC0000000 | 0x00ad) +#define NT_STATUS_PIPE_BUSY NT_STATUS(0xC0000000 | 0x00ae) +#define NT_STATUS_ILLEGAL_FUNCTION NT_STATUS(0xC0000000 | 0x00af) +#define NT_STATUS_PIPE_DISCONNECTED NT_STATUS(0xC0000000 | 0x00b0) +#define NT_STATUS_PIPE_CLOSING NT_STATUS(0xC0000000 | 0x00b1) +#define NT_STATUS_PIPE_CONNECTED NT_STATUS(0xC0000000 | 0x00b2) +#define NT_STATUS_PIPE_LISTENING NT_STATUS(0xC0000000 | 0x00b3) +#define NT_STATUS_INVALID_READ_MODE NT_STATUS(0xC0000000 | 0x00b4) +#define NT_STATUS_IO_TIMEOUT NT_STATUS(0xC0000000 | 0x00b5) +#define NT_STATUS_FILE_FORCED_CLOSED NT_STATUS(0xC0000000 | 0x00b6) +#define NT_STATUS_PROFILING_NOT_STARTED NT_STATUS(0xC0000000 | 0x00b7) +#define NT_STATUS_PROFILING_NOT_STOPPED NT_STATUS(0xC0000000 | 0x00b8) +#define NT_STATUS_COULD_NOT_INTERPRET NT_STATUS(0xC0000000 | 0x00b9) +#define NT_STATUS_FILE_IS_A_DIRECTORY NT_STATUS(0xC0000000 | 0x00ba) +#define NT_STATUS_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x00bb) +#define NT_STATUS_REMOTE_NOT_LISTENING NT_STATUS(0xC0000000 | 0x00bc) +#define NT_STATUS_DUPLICATE_NAME NT_STATUS(0xC0000000 | 0x00bd) +#define NT_STATUS_BAD_NETWORK_PATH NT_STATUS(0xC0000000 | 0x00be) +#define NT_STATUS_NETWORK_BUSY NT_STATUS(0xC0000000 | 0x00bf) +#define NT_STATUS_DEVICE_DOES_NOT_EXIST NT_STATUS(0xC0000000 | 0x00c0) +#define NT_STATUS_TOO_MANY_COMMANDS NT_STATUS(0xC0000000 | 0x00c1) +#define NT_STATUS_ADAPTER_HARDWARE_ERROR NT_STATUS(0xC0000000 | 0x00c2) +#define NT_STATUS_INVALID_NETWORK_RESPONSE NT_STATUS(0xC0000000 | 0x00c3) +#define NT_STATUS_UNEXPECTED_NETWORK_ERROR NT_STATUS(0xC0000000 | 0x00c4) +#define NT_STATUS_BAD_REMOTE_ADAPTER NT_STATUS(0xC0000000 | 0x00c5) +#define NT_STATUS_PRINT_QUEUE_FULL NT_STATUS(0xC0000000 | 0x00c6) +#define NT_STATUS_NO_SPOOL_SPACE NT_STATUS(0xC0000000 | 0x00c7) +#define NT_STATUS_PRINT_CANCELLED NT_STATUS(0xC0000000 | 0x00c8) +#define NT_STATUS_NETWORK_NAME_DELETED NT_STATUS(0xC0000000 | 0x00c9) +#define NT_STATUS_NETWORK_ACCESS_DENIED NT_STATUS(0xC0000000 | 0x00ca) +#define NT_STATUS_BAD_DEVICE_TYPE NT_STATUS(0xC0000000 | 0x00cb) +#define NT_STATUS_BAD_NETWORK_NAME NT_STATUS(0xC0000000 | 0x00cc) +#define NT_STATUS_TOO_MANY_NAMES NT_STATUS(0xC0000000 | 0x00cd) +#define NT_STATUS_TOO_MANY_SESSIONS NT_STATUS(0xC0000000 | 0x00ce) +#define NT_STATUS_SHARING_PAUSED NT_STATUS(0xC0000000 | 0x00cf) +#define NT_STATUS_REQUEST_NOT_ACCEPTED NT_STATUS(0xC0000000 | 0x00d0) +#define NT_STATUS_REDIRECTOR_PAUSED NT_STATUS(0xC0000000 | 0x00d1) +#define NT_STATUS_NET_WRITE_FAULT NT_STATUS(0xC0000000 | 0x00d2) +#define NT_STATUS_PROFILING_AT_LIMIT NT_STATUS(0xC0000000 | 0x00d3) +#define NT_STATUS_NOT_SAME_DEVICE NT_STATUS(0xC0000000 | 0x00d4) +#define NT_STATUS_FILE_RENAMED NT_STATUS(0xC0000000 | 0x00d5) +#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED NT_STATUS(0xC0000000 | 0x00d6) +#define NT_STATUS_NO_SECURITY_ON_OBJECT NT_STATUS(0xC0000000 | 0x00d7) +#define NT_STATUS_CANT_WAIT NT_STATUS(0xC0000000 | 0x00d8) +#define NT_STATUS_PIPE_EMPTY NT_STATUS(0xC0000000 | 0x00d9) +#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO NT_STATUS(0xC0000000 | 0x00da) +#define NT_STATUS_CANT_TERMINATE_SELF NT_STATUS(0xC0000000 | 0x00db) +#define NT_STATUS_INVALID_SERVER_STATE NT_STATUS(0xC0000000 | 0x00dc) +#define NT_STATUS_INVALID_DOMAIN_STATE NT_STATUS(0xC0000000 | 0x00dd) +#define NT_STATUS_INVALID_DOMAIN_ROLE NT_STATUS(0xC0000000 | 0x00de) +#define NT_STATUS_NO_SUCH_DOMAIN NT_STATUS(0xC0000000 | 0x00df) +#define NT_STATUS_DOMAIN_EXISTS NT_STATUS(0xC0000000 | 0x00e0) +#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED NT_STATUS(0xC0000000 | 0x00e1) +#define NT_STATUS_OPLOCK_NOT_GRANTED NT_STATUS(0xC0000000 | 0x00e2) +#define NT_STATUS_INVALID_OPLOCK_PROTOCOL NT_STATUS(0xC0000000 | 0x00e3) +#define NT_STATUS_INTERNAL_DB_CORRUPTION NT_STATUS(0xC0000000 | 0x00e4) +#define NT_STATUS_INTERNAL_ERROR NT_STATUS(0xC0000000 | 0x00e5) +#define NT_STATUS_GENERIC_NOT_MAPPED NT_STATUS(0xC0000000 | 0x00e6) +#define NT_STATUS_BAD_DESCRIPTOR_FORMAT NT_STATUS(0xC0000000 | 0x00e7) +#define NT_STATUS_INVALID_USER_BUFFER NT_STATUS(0xC0000000 | 0x00e8) +#define NT_STATUS_UNEXPECTED_IO_ERROR NT_STATUS(0xC0000000 | 0x00e9) +#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR NT_STATUS(0xC0000000 | 0x00ea) +#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR NT_STATUS(0xC0000000 | 0x00eb) +#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR NT_STATUS(0xC0000000 | 0x00ec) +#define NT_STATUS_NOT_LOGON_PROCESS NT_STATUS(0xC0000000 | 0x00ed) +#define NT_STATUS_LOGON_SESSION_EXISTS NT_STATUS(0xC0000000 | 0x00ee) +#define NT_STATUS_INVALID_PARAMETER_1 NT_STATUS(0xC0000000 | 0x00ef) +#define NT_STATUS_INVALID_PARAMETER_2 NT_STATUS(0xC0000000 | 0x00f0) +#define NT_STATUS_INVALID_PARAMETER_3 NT_STATUS(0xC0000000 | 0x00f1) +#define NT_STATUS_INVALID_PARAMETER_4 NT_STATUS(0xC0000000 | 0x00f2) +#define NT_STATUS_INVALID_PARAMETER_5 NT_STATUS(0xC0000000 | 0x00f3) +#define NT_STATUS_INVALID_PARAMETER_6 NT_STATUS(0xC0000000 | 0x00f4) +#define NT_STATUS_INVALID_PARAMETER_7 NT_STATUS(0xC0000000 | 0x00f5) +#define NT_STATUS_INVALID_PARAMETER_8 NT_STATUS(0xC0000000 | 0x00f6) +#define NT_STATUS_INVALID_PARAMETER_9 NT_STATUS(0xC0000000 | 0x00f7) +#define NT_STATUS_INVALID_PARAMETER_10 NT_STATUS(0xC0000000 | 0x00f8) +#define NT_STATUS_INVALID_PARAMETER_11 NT_STATUS(0xC0000000 | 0x00f9) +#define NT_STATUS_INVALID_PARAMETER_12 NT_STATUS(0xC0000000 | 0x00fa) +#define NT_STATUS_REDIRECTOR_NOT_STARTED NT_STATUS(0xC0000000 | 0x00fb) +#define NT_STATUS_REDIRECTOR_STARTED NT_STATUS(0xC0000000 | 0x00fc) +#define NT_STATUS_STACK_OVERFLOW NT_STATUS(0xC0000000 | 0x00fd) +#define NT_STATUS_NO_SUCH_PACKAGE NT_STATUS(0xC0000000 | 0x00fe) +#define NT_STATUS_BAD_FUNCTION_TABLE NT_STATUS(0xC0000000 | 0x00ff) +#define NT_STATUS_DIRECTORY_NOT_EMPTY NT_STATUS(0xC0000000 | 0x0101) +#define NT_STATUS_FILE_CORRUPT_ERROR NT_STATUS(0xC0000000 | 0x0102) +#define NT_STATUS_NOT_A_DIRECTORY NT_STATUS(0xC0000000 | 0x0103) +#define NT_STATUS_BAD_LOGON_SESSION_STATE NT_STATUS(0xC0000000 | 0x0104) +#define NT_STATUS_LOGON_SESSION_COLLISION NT_STATUS(0xC0000000 | 0x0105) +#define NT_STATUS_NAME_TOO_LONG NT_STATUS(0xC0000000 | 0x0106) +#define NT_STATUS_FILES_OPEN NT_STATUS(0xC0000000 | 0x0107) +#define NT_STATUS_CONNECTION_IN_USE NT_STATUS(0xC0000000 | 0x0108) +#define NT_STATUS_MESSAGE_NOT_FOUND NT_STATUS(0xC0000000 | 0x0109) +#define NT_STATUS_PROCESS_IS_TERMINATING NT_STATUS(0xC0000000 | 0x010a) +#define NT_STATUS_INVALID_LOGON_TYPE NT_STATUS(0xC0000000 | 0x010b) +#define NT_STATUS_NO_GUID_TRANSLATION NT_STATUS(0xC0000000 | 0x010c) +#define NT_STATUS_CANNOT_IMPERSONATE NT_STATUS(0xC0000000 | 0x010d) +#define NT_STATUS_IMAGE_ALREADY_LOADED NT_STATUS(0xC0000000 | 0x010e) +#define NT_STATUS_ABIOS_NOT_PRESENT NT_STATUS(0xC0000000 | 0x010f) +#define NT_STATUS_ABIOS_LID_NOT_EXIST NT_STATUS(0xC0000000 | 0x0110) +#define NT_STATUS_ABIOS_LID_ALREADY_OWNED NT_STATUS(0xC0000000 | 0x0111) +#define NT_STATUS_ABIOS_NOT_LID_OWNER NT_STATUS(0xC0000000 | 0x0112) +#define NT_STATUS_ABIOS_INVALID_COMMAND NT_STATUS(0xC0000000 | 0x0113) +#define NT_STATUS_ABIOS_INVALID_LID NT_STATUS(0xC0000000 | 0x0114) +#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x0115) +#define NT_STATUS_ABIOS_INVALID_SELECTOR NT_STATUS(0xC0000000 | 0x0116) +#define NT_STATUS_NO_LDT NT_STATUS(0xC0000000 | 0x0117) +#define NT_STATUS_INVALID_LDT_SIZE NT_STATUS(0xC0000000 | 0x0118) +#define NT_STATUS_INVALID_LDT_OFFSET NT_STATUS(0xC0000000 | 0x0119) +#define NT_STATUS_INVALID_LDT_DESCRIPTOR NT_STATUS(0xC0000000 | 0x011a) +#define NT_STATUS_INVALID_IMAGE_NE_FORMAT NT_STATUS(0xC0000000 | 0x011b) +#define NT_STATUS_RXACT_INVALID_STATE NT_STATUS(0xC0000000 | 0x011c) +#define NT_STATUS_RXACT_COMMIT_FAILURE NT_STATUS(0xC0000000 | 0x011d) +#define NT_STATUS_MAPPED_FILE_SIZE_ZERO NT_STATUS(0xC0000000 | 0x011e) +#define NT_STATUS_TOO_MANY_OPENED_FILES NT_STATUS(0xC0000000 | 0x011f) +#define NT_STATUS_CANCELLED NT_STATUS(0xC0000000 | 0x0120) +#define NT_STATUS_CANNOT_DELETE NT_STATUS(0xC0000000 | 0x0121) +#define NT_STATUS_INVALID_COMPUTER_NAME NT_STATUS(0xC0000000 | 0x0122) +#define NT_STATUS_FILE_DELETED NT_STATUS(0xC0000000 | 0x0123) +#define NT_STATUS_SPECIAL_ACCOUNT NT_STATUS(0xC0000000 | 0x0124) +#define NT_STATUS_SPECIAL_GROUP NT_STATUS(0xC0000000 | 0x0125) +#define NT_STATUS_SPECIAL_USER NT_STATUS(0xC0000000 | 0x0126) +#define NT_STATUS_MEMBERS_PRIMARY_GROUP NT_STATUS(0xC0000000 | 0x0127) +#define NT_STATUS_FILE_CLOSED NT_STATUS(0xC0000000 | 0x0128) +#define NT_STATUS_TOO_MANY_THREADS NT_STATUS(0xC0000000 | 0x0129) +#define NT_STATUS_THREAD_NOT_IN_PROCESS NT_STATUS(0xC0000000 | 0x012a) +#define NT_STATUS_TOKEN_ALREADY_IN_USE NT_STATUS(0xC0000000 | 0x012b) +#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED NT_STATUS(0xC0000000 | 0x012c) +#define NT_STATUS_COMMITMENT_LIMIT NT_STATUS(0xC0000000 | 0x012d) +#define NT_STATUS_INVALID_IMAGE_LE_FORMAT NT_STATUS(0xC0000000 | 0x012e) +#define NT_STATUS_INVALID_IMAGE_NOT_MZ NT_STATUS(0xC0000000 | 0x012f) +#define NT_STATUS_INVALID_IMAGE_PROTECT NT_STATUS(0xC0000000 | 0x0130) +#define NT_STATUS_INVALID_IMAGE_WIN_16 NT_STATUS(0xC0000000 | 0x0131) +#define NT_STATUS_LOGON_SERVER_CONFLICT NT_STATUS(0xC0000000 | 0x0132) +#define NT_STATUS_TIME_DIFFERENCE_AT_DC NT_STATUS(0xC0000000 | 0x0133) +#define NT_STATUS_SYNCHRONIZATION_REQUIRED NT_STATUS(0xC0000000 | 0x0134) +#define NT_STATUS_DLL_NOT_FOUND NT_STATUS(0xC0000000 | 0x0135) +#define NT_STATUS_OPEN_FAILED NT_STATUS(0xC0000000 | 0x0136) +#define NT_STATUS_IO_PRIVILEGE_FAILED NT_STATUS(0xC0000000 | 0x0137) +#define NT_STATUS_ORDINAL_NOT_FOUND NT_STATUS(0xC0000000 | 0x0138) +#define NT_STATUS_ENTRYPOINT_NOT_FOUND NT_STATUS(0xC0000000 | 0x0139) +#define NT_STATUS_CONTROL_C_EXIT NT_STATUS(0xC0000000 | 0x013a) +#define NT_STATUS_LOCAL_DISCONNECT NT_STATUS(0xC0000000 | 0x013b) +#define NT_STATUS_REMOTE_DISCONNECT NT_STATUS(0xC0000000 | 0x013c) +#define NT_STATUS_REMOTE_RESOURCES NT_STATUS(0xC0000000 | 0x013d) +#define NT_STATUS_LINK_FAILED NT_STATUS(0xC0000000 | 0x013e) +#define NT_STATUS_LINK_TIMEOUT NT_STATUS(0xC0000000 | 0x013f) +#define NT_STATUS_INVALID_CONNECTION NT_STATUS(0xC0000000 | 0x0140) +#define NT_STATUS_INVALID_ADDRESS NT_STATUS(0xC0000000 | 0x0141) +#define NT_STATUS_DLL_INIT_FAILED NT_STATUS(0xC0000000 | 0x0142) +#define NT_STATUS_MISSING_SYSTEMFILE NT_STATUS(0xC0000000 | 0x0143) +#define NT_STATUS_UNHANDLED_EXCEPTION NT_STATUS(0xC0000000 | 0x0144) +#define NT_STATUS_APP_INIT_FAILURE NT_STATUS(0xC0000000 | 0x0145) +#define NT_STATUS_PAGEFILE_CREATE_FAILED NT_STATUS(0xC0000000 | 0x0146) +#define NT_STATUS_NO_PAGEFILE NT_STATUS(0xC0000000 | 0x0147) +#define NT_STATUS_INVALID_LEVEL NT_STATUS(0xC0000000 | 0x0148) +#define NT_STATUS_WRONG_PASSWORD_CORE NT_STATUS(0xC0000000 | 0x0149) +#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT NT_STATUS(0xC0000000 | 0x014a) +#define NT_STATUS_PIPE_BROKEN NT_STATUS(0xC0000000 | 0x014b) +#define NT_STATUS_REGISTRY_CORRUPT NT_STATUS(0xC0000000 | 0x014c) +#define NT_STATUS_REGISTRY_IO_FAILED NT_STATUS(0xC0000000 | 0x014d) +#define NT_STATUS_NO_EVENT_PAIR NT_STATUS(0xC0000000 | 0x014e) +#define NT_STATUS_UNRECOGNIZED_VOLUME NT_STATUS(0xC0000000 | 0x014f) +#define NT_STATUS_SERIAL_NO_DEVICE_INITED NT_STATUS(0xC0000000 | 0x0150) +#define NT_STATUS_NO_SUCH_ALIAS NT_STATUS(0xC0000000 | 0x0151) +#define NT_STATUS_MEMBER_NOT_IN_ALIAS NT_STATUS(0xC0000000 | 0x0152) +#define NT_STATUS_MEMBER_IN_ALIAS NT_STATUS(0xC0000000 | 0x0153) +#define NT_STATUS_ALIAS_EXISTS NT_STATUS(0xC0000000 | 0x0154) +#define NT_STATUS_LOGON_NOT_GRANTED NT_STATUS(0xC0000000 | 0x0155) +#define NT_STATUS_TOO_MANY_SECRETS NT_STATUS(0xC0000000 | 0x0156) +#define NT_STATUS_SECRET_TOO_LONG NT_STATUS(0xC0000000 | 0x0157) +#define NT_STATUS_INTERNAL_DB_ERROR NT_STATUS(0xC0000000 | 0x0158) +#define NT_STATUS_FULLSCREEN_MODE NT_STATUS(0xC0000000 | 0x0159) +#define NT_STATUS_TOO_MANY_CONTEXT_IDS NT_STATUS(0xC0000000 | 0x015a) +#define NT_STATUS_LOGON_TYPE_NOT_GRANTED NT_STATUS(0xC0000000 | 0x015b) +#define NT_STATUS_NOT_REGISTRY_FILE NT_STATUS(0xC0000000 | 0x015c) +#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED NT_STATUS(0xC0000000 | 0x015d) +#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR NT_STATUS(0xC0000000 | 0x015e) +#define NT_STATUS_FT_MISSING_MEMBER NT_STATUS(0xC0000000 | 0x015f) +#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY NT_STATUS(0xC0000000 | 0x0160) +#define NT_STATUS_ILLEGAL_CHARACTER NT_STATUS(0xC0000000 | 0x0161) +#define NT_STATUS_UNMAPPABLE_CHARACTER NT_STATUS(0xC0000000 | 0x0162) +#define NT_STATUS_UNDEFINED_CHARACTER NT_STATUS(0xC0000000 | 0x0163) +#define NT_STATUS_FLOPPY_VOLUME NT_STATUS(0xC0000000 | 0x0164) +#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND NT_STATUS(0xC0000000 | 0x0165) +#define NT_STATUS_FLOPPY_WRONG_CYLINDER NT_STATUS(0xC0000000 | 0x0166) +#define NT_STATUS_FLOPPY_UNKNOWN_ERROR NT_STATUS(0xC0000000 | 0x0167) +#define NT_STATUS_FLOPPY_BAD_REGISTERS NT_STATUS(0xC0000000 | 0x0168) +#define NT_STATUS_DISK_RECALIBRATE_FAILED NT_STATUS(0xC0000000 | 0x0169) +#define NT_STATUS_DISK_OPERATION_FAILED NT_STATUS(0xC0000000 | 0x016a) +#define NT_STATUS_DISK_RESET_FAILED NT_STATUS(0xC0000000 | 0x016b) +#define NT_STATUS_SHARED_IRQ_BUSY NT_STATUS(0xC0000000 | 0x016c) +#define NT_STATUS_FT_ORPHANING NT_STATUS(0xC0000000 | 0x016d) +#define NT_STATUS_PARTITION_FAILURE NT_STATUS(0xC0000000 | 0x0172) +#define NT_STATUS_INVALID_BLOCK_LENGTH NT_STATUS(0xC0000000 | 0x0173) +#define NT_STATUS_DEVICE_NOT_PARTITIONED NT_STATUS(0xC0000000 | 0x0174) +#define NT_STATUS_UNABLE_TO_LOCK_MEDIA NT_STATUS(0xC0000000 | 0x0175) +#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA NT_STATUS(0xC0000000 | 0x0176) +#define NT_STATUS_EOM_OVERFLOW NT_STATUS(0xC0000000 | 0x0177) +#define NT_STATUS_NO_MEDIA NT_STATUS(0xC0000000 | 0x0178) +#define NT_STATUS_NO_SUCH_MEMBER NT_STATUS(0xC0000000 | 0x017a) +#define NT_STATUS_INVALID_MEMBER NT_STATUS(0xC0000000 | 0x017b) +#define NT_STATUS_KEY_DELETED NT_STATUS(0xC0000000 | 0x017c) +#define NT_STATUS_NO_LOG_SPACE NT_STATUS(0xC0000000 | 0x017d) +#define NT_STATUS_TOO_MANY_SIDS NT_STATUS(0xC0000000 | 0x017e) +#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED NT_STATUS(0xC0000000 | 0x017f) +#define NT_STATUS_KEY_HAS_CHILDREN NT_STATUS(0xC0000000 | 0x0180) +#define NT_STATUS_CHILD_MUST_BE_VOLATILE NT_STATUS(0xC0000000 | 0x0181) +#define NT_STATUS_DEVICE_CONFIGURATION_ERROR NT_STATUS(0xC0000000 | 0x0182) +#define NT_STATUS_DRIVER_INTERNAL_ERROR NT_STATUS(0xC0000000 | 0x0183) +#define NT_STATUS_INVALID_DEVICE_STATE NT_STATUS(0xC0000000 | 0x0184) +#define NT_STATUS_IO_DEVICE_ERROR NT_STATUS(0xC0000000 | 0x0185) +#define NT_STATUS_DEVICE_PROTOCOL_ERROR NT_STATUS(0xC0000000 | 0x0186) +#define NT_STATUS_BACKUP_CONTROLLER NT_STATUS(0xC0000000 | 0x0187) +#define NT_STATUS_LOG_FILE_FULL NT_STATUS(0xC0000000 | 0x0188) +#define NT_STATUS_TOO_LATE NT_STATUS(0xC0000000 | 0x0189) +#define NT_STATUS_NO_TRUST_LSA_SECRET NT_STATUS(0xC0000000 | 0x018a) +#define NT_STATUS_NO_TRUST_SAM_ACCOUNT NT_STATUS(0xC0000000 | 0x018b) +#define NT_STATUS_TRUSTED_DOMAIN_FAILURE NT_STATUS(0xC0000000 | 0x018c) +#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE NT_STATUS(0xC0000000 | 0x018d) +#define NT_STATUS_EVENTLOG_FILE_CORRUPT NT_STATUS(0xC0000000 | 0x018e) +#define NT_STATUS_EVENTLOG_CANT_START NT_STATUS(0xC0000000 | 0x018f) +#define NT_STATUS_TRUST_FAILURE NT_STATUS(0xC0000000 | 0x0190) +#define NT_STATUS_MUTANT_LIMIT_EXCEEDED NT_STATUS(0xC0000000 | 0x0191) +#define NT_STATUS_NETLOGON_NOT_STARTED NT_STATUS(0xC0000000 | 0x0192) +#define NT_STATUS_ACCOUNT_EXPIRED NT_STATUS(0xC0000000 | 0x0193) +#define NT_STATUS_POSSIBLE_DEADLOCK NT_STATUS(0xC0000000 | 0x0194) +#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT NT_STATUS(0xC0000000 | 0x0195) +#define NT_STATUS_REMOTE_SESSION_LIMIT NT_STATUS(0xC0000000 | 0x0196) +#define NT_STATUS_EVENTLOG_FILE_CHANGED NT_STATUS(0xC0000000 | 0x0197) +#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT NT_STATUS(0xC0000000 | 0x0198) +#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT NT_STATUS(0xC0000000 | 0x0199) +#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT NT_STATUS(0xC0000000 | 0x019a) +#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT NT_STATUS(0xC0000000 | 0x019b) +#define NT_STATUS_FS_DRIVER_REQUIRED NT_STATUS(0xC0000000 | 0x019c) +#define NT_STATUS_NO_USER_SESSION_KEY NT_STATUS(0xC0000000 | 0x0202) +#define NT_STATUS_USER_SESSION_DELETED NT_STATUS(0xC0000000 | 0x0203) +#define NT_STATUS_RESOURCE_LANG_NOT_FOUND NT_STATUS(0xC0000000 | 0x0204) +#define NT_STATUS_INSUFF_SERVER_RESOURCES NT_STATUS(0xC0000000 | 0x0205) +#define NT_STATUS_INVALID_BUFFER_SIZE NT_STATUS(0xC0000000 | 0x0206) +#define NT_STATUS_INVALID_ADDRESS_COMPONENT NT_STATUS(0xC0000000 | 0x0207) +#define NT_STATUS_INVALID_ADDRESS_WILDCARD NT_STATUS(0xC0000000 | 0x0208) +#define NT_STATUS_TOO_MANY_ADDRESSES NT_STATUS(0xC0000000 | 0x0209) +#define NT_STATUS_ADDRESS_ALREADY_EXISTS NT_STATUS(0xC0000000 | 0x020a) +#define NT_STATUS_ADDRESS_CLOSED NT_STATUS(0xC0000000 | 0x020b) +#define NT_STATUS_CONNECTION_DISCONNECTED NT_STATUS(0xC0000000 | 0x020c) +#define NT_STATUS_CONNECTION_RESET NT_STATUS(0xC0000000 | 0x020d) +#define NT_STATUS_TOO_MANY_NODES NT_STATUS(0xC0000000 | 0x020e) +#define NT_STATUS_TRANSACTION_ABORTED NT_STATUS(0xC0000000 | 0x020f) +#define NT_STATUS_TRANSACTION_TIMED_OUT NT_STATUS(0xC0000000 | 0x0210) +#define NT_STATUS_TRANSACTION_NO_RELEASE NT_STATUS(0xC0000000 | 0x0211) +#define NT_STATUS_TRANSACTION_NO_MATCH NT_STATUS(0xC0000000 | 0x0212) +#define NT_STATUS_TRANSACTION_RESPONDED NT_STATUS(0xC0000000 | 0x0213) +#define NT_STATUS_TRANSACTION_INVALID_ID NT_STATUS(0xC0000000 | 0x0214) +#define NT_STATUS_TRANSACTION_INVALID_TYPE NT_STATUS(0xC0000000 | 0x0215) +#define NT_STATUS_NOT_SERVER_SESSION NT_STATUS(0xC0000000 | 0x0216) +#define NT_STATUS_NOT_CLIENT_SESSION NT_STATUS(0xC0000000 | 0x0217) +#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE NT_STATUS(0xC0000000 | 0x0218) +#define NT_STATUS_DEBUG_ATTACH_FAILED NT_STATUS(0xC0000000 | 0x0219) +#define NT_STATUS_SYSTEM_PROCESS_TERMINATED NT_STATUS(0xC0000000 | 0x021a) +#define NT_STATUS_DATA_NOT_ACCEPTED NT_STATUS(0xC0000000 | 0x021b) +#define NT_STATUS_NO_BROWSER_SERVERS_FOUND NT_STATUS(0xC0000000 | 0x021c) +#define NT_STATUS_VDM_HARD_ERROR NT_STATUS(0xC0000000 | 0x021d) +#define NT_STATUS_DRIVER_CANCEL_TIMEOUT NT_STATUS(0xC0000000 | 0x021e) +#define NT_STATUS_REPLY_MESSAGE_MISMATCH NT_STATUS(0xC0000000 | 0x021f) +#define NT_STATUS_MAPPED_ALIGNMENT NT_STATUS(0xC0000000 | 0x0220) +#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH NT_STATUS(0xC0000000 | 0x0221) +#define NT_STATUS_LOST_WRITEBEHIND_DATA NT_STATUS(0xC0000000 | 0x0222) +#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID NT_STATUS(0xC0000000 | 0x0223) +#define NT_STATUS_PASSWORD_MUST_CHANGE NT_STATUS(0xC0000000 | 0x0224) +#define NT_STATUS_NOT_FOUND NT_STATUS(0xC0000000 | 0x0225) +#define NT_STATUS_NOT_TINY_STREAM NT_STATUS(0xC0000000 | 0x0226) +#define NT_STATUS_RECOVERY_FAILURE NT_STATUS(0xC0000000 | 0x0227) +#define NT_STATUS_STACK_OVERFLOW_READ NT_STATUS(0xC0000000 | 0x0228) +#define NT_STATUS_FAIL_CHECK NT_STATUS(0xC0000000 | 0x0229) +#define NT_STATUS_DUPLICATE_OBJECTID NT_STATUS(0xC0000000 | 0x022a) +#define NT_STATUS_OBJECTID_EXISTS NT_STATUS(0xC0000000 | 0x022b) +#define NT_STATUS_CONVERT_TO_LARGE NT_STATUS(0xC0000000 | 0x022c) +#define NT_STATUS_RETRY NT_STATUS(0xC0000000 | 0x022d) +#define NT_STATUS_FOUND_OUT_OF_SCOPE NT_STATUS(0xC0000000 | 0x022e) +#define NT_STATUS_ALLOCATE_BUCKET NT_STATUS(0xC0000000 | 0x022f) +#define NT_STATUS_PROPSET_NOT_FOUND NT_STATUS(0xC0000000 | 0x0230) +#define NT_STATUS_MARSHALL_OVERFLOW NT_STATUS(0xC0000000 | 0x0231) +#define NT_STATUS_INVALID_VARIANT NT_STATUS(0xC0000000 | 0x0232) +#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND NT_STATUS(0xC0000000 | 0x0233) +#define NT_STATUS_ACCOUNT_LOCKED_OUT NT_STATUS(0xC0000000 | 0x0234) +#define NT_STATUS_HANDLE_NOT_CLOSABLE NT_STATUS(0xC0000000 | 0x0235) +#define NT_STATUS_CONNECTION_REFUSED NT_STATUS(0xC0000000 | 0x0236) +#define NT_STATUS_GRACEFUL_DISCONNECT NT_STATUS(0xC0000000 | 0x0237) +#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED NT_STATUS(0xC0000000 | 0x0238) +#define NT_STATUS_ADDRESS_NOT_ASSOCIATED NT_STATUS(0xC0000000 | 0x0239) +#define NT_STATUS_CONNECTION_INVALID NT_STATUS(0xC0000000 | 0x023a) +#define NT_STATUS_CONNECTION_ACTIVE NT_STATUS(0xC0000000 | 0x023b) +#define NT_STATUS_NETWORK_UNREACHABLE NT_STATUS(0xC0000000 | 0x023c) +#define NT_STATUS_HOST_UNREACHABLE NT_STATUS(0xC0000000 | 0x023d) +#define NT_STATUS_PROTOCOL_UNREACHABLE NT_STATUS(0xC0000000 | 0x023e) +#define NT_STATUS_PORT_UNREACHABLE NT_STATUS(0xC0000000 | 0x023f) +#define NT_STATUS_REQUEST_ABORTED NT_STATUS(0xC0000000 | 0x0240) +#define NT_STATUS_CONNECTION_ABORTED NT_STATUS(0xC0000000 | 0x0241) +#define NT_STATUS_BAD_COMPRESSION_BUFFER NT_STATUS(0xC0000000 | 0x0242) +#define NT_STATUS_USER_MAPPED_FILE NT_STATUS(0xC0000000 | 0x0243) +#define NT_STATUS_AUDIT_FAILED NT_STATUS(0xC0000000 | 0x0244) +#define NT_STATUS_TIMER_RESOLUTION_NOT_SET NT_STATUS(0xC0000000 | 0x0245) +#define NT_STATUS_CONNECTION_COUNT_LIMIT NT_STATUS(0xC0000000 | 0x0246) +#define NT_STATUS_LOGIN_TIME_RESTRICTION NT_STATUS(0xC0000000 | 0x0247) +#define NT_STATUS_LOGIN_WKSTA_RESTRICTION NT_STATUS(0xC0000000 | 0x0248) +#define NT_STATUS_IMAGE_MP_UP_MISMATCH NT_STATUS(0xC0000000 | 0x0249) +#define NT_STATUS_INSUFFICIENT_LOGON_INFO NT_STATUS(0xC0000000 | 0x0250) +#define NT_STATUS_BAD_DLL_ENTRYPOINT NT_STATUS(0xC0000000 | 0x0251) +#define NT_STATUS_BAD_SERVICE_ENTRYPOINT NT_STATUS(0xC0000000 | 0x0252) +#define NT_STATUS_LPC_REPLY_LOST NT_STATUS(0xC0000000 | 0x0253) +#define NT_STATUS_IP_ADDRESS_CONFLICT1 NT_STATUS(0xC0000000 | 0x0254) +#define NT_STATUS_IP_ADDRESS_CONFLICT2 NT_STATUS(0xC0000000 | 0x0255) +#define NT_STATUS_REGISTRY_QUOTA_LIMIT NT_STATUS(0xC0000000 | 0x0256) +#define NT_STATUS_PATH_NOT_COVERED NT_STATUS(0xC0000000 | 0x0257) +#define NT_STATUS_NO_CALLBACK_ACTIVE NT_STATUS(0xC0000000 | 0x0258) +#define NT_STATUS_LICENSE_QUOTA_EXCEEDED NT_STATUS(0xC0000000 | 0x0259) +#define NT_STATUS_PWD_TOO_SHORT NT_STATUS(0xC0000000 | 0x025a) +#define NT_STATUS_PWD_TOO_RECENT NT_STATUS(0xC0000000 | 0x025b) +#define NT_STATUS_PWD_HISTORY_CONFLICT NT_STATUS(0xC0000000 | 0x025c) +#define NT_STATUS_PLUGPLAY_NO_DEVICE NT_STATUS(0xC0000000 | 0x025e) +#define NT_STATUS_UNSUPPORTED_COMPRESSION NT_STATUS(0xC0000000 | 0x025f) +#define NT_STATUS_INVALID_HW_PROFILE NT_STATUS(0xC0000000 | 0x0260) +#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH NT_STATUS(0xC0000000 | 0x0261) +#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND NT_STATUS(0xC0000000 | 0x0262) +#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND NT_STATUS(0xC0000000 | 0x0263) +#define NT_STATUS_RESOURCE_NOT_OWNED NT_STATUS(0xC0000000 | 0x0264) +#define NT_STATUS_TOO_MANY_LINKS NT_STATUS(0xC0000000 | 0x0265) +#define NT_STATUS_QUOTA_LIST_INCONSISTENT NT_STATUS(0xC0000000 | 0x0266) +#define NT_STATUS_FILE_IS_OFFLINE NT_STATUS(0xC0000000 | 0x0267) +#define NT_STATUS_NOT_A_REPARSE_POINT NT_STATUS(0xC0000000 | 0x0275) +#define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE) /* scheduler */ +#define NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x20004) +#define NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX NT_STATUS(0xC0000000 | 0x20026) + + +/* I use NT_STATUS_FOOBAR when I have no idea what error code to use - + * this means we need a torture test */ +#define NT_STATUS_FOOBAR NT_STATUS_UNSUCCESSFUL + +#endif /* _NTERR_H */ -- cgit From 4ac2be99588b48b0652a524bf12fb1aa9c3f5fbb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 7 Mar 2006 11:07:23 +0000 Subject: r13924: Split more prototypes out of include/proto.h + initial work on header file dependencies (This used to be commit 122835876748a3eaf5e8d31ad1abddab9acb8781) --- source4/libcli/util/clilsa.c | 1 + source4/libcli/util/nt_status.h | 127 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 source4/libcli/util/nt_status.h (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index bf5048b02a..97aa7e13ac 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -29,6 +29,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" #include "libcli/libcli.h" +#include "libcli/security/proto.h" #include "librpc/gen_ndr/ndr_lsa.h" struct smblsa_state { diff --git a/source4/libcli/util/nt_status.h b/source4/libcli/util/nt_status.h new file mode 100644 index 0000000000..a805a1cfbd --- /dev/null +++ b/source4/libcli/util/nt_status.h @@ -0,0 +1,127 @@ +/* + Unix SMB/CIFS implementation. + SMB parameters and setup, plus a whole lot more. + + Copyright (C) Andrew Tridgell 2001 + + 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. +*/ + +#ifndef _NT_STATUS_H +#define _NT_STATUS_H + +/* The Splint code analysis tool doesn't like immediate structures. */ + +#ifdef _SPLINT_ /* http://www.splint.org */ +#undef HAVE_IMMEDIATE_STRUCTURES +#endif + +/* the following rather strange looking definitions of NTSTATUS and WERROR + and there in order to catch common coding errors where different error types + are mixed up. This is especially important as we slowly convert Samba + from using BOOL for internal functions +*/ + +#if defined(HAVE_IMMEDIATE_STRUCTURES) +typedef struct {uint32_t v;} NTSTATUS; +#define NT_STATUS(x) ((NTSTATUS) { x }) +#define NT_STATUS_V(x) ((x).v) +#else +typedef uint32_t NTSTATUS; +#define NT_STATUS(x) (x) +#define NT_STATUS_V(x) (x) +#endif + +#if defined(HAVE_IMMEDIATE_STRUCTURES) +typedef struct {uint32_t v;} WERROR; +#define W_ERROR(x) ((WERROR) { x }) +#define W_ERROR_V(x) ((x).v) +#else +typedef uint32_t WERROR; +#define W_ERROR(x) (x) +#define W_ERROR_V(x) (x) +#endif + +#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0) +#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000) +/* checking for DOS error mapping here is ugly, but unfortunately the + alternative is a very intrusive rewrite of the torture code */ +#define NT_STATUS_EQUAL(x,y) (NT_STATUS_IS_DOS(x)||NT_STATUS_IS_DOS(y)?ntstatus_dos_equal(x,y):NT_STATUS_V(x) == NT_STATUS_V(y)) + +#define NT_STATUS_HAVE_NO_MEMORY(x) do { \ + if (!(x)) {\ + return NT_STATUS_NO_MEMORY;\ + }\ +} while (0) + +#define NT_STATUS_IS_OK_RETURN(x) do { \ + if (NT_STATUS_IS_OK(x)) {\ + return x;\ + }\ +} while (0) + +#define NT_STATUS_NOT_OK_RETURN(x) do { \ + if (!NT_STATUS_IS_OK(x)) {\ + return x;\ + }\ +} while (0) + +#define NT_STATUS_IS_ERR_RETURN(x) do { \ + if (NT_STATUS_IS_ERR(x)) {\ + return x;\ + }\ +} while (0) + +#define NT_STATUS_NOT_ERR_RETURN(x) do { \ + if (!NT_STATUS_IS_ERR(x)) {\ + return x;\ + }\ +} while (0) + +#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0) +#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y)) + +#define W_ERROR_HAVE_NO_MEMORY(x) do { \ + if (!(x)) {\ + return WERR_NOMEM;\ + }\ +} while (0) + +#define W_ERROR_IS_OK_RETURN(x) do { \ + if (W_ERROR_IS_OK(x)) {\ + return x;\ + }\ +} while (0) + +#define W_ERROR_NOT_OK_RETURN(x) do { \ + if (!W_ERROR_IS_OK(x)) {\ + return x;\ + }\ +} while (0) + +/* this defines special NTSTATUS codes to represent DOS errors. I + have chosen this macro to produce status codes in the invalid + NTSTATUS range */ +#define NT_STATUS_DOS(class, code) NT_STATUS(0xF1000000 | ((class)<<16) | code) +#define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF1000000) +#define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF) +#define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF) + +/* define ldap error codes as NTSTATUS codes */ +#define NT_STATUS_LDAP(code) NT_STATUS(0xF2000000 | code) +#define NT_STATUS_IS_LDAP(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF2000000) +#define NT_STATUS_LDAP_CODE(status) (NT_STATUS_V(status) & ~0xFF000000) + +#endif -- cgit From 1060f6b3f621cb70b075a879f129e57f10fdbf8a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 14 Mar 2006 23:35:30 +0000 Subject: r14402: Generate seperate headers for RPC client functions. (This used to be commit 7054ebf0249930843a2baf4d023ae8f62cedb109) --- source4/libcli/util/clilsa.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 97aa7e13ac..7cafef829a 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -31,6 +31,7 @@ #include "libcli/libcli.h" #include "libcli/security/proto.h" #include "librpc/gen_ndr/ndr_lsa.h" +#include "librpc/gen_ndr/ndr_lsa_c.h" struct smblsa_state { struct dcerpc_pipe *pipe; -- cgit From 8528016978b084213ef53d66e1b6e831b1a01acc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 00:23:11 +0000 Subject: r14464: Don't include ndr_BASENAME.h files unless strictly required, instead try to include just the BASENAME.h files (containing only structs) (This used to be commit 3dd477ca5147f28a962b8437e2611a8222d706bd) --- source4/libcli/util/clilsa.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 7cafef829a..f1f0f01c1d 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -31,6 +31,7 @@ #include "libcli/libcli.h" #include "libcli/security/proto.h" #include "librpc/gen_ndr/ndr_lsa.h" +#include "librpc/gen_ndr/ndr_security.h" #include "librpc/gen_ndr/ndr_lsa_c.h" struct smblsa_state { -- cgit From 4f1c8daa36a7a0372c5fd9eab51f3c16ee81c49d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 12:43:28 +0000 Subject: r14470: Remove some unnecessary headers. (This used to be commit f7312dab3b9aba2b2b82e8a6e0c483a32a03a63a) --- source4/libcli/util/clilsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index f1f0f01c1d..fab392ac04 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -30,8 +30,8 @@ #include "libcli/raw/libcliraw.h" #include "libcli/libcli.h" #include "libcli/security/proto.h" -#include "librpc/gen_ndr/ndr_lsa.h" #include "librpc/gen_ndr/ndr_security.h" +#include "librpc/gen_ndr/ndr_lsa.h" #include "librpc/gen_ndr/ndr_lsa_c.h" struct smblsa_state { -- cgit From 2438b90b32716a07589ccb5d747969c2bce974de Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 13:19:31 +0000 Subject: r14473: Modern splint has no problems with immediate structures. (This used to be commit 6046dd822078cf5daa1a00c90fab998608e6872a) --- source4/libcli/util/nt_status.h | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nt_status.h b/source4/libcli/util/nt_status.h index a805a1cfbd..fe1dbf866d 100644 --- a/source4/libcli/util/nt_status.h +++ b/source4/libcli/util/nt_status.h @@ -22,37 +22,19 @@ #ifndef _NT_STATUS_H #define _NT_STATUS_H -/* The Splint code analysis tool doesn't like immediate structures. */ - -#ifdef _SPLINT_ /* http://www.splint.org */ -#undef HAVE_IMMEDIATE_STRUCTURES -#endif - /* the following rather strange looking definitions of NTSTATUS and WERROR and there in order to catch common coding errors where different error types are mixed up. This is especially important as we slowly convert Samba from using BOOL for internal functions */ -#if defined(HAVE_IMMEDIATE_STRUCTURES) typedef struct {uint32_t v;} NTSTATUS; #define NT_STATUS(x) ((NTSTATUS) { x }) #define NT_STATUS_V(x) ((x).v) -#else -typedef uint32_t NTSTATUS; -#define NT_STATUS(x) (x) -#define NT_STATUS_V(x) (x) -#endif -#if defined(HAVE_IMMEDIATE_STRUCTURES) typedef struct {uint32_t v;} WERROR; #define W_ERROR(x) ((WERROR) { x }) #define W_ERROR_V(x) ((x).v) -#else -typedef uint32_t WERROR; -#define W_ERROR(x) (x) -#define W_ERROR_V(x) (x) -#endif #define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0) #define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000) -- cgit From 2d558d5e195bc35f7af2bd1d2150bf9882d0cc24 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 17 Mar 2006 01:36:32 +0000 Subject: r14498: Revert part of my commit that removed support for compilers that don't support immediate structures (This used to be commit 657a893b25bc6669f016a9d251e07120d025f436) --- source4/libcli/util/nt_status.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nt_status.h b/source4/libcli/util/nt_status.h index fe1dbf866d..06aeaa3dac 100644 --- a/source4/libcli/util/nt_status.h +++ b/source4/libcli/util/nt_status.h @@ -28,13 +28,25 @@ from using BOOL for internal functions */ +#if defined(HAVE_IMMEDIATE_STRUCTURES) typedef struct {uint32_t v;} NTSTATUS; #define NT_STATUS(x) ((NTSTATUS) { x }) #define NT_STATUS_V(x) ((x).v) +#else +typedef uint32_t NTSTATUS; +#define NT_STATUS(x) (x) +#define NT_STATUS_V(x) (x) +#endif +#if defined(HAVE_IMMEDIATE_STRUCTURES) typedef struct {uint32_t v;} WERROR; #define W_ERROR(x) ((WERROR) { x }) #define W_ERROR_V(x) ((x).v) +#else +typedef uint32_t WERROR; +#define W_ERROR(x) (x) +#define W_ERROR_V(x) (x) +#endif #define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0) #define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000) -- cgit From 935af3eb1963761b4c8fd9e0e9902ad592f948bf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 25 Mar 2006 18:47:47 +0000 Subject: r14724: Rearrange some source files, install more headers. (This used to be commit 7146c1600f29c349e5bb78f810e7e170b535dd37) --- source4/libcli/util/asn_1.h | 2 + source4/libcli/util/error.h | 27 +++ source4/libcli/util/smbdes.c | 381 ------------------------------------------- 3 files changed, 29 insertions(+), 381 deletions(-) create mode 100644 source4/libcli/util/error.h delete mode 100644 source4/libcli/util/smbdes.c (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn_1.h b/source4/libcli/util/asn_1.h index 2dc9bef06d..7033f92a7f 100644 --- a/source4/libcli/util/asn_1.h +++ b/source4/libcli/util/asn_1.h @@ -50,4 +50,6 @@ struct asn1_data { #define ASN1_MAX_OIDS 20 +#include "libcli/util/asn1_proto.h" + #endif /* _ASN_1_H */ diff --git a/source4/libcli/util/error.h b/source4/libcli/util/error.h new file mode 100644 index 0000000000..4aa1ff6a40 --- /dev/null +++ b/source4/libcli/util/error.h @@ -0,0 +1,27 @@ +/* + Unix SMB/CIFS implementation. + Error handling code + + 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. +*/ + +#ifndef _SAMBA_ERROR_H_ +#define _SAMBA_ERROR_H_ + +#include "libcli/util/nterr.h" +#include "libcli/util/doserr.h" +#include "libcli/util/proto.h" + +#endif /* _SAMBA_ERROR_H */ diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c deleted file mode 100644 index d392109b1e..0000000000 --- a/source4/libcli/util/smbdes.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - a partial implementation of DES designed for use in the - SMB authentication protocol - - Copyright (C) Andrew Tridgell 1998 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" - -/* NOTES: - - This code makes no attempt to be fast! In fact, it is a very - slow implementation - - This code is NOT a complete DES implementation. It implements only - the minimum necessary for SMB authentication, as used by all SMB - products (including every copy of Microsoft Windows95 ever sold) - - In particular, it can only do a unchained forward DES pass. This - means it is not possible to use this code for encryption/decryption - of data, instead it is only useful as a "hash" algorithm. - - There is no entry point into this code that allows normal DES operation. - - I believe this means that this code does not come under ITAR - regulations but this is NOT a legal opinion. If you are concerned - about the applicability of ITAR regulations to this code then you - should confirm it for yourself (and maybe let me know if you come - up with a different answer to the one above) -*/ - - -static const uint8_t perm1[56] = {57, 49, 41, 33, 25, 17, 9, - 1, 58, 50, 42, 34, 26, 18, - 10, 2, 59, 51, 43, 35, 27, - 19, 11, 3, 60, 52, 44, 36, - 63, 55, 47, 39, 31, 23, 15, - 7, 62, 54, 46, 38, 30, 22, - 14, 6, 61, 53, 45, 37, 29, - 21, 13, 5, 28, 20, 12, 4}; - -static const uint8_t perm2[48] = {14, 17, 11, 24, 1, 5, - 3, 28, 15, 6, 21, 10, - 23, 19, 12, 4, 26, 8, - 16, 7, 27, 20, 13, 2, - 41, 52, 31, 37, 47, 55, - 30, 40, 51, 45, 33, 48, - 44, 49, 39, 56, 34, 53, - 46, 42, 50, 36, 29, 32}; - -static const uint8_t perm3[64] = {58, 50, 42, 34, 26, 18, 10, 2, - 60, 52, 44, 36, 28, 20, 12, 4, - 62, 54, 46, 38, 30, 22, 14, 6, - 64, 56, 48, 40, 32, 24, 16, 8, - 57, 49, 41, 33, 25, 17, 9, 1, - 59, 51, 43, 35, 27, 19, 11, 3, - 61, 53, 45, 37, 29, 21, 13, 5, - 63, 55, 47, 39, 31, 23, 15, 7}; - -static const uint8_t perm4[48] = { 32, 1, 2, 3, 4, 5, - 4, 5, 6, 7, 8, 9, - 8, 9, 10, 11, 12, 13, - 12, 13, 14, 15, 16, 17, - 16, 17, 18, 19, 20, 21, - 20, 21, 22, 23, 24, 25, - 24, 25, 26, 27, 28, 29, - 28, 29, 30, 31, 32, 1}; - -static const uint8_t perm5[32] = { 16, 7, 20, 21, - 29, 12, 28, 17, - 1, 15, 23, 26, - 5, 18, 31, 10, - 2, 8, 24, 14, - 32, 27, 3, 9, - 19, 13, 30, 6, - 22, 11, 4, 25}; - - -static const uint8_t perm6[64] ={ 40, 8, 48, 16, 56, 24, 64, 32, - 39, 7, 47, 15, 55, 23, 63, 31, - 38, 6, 46, 14, 54, 22, 62, 30, - 37, 5, 45, 13, 53, 21, 61, 29, - 36, 4, 44, 12, 52, 20, 60, 28, - 35, 3, 43, 11, 51, 19, 59, 27, - 34, 2, 42, 10, 50, 18, 58, 26, - 33, 1, 41, 9, 49, 17, 57, 25}; - - -static const uint8_t sc[16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1}; - -static const uint8_t sbox[8][4][16] = { - {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7}, - {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8}, - {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0}, - {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}}, - - {{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10}, - {3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5}, - {0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15}, - {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}}, - - {{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8}, - {13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1}, - {13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7}, - {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}}, - - {{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15}, - {13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9}, - {10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4}, - {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}}, - - {{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9}, - {14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6}, - {4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14}, - {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}}, - - {{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11}, - {10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8}, - {9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6}, - {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}}, - - {{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1}, - {13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6}, - {1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2}, - {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}}, - - {{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7}, - {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2}, - {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8}, - {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}}}; - -static void permute(char *out, const char *in, const uint8_t *p, int n) -{ - int i; - for (i=0;i>1; - key[1] = ((str[0]&0x01)<<6) | (str[1]>>2); - key[2] = ((str[1]&0x03)<<5) | (str[2]>>3); - key[3] = ((str[2]&0x07)<<4) | (str[3]>>4); - key[4] = ((str[3]&0x0F)<<3) | (str[4]>>5); - key[5] = ((str[4]&0x1F)<<2) | (str[5]>>6); - key[6] = ((str[5]&0x3F)<<1) | (str[6]>>7); - key[7] = str[6]&0x7F; - for (i=0;i<8;i++) { - key[i] = (key[i]<<1); - } -} - -/* - basic des crypt using a 56 bit (7 byte) key -*/ -void des_crypt56(uint8_t out[8], const uint8_t in[8], const uint8_t key[7], int forw) -{ - int i; - char outb[64]; - char inb[64]; - char keyb[64]; - uint8_t key2[8]; - - str_to_key(key, key2); - - for (i=0;i<64;i++) { - inb[i] = (in[i/8] & (1<<(7-(i%8)))) ? 1 : 0; - keyb[i] = (key2[i/8] & (1<<(7-(i%8)))) ? 1 : 0; - outb[i] = 0; - } - - dohash(outb, inb, keyb, forw); - - for (i=0;i<8;i++) { - out[i] = 0; - } - - for (i=0;i<64;i++) { - if (outb[i]) - out[i/8] |= (1<<(7-(i%8))); - } -} - -void E_P16(const uint8_t *p14,uint8_t *p16) -{ - const uint8_t sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; - des_crypt56(p16, sp8, p14, 1); - des_crypt56(p16+8, sp8, p14+7, 1); -} - -void E_P24(const uint8_t *p21, const uint8_t *c8, uint8_t *p24) -{ - des_crypt56(p24, c8, p21, 1); - des_crypt56(p24+8, c8, p21+7, 1); - des_crypt56(p24+16, c8, p21+14, 1); -} - -void D_P16(const uint8_t *p14, const uint8_t *in, uint8_t *out) -{ - des_crypt56(out, in, p14, 0); - des_crypt56(out+8, in+8, p14+7, 0); -} - -void E_old_pw_hash( uint8_t *p14, const uint8_t *in, uint8_t *out) -{ - des_crypt56(out, in, p14, 1); - des_crypt56(out+8, in+8, p14+7, 1); -} - -/* des encryption with a 128 bit key */ -void des_crypt128(uint8_t out[8], const uint8_t in[8], const uint8_t key[16]) -{ - uint8_t buf[8]; - des_crypt56(buf, in, key, 1); - des_crypt56(out, buf, key+9, 1); -} - -/* des encryption with a 64 bit key */ -void des_crypt64(uint8_t out[8], const uint8_t in[8], const uint8_t key[8], int forw) -{ - uint8_t buf[8]; - uint8_t key2[8]; - ZERO_STRUCT(key2); - des_crypt56(buf, in, key, forw); - key2[0] = key[7]; - des_crypt56(out, buf, key2, forw); -} - -/* des encryption with a 112 bit (14 byte) key */ -void des_crypt112(uint8_t out[8], const uint8_t in[8], const uint8_t key[14], int forw) -{ - uint8_t buf[8]; - des_crypt56(buf, in, key, forw); - des_crypt56(out, buf, key+7, forw); -} - -/* des encryption of a 16 byte lump of data with a 112 bit key */ -void des_crypt112_16(uint8_t out[16], uint8_t in[16], const uint8_t key[14], int forw) -{ - des_crypt56(out, in, key, forw); - des_crypt56(out + 8, in + 8, key+7, forw); -} - -/* Decode a sam password hash into a password. The password hash is the - same method used to store passwords in the NT registry. The DES key - used is based on the RID of the user. */ -void sam_rid_crypt(uint_t rid, const uint8_t *in, uint8_t *out, int forw) -{ - uint8_t s[14]; - - s[0] = s[4] = s[8] = s[12] = (uint8_t)(rid & 0xFF); - s[1] = s[5] = s[9] = s[13] = (uint8_t)((rid >> 8) & 0xFF); - s[2] = s[6] = s[10] = (uint8_t)((rid >> 16) & 0xFF); - s[3] = s[7] = s[11] = (uint8_t)((rid >> 24) & 0xFF); - - des_crypt56(out, in, s, forw); - des_crypt56(out+8, in+8, s+7, forw); -} -- cgit From 1af925f394b1084779f5b1b5a10c2ec512d7e5be Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 2 Apr 2006 12:02:01 +0000 Subject: r14860: create libcli/security/security.h metze (This used to be commit 9ec706238c173992dc938d537bdf1103bf519dbf) --- source4/libcli/util/clilsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index fab392ac04..f5e49dd577 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -29,7 +29,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" #include "libcli/libcli.h" -#include "libcli/security/proto.h" +#include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_security.h" #include "librpc/gen_ndr/ndr_lsa.h" #include "librpc/gen_ndr/ndr_lsa_c.h" -- cgit From 69e40fa99af88f5cf78409c6ac5ebe8ca611ccb2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 3 Apr 2006 06:43:30 +0000 Subject: r14876: added ENOSYS to unix error mapping (This used to be commit 77f32a273541afcd07f6da8a26315bf21ea05c51) --- source4/libcli/util/errormap.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index bbaac629e4..f4feaeffc5 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1337,6 +1337,9 @@ const struct unix_error_map unix_nt_errmap[] = { #endif #ifdef ENODEV { ENODEV, NT_STATUS_NO_SUCH_DEVICE }, +#endif +#ifdef ENOSYS + { ENOSYS, NT_STATUS_INVALID_SYSTEM_SERVICE }, #endif { 0, NT_STATUS_UNSUCCESSFUL } }; -- cgit From e002300f238dd0937dd9f768e366c006945e8baa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 29 Apr 2006 17:34:49 +0000 Subject: r15328: Move some functions around, remove dependencies. Remove some autogenerated headers (which had prototypes now autogenerated by pidl) Remove ndr_security.h from a few places - it's no longer necessary (This used to be commit c19c2b51d3e1ad347120b06a22bda5ec586c22e8) --- source4/libcli/util/clilsa.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index f5e49dd577..e491d1c9ee 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -30,7 +30,6 @@ #include "libcli/raw/libcliraw.h" #include "libcli/libcli.h" #include "libcli/security/security.h" -#include "librpc/gen_ndr/ndr_security.h" #include "librpc/gen_ndr/ndr_lsa.h" #include "librpc/gen_ndr/ndr_lsa_c.h" -- cgit From edee7dd8fd07659458cfc6d0e656a93a607a8e33 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 May 2006 15:16:46 +0000 Subject: r15661: add NT_STATUS_OBJECTID_NOT_FOUND metze (This used to be commit 2c9db9429106094b8ee9fa45e6f9a89af7c3725f) --- source4/libcli/util/nterr.c | 1 + source4/libcli/util/nterr.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 45d0181103..ef53e030c7 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -544,6 +544,7 @@ static const nt_err_code_struct nt_errs[] = { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES }, { "NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED", NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED }, { "NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX", NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX }, + { "NT_STATUS_OBJECTID_NOT_FOUND", NT_STATUS_OBJECTID_NOT_FOUND }, { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES }, { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED }, diff --git a/source4/libcli/util/nterr.h b/source4/libcli/util/nterr.h index 08e3fa2db0..29afa511d4 100644 --- a/source4/libcli/util/nterr.h +++ b/source4/libcli/util/nterr.h @@ -575,6 +575,7 @@ #define NT_STATUS_QUOTA_LIST_INCONSISTENT NT_STATUS(0xC0000000 | 0x0266) #define NT_STATUS_FILE_IS_OFFLINE NT_STATUS(0xC0000000 | 0x0267) #define NT_STATUS_NOT_A_REPARSE_POINT NT_STATUS(0xC0000000 | 0x0275) +#define NT_STATUS_OBJECTID_NOT_FOUND NT_STATUS(0xC0000000 | 0x02F0) #define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE) /* scheduler */ #define NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x20004) #define NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX NT_STATUS(0xC0000000 | 0x20026) -- cgit From 39fd6db42b4186f573ab4728509d6b8a7c8a6973 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 21 May 2006 12:57:36 +0000 Subject: r15775: add some privilege related WERROR codes metze (This used to be commit 4e8c9bbd768a0d3f8719d8f2005d9b1b527c44fd) --- source4/libcli/util/doserr.c | 2 ++ source4/libcli/util/doserr.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index e1ef9d930a..65e9470280 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -74,6 +74,8 @@ static const struct werror_code_struct dos_errs[] = { "WERR_INVALID_OWNER", WERR_INVALID_OWNER }, { "WERR_INVALID_COMPUTERNAME", WERR_INVALID_COMPUTERNAME }, { "WERR_INVALID_DOMAINNAME", WERR_INVALID_DOMAINNAME }, + { "WERR_NO_SUCH_PRIVILEGE", WERR_NO_SUCH_PRIVILEGE }, + { "WERR_PRIVILEGE_NOT_HELD", WERR_PRIVILEGE_NOT_HELD }, { "WERR_NO_SUCH_USER", WERR_NO_SUCH_USER }, { "WERR_NO_SUCH_DOMAIN", WERR_NO_SUCH_DOMAIN }, { "WERR_DS_SERVICE_BUSY", WERR_DS_SERVICE_BUSY }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 5b8ff1dd3d..601320f6fe 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -192,6 +192,8 @@ #define WERR_UNKNOWN_REVISION W_ERROR(1305) #define WERR_REVISION_MISMATCH W_ERROR(1306) #define WERR_INVALID_OWNER W_ERROR(1307) +#define WERR_NO_SUCH_PRIVILEGE W_ERROR(1313) +#define WERR_PRIVILEGE_NOT_HELD W_ERROR(1314) #define WERR_NO_SUCH_USER W_ERROR(1317) #define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338) #define WERR_NO_SUCH_DOMAIN W_ERROR(1355) -- cgit From 79183f68fc2bbe9094f9ab4e1bf7c5a3c8d5dd07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 22 May 2006 02:07:11 +0000 Subject: r15794: fixed a problem with DOS status codes - found by kukks (thanks!) (This used to be commit 1a57b16715bf8b82e8f9118c3ab401acf081d02c) --- source4/libcli/util/errormap.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index f4feaeffc5..e6a1c0e71c 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1198,6 +1198,11 @@ void ntstatus_to_dos(NTSTATUS ntstatus, uint8_t *eclass, uint32_t *ecode) *ecode = 0; return; } + if (NT_STATUS_IS_DOS(ntstatus)) { + *eclass = NT_STATUS_DOS_CLASS(ntstatus); + *ecode = NT_STATUS_DOS_CODE(ntstatus); + return; + } for (i=0; NT_STATUS_V(ntstatus_to_dos_map[i].ntstatus); i++) { if (NT_STATUS_V(ntstatus) == NT_STATUS_V(ntstatus_to_dos_map[i].ntstatus)) { -- cgit From 91e4f9f6d85eadf10130b21c8ca341d0ddd5094c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Jul 2006 16:42:09 +0000 Subject: r16801: Adding WERR_DS_DRA_ACCESS_DENIED. Guenther (This used to be commit 075242b97614202ee265577c9e5dd499e56bd768) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/doserr.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 65e9470280..8dd9181f7b 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -89,6 +89,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DS_SINGLE_VALUE_CONSTRAINT", WERR_DS_SINGLE_VALUE_CONSTRAINT }, { "WERR_DS_DRA_DB_ERROR", WERR_DS_DRA_DB_ERROR }, { "WERR_DS_DRA_NO_REPLICA", WERR_DS_DRA_NO_REPLICA }, + { "WERR_DS_DRA_ACCESS_DENIED", WERR_DS_DRA_ACCESS_DENIED }, { "WERR_DS_DNS_LOOKUP_FAILURE", WERR_DS_DNS_LOOKUP_FAILURE }, { "WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX", WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX }, { "WERR_GENERAL_FAILURE", WERR_GENERAL_FAILURE }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 601320f6fe..70442056e3 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -260,6 +260,7 @@ #define WERR_DS_SINGLE_VALUE_CONSTRAINT W_ERROR(0x00002081) #define WERR_DS_DRA_DB_ERROR W_ERROR(0x00002103) #define WERR_DS_DRA_NO_REPLICA W_ERROR(0x00002104) +#define WERR_DS_DRA_ACCESS_DENIED W_ERROR(0x00002105) #define WERR_DS_DNS_LOOKUP_FAILURE W_ERROR(0x0000214c) #define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX W_ERROR(0x00002150) -- cgit From d89b4adf7abdc74f23960dee3f4961006ac12be6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 11 Jul 2006 18:06:53 +0000 Subject: r16949: add and fix some NOTIFY return codes metze (This used to be commit e40d62363c2123fff37b35c1c7004e85a6786c2a) --- source4/libcli/util/nterr.c | 2 ++ source4/libcli/util/nterr.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index ef53e030c7..589d8627e6 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -547,6 +547,8 @@ static const nt_err_code_struct nt_errs[] = { "NT_STATUS_OBJECTID_NOT_FOUND", NT_STATUS_OBJECTID_NOT_FOUND }, { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES }, { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED }, + { "STATUS_NOTIFY_CLEANUP", STATUS_NOTIFY_CLEANUP }, + { "STATUS_NOTIFY_ENUM_DIR", STATUS_NOTIFY_ENUM_DIR }, DOS_CODE(ERRDOS, ERRsuccess), DOS_CODE(ERRDOS, ERRbadfunc), diff --git a/source4/libcli/util/nterr.h b/source4/libcli/util/nterr.h index 29afa511d4..baf15d80ef 100644 --- a/source4/libcli/util/nterr.h +++ b/source4/libcli/util/nterr.h @@ -37,9 +37,10 @@ #define STATUS_PENDING NT_STATUS(0x0103) #define STATUS_MORE_ENTRIES NT_STATUS(0x0105) #define STATUS_SOME_UNMAPPED NT_STATUS(0x0107) +#define STATUS_NOTIFY_CLEANUP NT_STATUS(0x010b) +#define STATUS_NOTIFY_ENUM_DIR NT_STATUS(0x010c) #define ERROR_INVALID_PARAMETER NT_STATUS(0x0057) #define ERROR_INSUFFICIENT_BUFFER NT_STATUS(0x007a) -#define STATUS_NOTIFY_ENUM_DIR NT_STATUS(0x010c) #define ERROR_INVALID_DATATYPE NT_STATUS(0x070c) /* Win32 Error codes extracted using a loop in smbclient then printing a -- cgit From 3455998edc03268b7b73c80cf1630127e5a3f8df Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 06:20:55 +0000 Subject: r17414: add new error code metze (This used to be commit e15a015a1d9aa3872271c0c5542e7d055a6f673a) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/doserr.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 8dd9181f7b..91a47bfbb5 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -86,6 +86,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DS_DRA_BAD_DN", WERR_DS_DRA_BAD_DN }, { "WERR_DS_DRA_BAD_NC", WERR_DS_DRA_BAD_NC }, { "WERR_DS_DRA_INTERNAL_ERROR", WERR_DS_DRA_INTERNAL_ERROR }, + { "WERR_DS_DRA_OUT_OF_MEM", WERR_DS_DRA_OUT_OF_MEM }, { "WERR_DS_SINGLE_VALUE_CONSTRAINT", WERR_DS_SINGLE_VALUE_CONSTRAINT }, { "WERR_DS_DRA_DB_ERROR", WERR_DS_DRA_DB_ERROR }, { "WERR_DS_DRA_NO_REPLICA", WERR_DS_DRA_NO_REPLICA }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 70442056e3..386735617a 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -257,6 +257,7 @@ #define WERR_DS_DRA_BAD_DN W_ERROR(0x000020f7) #define WERR_DS_DRA_BAD_NC W_ERROR(0x000020f8) #define WERR_DS_DRA_INTERNAL_ERROR W_ERROR(0x000020fa) +#define WERR_DS_DRA_OUT_OF_MEM W_ERROR(0x000020fe) #define WERR_DS_SINGLE_VALUE_CONSTRAINT W_ERROR(0x00002081) #define WERR_DS_DRA_DB_ERROR W_ERROR(0x00002103) #define WERR_DS_DRA_NO_REPLICA W_ERROR(0x00002104) -- cgit From b0a264f1ae1457910a66a118104d172d2e73637b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 16 Aug 2006 08:53:25 +0000 Subject: r17567: add error code I got from DsGetNCChanges when I don't use the DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION flag on DsBind metze (This used to be commit 8458ee72c5c1005ab80b9f7ea6efe617e5c76106) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/doserr.h | 3 +++ 2 files changed, 4 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 91a47bfbb5..c7d7053165 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -101,6 +101,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_CLASS_NOT_REGISTERED", WERR_CLASS_NOT_REGISTERED }, { "WERR_NO_SHUTDOWN_IN_PROGRESS", WERR_NO_SHUTDOWN_IN_PROGRESS }, { "WERR_SHUTDOWN_ALREADY_IN_PROGRESS", WERR_SHUTDOWN_ALREADY_IN_PROGRESS }, + { "WERR_SEC_E_ALGORITHM_MISMATCH", WERR_SEC_E_ALGORITHM_MISMATCH }, { NULL, W_ERROR(0) } }; diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 386735617a..32807da47c 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -265,6 +265,9 @@ #define WERR_DS_DNS_LOOKUP_FAILURE W_ERROR(0x0000214c) #define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX W_ERROR(0x00002150) +/* SEC errors */ +#define WERR_SEC_E_ALGORITHM_MISMATCH W_ERROR(0x80090331) + #define WERR_FOOBAR WERR_GENERAL_FAILURE #endif /* _DOSERR_H */ -- cgit From f3fd73ed52349a75890c30a7dfac72fa20618e3a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Sep 2006 20:44:54 +0000 Subject: r18633: Add a couple of new WERR codes encountered with dfs torture testing. Guenther (This used to be commit e2879f6fc21e5ca96b24ed11e4a460a0ebada8c3) --- source4/libcli/util/doserr.c | 7 ++++++- source4/libcli/util/doserr.h | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index c7d7053165..c0a4e2cb96 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -36,9 +36,10 @@ static const struct werror_code_struct dos_errs[] = { "WERR_BADFID", WERR_BADFID }, { "WERR_BADFUNC", WERR_BADFUNC }, { "WERR_BAD_NETPATH", WERR_BAD_NETPATH }, + { "WERR_UNEXP_NET_ERR", WERR_UNEXP_NET_ERR }, { "WERR_INSUFFICIENT_BUFFER", WERR_INSUFFICIENT_BUFFER }, { "WERR_NO_SUCH_SHARE", WERR_NO_SUCH_SHARE }, - { "WERR_ALREADY_EXISTS", WERR_ALREADY_EXISTS }, + { "WERR_FILE_EXISTS", WERR_FILE_EXISTS }, { "WERR_INVALID_PARAM", WERR_INVALID_PARAM }, { "WERR_NOT_SUPPORTED", WERR_NOT_SUPPORTED }, { "WERR_BAD_PASSWORD", WERR_BAD_PASSWORD }, @@ -46,6 +47,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_INVALID_NAME", WERR_INVALID_NAME }, { "WERR_UNKNOWN_LEVEL", WERR_UNKNOWN_LEVEL }, { "WERR_OBJECT_PATH_INVALID", WERR_OBJECT_PATH_INVALID }, + { "WERR_ALREADY_EXISTS", WERR_ALREADY_EXISTS }, { "WERR_NO_MORE_ITEMS", WERR_NO_MORE_ITEMS }, { "WERR_MORE_DATA", WERR_MORE_DATA }, { "WERR_UNKNOWN_PRINTER_DRIVER", WERR_UNKNOWN_PRINTER_DRIVER }, @@ -55,10 +57,12 @@ static const struct werror_code_struct dos_errs[] = { "WERR_INVALID_ENVIRONMENT", WERR_INVALID_ENVIRONMENT }, { "WERR_INVALID_FORM_NAME", WERR_INVALID_FORM_NAME }, { "WERR_INVALID_FORM_SIZE", WERR_INVALID_FORM_SIZE }, + { "WERR_ALREADY_SHARED", WERR_ALREADY_SHARED }, { "WERR_BUF_TOO_SMALL", WERR_BUF_TOO_SMALL }, { "WERR_JOB_NOT_FOUND", WERR_JOB_NOT_FOUND }, { "WERR_DEST_NOT_FOUND", WERR_DEST_NOT_FOUND }, { "WERR_NOT_LOCAL_DOMAIN", WERR_NOT_LOCAL_DOMAIN }, + { "WERR_DEVICE_NOT_AVAILABLE", WERR_DEVICE_NOT_AVAILABLE }, { "WERR_PRINTER_DRIVER_IN_USE", WERR_PRINTER_DRIVER_IN_USE }, { "WERR_STATUS_MORE_ENTRIES", WERR_STATUS_MORE_ENTRIES }, { "WERR_NET_NAME_NOT_FOUND", WERR_NET_NAME_NOT_FOUND }, @@ -97,6 +101,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_PRINTQ_FULL", WERR_PRINTQ_FULL }, { "WERR_NO_SPOOL_SPACE", WERR_NO_SPOOL_SPACE }, { "WERR_CAN_NOT_COMPLETE", WERR_CAN_NOT_COMPLETE }, + { "WERR_NOT_FOUND", WERR_NOT_FOUND }, { "WERR_SERVER_UNAVAILABLE", WERR_SERVER_UNAVAILABLE }, { "WERR_CLASS_NOT_REGISTERED", WERR_CLASS_NOT_REGISTERED }, { "WERR_NO_SHUTDOWN_IN_PROGRESS", WERR_NO_SHUTDOWN_IN_PROGRESS }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 32807da47c..d80cdd1052 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -174,19 +174,22 @@ #define WERR_GENERAL_FAILURE W_ERROR(31) #define WERR_NOT_SUPPORTED W_ERROR(50) #define WERR_BAD_NETPATH W_ERROR(53) +#define WERR_UNEXP_NET_ERR W_ERROR(59) #define WERR_PRINTQ_FULL W_ERROR(61) #define WERR_NO_SPOOL_SPACE W_ERROR(62) #define WERR_NO_SUCH_SHARE W_ERROR(67) -#define WERR_ALREADY_EXISTS W_ERROR(80) +#define WERR_FILE_EXISTS W_ERROR(80) #define WERR_BAD_PASSWORD W_ERROR(86) #define WERR_INVALID_PARAM W_ERROR(87) #define WERR_INSUFFICIENT_BUFFER W_ERROR(122) #define WERR_INVALID_NAME W_ERROR(123) #define WERR_UNKNOWN_LEVEL W_ERROR(124) #define WERR_OBJECT_PATH_INVALID W_ERROR(161) +#define WERR_ALREADY_EXISTS W_ERROR(183) #define WERR_NO_MORE_ITEMS W_ERROR(259) #define WERR_MORE_DATA W_ERROR(234) #define WERR_CAN_NOT_COMPLETE W_ERROR(1003) +#define WERR_NOT_FOUND W_ERROR(1168) #define WERR_INVALID_COMPUTERNAME W_ERROR(1210) #define WERR_INVALID_DOMAINNAME W_ERROR(1212) #define WERR_UNKNOWN_REVISION W_ERROR(1305) @@ -200,10 +203,12 @@ #define WERR_SERVER_UNAVAILABLE W_ERROR(1722) #define WERR_INVALID_FORM_NAME W_ERROR(1902) #define WERR_INVALID_FORM_SIZE W_ERROR(1903) +#define WERR_ALREADY_SHARED W_ERROR(2118) #define WERR_BUF_TOO_SMALL W_ERROR(2123) #define WERR_JOB_NOT_FOUND W_ERROR(2151) #define WERR_DEST_NOT_FOUND W_ERROR(2152) #define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320) +#define WERR_DEVICE_NOT_AVAILABLE W_ERROR(4319) #define WERR_STATUS_MORE_ENTRIES W_ERROR(0x0105) #define WERR_PRINTER_DRIVER_ALREADY_INSTALLED W_ERROR(ERRdriveralreadyinstalled) -- cgit From 333557e28fc1c1934756b96f08711e050568926f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 23 Sep 2006 19:04:39 +0000 Subject: r18847: Add WERR_NO_SYSTEM_RESOURCES showing up in dfs torture testing. Guenther (This used to be commit 692746ff8d1352a93a19ba9d537ca894a2ea186f) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/doserr.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index c0a4e2cb96..ed1700aeb0 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -82,6 +82,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_PRIVILEGE_NOT_HELD", WERR_PRIVILEGE_NOT_HELD }, { "WERR_NO_SUCH_USER", WERR_NO_SUCH_USER }, { "WERR_NO_SUCH_DOMAIN", WERR_NO_SUCH_DOMAIN }, + { "WERR_NO_SYSTEM_RESOURCES", WERR_NO_SYSTEM_RESOURCES }, { "WERR_DS_SERVICE_BUSY", WERR_DS_SERVICE_BUSY }, { "WERR_DS_SERVICE_UNAVAILABLE", WERR_DS_SERVICE_UNAVAILABLE }, { "WERR_DS_NO_SUCH_OBJECT", WERR_DS_NO_SUCH_OBJECT }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index d80cdd1052..d5a6b2e90d 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -200,6 +200,7 @@ #define WERR_NO_SUCH_USER W_ERROR(1317) #define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338) #define WERR_NO_SUCH_DOMAIN W_ERROR(1355) +#define WERR_NO_SYSTEM_RESOURCES W_ERROR(1450) #define WERR_SERVER_UNAVAILABLE W_ERROR(1722) #define WERR_INVALID_FORM_NAME W_ERROR(1902) #define WERR_INVALID_FORM_SIZE W_ERROR(1903) -- cgit From a0c614ede22e629eea267b54d3b1852fe9cc2aad Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 26 Sep 2006 11:27:09 +0000 Subject: r18916: fixed the messaging layer on *BSD systems. When a socket was full we were getting ENOBUFS, which mapped to NT_STATUS_NO_MEMORY, which in turn caused the messaging code to loop trying until it gave up. Now it correctly falls back to select. Messaging speed goes from 3 messages per second to over 7000 on my test vmware box. Not bad for a one line change :) (This used to be commit 6568f30adf980c572f9ffd6ff884336ebe652f90) --- source4/libcli/util/errormap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index e6a1c0e71c..2ff9803d39 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1278,7 +1278,7 @@ const struct unix_error_map unix_nt_errmap[] = { { ENOTSOCK, NT_STATUS_INVALID_HANDLE }, { EFAULT, NT_STATUS_INVALID_PARAMETER }, { EMSGSIZE, NT_STATUS_INVALID_BUFFER_SIZE }, - { ENOBUFS, NT_STATUS_NO_MEMORY }, + { ENOBUFS, STATUS_MORE_ENTRIES }, { ENOMEM, NT_STATUS_NO_MEMORY }, { EPIPE, NT_STATUS_CONNECTION_DISCONNECTED }, { ECONNREFUSED, NT_STATUS_CONNECTION_REFUSED }, -- cgit From bbe3cffb4b86439cccb39471ca386ee9321239ae Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Sep 2006 01:17:16 +0000 Subject: r18968: EWOULDBLOCK should also be mapped to STATUS_MORE_ENTRIES (This used to be commit 27114fe1752f20c58948b34264e38db263f7a0ea) --- source4/libcli/util/errormap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 2ff9803d39..1e90969f95 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1262,6 +1262,10 @@ struct unix_error_map { const struct unix_error_map unix_nt_errmap[] = { { EAGAIN, STATUS_MORE_ENTRIES }, { EINTR, STATUS_MORE_ENTRIES }, + { ENOBUFS, STATUS_MORE_ENTRIES }, +#ifdef EWOULDBLOCK + { EWOULDBLOCK, STATUS_MORE_ENTRIES }, +#endif { EINPROGRESS, NT_STATUS_MORE_PROCESSING_REQUIRED }, { EPERM, NT_STATUS_ACCESS_DENIED }, { EACCES, NT_STATUS_ACCESS_DENIED }, @@ -1278,7 +1282,6 @@ const struct unix_error_map unix_nt_errmap[] = { { ENOTSOCK, NT_STATUS_INVALID_HANDLE }, { EFAULT, NT_STATUS_INVALID_PARAMETER }, { EMSGSIZE, NT_STATUS_INVALID_BUFFER_SIZE }, - { ENOBUFS, STATUS_MORE_ENTRIES }, { ENOMEM, NT_STATUS_NO_MEMORY }, { EPIPE, NT_STATUS_CONNECTION_DISCONNECTED }, { ECONNREFUSED, NT_STATUS_CONNECTION_REFUSED }, -- cgit From 31454d2e8b70f7aca87099dba25abe790781c7a7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Sep 2006 04:45:15 +0000 Subject: r18989: Fixes found by these two LDAP testsuites: - http://www.ee.oulu.fi/research/ouspg/protos/testing/c06/ldapv3/ - http://gleg.net/protover_ldap_sample.shtml Also fixes found by a subsequent audit of the code for similar issues. (This used to be commit 441a4f6262459dabfefd9bb12622ada9c007a60c) --- source4/libcli/util/asn1.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index db3f7823fa..01c869dc17 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -396,6 +396,9 @@ BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag) nesting->start = data->ofs; nesting->next = data->nesting; data->nesting = nesting; + if (asn1_tag_remaining(data) == -1) { + return False; + } return !data->has_error; } @@ -426,11 +429,21 @@ BOOL asn1_end_tag(struct asn1_data *data) /* work out how many bytes are left in this nested tag */ int asn1_tag_remaining(struct asn1_data *data) { + int remaining; + if (data->has_error) { + return -1; + } + if (!data->nesting) { data->has_error = True; return -1; } - return data->nesting->taglen - (data->ofs - data->nesting->start); + remaining = data->nesting->taglen - (data->ofs - data->nesting->start); + if (remaining > (data->length - data->ofs)) { + data->has_error = True; + return -1; + } + return remaining; } /* read an object ID from a ASN1 buffer */ @@ -518,6 +531,10 @@ BOOL asn1_read_OctetString(struct asn1_data *data, DATA_BLOB *blob) return False; } *blob = data_blob(NULL, len+1); + if (!blob->data) { + data->has_error = True; + return False; + } asn1_read(data, blob->data, len); asn1_end_tag(data); blob->length--; @@ -542,6 +559,10 @@ BOOL asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blo return False; } *blob = data_blob(NULL, len); + if (!blob->data) { + data->has_error = True; + return False; + } asn1_read(data, blob->data, len); asn1_end_tag(data); return !data->has_error; -- cgit From 7c793e1bb74593357708e92dba6a99d89ac77c59 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 7 Oct 2006 05:28:14 +0000 Subject: r19162: Merge WERR code from Samba 3. Guenther (This used to be commit d9562e0f83d76043da7955e89b1fff8a1d921a36) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/doserr.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index ed1700aeb0..fe2b555ab6 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -78,6 +78,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_INVALID_OWNER", WERR_INVALID_OWNER }, { "WERR_INVALID_COMPUTERNAME", WERR_INVALID_COMPUTERNAME }, { "WERR_INVALID_DOMAINNAME", WERR_INVALID_DOMAINNAME }, + { "WERR_NO_LOGON_SERVERS", WERR_NO_LOGON_SERVERS }, { "WERR_NO_SUCH_PRIVILEGE", WERR_NO_SUCH_PRIVILEGE }, { "WERR_PRIVILEGE_NOT_HELD", WERR_PRIVILEGE_NOT_HELD }, { "WERR_NO_SUCH_USER", WERR_NO_SUCH_USER }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index d5a6b2e90d..0e1bcd4499 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -195,6 +195,7 @@ #define WERR_UNKNOWN_REVISION W_ERROR(1305) #define WERR_REVISION_MISMATCH W_ERROR(1306) #define WERR_INVALID_OWNER W_ERROR(1307) +#define WERR_NO_LOGON_SERVERS W_ERROR(1311) #define WERR_NO_SUCH_PRIVILEGE W_ERROR(1313) #define WERR_PRIVILEGE_NOT_HELD W_ERROR(1314) #define WERR_NO_SUCH_USER W_ERROR(1317) -- cgit From c7367e873e4896566fb2b954aaadeeef0b734b33 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Nov 2006 10:37:21 +0000 Subject: r19734: display LDAP error code nicer metze (This used to be commit a0a45c3326560b9b31d0e17f1439d2638e91aee0) --- source4/libcli/util/nterr.c | 53 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 6 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 589d8627e6..5b6e2b2b50 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -22,6 +22,7 @@ #include "includes.h" #include "pstring.h" +#include "libcli/ldap/ldap.h" typedef struct { @@ -30,6 +31,7 @@ typedef struct } nt_err_code_struct; #define DOS_CODE(class, code) { #class ":" #code, NT_STATUS_DOS(class, code) } +#define LDAP_CODE(code) { #code, NT_STATUS_LDAP(code) } static const nt_err_code_struct nt_errs[] = { @@ -671,6 +673,46 @@ static const nt_err_code_struct nt_errs[] = DOS_CODE(ERRHRD, ERRsharebufexc), DOS_CODE(ERRHRD, ERRdiskfull), + LDAP_CODE(LDAP_SUCCESS), + LDAP_CODE(LDAP_OPERATIONS_ERROR), + LDAP_CODE(LDAP_PROTOCOL_ERROR), + LDAP_CODE(LDAP_TIME_LIMIT_EXCEEDED), + LDAP_CODE(LDAP_SIZE_LIMIT_EXCEEDED), + LDAP_CODE(LDAP_COMPARE_FALSE), + LDAP_CODE(LDAP_COMPARE_TRUE), + LDAP_CODE(LDAP_AUTH_METHOD_NOT_SUPPORTED), + LDAP_CODE(LDAP_STRONG_AUTH_REQUIRED), + LDAP_CODE(LDAP_REFERRAL), + LDAP_CODE(LDAP_ADMIN_LIMIT_EXCEEDED), + LDAP_CODE(LDAP_UNAVAILABLE_CRITICAL_EXTENSION), + LDAP_CODE(LDAP_CONFIDENTIALITY_REQUIRED), + LDAP_CODE(LDAP_SASL_BIND_IN_PROGRESS), + LDAP_CODE(LDAP_NO_SUCH_ATTRIBUTE), + LDAP_CODE(LDAP_UNDEFINED_ATTRIBUTE_TYPE), + LDAP_CODE(LDAP_INAPPROPRIATE_MATCHING), + LDAP_CODE(LDAP_CONSTRAINT_VIOLATION), + LDAP_CODE(LDAP_ATTRIBUTE_OR_VALUE_EXISTS), + LDAP_CODE(LDAP_INVALID_ATTRIBUTE_SYNTAX), + LDAP_CODE(LDAP_NO_SUCH_OBJECT), + LDAP_CODE(LDAP_ALIAS_PROBLEM), + LDAP_CODE(LDAP_INVALID_DN_SYNTAX), + LDAP_CODE(LDAP_ALIAS_DEREFERENCING_PROBLEM), + LDAP_CODE(LDAP_INAPPROPRIATE_AUTHENTICATION), + LDAP_CODE(LDAP_INVALID_CREDENTIALS), + LDAP_CODE(LDAP_INSUFFICIENT_ACCESS_RIGHTs), + LDAP_CODE(LDAP_BUSY), + LDAP_CODE(LDAP_UNAVAILABLE), + LDAP_CODE(LDAP_UNWILLING_TO_PERFORM), + LDAP_CODE(LDAP_LOOP_DETECT), + LDAP_CODE(LDAP_NAMING_VIOLATION), + LDAP_CODE(LDAP_OBJECT_CLASS_VIOLATION), + LDAP_CODE(LDAP_NOT_ALLOWED_ON_NON_LEAF), + LDAP_CODE(LDAP_NOT_ALLOWED_ON_RDN), + LDAP_CODE(LDAP_ENTRY_ALREADY_EXISTS), + LDAP_CODE(LDAP_OBJECT_CLASS_MODS_PROHIBITED), + LDAP_CODE(LDAP_AFFECTS_MULTIPLE_DSAS), + LDAP_CODE(LDAP_OTHER), + { NULL, NT_STATUS(0) } }; @@ -772,7 +814,6 @@ static const nt_err_code_struct nt_err_desc[] = { NULL, NT_STATUS(0) } }; - /***************************************************************************** returns an NT error message. not amazingly helpful, but better than a number. *****************************************************************************/ @@ -781,11 +822,6 @@ const char *nt_errstr(NTSTATUS nt_code) static char msg[40]; int idx = 0; - if (NT_STATUS_IS_LDAP(nt_code)) { - slprintf(msg, sizeof(msg), "LDAP code %u", NT_STATUS_LDAP_CODE(nt_code)); - return msg; - } - while (nt_errs[idx].nt_errstr != NULL) { if (NT_STATUS_V(nt_errs[idx].nt_errcode) == NT_STATUS_V(nt_code)) { @@ -794,6 +830,11 @@ const char *nt_errstr(NTSTATUS nt_code) idx++; } + if (NT_STATUS_IS_LDAP(nt_code)) { + slprintf(msg, sizeof(msg), "LDAP code %u", NT_STATUS_LDAP_CODE(nt_code)); + return msg; + } + slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code)); return msg; -- cgit From be69066736c23f40d9131e608ead94874208da05 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 7 Dec 2006 20:12:24 +0000 Subject: r20072: make sure WERR_ACCESS_DENIED gets mapped to NT_STATUS_ACCESS_DENIED metze (This used to be commit 417f64184e734ab4ce5c78dc3d268c5c4a2cd18d) --- source4/libcli/util/errormap.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 1e90969f95..ff6acf9dd9 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -617,6 +617,11 @@ static const struct { NTSTATUS ntstatus; WERROR werror; } ntstatus_to_werror_map[] = { + /* + * we add this manualy here, so that W_ERROR(0x5) + * gets mapped to NTSTATUS_ACCESS_DENIED + */ + {NT_STATUS_ACCESS_DENIED, WERR_ACCESS_DENIED}, {NT_STATUS(0x103), W_ERROR(0x3e5)}, {NT_STATUS(0x105), W_ERROR(0xea)}, {NT_STATUS(0x106), W_ERROR(0x514)}, -- cgit From f9609d779dcbae389386ab594605d188c6933766 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 8 Dec 2006 18:01:30 +0000 Subject: r20080: add error code that maps to NT_STATUS_INVALID_NETWORD_RESPONSE metze (This used to be commit cb5c2e9dc6838145fe9f6f2e727a1df26e688467) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/doserr.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index fe2b555ab6..6f0d27e8ab 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -36,6 +36,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_BADFID", WERR_BADFID }, { "WERR_BADFUNC", WERR_BADFUNC }, { "WERR_BAD_NETPATH", WERR_BAD_NETPATH }, + { "WERR_BAD_NET_RESP", WERR_BAD_NET_RESP }, { "WERR_UNEXP_NET_ERR", WERR_UNEXP_NET_ERR }, { "WERR_INSUFFICIENT_BUFFER", WERR_INSUFFICIENT_BUFFER }, { "WERR_NO_SUCH_SHARE", WERR_NO_SUCH_SHARE }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 0e1bcd4499..18b66065e2 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -174,6 +174,7 @@ #define WERR_GENERAL_FAILURE W_ERROR(31) #define WERR_NOT_SUPPORTED W_ERROR(50) #define WERR_BAD_NETPATH W_ERROR(53) +#define WERR_BAD_NET_RESP W_ERROR(58) #define WERR_UNEXP_NET_ERR W_ERROR(59) #define WERR_PRINTQ_FULL W_ERROR(61) #define WERR_NO_SPOOL_SPACE W_ERROR(62) -- cgit From f37b7b85821c821c358bf900fd621bf9aada5c35 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 16 Dec 2006 17:21:53 +0000 Subject: r20213: add 2 error codes related to the msDs-IntId attribute metze (This used to be commit dd5df84cccd10e9880648eecbff6faf7252d5e73) --- source4/libcli/util/doserr.c | 2 ++ source4/libcli/util/doserr.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 6f0d27e8ab..4b39dace47 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -100,6 +100,8 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DS_DRA_ACCESS_DENIED", WERR_DS_DRA_ACCESS_DENIED }, { "WERR_DS_DNS_LOOKUP_FAILURE", WERR_DS_DNS_LOOKUP_FAILURE }, { "WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX", WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX }, + { "WERR_DS_NO_MSDS_INTID", WERR_DS_NO_MSDS_INTID }, + { "WERR_DS_DUP_MSDS_INTID", WERR_DS_DUP_MSDS_INTID }, { "WERR_GENERAL_FAILURE", WERR_GENERAL_FAILURE }, { "WERR_PRINTQ_FULL", WERR_PRINTQ_FULL }, { "WERR_NO_SPOOL_SPACE", WERR_NO_SPOOL_SPACE }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 18b66065e2..0cf53c1cf2 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -272,6 +272,8 @@ #define WERR_DS_DRA_ACCESS_DENIED W_ERROR(0x00002105) #define WERR_DS_DNS_LOOKUP_FAILURE W_ERROR(0x0000214c) #define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX W_ERROR(0x00002150) +#define WERR_DS_NO_MSDS_INTID W_ERROR(0x00002194) +#define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195) /* SEC errors */ #define WERR_SEC_E_ALGORITHM_MISMATCH W_ERROR(0x80090331) -- cgit From b55a68b368d2e14545f374938071a7f09af3c263 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Dec 2006 19:25:49 +0000 Subject: r20258: add functions to read and write asn1 encoded OID strings without leading tag metze (This used to be commit 576d4c54cca844164b90e5d6ec71fe44b59607b7) --- source4/libcli/util/asn1.c | 75 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 17 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 01c869dc17..c8e2d6f301 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -185,25 +185,37 @@ BOOL asn1_write_Integer(struct asn1_data *data, int i) return asn1_pop_tag(data); } -/* write an object ID to a ASN1 buffer */ -BOOL asn1_write_OID(struct asn1_data *data, const char *OID) +BOOL asn1_write_OID_String(struct asn1_data *data, const char *OID) { uint_t v, v2; const char *p = (const char *)OID; char *newp; - if (!asn1_push_tag(data, ASN1_OID)) + v = strtoul(p, &newp, 10); + if (newp[0] != '.') { + data->has_error = True; return False; - v = strtol(p, &newp, 10); - p = newp; - v2 = strtol(p, &newp, 10); - p = newp; + } + p = newp + 1; + v2 = strtoul(p, &newp, 10); + if (newp[0] != '.') { + data->has_error = True; + return False; + } + p = newp + 1; if (!asn1_write_uint8(data, 40*v + v2)) return False; while (*p) { - v = strtol(p, &newp, 10); - p = newp; + v = strtoul(p, &newp, 10); + if (newp[0] == '.') { + p = newp + 1; + } else if (newp[0] == '\0') { + p = newp; + } else { + data->has_error = True; + return False; + } if (v >= (1<<28)) asn1_write_uint8(data, 0x80 | ((v>>28)&0xff)); if (v >= (1<<21)) asn1_write_uint8(data, 0x80 | ((v>>21)&0xff)); if (v >= (1<<14)) asn1_write_uint8(data, 0x80 | ((v>>14)&0xff)); @@ -211,6 +223,15 @@ BOOL asn1_write_OID(struct asn1_data *data, const char *OID) if (!asn1_write_uint8(data, v&0x7f)) return False; } + + return !data->has_error; +} + +/* write an object ID to a ASN1 buffer */ +BOOL asn1_write_OID(struct asn1_data *data, const char *OID) +{ + if (!asn1_push_tag(data, ASN1_OID)) return False; + if (!asn1_write_OID_String(data, OID)) return False; return asn1_pop_tag(data); } @@ -447,16 +468,17 @@ int asn1_tag_remaining(struct asn1_data *data) } /* read an object ID from a ASN1 buffer */ -BOOL asn1_read_OID(struct asn1_data *data, const char **OID) +BOOL asn1_read_OID_String(struct asn1_data *data, const char **OID) { uint8_t b; char *tmp_oid = NULL; - if (!asn1_start_tag(data, ASN1_OID)) return False; - asn1_read_uint8(data, &b); + if (!asn1_read_uint8(data, &b)) return False; tmp_oid = talloc_asprintf(NULL, "%u", b/40); - tmp_oid = talloc_asprintf_append(tmp_oid, " %u", b%40); + if (!tmp_oid) goto nomem; + tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", b%40); + if (!tmp_oid) goto nomem; while (!data->has_error && asn1_tag_remaining(data) > 0) { uint_t v = 0; @@ -464,15 +486,34 @@ BOOL asn1_read_OID(struct asn1_data *data, const char **OID) asn1_read_uint8(data, &b); v = (v<<7) | (b&0x7f); } while (!data->has_error && (b & 0x80)); - tmp_oid = talloc_asprintf_append(tmp_oid, " %u", v); + tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", v); + if (!tmp_oid) goto nomem; } - asn1_end_tag(data); + if (!data->has_error) { + *OID = talloc_strdup(NULL, tmp_oid); + if (!*OID) goto nomem; + } - *OID = talloc_strdup(NULL, tmp_oid); talloc_free(tmp_oid); + return !data->has_error; +nomem: + talloc_free(tmp_oid); + data->has_error = True; + return False; +} - return (*OID && !data->has_error); +/* read an object ID from a ASN1 buffer */ +BOOL asn1_read_OID(struct asn1_data *data, const char **OID) +{ + if (!asn1_start_tag(data, ASN1_OID)) return False; + if (!asn1_read_OID_String(data, OID)) return False; + if (!asn1_end_tag(data)) { + talloc_free(discard_const(*OID)); + *OID = NULL; + return False; + } + return True; } /* check that the next object ID is correct */ -- cgit From 3853f820e630641d302435933241875a64b5980c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Dec 2006 19:28:49 +0000 Subject: r20259: add function to start a fake tag so that asn1_read_OID_String() can work alone metze (This used to be commit ea70f6ff07930951d98a952b03963d0ba358fec4) --- source4/libcli/util/asn1.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index c8e2d6f301..83044f8e30 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -423,6 +423,25 @@ BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag) return !data->has_error; } +BOOL asn1_start_fake_tag(struct asn1_data *data) +{ + struct nesting *nesting; + + nesting = talloc(NULL, struct nesting); + if (!nesting) { + data->has_error = True; + return False; + } + + nesting->start = data->ofs; + nesting->taglen = data->length - data->ofs; + nesting->next = data->nesting; + data->nesting = nesting; + if (asn1_tag_remaining(data) == -1) { + return False; + } + return !data->has_error; +} /* stop reading a tag */ BOOL asn1_end_tag(struct asn1_data *data) -- cgit From bfa5a5a4412ce810da91c2b3d8e6f1b86f24eb5a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 20 Dec 2006 12:51:29 +0000 Subject: r20276: remove unneeded talloc_strdup() metze (This used to be commit c4733b20c7c113dc1abfb2219a899b80bbcc2875) --- source4/libcli/util/asn1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 83044f8e30..3c669292cb 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -510,11 +510,11 @@ BOOL asn1_read_OID_String(struct asn1_data *data, const char **OID) } if (!data->has_error) { - *OID = talloc_strdup(NULL, tmp_oid); - if (!*OID) goto nomem; + *OID = tmp_oid; + } else { + talloc_free(tmp_oid); } - talloc_free(tmp_oid); return !data->has_error; nomem: talloc_free(tmp_oid); -- cgit From 06c58a3dbbf76a0790627fd13b788a4626fca78e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 20 Dec 2006 12:53:58 +0000 Subject: r20277: make sure the asn1 structure has a welldefined state after a asn1_free() metze (This used to be commit 7e7d1a1da2d64d28915a06c399072de1caf108c4) --- source4/libcli/util/asn1.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 3c669292cb..c82269fd60 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -25,6 +25,8 @@ void asn1_free(struct asn1_data *data) { talloc_free(data->data); + ZERO_STRUCTP(data); + data->has_error = True; } /* write to the ASN1 buffer, advancing the buffer pointer */ -- cgit From 52455cb9224bc7358f6700c8e3a233ff8c9a0f2a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 20 Dec 2006 15:51:02 +0000 Subject: r20284: Simplify OID primitive BER parsing. Do not require an artificial ASN.1 context to be setup. Simo. (This used to be commit 14b3b9861ae47498c74a6643e6979b3d85260a61) --- source4/libcli/util/asn1.c | 146 ++++++++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 63 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index c82269fd60..d139996bd0 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -187,27 +187,28 @@ BOOL asn1_write_Integer(struct asn1_data *data, int i) return asn1_pop_tag(data); } -BOOL asn1_write_OID_String(struct asn1_data *data, const char *OID) +BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID) { uint_t v, v2; const char *p = (const char *)OID; char *newp; + int i; v = strtoul(p, &newp, 10); - if (newp[0] != '.') { - data->has_error = True; - return False; - } + if (newp[0] != '.') return False; p = newp + 1; + v2 = strtoul(p, &newp, 10); - if (newp[0] != '.') { - data->has_error = True; - return False; - } + if (newp[0] != '.') return False; p = newp + 1; - if (!asn1_write_uint8(data, 40*v + v2)) - return False; + /*the ber representation can't use more space then the string one */ + *blob = data_blob(NULL, strlen(OID)); + if (!blob->data) return False; + + blob->data[0] = 40*v + v2; + + i = 1; while (*p) { v = strtoul(p, &newp, 10); if (newp[0] == '.') { @@ -215,25 +216,38 @@ BOOL asn1_write_OID_String(struct asn1_data *data, const char *OID) } else if (newp[0] == '\0') { p = newp; } else { - data->has_error = True; + data_blob_free(blob); return False; } - if (v >= (1<<28)) asn1_write_uint8(data, 0x80 | ((v>>28)&0xff)); - if (v >= (1<<21)) asn1_write_uint8(data, 0x80 | ((v>>21)&0xff)); - if (v >= (1<<14)) asn1_write_uint8(data, 0x80 | ((v>>14)&0xff)); - if (v >= (1<<7)) asn1_write_uint8(data, 0x80 | ((v>>7)&0xff)); - if (!asn1_write_uint8(data, v&0x7f)) - return False; + if (v >= (1<<28)) blob->data[i++] = (0x80 | ((v>>28)&0x7f)); + if (v >= (1<<21)) blob->data[i++] = (0x80 | ((v>>21)&0x7f)); + if (v >= (1<<14)) blob->data[i++] = (0x80 | ((v>>14)&0x7f)); + if (v >= (1<<7)) blob->data[i++] = (0x80 | ((v>>7)&0x7f)); + blob->data[i++] = (v&0x7f); } - return !data->has_error; + blob->length = i; + + return True; } /* write an object ID to a ASN1 buffer */ BOOL asn1_write_OID(struct asn1_data *data, const char *OID) { + DATA_BLOB blob; + if (!asn1_push_tag(data, ASN1_OID)) return False; - if (!asn1_write_OID_String(data, OID)) return False; + + if (!ber_write_OID_String(&blob, OID)) { + data->has_error = True; + return False; + } + + if (!asn1_write(data, blob.data, blob.length)) { + data->has_error = True; + return False; + } + data_blob_free(&blob); return asn1_pop_tag(data); } @@ -425,26 +439,6 @@ BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag) return !data->has_error; } -BOOL asn1_start_fake_tag(struct asn1_data *data) -{ - struct nesting *nesting; - - nesting = talloc(NULL, struct nesting); - if (!nesting) { - data->has_error = True; - return False; - } - - nesting->start = data->ofs; - nesting->taglen = data->length - data->ofs; - nesting->next = data->nesting; - data->nesting = nesting; - if (asn1_tag_remaining(data) == -1) { - return False; - } - return !data->has_error; -} - /* stop reading a tag */ BOOL asn1_end_tag(struct asn1_data *data) { @@ -488,52 +482,78 @@ int asn1_tag_remaining(struct asn1_data *data) return remaining; } -/* read an object ID from a ASN1 buffer */ -BOOL asn1_read_OID_String(struct asn1_data *data, const char **OID) +/* read an object ID from a data blob */ +BOOL ber_read_OID_String(DATA_BLOB blob, const char **OID) { - uint8_t b; + int i; + uint8_t *b; + uint_t v; char *tmp_oid = NULL; - if (!asn1_read_uint8(data, &b)) return False; + if (blob.length < 2) return False; + + b = blob.data; - tmp_oid = talloc_asprintf(NULL, "%u", b/40); + tmp_oid = talloc_asprintf(NULL, "%u", b[0]/40); if (!tmp_oid) goto nomem; - tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", b%40); + tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", b[0]%40); if (!tmp_oid) goto nomem; - while (!data->has_error && asn1_tag_remaining(data) > 0) { - uint_t v = 0; - do { - asn1_read_uint8(data, &b); - v = (v<<7) | (b&0x7f); - } while (!data->has_error && (b & 0x80)); - tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", v); + for(i = 1, v = 0; i < blob.length; i++) { + v = (v<<7) | (b[i]&0x7f); + if ( ! (b[i] & 0x80)) { + tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", v); + v = 0; + } if (!tmp_oid) goto nomem; } - if (!data->has_error) { - *OID = tmp_oid; - } else { + if (v != 0) { talloc_free(tmp_oid); + return False; } - return !data->has_error; + *OID = tmp_oid; + return True; + nomem: - talloc_free(tmp_oid); - data->has_error = True; return False; } /* read an object ID from a ASN1 buffer */ BOOL asn1_read_OID(struct asn1_data *data, const char **OID) { + DATA_BLOB blob; + int len; + if (!asn1_start_tag(data, ASN1_OID)) return False; - if (!asn1_read_OID_String(data, OID)) return False; - if (!asn1_end_tag(data)) { - talloc_free(discard_const(*OID)); - *OID = NULL; + + len = asn1_tag_remaining(data); + if (len < 0) { + data->has_error = True; + return False; + } + + blob = data_blob(NULL, len); + if (!blob.data) { + data->has_error = True; + return False; + } + + asn1_read(data, blob.data, len); + asn1_end_tag(data); + if (data->has_error) { + data_blob_free(&blob); return False; } + + if (!ber_read_OID_String(blob, OID)) { + data->has_error = True; + data_blob_free(&blob); + return False; + } + + data_blob_free(&blob); return True; } -- cgit From 84e7faf6cdb4330316bf21a21b0448e074064996 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 21 Dec 2006 21:14:53 +0000 Subject: r20308: ContextSimple can be zero length -- seen in a multi-step gssapi ldap bind. Did not find that in Samba3 code, so there's nothing to port. Volker (This used to be commit 9bdc19b6d5fe3dff57a07f4b760840d0043a53ad) --- source4/libcli/util/asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index d139996bd0..b1328344c5 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -641,7 +641,7 @@ BOOL asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blo return False; } *blob = data_blob(NULL, len); - if (!blob->data) { + if ((len != 0) && (!blob->data)) { data->has_error = True; return False; } -- cgit From 11018b0e134bee5bd7f7680114343e9f17f529e1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 28 Dec 2006 12:17:01 +0000 Subject: r20378: add new error code that says the schema mismatches between DC's metze (This used to be commit e769029f42f848db8121c7dcfe5be261861776c8) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/doserr.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 4b39dace47..5a4660c095 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -89,6 +89,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DS_SERVICE_UNAVAILABLE", WERR_DS_SERVICE_UNAVAILABLE }, { "WERR_DS_NO_SUCH_OBJECT", WERR_DS_NO_SUCH_OBJECT }, { "WERR_DS_OBJ_NOT_FOUND", WERR_DS_OBJ_NOT_FOUND }, + { "WERR_DS_DRA_SCHEMA_MISMATCH", WERR_DS_DRA_SCHEMA_MISMATCH }, { "WERR_DS_DRA_INVALID_PARAMETER", WERR_DS_DRA_INVALID_PARAMETER }, { "WERR_DS_DRA_BAD_DN", WERR_DS_DRA_BAD_DN }, { "WERR_DS_DRA_BAD_NC", WERR_DS_DRA_BAD_NC }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 0cf53c1cf2..17a9757d6e 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -261,6 +261,7 @@ #define WERR_DS_SERVICE_UNAVAILABLE W_ERROR(0x0000200f) #define WERR_DS_NO_SUCH_OBJECT W_ERROR(0x00002030) #define WERR_DS_OBJ_NOT_FOUND W_ERROR(0x0000208d) +#define WERR_DS_DRA_SCHEMA_MISMATCH W_ERROR(0x000020e2) #define WERR_DS_DRA_INVALID_PARAMETER W_ERROR(0x000020f5) #define WERR_DS_DRA_BAD_DN W_ERROR(0x000020f7) #define WERR_DS_DRA_BAD_NC W_ERROR(0x000020f8) -- cgit From a2f568f0008238bc76f7b8d32f21f75b239a4925 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 29 Dec 2006 10:34:15 +0000 Subject: r20404: add error code for missing attribute syntax metze (This used to be commit 769ce9799b0e9d1ccc5f2155440e5dedf655d40c) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/doserr.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 5a4660c095..c23e62afd8 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -89,6 +89,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DS_SERVICE_UNAVAILABLE", WERR_DS_SERVICE_UNAVAILABLE }, { "WERR_DS_NO_SUCH_OBJECT", WERR_DS_NO_SUCH_OBJECT }, { "WERR_DS_OBJ_NOT_FOUND", WERR_DS_OBJ_NOT_FOUND }, + { "WERR_DS_ATT_SCHEMA_REQ_SYNTAX", WERR_DS_ATT_SCHEMA_REQ_SYNTAX }, { "WERR_DS_DRA_SCHEMA_MISMATCH", WERR_DS_DRA_SCHEMA_MISMATCH }, { "WERR_DS_DRA_INVALID_PARAMETER", WERR_DS_DRA_INVALID_PARAMETER }, { "WERR_DS_DRA_BAD_DN", WERR_DS_DRA_BAD_DN }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 17a9757d6e..84b84bb6f5 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -261,6 +261,7 @@ #define WERR_DS_SERVICE_UNAVAILABLE W_ERROR(0x0000200f) #define WERR_DS_NO_SUCH_OBJECT W_ERROR(0x00002030) #define WERR_DS_OBJ_NOT_FOUND W_ERROR(0x0000208d) +#define WERR_DS_ATT_SCHEMA_REQ_SYNTAX W_ERROR(0x000020e0) #define WERR_DS_DRA_SCHEMA_MISMATCH W_ERROR(0x000020e2) #define WERR_DS_DRA_INVALID_PARAMETER W_ERROR(0x000020f5) #define WERR_DS_DRA_BAD_DN W_ERROR(0x000020f7) -- cgit From 15f6cf2449898432112140aea9f3f9445ca2ea68 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 14 Jan 2007 15:17:48 +0000 Subject: r20765: add two more schema related error codes metze (This used to be commit 75f5a88f2229fa604726ecb0ebb2b5a4589d5b86) --- source4/libcli/util/doserr.c | 2 ++ source4/libcli/util/doserr.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index c23e62afd8..51a633238f 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -89,6 +89,8 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DS_SERVICE_UNAVAILABLE", WERR_DS_SERVICE_UNAVAILABLE }, { "WERR_DS_NO_SUCH_OBJECT", WERR_DS_NO_SUCH_OBJECT }, { "WERR_DS_OBJ_NOT_FOUND", WERR_DS_OBJ_NOT_FOUND }, + { "WERR_DS_SCHEMA_NOT_LOADED", WERR_DS_SCHEMA_NOT_LOADED }, + { "WERR_DS_SCHEMA_ALLOC_FAILED", WERR_DS_SCHEMA_ALLOC_FAILED }, { "WERR_DS_ATT_SCHEMA_REQ_SYNTAX", WERR_DS_ATT_SCHEMA_REQ_SYNTAX }, { "WERR_DS_DRA_SCHEMA_MISMATCH", WERR_DS_DRA_SCHEMA_MISMATCH }, { "WERR_DS_DRA_INVALID_PARAMETER", WERR_DS_DRA_INVALID_PARAMETER }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 84b84bb6f5..79bbb1a4d8 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -261,6 +261,8 @@ #define WERR_DS_SERVICE_UNAVAILABLE W_ERROR(0x0000200f) #define WERR_DS_NO_SUCH_OBJECT W_ERROR(0x00002030) #define WERR_DS_OBJ_NOT_FOUND W_ERROR(0x0000208d) +#define WERR_DS_SCHEMA_NOT_LOADED W_ERROR(0x20de) +#define WERR_DS_SCHEMA_ALLOC_FAILED W_ERROR(0x20df) #define WERR_DS_ATT_SCHEMA_REQ_SYNTAX W_ERROR(0x000020e0) #define WERR_DS_DRA_SCHEMA_MISMATCH W_ERROR(0x000020e2) #define WERR_DS_DRA_INVALID_PARAMETER W_ERROR(0x000020f5) -- cgit From 10c928a94f6fafd79ae4c9e581c793bbf700a9b5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Feb 2007 09:36:53 +0000 Subject: r21291: add two more error codes metze (This used to be commit dd04c5dec58b18048ca5029f7bfe513242cbe4e9) --- source4/libcli/util/doserr.c | 2 ++ source4/libcli/util/doserr.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 51a633238f..3f646f4be5 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -115,6 +115,8 @@ static const struct werror_code_struct dos_errs[] = { "WERR_CLASS_NOT_REGISTERED", WERR_CLASS_NOT_REGISTERED }, { "WERR_NO_SHUTDOWN_IN_PROGRESS", WERR_NO_SHUTDOWN_IN_PROGRESS }, { "WERR_SHUTDOWN_ALREADY_IN_PROGRESS", WERR_SHUTDOWN_ALREADY_IN_PROGRESS }, + { "WERR_SEC_E_ENCRYPT_FAILURE", WERR_SEC_E_ENCRYPT_FAILURE }, + { "WERR_SEC_E_DECRYPT_FAILURE", WERR_SEC_E_DECRYPT_FAILURE }, { "WERR_SEC_E_ALGORITHM_MISMATCH", WERR_SEC_E_ALGORITHM_MISMATCH }, { NULL, W_ERROR(0) } }; diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 79bbb1a4d8..69499c17e9 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -280,7 +280,9 @@ #define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195) /* SEC errors */ -#define WERR_SEC_E_ALGORITHM_MISMATCH W_ERROR(0x80090331) +#define WERR_SEC_E_ENCRYPT_FAILURE W_ERROR(0x80090329) +#define WERR_SEC_E_DECRYPT_FAILURE W_ERROR(0x80090330) +#define WERR_SEC_E_ALGORITHM_MISMATCH W_ERROR(0x80090331) #define WERR_FOOBAR WERR_GENERAL_FAILURE -- cgit From 97416e6b011a3c733d07f83073bf12796c7ecc6b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 12 Feb 2007 12:12:12 +0000 Subject: r21297: Remove the GTK+ tools and library from the main repository. They are now maintained separately in bzr at http://people.samba.org/bzr/jelmer/samba-gtk This also adds some more headers to the list that is installed and a couple of extra #include lines so these headers can be used externally without problems. (This used to be commit 07652f65ce7a5b19130f1a27cbf0e1e5fae13454) --- source4/libcli/util/nt_status.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nt_status.h b/source4/libcli/util/nt_status.h index 06aeaa3dac..3e2a126b41 100644 --- a/source4/libcli/util/nt_status.h +++ b/source4/libcli/util/nt_status.h @@ -22,6 +22,8 @@ #ifndef _NT_STATUS_H #define _NT_STATUS_H +#include + /* the following rather strange looking definitions of NTSTATUS and WERROR and there in order to catch common coding errors where different error types are mixed up. This is especially important as we slowly convert Samba -- cgit From 7f9d949bd34cbeaca8452ea08d39c0e4bbd3a669 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 23 Feb 2007 07:32:13 +0000 Subject: r21510: make it possible to push tags with length > 0xFFFFFF metze (This used to be commit 8e604107da4a8a1bf6ccab45e85e147daab29519) --- source4/libcli/util/asn1.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index b1328344c5..e64ffdf86c 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -89,7 +89,18 @@ BOOL asn1_pop_tag(struct asn1_data *data) /* yes, this is ugly. We don't know in advance how many bytes the length of a tag will take, so we assumed 1 byte. If we were wrong then we need to correct our mistake */ - if (len > 0xFFFF) { + if (len > 0xFFFFFF) { + data->data[nesting->start] = 0x84; + if (!asn1_write_uint8(data, 0)) return False; + if (!asn1_write_uint8(data, 0)) return False; + if (!asn1_write_uint8(data, 0)) return False; + if (!asn1_write_uint8(data, 0)) return False; + memmove(data->data+nesting->start+5, data->data+nesting->start+1, len); + data->data[nesting->start+1] = (len>>24) & 0xFF; + data->data[nesting->start+2] = (len>>16) & 0xFF; + data->data[nesting->start+3] = (len>>8) & 0xFF; + data->data[nesting->start+4] = len&0xff; + } else if (len > 0xFFFF) { data->data[nesting->start] = 0x83; if (!asn1_write_uint8(data, 0)) return False; if (!asn1_write_uint8(data, 0)) return False; -- cgit From 60fd088c480e474c3db8870f1288462a8452cea3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 26 Feb 2007 05:37:19 +0000 Subject: r21535: - fixed a crash in the RAW-ACLS test. When a dcerpc_pipe is created using the pattern in the clilsa code, it didn't fill in the p->binding structure. This affects nearly all users of dcerpc_pipe_open_smb(), so the simplest fix is to ensure that dcerpc_pipe_open_smb() initialises the binding if its not already there. - re-enable the RAW-ACLS test (This used to be commit d8875c286d2be49c01703d8fd58bbc1842054bd9) --- source4/libcli/util/clilsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index e491d1c9ee..cd9a02deb1 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -86,7 +86,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) } /* open the LSA pipe */ - status = dcerpc_pipe_open_smb(lsa->pipe->conn, lsa->ipc_tree, DCERPC_LSARPC_NAME); + status = dcerpc_pipe_open_smb(lsa->pipe, lsa->ipc_tree, DCERPC_LSARPC_NAME); if (!NT_STATUS_IS_OK(status)) { talloc_free(lsa); return status; -- cgit From 505fd4eb9901a1ff8ecbd244fe2227eae59ca2d6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Feb 2007 17:19:35 +0000 Subject: r21591: add new error code metze (This used to be commit 04da3db29d57ffeab3ba39551b326b8c176a5bcb) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/doserr.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 3f646f4be5..716ca438db 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -73,6 +73,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DFS_NO_SUCH_SERVER", WERR_DFS_NO_SUCH_SERVER }, { "WERR_DFS_INTERNAL_ERROR", WERR_DFS_INTERNAL_ERROR }, { "WERR_DFS_CANT_CREATE_JUNCT", WERR_DFS_CANT_CREATE_JUNCT }, + { "WERR_LOGON_FAILURE", WERR_LOGON_FAILURE }, { "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR }, { "WERR_UNKNOWN_REVISION", WERR_UNKNOWN_REVISION }, { "WERR_REVISION_MISMATCH", WERR_REVISION_MISMATCH }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 69499c17e9..a45831347f 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -200,6 +200,7 @@ #define WERR_NO_SUCH_PRIVILEGE W_ERROR(1313) #define WERR_PRIVILEGE_NOT_HELD W_ERROR(1314) #define WERR_NO_SUCH_USER W_ERROR(1317) +#define WERR_LOGON_FAILURE W_ERROR(1326) #define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338) #define WERR_NO_SUCH_DOMAIN W_ERROR(1355) #define WERR_NO_SYSTEM_RESOURCES W_ERROR(1450) -- cgit From cb00a33c672ce78dc58a722804013e5b567fdf45 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 15 May 2007 07:16:04 +0000 Subject: r22884: Be consistant with the case of these constants. Andrew Bartlett (This used to be commit 7b086eebd6af21674ca18c7d9b35cb2c6b57514a) --- source4/libcli/util/nterr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 5b6e2b2b50..59d4bb0c1f 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -699,7 +699,7 @@ static const nt_err_code_struct nt_errs[] = LDAP_CODE(LDAP_ALIAS_DEREFERENCING_PROBLEM), LDAP_CODE(LDAP_INAPPROPRIATE_AUTHENTICATION), LDAP_CODE(LDAP_INVALID_CREDENTIALS), - LDAP_CODE(LDAP_INSUFFICIENT_ACCESS_RIGHTs), + LDAP_CODE(LDAP_INSUFFICIENT_ACCESS_RIGHTS), LDAP_CODE(LDAP_BUSY), LDAP_CODE(LDAP_UNAVAILABLE), LDAP_CODE(LDAP_UNWILLING_TO_PERFORM), -- cgit From 402218516a141722cf6cf42c29f15834122acbd7 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 17 May 2007 01:17:43 +0000 Subject: r22958: For SRVSVC/NetFileClose only Administrator is allowed to close open files. If a normal user tries to close a file that exists, even that users own files the server responds with this error on w2k if the file does not exist, the server instead responds with WERR_BADFILE (This used to be commit c17df8bed66d70765b85b6e04f2ad0a57073ffb4) --- source4/libcli/util/doserr.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index a45831347f..6df5181654 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -211,6 +211,7 @@ #define WERR_BUF_TOO_SMALL W_ERROR(2123) #define WERR_JOB_NOT_FOUND W_ERROR(2151) #define WERR_DEST_NOT_FOUND W_ERROR(2152) +#define WERR_FID_NOT_FOUND W_ERROR(2314) #define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320) #define WERR_DEVICE_NOT_AVAILABLE W_ERROR(4319) #define WERR_STATUS_MORE_ENTRIES W_ERROR(0x0105) -- cgit From a777eb0cfa5b135acc0bb5fd6396362b72c2315b Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Fri, 18 May 2007 05:21:25 +0000 Subject: r22986: error 2312 is returned when NetSessDel() fails because a matching session (username/clientname) could not be found (This used to be commit e2b46d280db114656e18f023a9efa939b5c893d5) --- source4/libcli/util/doserr.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 6df5181654..ddcc060eb6 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -211,6 +211,7 @@ #define WERR_BUF_TOO_SMALL W_ERROR(2123) #define WERR_JOB_NOT_FOUND W_ERROR(2151) #define WERR_DEST_NOT_FOUND W_ERROR(2152) +#define WERR_SESSION_NOT_FOUND W_ERROR(2312) #define WERR_FID_NOT_FOUND W_ERROR(2314) #define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320) #define WERR_DEVICE_NOT_AVAILABLE W_ERROR(4319) -- cgit From 7bb939b1cb2b39a8271cf16d9f5fce5312a9af10 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 21 May 2007 06:12:06 +0000 Subject: r23030: finally fixed up our asn1 code to use better memory allocation. This should allow us to fix some long standing memory leaks. (This used to be commit 3db49c2ec9968221c1361785b94061046ecd159d) --- source4/libcli/util/asn1.c | 61 ++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index e64ffdf86c..d02f6be9c7 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -21,12 +21,16 @@ #include "includes.h" #include "libcli/util/asn_1.h" +/* allocate an asn1 structure */ +struct asn1_data *asn1_init(TALLOC_CTX *mem_ctx) +{ + return talloc_zero(NULL, struct asn1_data); +} + /* free an asn1 structure */ void asn1_free(struct asn1_data *data) { - talloc_free(data->data); - ZERO_STRUCTP(data); - data->has_error = True; + talloc_free(data); } /* write to the ASN1 buffer, advancing the buffer pointer */ @@ -35,7 +39,7 @@ BOOL asn1_write(struct asn1_data *data, const void *p, int len) if (data->has_error) return False; if (data->length < data->ofs+len) { uint8_t *newp; - newp = talloc_realloc(NULL, data->data, uint8_t, data->ofs+len); + newp = talloc_realloc(data, data->data, uint8_t, data->ofs+len); if (!newp) { asn1_free(data); data->has_error = True; @@ -61,7 +65,7 @@ BOOL asn1_push_tag(struct asn1_data *data, uint8_t tag) struct nesting *nesting; asn1_write_uint8(data, tag); - nesting = talloc(NULL, struct nesting); + nesting = talloc(data, struct nesting); if (!nesting) { data->has_error = True; return False; @@ -341,7 +345,7 @@ BOOL asn1_check_BOOLEAN(struct asn1_data *data, BOOL v) BOOL asn1_load(struct asn1_data *data, DATA_BLOB blob) { ZERO_STRUCTP(data); - data->data = talloc_memdup(NULL, blob.data, blob.length); + data->data = talloc_memdup(data, blob.data, blob.length); if (!data->data) { data->has_error = True; return False; @@ -417,7 +421,7 @@ BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag) data->has_error = True; return False; } - nesting = talloc(NULL, struct nesting); + nesting = talloc(data, struct nesting); if (!nesting) { data->has_error = True; return False; @@ -494,7 +498,7 @@ int asn1_tag_remaining(struct asn1_data *data) } /* read an object ID from a data blob */ -BOOL ber_read_OID_String(DATA_BLOB blob, const char **OID) +BOOL ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID) { int i; uint8_t *b; @@ -505,7 +509,7 @@ BOOL ber_read_OID_String(DATA_BLOB blob, const char **OID) b = blob.data; - tmp_oid = talloc_asprintf(NULL, "%u", b[0]/40); + tmp_oid = talloc_asprintf(mem_ctx, "%u", b[0]/40); if (!tmp_oid) goto nomem; tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", b[0]%40); if (!tmp_oid) goto nomem; @@ -532,7 +536,7 @@ nomem: } /* read an object ID from a ASN1 buffer */ -BOOL asn1_read_OID(struct asn1_data *data, const char **OID) +BOOL asn1_read_OID(struct asn1_data *data, TALLOC_CTX *mem_ctx, const char **OID) { DATA_BLOB blob; int len; @@ -558,7 +562,7 @@ BOOL asn1_read_OID(struct asn1_data *data, const char **OID) return False; } - if (!ber_read_OID_String(blob, OID)) { + if (!ber_read_OID_String(mem_ctx, blob, OID)) { data->has_error = True; data_blob_free(&blob); return False; @@ -573,9 +577,10 @@ BOOL asn1_check_OID(struct asn1_data *data, const char *OID) { const char *id; - if (!asn1_read_OID(data, &id)) return False; + if (!asn1_read_OID(data, data, &id)) return False; if (strcmp(id, OID) != 0) { + talloc_free(discard_const(id)); data->has_error = True; return False; } @@ -584,7 +589,7 @@ BOOL asn1_check_OID(struct asn1_data *data, const char *OID) } /* read a LDAPString from a ASN1 buffer */ -BOOL asn1_read_LDAPString(struct asn1_data *data, char **s) +BOOL asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s) { int len; len = asn1_tag_remaining(data); @@ -592,7 +597,7 @@ BOOL asn1_read_LDAPString(struct asn1_data *data, char **s) data->has_error = True; return False; } - *s = talloc_size(NULL, len+1); + *s = talloc_size(mem_ctx, len+1); if (! *s) { data->has_error = True; return False; @@ -604,16 +609,16 @@ BOOL asn1_read_LDAPString(struct asn1_data *data, char **s) /* read a GeneralString from a ASN1 buffer */ -BOOL asn1_read_GeneralString(struct asn1_data *data, char **s) +BOOL asn1_read_GeneralString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s) { if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False; - if (!asn1_read_LDAPString(data, s)) return False; + if (!asn1_read_LDAPString(data, mem_ctx, s)) return False; return asn1_end_tag(data); } /* read a octet string blob */ -BOOL asn1_read_OctetString(struct asn1_data *data, DATA_BLOB *blob) +BOOL asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLOB *blob) { int len; ZERO_STRUCTP(blob); @@ -623,7 +628,7 @@ BOOL asn1_read_OctetString(struct asn1_data *data, DATA_BLOB *blob) data->has_error = True; return False; } - *blob = data_blob(NULL, len+1); + *blob = data_blob_talloc(mem_ctx, NULL, len+1); if (!blob->data) { data->has_error = True; return False; @@ -727,19 +732,21 @@ BOOL asn1_write_enumerated(struct asn1_data *data, uint8_t v) */ NTSTATUS asn1_full_tag(DATA_BLOB blob, uint8_t tag, size_t *packet_size) { - struct asn1_data asn1; + struct asn1_data *asn1 = asn1_init(NULL); int size; - ZERO_STRUCT(asn1); - asn1.data = blob.data; - asn1.length = blob.length; - asn1_start_tag(&asn1, tag); - if (asn1.has_error) { - talloc_free(asn1.nesting); + NT_STATUS_HAVE_NO_MEMORY(asn1); + + asn1->data = blob.data; + asn1->length = blob.length; + asn1_start_tag(asn1, tag); + if (asn1->has_error) { + talloc_free(asn1); return STATUS_MORE_ENTRIES; } - size = asn1_tag_remaining(&asn1) + asn1.ofs; - talloc_free(asn1.nesting); + size = asn1_tag_remaining(asn1) + asn1->ofs; + + talloc_free(asn1); if (size > blob.length) { return STATUS_MORE_ENTRIES; -- cgit From 931f594cf16b8c7f9f416d7a8831432b783a0ec8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 21 May 2007 12:47:18 +0000 Subject: r23036: error checking on asn1_init() failure (This used to be commit 26cf8494084c0106ef0e1c9b6ef40eeadf945ef2) --- source4/libcli/util/asn1.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index d02f6be9c7..81ce72bed9 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -24,7 +24,11 @@ /* allocate an asn1 structure */ struct asn1_data *asn1_init(TALLOC_CTX *mem_ctx) { - return talloc_zero(NULL, struct asn1_data); + struct asn1_data *ret = talloc_zero(NULL, struct asn1_data); + if (ret == NULL) { + DEBUG(0,("asn1_init failed! out of memory\n")); + } + return ret; } /* free an asn1 structure */ -- cgit From 774d66c1e69ab17dc3c3c188dafc6b2b005fd562 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 21 May 2007 13:33:46 +0000 Subject: r23037: actually fix the asn1 memory leak :-) metze (This used to be commit 13bda1152d3b88c0b93610d4698ce24183334276) --- source4/libcli/util/asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 81ce72bed9..477887b96a 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -24,7 +24,7 @@ /* allocate an asn1 structure */ struct asn1_data *asn1_init(TALLOC_CTX *mem_ctx) { - struct asn1_data *ret = talloc_zero(NULL, struct asn1_data); + struct asn1_data *ret = talloc_zero(mem_ctx, struct asn1_data); if (ret == NULL) { DEBUG(0,("asn1_init failed! out of memory\n")); } -- cgit From eb9ae52981d0275d3830fb533a06472aef3508db Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Jun 2007 10:32:29 +0000 Subject: r23381: Merge netr_GetDcName WERROR return and WERROR_DOMAIN_CONTROLLER_NOT_FOUND from SAMBA_3_0. Guenther (This used to be commit 841ad140a34648ff52d5e44a6642f346ef9eee02) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/doserr.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 716ca438db..76c59570a9 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -63,6 +63,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_JOB_NOT_FOUND", WERR_JOB_NOT_FOUND }, { "WERR_DEST_NOT_FOUND", WERR_DEST_NOT_FOUND }, { "WERR_NOT_LOCAL_DOMAIN", WERR_NOT_LOCAL_DOMAIN }, + { "WERR_DOMAIN_CONTROLLER_NOT_FOUND", WERR_DOMAIN_CONTROLLER_NOT_FOUND }, { "WERR_DEVICE_NOT_AVAILABLE", WERR_DEVICE_NOT_AVAILABLE }, { "WERR_PRINTER_DRIVER_IN_USE", WERR_PRINTER_DRIVER_IN_USE }, { "WERR_STATUS_MORE_ENTRIES", WERR_STATUS_MORE_ENTRIES }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index ddcc060eb6..b091a290b9 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -214,6 +214,7 @@ #define WERR_SESSION_NOT_FOUND W_ERROR(2312) #define WERR_FID_NOT_FOUND W_ERROR(2314) #define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320) +#define WERR_DOMAIN_CONTROLLER_NOT_FOUND W_ERROR(2453) #define WERR_DEVICE_NOT_AVAILABLE W_ERROR(4319) #define WERR_STATUS_MORE_ENTRIES W_ERROR(0x0105) -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/libcli/util/asn1.c | 5 ++--- source4/libcli/util/asn_1.h | 5 ++--- source4/libcli/util/clierror.c | 5 ++--- source4/libcli/util/clilsa.c | 5 ++--- source4/libcli/util/doserr.h | 5 ++--- source4/libcli/util/error.h | 5 ++--- source4/libcli/util/nt_status.h | 5 ++--- source4/libcli/util/nterr.h | 5 ++--- 8 files changed, 16 insertions(+), 24 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 477887b96a..e7a2e163aa 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" diff --git a/source4/libcli/util/asn_1.h b/source4/libcli/util/asn_1.h index 7033f92a7f..6c70423e96 100644 --- a/source4/libcli/util/asn_1.h +++ b/source4/libcli/util/asn_1.h @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #ifndef _ASN_1_H diff --git a/source4/libcli/util/clierror.c b/source4/libcli/util/clierror.c index 52607b1a47..89bba21ed6 100644 --- a/source4/libcli/util/clierror.c +++ b/source4/libcli/util/clierror.c @@ -6,7 +6,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, @@ -15,8 +15,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" diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index cd9a02deb1..a82f687053 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.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, @@ -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 . */ /* diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index b091a290b9..7dc938b2e7 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -8,7 +8,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, @@ -17,8 +17,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 . */ #ifndef _DOSERR_H diff --git a/source4/libcli/util/error.h b/source4/libcli/util/error.h index 4aa1ff6a40..8a641c8eb9 100644 --- a/source4/libcli/util/error.h +++ b/source4/libcli/util/error.h @@ -4,7 +4,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, @@ -13,8 +13,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 . */ #ifndef _SAMBA_ERROR_H_ diff --git a/source4/libcli/util/nt_status.h b/source4/libcli/util/nt_status.h index 3e2a126b41..8d81aab175 100644 --- a/source4/libcli/util/nt_status.h +++ b/source4/libcli/util/nt_status.h @@ -6,7 +6,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, @@ -15,8 +15,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 . */ #ifndef _NT_STATUS_H diff --git a/source4/libcli/util/nterr.h b/source4/libcli/util/nterr.h index baf15d80ef..1ee867a0aa 100644 --- a/source4/libcli/util/nterr.h +++ b/source4/libcli/util/nterr.h @@ -8,7 +8,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, @@ -17,8 +17,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 . */ #ifndef _NTERR_H -- cgit From b8d69a7ea2505b706ff7c74d7c97bc89d82dfa07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit 84b468b2f8f2dffda89593f816e8bc6a8b6d42ac) --- source4/libcli/util/doserr.c | 2 +- source4/libcli/util/errormap.c | 2 +- source4/libcli/util/nterr.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 76c59570a9..a81d98a8e9 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index ff6acf9dd9..20e7a464e5 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.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, diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 59d4bb0c1f..8205e45d21 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, -- cgit From cd1217ff5ff18e53c6c9fa3d4f4fd56193fe2a17 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 05:23:25 +0000 Subject: r23801: The FSF has moved around a lot. This fixes their Mass Ave address. (This used to be commit 5c9b19271e0e3ad897499707003ce4703ffa4870) --- source4/libcli/util/doserr.c | 3 +-- source4/libcli/util/errormap.c | 3 +-- source4/libcli/util/nterr.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index a81d98a8e9..3b1c2d264a 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* DOS error codes. please read doserr.h */ diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 20e7a464e5..711f02a626 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.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" diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 8205e45d21..3aea0b51bc 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* NT error codes. please read nterr.h */ -- cgit From 5f6b501f217bf95522e2d1fe63ee1298feb1abd7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 3 Aug 2007 08:25:15 +0000 Subject: r24146: It is not an error for a Win2k3-only server not to support the NT4 replication call. Andrew Bartlett (This used to be commit 59cba32c09f5b014788e4fb0479ed31f26a3d7e2) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/doserr.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 3b1c2d264a..d62a31c1fa 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -75,6 +75,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DFS_CANT_CREATE_JUNCT", WERR_DFS_CANT_CREATE_JUNCT }, { "WERR_LOGON_FAILURE", WERR_LOGON_FAILURE }, { "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR }, + { "WERR_INVALID_DOMAIN_ROLE", WERR_INVALID_DOMAIN_ROLE }, { "WERR_UNKNOWN_REVISION", WERR_UNKNOWN_REVISION }, { "WERR_REVISION_MISMATCH", WERR_REVISION_MISMATCH }, { "WERR_INVALID_OWNER", WERR_INVALID_OWNER }, diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 7dc938b2e7..0478eff947 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -201,6 +201,7 @@ #define WERR_NO_SUCH_USER W_ERROR(1317) #define WERR_LOGON_FAILURE W_ERROR(1326) #define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338) +#define WERR_INVALID_DOMAIN_ROLE W_ERROR(1354) #define WERR_NO_SUCH_DOMAIN W_ERROR(1355) #define WERR_NO_SYSTEM_RESOURCES W_ERROR(1450) #define WERR_SERVER_UNAVAILABLE W_ERROR(1722) -- cgit From f14bd1a90ab47a418c0ec2492990a417a0bb3bf6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 19 Aug 2007 21:23:03 +0000 Subject: r24557: rename 'dcerpc_table_' -> 'ndr_table_' metze (This used to be commit 84651aee81aaabbebf52ffc3fbcbabb2eec6eed5) --- source4/libcli/util/clilsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index a82f687053..d51ad5e12d 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -92,7 +92,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) } /* bind to the LSA pipe */ - status = dcerpc_bind_auth_none(lsa->pipe, &dcerpc_table_lsarpc); + status = dcerpc_bind_auth_none(lsa->pipe, &ndr_table_lsarpc); if (!NT_STATUS_IS_OK(status)) { talloc_free(lsa); return status; -- cgit From 0d7d5a6d492253f184ac58fe45ca22af5a3731de Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 19 Aug 2007 22:09:21 +0000 Subject: r24560: rename some DCERPC_ prefixes into NDR_ metze (This used to be commit f874eca5dab74e930d0ec52abeb06295d2d90476) --- source4/libcli/util/clilsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index d51ad5e12d..6fd84bbe74 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -85,7 +85,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) } /* open the LSA pipe */ - status = dcerpc_pipe_open_smb(lsa->pipe, lsa->ipc_tree, DCERPC_LSARPC_NAME); + status = dcerpc_pipe_open_smb(lsa->pipe, lsa->ipc_tree, NDR_LSARPC_NAME); if (!NT_STATUS_IS_OK(status)) { talloc_free(lsa); return status; -- cgit From 61ffa08f4c95e29d301de9fbabd6e71c2dbc1056 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 27 Aug 2007 18:10:19 +0000 Subject: r24712: No longer expose the 'BOOL' data type in any interfaces. (This used to be commit 1ce32673d960c8b05b6c1b1b99e1976a402417ae) --- source4/libcli/util/asn_1.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn_1.h b/source4/libcli/util/asn_1.h index 6c70423e96..612a8a932f 100644 --- a/source4/libcli/util/asn_1.h +++ b/source4/libcli/util/asn_1.h @@ -31,7 +31,7 @@ struct asn1_data { size_t length; off_t ofs; struct nesting *nesting; - BOOL has_error; + bool has_error; }; #define ASN1_APPLICATION(x) ((x)+0x60) -- cgit From cd962355abad90a2161765a7be7d26e63572cab7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Sep 2007 15:08:14 +0000 Subject: r25000: Fix some more C++ compatibility warnings. (This used to be commit 08bb1ef643ab906f1645cf6f32763dc73b1884e4) --- source4/libcli/util/asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index e7a2e163aa..8bd091a319 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -600,7 +600,7 @@ BOOL asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s) data->has_error = True; return False; } - *s = talloc_size(mem_ctx, len+1); + *s = talloc_array(mem_ctx, char, len+1); if (! *s) { data->has_error = True; return False; -- cgit From 922101afbd64b42c01e1093b9d58fff24b1f852e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Sep 2007 22:01:15 +0000 Subject: r25010: Avoid uses of pstring (This used to be commit cce7785474fc536dd44b39403c785b524b128144) --- source4/libcli/util/doserr.c | 3 +-- source4/libcli/util/nterr.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index d62a31c1fa..49818e573a 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -20,7 +20,6 @@ /* DOS error codes. please read doserr.h */ #include "includes.h" -#include "pstring.h" struct werror_code_struct { const char *dos_errstr; @@ -133,7 +132,7 @@ static const struct werror_code_struct dos_errs[] = *****************************************************************************/ const char *win_errstr(WERROR werror) { - static pstring msg; + static char msg[40]; int idx = 0; while (dos_errs[idx].dos_errstr != NULL) { diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 3aea0b51bc..b1f345016d 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -20,7 +20,6 @@ /* NT error codes. please read nterr.h */ #include "includes.h" -#include "pstring.h" #include "libcli/ldap/ldap.h" typedef struct @@ -862,7 +861,7 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code) *****************************************************************************/ const char *get_nt_error_c_code(NTSTATUS nt_code) { - static pstring out; + static char out[40]; int idx = 0; while (nt_errs[idx].nt_errstr != NULL) { -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/libcli/util/errormap.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 711f02a626..347d513e9c 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "param/param.h" /* This map was extracted by the ERRMAPEXTRACT smbtorture command. The setup was a Samba HEAD (2002-01-03) PDC and an Win2k member -- cgit From dccf3f99e45137b6cd18c1de1c79808ad67130d1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 13:27:14 +0000 Subject: r25027: Fix more warnings. (This used to be commit 5085c53fcfade614e83d21fc2c1a5bc43bb2a729) --- source4/libcli/util/clilsa.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 6fd84bbe74..0fdf8a8e3a 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -31,6 +31,7 @@ #include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_lsa.h" #include "librpc/gen_ndr/ndr_lsa_c.h" +#include "libcli/util/clilsa.h" struct smblsa_state { struct dcerpc_pipe *pipe; -- cgit From 9a012df08ee829c1d40fc88ba12a0ea479f60be0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 14 Sep 2007 23:21:00 +0000 Subject: r25175: Change to talloc_asprintf_append_buffer(). Jeremy. (This used to be commit 0844dbf597191b3e4d35a696695b229e986daec4) --- source4/libcli/util/asn1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 8bd091a319..7e2d54fcbd 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -514,13 +514,13 @@ BOOL ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID) tmp_oid = talloc_asprintf(mem_ctx, "%u", b[0]/40); if (!tmp_oid) goto nomem; - tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", b[0]%40); + tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", b[0]%40); if (!tmp_oid) goto nomem; for(i = 1, v = 0; i < blob.length; i++) { v = (v<<7) | (b[i]&0x7f); if ( ! (b[i] & 0x80)) { - tmp_oid = talloc_asprintf_append(tmp_oid, ".%u", v); + tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", v); v = 0; } if (!tmp_oid) goto nomem; -- cgit From f35373709444780c4bf338c17b26ce9cc3ebab50 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Sep 2007 13:31:05 +0000 Subject: r25212: merge some stuff from samba3 metze (This used to be commit 502251451aa78b82131283d0590b382943b1d156) --- source4/libcli/util/asn1.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 7e2d54fcbd..f2098de5c5 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -360,6 +360,9 @@ BOOL asn1_load(struct asn1_data *data, DATA_BLOB blob) /* Peek into an ASN1 buffer, not advancing the pointer */ BOOL asn1_peek(struct asn1_data *data, void *p, int len) { + if (data->has_error) + return False; + if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len) return False; @@ -405,7 +408,7 @@ BOOL asn1_peek_tag(struct asn1_data *data, uint8_t tag) return False; } - if (!asn1_peek(data, &b, sizeof(b))) + if (!asn1_peek_uint8(data, &b)) return False; return (b == tag); -- cgit From 9b009c900987517359485799be8be4167494b376 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Sep 2007 21:35:03 +0000 Subject: r25301: Merge my includes.h cleanups. (This used to be commit 37425495f392a2d0122a93aa2c42758eab7dab5a) --- source4/libcli/util/clierror.c | 72 ----- source4/libcli/util/doserr.h | 125 -------- source4/libcli/util/error.h | 29 +- source4/libcli/util/nt_status.h | 122 -------- source4/libcli/util/nterr.h | 588 ---------------------------------- source4/libcli/util/ntstatus.h | 675 ++++++++++++++++++++++++++++++++++++++++ source4/libcli/util/werror.h | 193 ++++++++++++ 7 files changed, 895 insertions(+), 909 deletions(-) delete mode 100644 source4/libcli/util/clierror.c delete mode 100644 source4/libcli/util/nt_status.h delete mode 100644 source4/libcli/util/nterr.h create mode 100644 source4/libcli/util/ntstatus.h create mode 100644 source4/libcli/util/werror.h (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clierror.c b/source4/libcli/util/clierror.c deleted file mode 100644 index 89bba21ed6..0000000000 --- a/source4/libcli/util/clierror.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - Unix SMB/CIFS implementation. - client error handling routines - Copyright (C) Andrew Tridgell 1994-1998 - Copyright (C) James Myers 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 - 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, - 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, see . -*/ - -#include "includes.h" -#include "libcli/raw/libcliraw.h" - - -/*************************************************************************** - Return an error message from the last response -****************************************************************************/ -const char *smbcli_errstr(struct smbcli_tree *tree) -{ - switch (tree->session->transport->error.etype) { - case ETYPE_SMB: - return nt_errstr(tree->session->transport->error.e.nt_status); - - case ETYPE_SOCKET: - return "socket_error"; - - case ETYPE_NBT: - return "nbt_error"; - - case ETYPE_NONE: - return "no_error"; - } - return NULL; -} - - -/* Return the 32-bit NT status code from the last packet */ -NTSTATUS smbcli_nt_error(struct smbcli_tree *tree) -{ - switch (tree->session->transport->error.etype) { - case ETYPE_SMB: - return tree->session->transport->error.e.nt_status; - - case ETYPE_SOCKET: - return NT_STATUS_UNSUCCESSFUL; - - case ETYPE_NBT: - return NT_STATUS_UNSUCCESSFUL; - - case ETYPE_NONE: - return NT_STATUS_OK; - } - - return NT_STATUS_UNSUCCESSFUL; -} - - -/* Return true if the last packet was an error */ -BOOL smbcli_is_error(struct smbcli_tree *tree) -{ - return NT_STATUS_IS_ERR(smbcli_nt_error(tree)); -} diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index 0478eff947..bec268a565 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -161,133 +161,8 @@ #define ERRsharebufexc 36 /* share buffer exceeded */ #define ERRdiskfull 39 - -/* these are win32 error codes. There are only a few places where - these matter for Samba, primarily in the NT printing code */ -#define WERR_OK W_ERROR(0) -#define WERR_BADFUNC W_ERROR(1) -#define WERR_BADFILE W_ERROR(2) -#define WERR_ACCESS_DENIED W_ERROR(5) -#define WERR_BADFID W_ERROR(6) -#define WERR_NOMEM W_ERROR(8) -#define WERR_GENERAL_FAILURE W_ERROR(31) -#define WERR_NOT_SUPPORTED W_ERROR(50) -#define WERR_BAD_NETPATH W_ERROR(53) -#define WERR_BAD_NET_RESP W_ERROR(58) -#define WERR_UNEXP_NET_ERR W_ERROR(59) -#define WERR_PRINTQ_FULL W_ERROR(61) -#define WERR_NO_SPOOL_SPACE W_ERROR(62) -#define WERR_NO_SUCH_SHARE W_ERROR(67) -#define WERR_FILE_EXISTS W_ERROR(80) -#define WERR_BAD_PASSWORD W_ERROR(86) -#define WERR_INVALID_PARAM W_ERROR(87) -#define WERR_INSUFFICIENT_BUFFER W_ERROR(122) -#define WERR_INVALID_NAME W_ERROR(123) -#define WERR_UNKNOWN_LEVEL W_ERROR(124) -#define WERR_OBJECT_PATH_INVALID W_ERROR(161) -#define WERR_ALREADY_EXISTS W_ERROR(183) -#define WERR_NO_MORE_ITEMS W_ERROR(259) -#define WERR_MORE_DATA W_ERROR(234) -#define WERR_CAN_NOT_COMPLETE W_ERROR(1003) -#define WERR_NOT_FOUND W_ERROR(1168) -#define WERR_INVALID_COMPUTERNAME W_ERROR(1210) -#define WERR_INVALID_DOMAINNAME W_ERROR(1212) -#define WERR_UNKNOWN_REVISION W_ERROR(1305) -#define WERR_REVISION_MISMATCH W_ERROR(1306) -#define WERR_INVALID_OWNER W_ERROR(1307) -#define WERR_NO_LOGON_SERVERS W_ERROR(1311) -#define WERR_NO_SUCH_PRIVILEGE W_ERROR(1313) -#define WERR_PRIVILEGE_NOT_HELD W_ERROR(1314) -#define WERR_NO_SUCH_USER W_ERROR(1317) -#define WERR_LOGON_FAILURE W_ERROR(1326) -#define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338) -#define WERR_INVALID_DOMAIN_ROLE W_ERROR(1354) -#define WERR_NO_SUCH_DOMAIN W_ERROR(1355) -#define WERR_NO_SYSTEM_RESOURCES W_ERROR(1450) -#define WERR_SERVER_UNAVAILABLE W_ERROR(1722) -#define WERR_INVALID_FORM_NAME W_ERROR(1902) -#define WERR_INVALID_FORM_SIZE W_ERROR(1903) -#define WERR_ALREADY_SHARED W_ERROR(2118) -#define WERR_BUF_TOO_SMALL W_ERROR(2123) -#define WERR_JOB_NOT_FOUND W_ERROR(2151) -#define WERR_DEST_NOT_FOUND W_ERROR(2152) -#define WERR_SESSION_NOT_FOUND W_ERROR(2312) -#define WERR_FID_NOT_FOUND W_ERROR(2314) -#define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320) -#define WERR_DOMAIN_CONTROLLER_NOT_FOUND W_ERROR(2453) -#define WERR_DEVICE_NOT_AVAILABLE W_ERROR(4319) -#define WERR_STATUS_MORE_ENTRIES W_ERROR(0x0105) - -#define WERR_PRINTER_DRIVER_ALREADY_INSTALLED W_ERROR(ERRdriveralreadyinstalled) -#define WERR_UNKNOWN_PORT W_ERROR(ERRunknownprinterport) -#define WERR_UNKNOWN_PRINTER_DRIVER W_ERROR(ERRunknownprinterdriver) -#define WERR_UNKNOWN_PRINTPROCESSOR W_ERROR(ERRunknownprintprocessor) -#define WERR_INVALID_SEPARATOR_FILE W_ERROR(ERRinvalidseparatorfile) -#define WERR_INVALID_PRIORITY W_ERROR(ERRinvalidjobpriority) -#define WERR_INVALID_PRINTER_NAME W_ERROR(ERRinvalidprintername) -#define WERR_PRINTER_ALREADY_EXISTS W_ERROR(ERRprinteralreadyexists) -#define WERR_INVALID_PRINTER_COMMAND W_ERROR(ERRinvalidprintercommand) -#define WERR_INVALID_DATATYPE W_ERROR(ERRinvaliddatatype) -#define WERR_INVALID_ENVIRONMENT W_ERROR(ERRinvalidenvironment) - -#define WERR_UNKNOWN_PRINT_MONITOR W_ERROR(ERRunknownprintmonitor) -#define WERR_PRINTER_DRIVER_IN_USE W_ERROR(ERRprinterdriverinuse) -#define WERR_SPOOL_FILE_NOT_FOUND W_ERROR(ERRspoolfilenotfound) -#define WERR_SPL_NO_STARTDOC W_ERROR(ERRnostartdoc) -#define WERR_SPL_NO_ADDJOB W_ERROR(ERRnoaddjob) -#define WERR_PRINT_PROCESSOR_ALREADY_INSTALLED W_ERROR(ERRprintprocessoralreadyinstalled) -#define WERR_PRINT_MONITOR_ALREADY_INSTALLED W_ERROR(ERRprintmonitoralreadyinstalled) -#define WERR_INVALID_PRINT_MONITOR W_ERROR(ERRinvalidprintmonitor) -#define WERR_PRINT_MONITOR_IN_USE W_ERROR(ERRprintmonitorinuse) -#define WERR_PRINTER_HAS_JOBS_QUEUED W_ERROR(ERRprinterhasjobsqueued) - -#define WERR_CLASS_NOT_REGISTERED W_ERROR(0x40154) -#define WERR_NO_SHUTDOWN_IN_PROGRESS W_ERROR(0x45c) -#define WERR_SHUTDOWN_ALREADY_IN_PROGRESS W_ERROR(0x45b) - - #ifndef NERR_BASE #define NERR_BASE (2100) #endif -#define WERR_NET_NAME_NOT_FOUND W_ERROR(NERR_BASE+210) -#define WERR_DEVICE_NOT_SHARED W_ERROR(NERR_BASE+211) - -/* DFS errors */ -#define WERR_DFS_NO_SUCH_VOL W_ERROR(NERR_BASE+562) -#define WERR_DFS_NO_SUCH_SHARE W_ERROR(NERR_BASE+565) -#define WERR_DFS_NO_SUCH_SERVER W_ERROR(NERR_BASE+573) -#define WERR_DFS_INTERNAL_ERROR W_ERROR(NERR_BASE+590) -#define WERR_DFS_CANT_CREATE_JUNCT W_ERROR(NERR_BASE+569) - -/* DS errors */ -#define WERR_DS_SERVICE_BUSY W_ERROR(0x0000200e) -#define WERR_DS_SERVICE_UNAVAILABLE W_ERROR(0x0000200f) -#define WERR_DS_NO_SUCH_OBJECT W_ERROR(0x00002030) -#define WERR_DS_OBJ_NOT_FOUND W_ERROR(0x0000208d) -#define WERR_DS_SCHEMA_NOT_LOADED W_ERROR(0x20de) -#define WERR_DS_SCHEMA_ALLOC_FAILED W_ERROR(0x20df) -#define WERR_DS_ATT_SCHEMA_REQ_SYNTAX W_ERROR(0x000020e0) -#define WERR_DS_DRA_SCHEMA_MISMATCH W_ERROR(0x000020e2) -#define WERR_DS_DRA_INVALID_PARAMETER W_ERROR(0x000020f5) -#define WERR_DS_DRA_BAD_DN W_ERROR(0x000020f7) -#define WERR_DS_DRA_BAD_NC W_ERROR(0x000020f8) -#define WERR_DS_DRA_INTERNAL_ERROR W_ERROR(0x000020fa) -#define WERR_DS_DRA_OUT_OF_MEM W_ERROR(0x000020fe) -#define WERR_DS_SINGLE_VALUE_CONSTRAINT W_ERROR(0x00002081) -#define WERR_DS_DRA_DB_ERROR W_ERROR(0x00002103) -#define WERR_DS_DRA_NO_REPLICA W_ERROR(0x00002104) -#define WERR_DS_DRA_ACCESS_DENIED W_ERROR(0x00002105) -#define WERR_DS_DNS_LOOKUP_FAILURE W_ERROR(0x0000214c) -#define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX W_ERROR(0x00002150) -#define WERR_DS_NO_MSDS_INTID W_ERROR(0x00002194) -#define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195) - -/* SEC errors */ -#define WERR_SEC_E_ENCRYPT_FAILURE W_ERROR(0x80090329) -#define WERR_SEC_E_DECRYPT_FAILURE W_ERROR(0x80090330) -#define WERR_SEC_E_ALGORITHM_MISMATCH W_ERROR(0x80090331) - -#define WERR_FOOBAR WERR_GENERAL_FAILURE - #endif /* _DOSERR_H */ diff --git a/source4/libcli/util/error.h b/source4/libcli/util/error.h index 8a641c8eb9..dd2de3da75 100644 --- a/source4/libcli/util/error.h +++ b/source4/libcli/util/error.h @@ -19,8 +19,33 @@ #ifndef _SAMBA_ERROR_H_ #define _SAMBA_ERROR_H_ -#include "libcli/util/nterr.h" +#include "libcli/util/werror.h" #include "libcli/util/doserr.h" -#include "libcli/util/proto.h" +#include "libcli/util/ntstatus.h" + +/** NT error on DOS connection! (NT_STATUS_OK) */ +bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2); + +/***************************************************************************** +convert a NT status code to a dos class/code + *****************************************************************************/ +void ntstatus_to_dos(NTSTATUS ntstatus, uint8_t *eclass, uint32_t *ecode); + +/***************************************************************************** +convert a WERROR to a NT status32 code + *****************************************************************************/ +NTSTATUS werror_to_ntstatus(WERROR error); + +/***************************************************************************** +convert a NTSTATUS to a WERROR + *****************************************************************************/ +WERROR ntstatus_to_werror(NTSTATUS error); + +/********************************************************************* + Map an NT error code from a Unix error code. +*********************************************************************/ +NTSTATUS map_nt_error_from_unix(int unix_error); + + #endif /* _SAMBA_ERROR_H */ diff --git a/source4/libcli/util/nt_status.h b/source4/libcli/util/nt_status.h deleted file mode 100644 index 8d81aab175..0000000000 --- a/source4/libcli/util/nt_status.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB parameters and setup, plus a whole lot more. - - Copyright (C) Andrew Tridgell 2001 - - 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 3 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, see . -*/ - -#ifndef _NT_STATUS_H -#define _NT_STATUS_H - -#include - -/* the following rather strange looking definitions of NTSTATUS and WERROR - and there in order to catch common coding errors where different error types - are mixed up. This is especially important as we slowly convert Samba - from using BOOL for internal functions -*/ - -#if defined(HAVE_IMMEDIATE_STRUCTURES) -typedef struct {uint32_t v;} NTSTATUS; -#define NT_STATUS(x) ((NTSTATUS) { x }) -#define NT_STATUS_V(x) ((x).v) -#else -typedef uint32_t NTSTATUS; -#define NT_STATUS(x) (x) -#define NT_STATUS_V(x) (x) -#endif - -#if defined(HAVE_IMMEDIATE_STRUCTURES) -typedef struct {uint32_t v;} WERROR; -#define W_ERROR(x) ((WERROR) { x }) -#define W_ERROR_V(x) ((x).v) -#else -typedef uint32_t WERROR; -#define W_ERROR(x) (x) -#define W_ERROR_V(x) (x) -#endif - -#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0) -#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000) -/* checking for DOS error mapping here is ugly, but unfortunately the - alternative is a very intrusive rewrite of the torture code */ -#define NT_STATUS_EQUAL(x,y) (NT_STATUS_IS_DOS(x)||NT_STATUS_IS_DOS(y)?ntstatus_dos_equal(x,y):NT_STATUS_V(x) == NT_STATUS_V(y)) - -#define NT_STATUS_HAVE_NO_MEMORY(x) do { \ - if (!(x)) {\ - return NT_STATUS_NO_MEMORY;\ - }\ -} while (0) - -#define NT_STATUS_IS_OK_RETURN(x) do { \ - if (NT_STATUS_IS_OK(x)) {\ - return x;\ - }\ -} while (0) - -#define NT_STATUS_NOT_OK_RETURN(x) do { \ - if (!NT_STATUS_IS_OK(x)) {\ - return x;\ - }\ -} while (0) - -#define NT_STATUS_IS_ERR_RETURN(x) do { \ - if (NT_STATUS_IS_ERR(x)) {\ - return x;\ - }\ -} while (0) - -#define NT_STATUS_NOT_ERR_RETURN(x) do { \ - if (!NT_STATUS_IS_ERR(x)) {\ - return x;\ - }\ -} while (0) - -#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0) -#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y)) - -#define W_ERROR_HAVE_NO_MEMORY(x) do { \ - if (!(x)) {\ - return WERR_NOMEM;\ - }\ -} while (0) - -#define W_ERROR_IS_OK_RETURN(x) do { \ - if (W_ERROR_IS_OK(x)) {\ - return x;\ - }\ -} while (0) - -#define W_ERROR_NOT_OK_RETURN(x) do { \ - if (!W_ERROR_IS_OK(x)) {\ - return x;\ - }\ -} while (0) - -/* this defines special NTSTATUS codes to represent DOS errors. I - have chosen this macro to produce status codes in the invalid - NTSTATUS range */ -#define NT_STATUS_DOS(class, code) NT_STATUS(0xF1000000 | ((class)<<16) | code) -#define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF1000000) -#define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF) -#define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF) - -/* define ldap error codes as NTSTATUS codes */ -#define NT_STATUS_LDAP(code) NT_STATUS(0xF2000000 | code) -#define NT_STATUS_IS_LDAP(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF2000000) -#define NT_STATUS_LDAP_CODE(status) (NT_STATUS_V(status) & ~0xFF000000) - -#endif diff --git a/source4/libcli/util/nterr.h b/source4/libcli/util/nterr.h deleted file mode 100644 index 1ee867a0aa..0000000000 --- a/source4/libcli/util/nterr.h +++ /dev/null @@ -1,588 +0,0 @@ -/* - Unix SMB/CIFS implementation. - NT error code constants - Copyright (C) Andrew Tridgell 1992-2000 - Copyright (C) John H Terpstra 1996-2000 - Copyright (C) Luke Kenneth Casson Leighton 1996-2000 - Copyright (C) Paul Ashton 1998-2000 - - 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 3 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, see . -*/ - -#ifndef _NTERR_H -#define _NTERR_H - -/* Win32 Status codes. */ - -#define STATUS_BUFFER_OVERFLOW NT_STATUS(0x80000005) -#define STATUS_NO_MORE_FILES NT_STATUS(0x80000006) -#define STATUS_NO_MORE_EAS NT_STATUS(0x80000012) -#define STATUS_INVALID_EA_NAME NT_STATUS(0x80000013) -#define STATUS_EA_LIST_INCONSISTENT NT_STATUS(0x80000014) -#define STATUS_INVALID_EA_FLAG NT_STATUS(0x80000015) -#define NT_STATUS_NO_MORE_ENTRIES NT_STATUS(0x8000001a) - -#define STATUS_PENDING NT_STATUS(0x0103) -#define STATUS_MORE_ENTRIES NT_STATUS(0x0105) -#define STATUS_SOME_UNMAPPED NT_STATUS(0x0107) -#define STATUS_NOTIFY_CLEANUP NT_STATUS(0x010b) -#define STATUS_NOTIFY_ENUM_DIR NT_STATUS(0x010c) -#define ERROR_INVALID_PARAMETER NT_STATUS(0x0057) -#define ERROR_INSUFFICIENT_BUFFER NT_STATUS(0x007a) -#define ERROR_INVALID_DATATYPE NT_STATUS(0x070c) - -/* Win32 Error codes extracted using a loop in smbclient then printing a - netmon sniff to a file. */ - -/* - -------------- - / \ - / REST \ - / IN \ - / PEACE \ - / \ - | NT_STATUS_NOPROBLEMO | - | | - | | - | 4 September | - | | - | 2001 | - *| * * * | * - _________)/\\_//(\/(/\)/\//\/\///|_)_______ -*/ - -#define NT_STATUS_OK NT_STATUS(0x0000) -#define NT_STATUS_UNSUCCESSFUL NT_STATUS(0xC0000000 | 0x0001) -#define NT_STATUS_NOT_IMPLEMENTED NT_STATUS(0xC0000000 | 0x0002) -#define NT_STATUS_INVALID_INFO_CLASS NT_STATUS(0xC0000000 | 0x0003) -#define NT_STATUS_INFO_LENGTH_MISMATCH NT_STATUS(0xC0000000 | 0x0004) -#define NT_STATUS_ACCESS_VIOLATION NT_STATUS(0xC0000000 | 0x0005) -#define NT_STATUS_IN_PAGE_ERROR NT_STATUS(0xC0000000 | 0x0006) -#define NT_STATUS_PAGEFILE_QUOTA NT_STATUS(0xC0000000 | 0x0007) -#define NT_STATUS_INVALID_HANDLE NT_STATUS(0xC0000000 | 0x0008) -#define NT_STATUS_BAD_INITIAL_STACK NT_STATUS(0xC0000000 | 0x0009) -#define NT_STATUS_BAD_INITIAL_PC NT_STATUS(0xC0000000 | 0x000a) -#define NT_STATUS_INVALID_CID NT_STATUS(0xC0000000 | 0x000b) -#define NT_STATUS_TIMER_NOT_CANCELED NT_STATUS(0xC0000000 | 0x000c) -#define NT_STATUS_INVALID_PARAMETER NT_STATUS(0xC0000000 | 0x000d) -#define NT_STATUS_NO_SUCH_DEVICE NT_STATUS(0xC0000000 | 0x000e) -#define NT_STATUS_NO_SUCH_FILE NT_STATUS(0xC0000000 | 0x000f) -#define NT_STATUS_INVALID_DEVICE_REQUEST NT_STATUS(0xC0000000 | 0x0010) -#define NT_STATUS_END_OF_FILE NT_STATUS(0xC0000000 | 0x0011) -#define NT_STATUS_WRONG_VOLUME NT_STATUS(0xC0000000 | 0x0012) -#define NT_STATUS_NO_MEDIA_IN_DEVICE NT_STATUS(0xC0000000 | 0x0013) -#define NT_STATUS_UNRECOGNIZED_MEDIA NT_STATUS(0xC0000000 | 0x0014) -#define NT_STATUS_NONEXISTENT_SECTOR NT_STATUS(0xC0000000 | 0x0015) -#define NT_STATUS_MORE_PROCESSING_REQUIRED NT_STATUS(0xC0000000 | 0x0016) -#if 0 -/* this demonstrates a little trick when tracking down error codes */ -#define NT_STATUS_NO_MEMORY (printf("no memory at %s\n", __location__), NT_STATUS(0xC0000000 | 0x0017)) -#else -#define NT_STATUS_NO_MEMORY NT_STATUS(0xC0000000 | 0x0017) -#endif -#define NT_STATUS_CONFLICTING_ADDRESSES NT_STATUS(0xC0000000 | 0x0018) -#define NT_STATUS_NOT_MAPPED_VIEW NT_STATUS(0xC0000000 | 0x0019) -#define NT_STATUS_UNABLE_TO_FREE_VM NT_STATUS(0xC0000000 | 0x001a) -#define NT_STATUS_UNABLE_TO_DELETE_SECTION NT_STATUS(0xC0000000 | 0x001b) -#define NT_STATUS_INVALID_SYSTEM_SERVICE NT_STATUS(0xC0000000 | 0x001c) -#define NT_STATUS_ILLEGAL_INSTRUCTION NT_STATUS(0xC0000000 | 0x001d) -#define NT_STATUS_INVALID_LOCK_SEQUENCE NT_STATUS(0xC0000000 | 0x001e) -#define NT_STATUS_INVALID_VIEW_SIZE NT_STATUS(0xC0000000 | 0x001f) -#define NT_STATUS_INVALID_FILE_FOR_SECTION NT_STATUS(0xC0000000 | 0x0020) -#define NT_STATUS_ALREADY_COMMITTED NT_STATUS(0xC0000000 | 0x0021) -#if 0 -/* this demonstrates a little trick when tracking down error codes */ -#define NT_STATUS_ACCESS_DENIED (printf("access denied at %s\n", __location__), NT_STATUS(0xC0000000 | 0x0022)) -#else -#define NT_STATUS_ACCESS_DENIED NT_STATUS(0xC0000000 | 0x0022) -#endif -#define NT_STATUS_BUFFER_TOO_SMALL NT_STATUS(0xC0000000 | 0x0023) -#define NT_STATUS_OBJECT_TYPE_MISMATCH NT_STATUS(0xC0000000 | 0x0024) -#define NT_STATUS_NONCONTINUABLE_EXCEPTION NT_STATUS(0xC0000000 | 0x0025) -#define NT_STATUS_INVALID_DISPOSITION NT_STATUS(0xC0000000 | 0x0026) -#define NT_STATUS_UNWIND NT_STATUS(0xC0000000 | 0x0027) -#define NT_STATUS_BAD_STACK NT_STATUS(0xC0000000 | 0x0028) -#define NT_STATUS_INVALID_UNWIND_TARGET NT_STATUS(0xC0000000 | 0x0029) -#define NT_STATUS_NOT_LOCKED NT_STATUS(0xC0000000 | 0x002a) -#define NT_STATUS_PARITY_ERROR NT_STATUS(0xC0000000 | 0x002b) -#define NT_STATUS_UNABLE_TO_DECOMMIT_VM NT_STATUS(0xC0000000 | 0x002c) -#define NT_STATUS_NOT_COMMITTED NT_STATUS(0xC0000000 | 0x002d) -#define NT_STATUS_INVALID_PORT_ATTRIBUTES NT_STATUS(0xC0000000 | 0x002e) -#define NT_STATUS_PORT_MESSAGE_TOO_LONG NT_STATUS(0xC0000000 | 0x002f) -#define NT_STATUS_INVALID_PARAMETER_MIX NT_STATUS(0xC0000000 | 0x0030) -#define NT_STATUS_INVALID_QUOTA_LOWER NT_STATUS(0xC0000000 | 0x0031) -#define NT_STATUS_DISK_CORRUPT_ERROR NT_STATUS(0xC0000000 | 0x0032) -#define NT_STATUS_OBJECT_NAME_INVALID NT_STATUS(0xC0000000 | 0x0033) -#define NT_STATUS_OBJECT_NAME_NOT_FOUND NT_STATUS(0xC0000000 | 0x0034) -#define NT_STATUS_OBJECT_NAME_COLLISION NT_STATUS(0xC0000000 | 0x0035) -#define NT_STATUS_HANDLE_NOT_WAITABLE NT_STATUS(0xC0000000 | 0x0036) -#define NT_STATUS_PORT_DISCONNECTED NT_STATUS(0xC0000000 | 0x0037) -#define NT_STATUS_DEVICE_ALREADY_ATTACHED NT_STATUS(0xC0000000 | 0x0038) -#define NT_STATUS_OBJECT_PATH_INVALID NT_STATUS(0xC0000000 | 0x0039) -#define NT_STATUS_OBJECT_PATH_NOT_FOUND NT_STATUS(0xC0000000 | 0x003a) -#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD NT_STATUS(0xC0000000 | 0x003b) -#define NT_STATUS_DATA_OVERRUN NT_STATUS(0xC0000000 | 0x003c) -#define NT_STATUS_DATA_LATE_ERROR NT_STATUS(0xC0000000 | 0x003d) -#define NT_STATUS_DATA_ERROR NT_STATUS(0xC0000000 | 0x003e) -#define NT_STATUS_CRC_ERROR NT_STATUS(0xC0000000 | 0x003f) -#define NT_STATUS_SECTION_TOO_BIG NT_STATUS(0xC0000000 | 0x0040) -#define NT_STATUS_PORT_CONNECTION_REFUSED NT_STATUS(0xC0000000 | 0x0041) -#define NT_STATUS_INVALID_PORT_HANDLE NT_STATUS(0xC0000000 | 0x0042) -#define NT_STATUS_SHARING_VIOLATION NT_STATUS(0xC0000000 | 0x0043) -#define NT_STATUS_QUOTA_EXCEEDED NT_STATUS(0xC0000000 | 0x0044) -#define NT_STATUS_INVALID_PAGE_PROTECTION NT_STATUS(0xC0000000 | 0x0045) -#define NT_STATUS_MUTANT_NOT_OWNED NT_STATUS(0xC0000000 | 0x0046) -#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED NT_STATUS(0xC0000000 | 0x0047) -#define NT_STATUS_PORT_ALREADY_SET NT_STATUS(0xC0000000 | 0x0048) -#define NT_STATUS_SECTION_NOT_IMAGE NT_STATUS(0xC0000000 | 0x0049) -#define NT_STATUS_SUSPEND_COUNT_EXCEEDED NT_STATUS(0xC0000000 | 0x004a) -#define NT_STATUS_THREAD_IS_TERMINATING NT_STATUS(0xC0000000 | 0x004b) -#define NT_STATUS_BAD_WORKING_SET_LIMIT NT_STATUS(0xC0000000 | 0x004c) -#define NT_STATUS_INCOMPATIBLE_FILE_MAP NT_STATUS(0xC0000000 | 0x004d) -#define NT_STATUS_SECTION_PROTECTION NT_STATUS(0xC0000000 | 0x004e) -#define NT_STATUS_EAS_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x004f) -#define NT_STATUS_EA_TOO_LARGE NT_STATUS(0xC0000000 | 0x0050) -#define NT_STATUS_NONEXISTENT_EA_ENTRY NT_STATUS(0xC0000000 | 0x0051) -#define NT_STATUS_NO_EAS_ON_FILE NT_STATUS(0xC0000000 | 0x0052) -#define NT_STATUS_EA_CORRUPT_ERROR NT_STATUS(0xC0000000 | 0x0053) -#define NT_STATUS_FILE_LOCK_CONFLICT NT_STATUS(0xC0000000 | 0x0054) -#define NT_STATUS_LOCK_NOT_GRANTED NT_STATUS(0xC0000000 | 0x0055) -#define NT_STATUS_DELETE_PENDING NT_STATUS(0xC0000000 | 0x0056) -#define NT_STATUS_CTL_FILE_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x0057) -#define NT_STATUS_UNKNOWN_REVISION NT_STATUS(0xC0000000 | 0x0058) -#define NT_STATUS_REVISION_MISMATCH NT_STATUS(0xC0000000 | 0x0059) -#define NT_STATUS_INVALID_OWNER NT_STATUS(0xC0000000 | 0x005a) -#define NT_STATUS_INVALID_PRIMARY_GROUP NT_STATUS(0xC0000000 | 0x005b) -#define NT_STATUS_NO_IMPERSONATION_TOKEN NT_STATUS(0xC0000000 | 0x005c) -#define NT_STATUS_CANT_DISABLE_MANDATORY NT_STATUS(0xC0000000 | 0x005d) -#define NT_STATUS_NO_LOGON_SERVERS NT_STATUS(0xC0000000 | 0x005e) -#define NT_STATUS_NO_SUCH_LOGON_SESSION NT_STATUS(0xC0000000 | 0x005f) -#define NT_STATUS_NO_SUCH_PRIVILEGE NT_STATUS(0xC0000000 | 0x0060) -#define NT_STATUS_PRIVILEGE_NOT_HELD NT_STATUS(0xC0000000 | 0x0061) -#define NT_STATUS_INVALID_ACCOUNT_NAME NT_STATUS(0xC0000000 | 0x0062) -#define NT_STATUS_USER_EXISTS NT_STATUS(0xC0000000 | 0x0063) -#define NT_STATUS_NO_SUCH_USER NT_STATUS(0xC0000000 | 0x0064) -#define NT_STATUS_GROUP_EXISTS NT_STATUS(0xC0000000 | 0x0065) -#define NT_STATUS_NO_SUCH_GROUP NT_STATUS(0xC0000000 | 0x0066) -#define NT_STATUS_MEMBER_IN_GROUP NT_STATUS(0xC0000000 | 0x0067) -#define NT_STATUS_MEMBER_NOT_IN_GROUP NT_STATUS(0xC0000000 | 0x0068) -#define NT_STATUS_LAST_ADMIN NT_STATUS(0xC0000000 | 0x0069) -#define NT_STATUS_WRONG_PASSWORD NT_STATUS(0xC0000000 | 0x006a) -#define NT_STATUS_ILL_FORMED_PASSWORD NT_STATUS(0xC0000000 | 0x006b) -#define NT_STATUS_PASSWORD_RESTRICTION NT_STATUS(0xC0000000 | 0x006c) -#define NT_STATUS_LOGON_FAILURE NT_STATUS(0xC0000000 | 0x006d) -#define NT_STATUS_ACCOUNT_RESTRICTION NT_STATUS(0xC0000000 | 0x006e) -#define NT_STATUS_INVALID_LOGON_HOURS NT_STATUS(0xC0000000 | 0x006f) -#define NT_STATUS_INVALID_WORKSTATION NT_STATUS(0xC0000000 | 0x0070) -#define NT_STATUS_PASSWORD_EXPIRED NT_STATUS(0xC0000000 | 0x0071) -#define NT_STATUS_ACCOUNT_DISABLED NT_STATUS(0xC0000000 | 0x0072) -#define NT_STATUS_NONE_MAPPED NT_STATUS(0xC0000000 | 0x0073) -#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED NT_STATUS(0xC0000000 | 0x0074) -#define NT_STATUS_LUIDS_EXHAUSTED NT_STATUS(0xC0000000 | 0x0075) -#define NT_STATUS_INVALID_SUB_AUTHORITY NT_STATUS(0xC0000000 | 0x0076) -#define NT_STATUS_INVALID_ACL NT_STATUS(0xC0000000 | 0x0077) -#define NT_STATUS_INVALID_SID NT_STATUS(0xC0000000 | 0x0078) -#define NT_STATUS_INVALID_SECURITY_DESCR NT_STATUS(0xC0000000 | 0x0079) -#define NT_STATUS_PROCEDURE_NOT_FOUND NT_STATUS(0xC0000000 | 0x007a) -#define NT_STATUS_INVALID_IMAGE_FORMAT NT_STATUS(0xC0000000 | 0x007b) -#define NT_STATUS_NO_TOKEN NT_STATUS(0xC0000000 | 0x007c) -#define NT_STATUS_BAD_INHERITANCE_ACL NT_STATUS(0xC0000000 | 0x007d) -#define NT_STATUS_RANGE_NOT_LOCKED NT_STATUS(0xC0000000 | 0x007e) -#define NT_STATUS_DISK_FULL NT_STATUS(0xC0000000 | 0x007f) -#define NT_STATUS_SERVER_DISABLED NT_STATUS(0xC0000000 | 0x0080) -#define NT_STATUS_SERVER_NOT_DISABLED NT_STATUS(0xC0000000 | 0x0081) -#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED NT_STATUS(0xC0000000 | 0x0082) -#define NT_STATUS_GUIDS_EXHAUSTED NT_STATUS(0xC0000000 | 0x0083) -#define NT_STATUS_INVALID_ID_AUTHORITY NT_STATUS(0xC0000000 | 0x0084) -#define NT_STATUS_AGENTS_EXHAUSTED NT_STATUS(0xC0000000 | 0x0085) -#define NT_STATUS_INVALID_VOLUME_LABEL NT_STATUS(0xC0000000 | 0x0086) -#define NT_STATUS_SECTION_NOT_EXTENDED NT_STATUS(0xC0000000 | 0x0087) -#define NT_STATUS_NOT_MAPPED_DATA NT_STATUS(0xC0000000 | 0x0088) -#define NT_STATUS_RESOURCE_DATA_NOT_FOUND NT_STATUS(0xC0000000 | 0x0089) -#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND NT_STATUS(0xC0000000 | 0x008a) -#define NT_STATUS_RESOURCE_NAME_NOT_FOUND NT_STATUS(0xC0000000 | 0x008b) -#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED NT_STATUS(0xC0000000 | 0x008c) -#define NT_STATUS_FLOAT_DENORMAL_OPERAND NT_STATUS(0xC0000000 | 0x008d) -#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO NT_STATUS(0xC0000000 | 0x008e) -#define NT_STATUS_FLOAT_INEXACT_RESULT NT_STATUS(0xC0000000 | 0x008f) -#define NT_STATUS_FLOAT_INVALID_OPERATION NT_STATUS(0xC0000000 | 0x0090) -#define NT_STATUS_FLOAT_OVERFLOW NT_STATUS(0xC0000000 | 0x0091) -#define NT_STATUS_FLOAT_STACK_CHECK NT_STATUS(0xC0000000 | 0x0092) -#define NT_STATUS_FLOAT_UNDERFLOW NT_STATUS(0xC0000000 | 0x0093) -#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO NT_STATUS(0xC0000000 | 0x0094) -#define NT_STATUS_INTEGER_OVERFLOW NT_STATUS(0xC0000000 | 0x0095) -#define NT_STATUS_PRIVILEGED_INSTRUCTION NT_STATUS(0xC0000000 | 0x0096) -#define NT_STATUS_TOO_MANY_PAGING_FILES NT_STATUS(0xC0000000 | 0x0097) -#define NT_STATUS_FILE_INVALID NT_STATUS(0xC0000000 | 0x0098) -#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED NT_STATUS(0xC0000000 | 0x0099) -#define NT_STATUS_INSUFFICIENT_RESOURCES NT_STATUS(0xC0000000 | 0x009a) -#define NT_STATUS_DFS_EXIT_PATH_FOUND NT_STATUS(0xC0000000 | 0x009b) -#define NT_STATUS_DEVICE_DATA_ERROR NT_STATUS(0xC0000000 | 0x009c) -#define NT_STATUS_DEVICE_NOT_CONNECTED NT_STATUS(0xC0000000 | 0x009d) -#define NT_STATUS_DEVICE_POWER_FAILURE NT_STATUS(0xC0000000 | 0x009e) -#define NT_STATUS_FREE_VM_NOT_AT_BASE NT_STATUS(0xC0000000 | 0x009f) -#define NT_STATUS_MEMORY_NOT_ALLOCATED NT_STATUS(0xC0000000 | 0x00a0) -#define NT_STATUS_WORKING_SET_QUOTA NT_STATUS(0xC0000000 | 0x00a1) -#define NT_STATUS_MEDIA_WRITE_PROTECTED NT_STATUS(0xC0000000 | 0x00a2) -#define NT_STATUS_DEVICE_NOT_READY NT_STATUS(0xC0000000 | 0x00a3) -#define NT_STATUS_INVALID_GROUP_ATTRIBUTES NT_STATUS(0xC0000000 | 0x00a4) -#define NT_STATUS_BAD_IMPERSONATION_LEVEL NT_STATUS(0xC0000000 | 0x00a5) -#define NT_STATUS_CANT_OPEN_ANONYMOUS NT_STATUS(0xC0000000 | 0x00a6) -#define NT_STATUS_BAD_VALIDATION_CLASS NT_STATUS(0xC0000000 | 0x00a7) -#define NT_STATUS_BAD_TOKEN_TYPE NT_STATUS(0xC0000000 | 0x00a8) -#define NT_STATUS_BAD_MASTER_BOOT_RECORD NT_STATUS(0xC0000000 | 0x00a9) -#define NT_STATUS_INSTRUCTION_MISALIGNMENT NT_STATUS(0xC0000000 | 0x00aa) -#define NT_STATUS_INSTANCE_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x00ab) -#define NT_STATUS_PIPE_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x00ac) -#define NT_STATUS_INVALID_PIPE_STATE NT_STATUS(0xC0000000 | 0x00ad) -#define NT_STATUS_PIPE_BUSY NT_STATUS(0xC0000000 | 0x00ae) -#define NT_STATUS_ILLEGAL_FUNCTION NT_STATUS(0xC0000000 | 0x00af) -#define NT_STATUS_PIPE_DISCONNECTED NT_STATUS(0xC0000000 | 0x00b0) -#define NT_STATUS_PIPE_CLOSING NT_STATUS(0xC0000000 | 0x00b1) -#define NT_STATUS_PIPE_CONNECTED NT_STATUS(0xC0000000 | 0x00b2) -#define NT_STATUS_PIPE_LISTENING NT_STATUS(0xC0000000 | 0x00b3) -#define NT_STATUS_INVALID_READ_MODE NT_STATUS(0xC0000000 | 0x00b4) -#define NT_STATUS_IO_TIMEOUT NT_STATUS(0xC0000000 | 0x00b5) -#define NT_STATUS_FILE_FORCED_CLOSED NT_STATUS(0xC0000000 | 0x00b6) -#define NT_STATUS_PROFILING_NOT_STARTED NT_STATUS(0xC0000000 | 0x00b7) -#define NT_STATUS_PROFILING_NOT_STOPPED NT_STATUS(0xC0000000 | 0x00b8) -#define NT_STATUS_COULD_NOT_INTERPRET NT_STATUS(0xC0000000 | 0x00b9) -#define NT_STATUS_FILE_IS_A_DIRECTORY NT_STATUS(0xC0000000 | 0x00ba) -#define NT_STATUS_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x00bb) -#define NT_STATUS_REMOTE_NOT_LISTENING NT_STATUS(0xC0000000 | 0x00bc) -#define NT_STATUS_DUPLICATE_NAME NT_STATUS(0xC0000000 | 0x00bd) -#define NT_STATUS_BAD_NETWORK_PATH NT_STATUS(0xC0000000 | 0x00be) -#define NT_STATUS_NETWORK_BUSY NT_STATUS(0xC0000000 | 0x00bf) -#define NT_STATUS_DEVICE_DOES_NOT_EXIST NT_STATUS(0xC0000000 | 0x00c0) -#define NT_STATUS_TOO_MANY_COMMANDS NT_STATUS(0xC0000000 | 0x00c1) -#define NT_STATUS_ADAPTER_HARDWARE_ERROR NT_STATUS(0xC0000000 | 0x00c2) -#define NT_STATUS_INVALID_NETWORK_RESPONSE NT_STATUS(0xC0000000 | 0x00c3) -#define NT_STATUS_UNEXPECTED_NETWORK_ERROR NT_STATUS(0xC0000000 | 0x00c4) -#define NT_STATUS_BAD_REMOTE_ADAPTER NT_STATUS(0xC0000000 | 0x00c5) -#define NT_STATUS_PRINT_QUEUE_FULL NT_STATUS(0xC0000000 | 0x00c6) -#define NT_STATUS_NO_SPOOL_SPACE NT_STATUS(0xC0000000 | 0x00c7) -#define NT_STATUS_PRINT_CANCELLED NT_STATUS(0xC0000000 | 0x00c8) -#define NT_STATUS_NETWORK_NAME_DELETED NT_STATUS(0xC0000000 | 0x00c9) -#define NT_STATUS_NETWORK_ACCESS_DENIED NT_STATUS(0xC0000000 | 0x00ca) -#define NT_STATUS_BAD_DEVICE_TYPE NT_STATUS(0xC0000000 | 0x00cb) -#define NT_STATUS_BAD_NETWORK_NAME NT_STATUS(0xC0000000 | 0x00cc) -#define NT_STATUS_TOO_MANY_NAMES NT_STATUS(0xC0000000 | 0x00cd) -#define NT_STATUS_TOO_MANY_SESSIONS NT_STATUS(0xC0000000 | 0x00ce) -#define NT_STATUS_SHARING_PAUSED NT_STATUS(0xC0000000 | 0x00cf) -#define NT_STATUS_REQUEST_NOT_ACCEPTED NT_STATUS(0xC0000000 | 0x00d0) -#define NT_STATUS_REDIRECTOR_PAUSED NT_STATUS(0xC0000000 | 0x00d1) -#define NT_STATUS_NET_WRITE_FAULT NT_STATUS(0xC0000000 | 0x00d2) -#define NT_STATUS_PROFILING_AT_LIMIT NT_STATUS(0xC0000000 | 0x00d3) -#define NT_STATUS_NOT_SAME_DEVICE NT_STATUS(0xC0000000 | 0x00d4) -#define NT_STATUS_FILE_RENAMED NT_STATUS(0xC0000000 | 0x00d5) -#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED NT_STATUS(0xC0000000 | 0x00d6) -#define NT_STATUS_NO_SECURITY_ON_OBJECT NT_STATUS(0xC0000000 | 0x00d7) -#define NT_STATUS_CANT_WAIT NT_STATUS(0xC0000000 | 0x00d8) -#define NT_STATUS_PIPE_EMPTY NT_STATUS(0xC0000000 | 0x00d9) -#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO NT_STATUS(0xC0000000 | 0x00da) -#define NT_STATUS_CANT_TERMINATE_SELF NT_STATUS(0xC0000000 | 0x00db) -#define NT_STATUS_INVALID_SERVER_STATE NT_STATUS(0xC0000000 | 0x00dc) -#define NT_STATUS_INVALID_DOMAIN_STATE NT_STATUS(0xC0000000 | 0x00dd) -#define NT_STATUS_INVALID_DOMAIN_ROLE NT_STATUS(0xC0000000 | 0x00de) -#define NT_STATUS_NO_SUCH_DOMAIN NT_STATUS(0xC0000000 | 0x00df) -#define NT_STATUS_DOMAIN_EXISTS NT_STATUS(0xC0000000 | 0x00e0) -#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED NT_STATUS(0xC0000000 | 0x00e1) -#define NT_STATUS_OPLOCK_NOT_GRANTED NT_STATUS(0xC0000000 | 0x00e2) -#define NT_STATUS_INVALID_OPLOCK_PROTOCOL NT_STATUS(0xC0000000 | 0x00e3) -#define NT_STATUS_INTERNAL_DB_CORRUPTION NT_STATUS(0xC0000000 | 0x00e4) -#define NT_STATUS_INTERNAL_ERROR NT_STATUS(0xC0000000 | 0x00e5) -#define NT_STATUS_GENERIC_NOT_MAPPED NT_STATUS(0xC0000000 | 0x00e6) -#define NT_STATUS_BAD_DESCRIPTOR_FORMAT NT_STATUS(0xC0000000 | 0x00e7) -#define NT_STATUS_INVALID_USER_BUFFER NT_STATUS(0xC0000000 | 0x00e8) -#define NT_STATUS_UNEXPECTED_IO_ERROR NT_STATUS(0xC0000000 | 0x00e9) -#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR NT_STATUS(0xC0000000 | 0x00ea) -#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR NT_STATUS(0xC0000000 | 0x00eb) -#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR NT_STATUS(0xC0000000 | 0x00ec) -#define NT_STATUS_NOT_LOGON_PROCESS NT_STATUS(0xC0000000 | 0x00ed) -#define NT_STATUS_LOGON_SESSION_EXISTS NT_STATUS(0xC0000000 | 0x00ee) -#define NT_STATUS_INVALID_PARAMETER_1 NT_STATUS(0xC0000000 | 0x00ef) -#define NT_STATUS_INVALID_PARAMETER_2 NT_STATUS(0xC0000000 | 0x00f0) -#define NT_STATUS_INVALID_PARAMETER_3 NT_STATUS(0xC0000000 | 0x00f1) -#define NT_STATUS_INVALID_PARAMETER_4 NT_STATUS(0xC0000000 | 0x00f2) -#define NT_STATUS_INVALID_PARAMETER_5 NT_STATUS(0xC0000000 | 0x00f3) -#define NT_STATUS_INVALID_PARAMETER_6 NT_STATUS(0xC0000000 | 0x00f4) -#define NT_STATUS_INVALID_PARAMETER_7 NT_STATUS(0xC0000000 | 0x00f5) -#define NT_STATUS_INVALID_PARAMETER_8 NT_STATUS(0xC0000000 | 0x00f6) -#define NT_STATUS_INVALID_PARAMETER_9 NT_STATUS(0xC0000000 | 0x00f7) -#define NT_STATUS_INVALID_PARAMETER_10 NT_STATUS(0xC0000000 | 0x00f8) -#define NT_STATUS_INVALID_PARAMETER_11 NT_STATUS(0xC0000000 | 0x00f9) -#define NT_STATUS_INVALID_PARAMETER_12 NT_STATUS(0xC0000000 | 0x00fa) -#define NT_STATUS_REDIRECTOR_NOT_STARTED NT_STATUS(0xC0000000 | 0x00fb) -#define NT_STATUS_REDIRECTOR_STARTED NT_STATUS(0xC0000000 | 0x00fc) -#define NT_STATUS_STACK_OVERFLOW NT_STATUS(0xC0000000 | 0x00fd) -#define NT_STATUS_NO_SUCH_PACKAGE NT_STATUS(0xC0000000 | 0x00fe) -#define NT_STATUS_BAD_FUNCTION_TABLE NT_STATUS(0xC0000000 | 0x00ff) -#define NT_STATUS_DIRECTORY_NOT_EMPTY NT_STATUS(0xC0000000 | 0x0101) -#define NT_STATUS_FILE_CORRUPT_ERROR NT_STATUS(0xC0000000 | 0x0102) -#define NT_STATUS_NOT_A_DIRECTORY NT_STATUS(0xC0000000 | 0x0103) -#define NT_STATUS_BAD_LOGON_SESSION_STATE NT_STATUS(0xC0000000 | 0x0104) -#define NT_STATUS_LOGON_SESSION_COLLISION NT_STATUS(0xC0000000 | 0x0105) -#define NT_STATUS_NAME_TOO_LONG NT_STATUS(0xC0000000 | 0x0106) -#define NT_STATUS_FILES_OPEN NT_STATUS(0xC0000000 | 0x0107) -#define NT_STATUS_CONNECTION_IN_USE NT_STATUS(0xC0000000 | 0x0108) -#define NT_STATUS_MESSAGE_NOT_FOUND NT_STATUS(0xC0000000 | 0x0109) -#define NT_STATUS_PROCESS_IS_TERMINATING NT_STATUS(0xC0000000 | 0x010a) -#define NT_STATUS_INVALID_LOGON_TYPE NT_STATUS(0xC0000000 | 0x010b) -#define NT_STATUS_NO_GUID_TRANSLATION NT_STATUS(0xC0000000 | 0x010c) -#define NT_STATUS_CANNOT_IMPERSONATE NT_STATUS(0xC0000000 | 0x010d) -#define NT_STATUS_IMAGE_ALREADY_LOADED NT_STATUS(0xC0000000 | 0x010e) -#define NT_STATUS_ABIOS_NOT_PRESENT NT_STATUS(0xC0000000 | 0x010f) -#define NT_STATUS_ABIOS_LID_NOT_EXIST NT_STATUS(0xC0000000 | 0x0110) -#define NT_STATUS_ABIOS_LID_ALREADY_OWNED NT_STATUS(0xC0000000 | 0x0111) -#define NT_STATUS_ABIOS_NOT_LID_OWNER NT_STATUS(0xC0000000 | 0x0112) -#define NT_STATUS_ABIOS_INVALID_COMMAND NT_STATUS(0xC0000000 | 0x0113) -#define NT_STATUS_ABIOS_INVALID_LID NT_STATUS(0xC0000000 | 0x0114) -#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x0115) -#define NT_STATUS_ABIOS_INVALID_SELECTOR NT_STATUS(0xC0000000 | 0x0116) -#define NT_STATUS_NO_LDT NT_STATUS(0xC0000000 | 0x0117) -#define NT_STATUS_INVALID_LDT_SIZE NT_STATUS(0xC0000000 | 0x0118) -#define NT_STATUS_INVALID_LDT_OFFSET NT_STATUS(0xC0000000 | 0x0119) -#define NT_STATUS_INVALID_LDT_DESCRIPTOR NT_STATUS(0xC0000000 | 0x011a) -#define NT_STATUS_INVALID_IMAGE_NE_FORMAT NT_STATUS(0xC0000000 | 0x011b) -#define NT_STATUS_RXACT_INVALID_STATE NT_STATUS(0xC0000000 | 0x011c) -#define NT_STATUS_RXACT_COMMIT_FAILURE NT_STATUS(0xC0000000 | 0x011d) -#define NT_STATUS_MAPPED_FILE_SIZE_ZERO NT_STATUS(0xC0000000 | 0x011e) -#define NT_STATUS_TOO_MANY_OPENED_FILES NT_STATUS(0xC0000000 | 0x011f) -#define NT_STATUS_CANCELLED NT_STATUS(0xC0000000 | 0x0120) -#define NT_STATUS_CANNOT_DELETE NT_STATUS(0xC0000000 | 0x0121) -#define NT_STATUS_INVALID_COMPUTER_NAME NT_STATUS(0xC0000000 | 0x0122) -#define NT_STATUS_FILE_DELETED NT_STATUS(0xC0000000 | 0x0123) -#define NT_STATUS_SPECIAL_ACCOUNT NT_STATUS(0xC0000000 | 0x0124) -#define NT_STATUS_SPECIAL_GROUP NT_STATUS(0xC0000000 | 0x0125) -#define NT_STATUS_SPECIAL_USER NT_STATUS(0xC0000000 | 0x0126) -#define NT_STATUS_MEMBERS_PRIMARY_GROUP NT_STATUS(0xC0000000 | 0x0127) -#define NT_STATUS_FILE_CLOSED NT_STATUS(0xC0000000 | 0x0128) -#define NT_STATUS_TOO_MANY_THREADS NT_STATUS(0xC0000000 | 0x0129) -#define NT_STATUS_THREAD_NOT_IN_PROCESS NT_STATUS(0xC0000000 | 0x012a) -#define NT_STATUS_TOKEN_ALREADY_IN_USE NT_STATUS(0xC0000000 | 0x012b) -#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED NT_STATUS(0xC0000000 | 0x012c) -#define NT_STATUS_COMMITMENT_LIMIT NT_STATUS(0xC0000000 | 0x012d) -#define NT_STATUS_INVALID_IMAGE_LE_FORMAT NT_STATUS(0xC0000000 | 0x012e) -#define NT_STATUS_INVALID_IMAGE_NOT_MZ NT_STATUS(0xC0000000 | 0x012f) -#define NT_STATUS_INVALID_IMAGE_PROTECT NT_STATUS(0xC0000000 | 0x0130) -#define NT_STATUS_INVALID_IMAGE_WIN_16 NT_STATUS(0xC0000000 | 0x0131) -#define NT_STATUS_LOGON_SERVER_CONFLICT NT_STATUS(0xC0000000 | 0x0132) -#define NT_STATUS_TIME_DIFFERENCE_AT_DC NT_STATUS(0xC0000000 | 0x0133) -#define NT_STATUS_SYNCHRONIZATION_REQUIRED NT_STATUS(0xC0000000 | 0x0134) -#define NT_STATUS_DLL_NOT_FOUND NT_STATUS(0xC0000000 | 0x0135) -#define NT_STATUS_OPEN_FAILED NT_STATUS(0xC0000000 | 0x0136) -#define NT_STATUS_IO_PRIVILEGE_FAILED NT_STATUS(0xC0000000 | 0x0137) -#define NT_STATUS_ORDINAL_NOT_FOUND NT_STATUS(0xC0000000 | 0x0138) -#define NT_STATUS_ENTRYPOINT_NOT_FOUND NT_STATUS(0xC0000000 | 0x0139) -#define NT_STATUS_CONTROL_C_EXIT NT_STATUS(0xC0000000 | 0x013a) -#define NT_STATUS_LOCAL_DISCONNECT NT_STATUS(0xC0000000 | 0x013b) -#define NT_STATUS_REMOTE_DISCONNECT NT_STATUS(0xC0000000 | 0x013c) -#define NT_STATUS_REMOTE_RESOURCES NT_STATUS(0xC0000000 | 0x013d) -#define NT_STATUS_LINK_FAILED NT_STATUS(0xC0000000 | 0x013e) -#define NT_STATUS_LINK_TIMEOUT NT_STATUS(0xC0000000 | 0x013f) -#define NT_STATUS_INVALID_CONNECTION NT_STATUS(0xC0000000 | 0x0140) -#define NT_STATUS_INVALID_ADDRESS NT_STATUS(0xC0000000 | 0x0141) -#define NT_STATUS_DLL_INIT_FAILED NT_STATUS(0xC0000000 | 0x0142) -#define NT_STATUS_MISSING_SYSTEMFILE NT_STATUS(0xC0000000 | 0x0143) -#define NT_STATUS_UNHANDLED_EXCEPTION NT_STATUS(0xC0000000 | 0x0144) -#define NT_STATUS_APP_INIT_FAILURE NT_STATUS(0xC0000000 | 0x0145) -#define NT_STATUS_PAGEFILE_CREATE_FAILED NT_STATUS(0xC0000000 | 0x0146) -#define NT_STATUS_NO_PAGEFILE NT_STATUS(0xC0000000 | 0x0147) -#define NT_STATUS_INVALID_LEVEL NT_STATUS(0xC0000000 | 0x0148) -#define NT_STATUS_WRONG_PASSWORD_CORE NT_STATUS(0xC0000000 | 0x0149) -#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT NT_STATUS(0xC0000000 | 0x014a) -#define NT_STATUS_PIPE_BROKEN NT_STATUS(0xC0000000 | 0x014b) -#define NT_STATUS_REGISTRY_CORRUPT NT_STATUS(0xC0000000 | 0x014c) -#define NT_STATUS_REGISTRY_IO_FAILED NT_STATUS(0xC0000000 | 0x014d) -#define NT_STATUS_NO_EVENT_PAIR NT_STATUS(0xC0000000 | 0x014e) -#define NT_STATUS_UNRECOGNIZED_VOLUME NT_STATUS(0xC0000000 | 0x014f) -#define NT_STATUS_SERIAL_NO_DEVICE_INITED NT_STATUS(0xC0000000 | 0x0150) -#define NT_STATUS_NO_SUCH_ALIAS NT_STATUS(0xC0000000 | 0x0151) -#define NT_STATUS_MEMBER_NOT_IN_ALIAS NT_STATUS(0xC0000000 | 0x0152) -#define NT_STATUS_MEMBER_IN_ALIAS NT_STATUS(0xC0000000 | 0x0153) -#define NT_STATUS_ALIAS_EXISTS NT_STATUS(0xC0000000 | 0x0154) -#define NT_STATUS_LOGON_NOT_GRANTED NT_STATUS(0xC0000000 | 0x0155) -#define NT_STATUS_TOO_MANY_SECRETS NT_STATUS(0xC0000000 | 0x0156) -#define NT_STATUS_SECRET_TOO_LONG NT_STATUS(0xC0000000 | 0x0157) -#define NT_STATUS_INTERNAL_DB_ERROR NT_STATUS(0xC0000000 | 0x0158) -#define NT_STATUS_FULLSCREEN_MODE NT_STATUS(0xC0000000 | 0x0159) -#define NT_STATUS_TOO_MANY_CONTEXT_IDS NT_STATUS(0xC0000000 | 0x015a) -#define NT_STATUS_LOGON_TYPE_NOT_GRANTED NT_STATUS(0xC0000000 | 0x015b) -#define NT_STATUS_NOT_REGISTRY_FILE NT_STATUS(0xC0000000 | 0x015c) -#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED NT_STATUS(0xC0000000 | 0x015d) -#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR NT_STATUS(0xC0000000 | 0x015e) -#define NT_STATUS_FT_MISSING_MEMBER NT_STATUS(0xC0000000 | 0x015f) -#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY NT_STATUS(0xC0000000 | 0x0160) -#define NT_STATUS_ILLEGAL_CHARACTER NT_STATUS(0xC0000000 | 0x0161) -#define NT_STATUS_UNMAPPABLE_CHARACTER NT_STATUS(0xC0000000 | 0x0162) -#define NT_STATUS_UNDEFINED_CHARACTER NT_STATUS(0xC0000000 | 0x0163) -#define NT_STATUS_FLOPPY_VOLUME NT_STATUS(0xC0000000 | 0x0164) -#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND NT_STATUS(0xC0000000 | 0x0165) -#define NT_STATUS_FLOPPY_WRONG_CYLINDER NT_STATUS(0xC0000000 | 0x0166) -#define NT_STATUS_FLOPPY_UNKNOWN_ERROR NT_STATUS(0xC0000000 | 0x0167) -#define NT_STATUS_FLOPPY_BAD_REGISTERS NT_STATUS(0xC0000000 | 0x0168) -#define NT_STATUS_DISK_RECALIBRATE_FAILED NT_STATUS(0xC0000000 | 0x0169) -#define NT_STATUS_DISK_OPERATION_FAILED NT_STATUS(0xC0000000 | 0x016a) -#define NT_STATUS_DISK_RESET_FAILED NT_STATUS(0xC0000000 | 0x016b) -#define NT_STATUS_SHARED_IRQ_BUSY NT_STATUS(0xC0000000 | 0x016c) -#define NT_STATUS_FT_ORPHANING NT_STATUS(0xC0000000 | 0x016d) -#define NT_STATUS_PARTITION_FAILURE NT_STATUS(0xC0000000 | 0x0172) -#define NT_STATUS_INVALID_BLOCK_LENGTH NT_STATUS(0xC0000000 | 0x0173) -#define NT_STATUS_DEVICE_NOT_PARTITIONED NT_STATUS(0xC0000000 | 0x0174) -#define NT_STATUS_UNABLE_TO_LOCK_MEDIA NT_STATUS(0xC0000000 | 0x0175) -#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA NT_STATUS(0xC0000000 | 0x0176) -#define NT_STATUS_EOM_OVERFLOW NT_STATUS(0xC0000000 | 0x0177) -#define NT_STATUS_NO_MEDIA NT_STATUS(0xC0000000 | 0x0178) -#define NT_STATUS_NO_SUCH_MEMBER NT_STATUS(0xC0000000 | 0x017a) -#define NT_STATUS_INVALID_MEMBER NT_STATUS(0xC0000000 | 0x017b) -#define NT_STATUS_KEY_DELETED NT_STATUS(0xC0000000 | 0x017c) -#define NT_STATUS_NO_LOG_SPACE NT_STATUS(0xC0000000 | 0x017d) -#define NT_STATUS_TOO_MANY_SIDS NT_STATUS(0xC0000000 | 0x017e) -#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED NT_STATUS(0xC0000000 | 0x017f) -#define NT_STATUS_KEY_HAS_CHILDREN NT_STATUS(0xC0000000 | 0x0180) -#define NT_STATUS_CHILD_MUST_BE_VOLATILE NT_STATUS(0xC0000000 | 0x0181) -#define NT_STATUS_DEVICE_CONFIGURATION_ERROR NT_STATUS(0xC0000000 | 0x0182) -#define NT_STATUS_DRIVER_INTERNAL_ERROR NT_STATUS(0xC0000000 | 0x0183) -#define NT_STATUS_INVALID_DEVICE_STATE NT_STATUS(0xC0000000 | 0x0184) -#define NT_STATUS_IO_DEVICE_ERROR NT_STATUS(0xC0000000 | 0x0185) -#define NT_STATUS_DEVICE_PROTOCOL_ERROR NT_STATUS(0xC0000000 | 0x0186) -#define NT_STATUS_BACKUP_CONTROLLER NT_STATUS(0xC0000000 | 0x0187) -#define NT_STATUS_LOG_FILE_FULL NT_STATUS(0xC0000000 | 0x0188) -#define NT_STATUS_TOO_LATE NT_STATUS(0xC0000000 | 0x0189) -#define NT_STATUS_NO_TRUST_LSA_SECRET NT_STATUS(0xC0000000 | 0x018a) -#define NT_STATUS_NO_TRUST_SAM_ACCOUNT NT_STATUS(0xC0000000 | 0x018b) -#define NT_STATUS_TRUSTED_DOMAIN_FAILURE NT_STATUS(0xC0000000 | 0x018c) -#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE NT_STATUS(0xC0000000 | 0x018d) -#define NT_STATUS_EVENTLOG_FILE_CORRUPT NT_STATUS(0xC0000000 | 0x018e) -#define NT_STATUS_EVENTLOG_CANT_START NT_STATUS(0xC0000000 | 0x018f) -#define NT_STATUS_TRUST_FAILURE NT_STATUS(0xC0000000 | 0x0190) -#define NT_STATUS_MUTANT_LIMIT_EXCEEDED NT_STATUS(0xC0000000 | 0x0191) -#define NT_STATUS_NETLOGON_NOT_STARTED NT_STATUS(0xC0000000 | 0x0192) -#define NT_STATUS_ACCOUNT_EXPIRED NT_STATUS(0xC0000000 | 0x0193) -#define NT_STATUS_POSSIBLE_DEADLOCK NT_STATUS(0xC0000000 | 0x0194) -#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT NT_STATUS(0xC0000000 | 0x0195) -#define NT_STATUS_REMOTE_SESSION_LIMIT NT_STATUS(0xC0000000 | 0x0196) -#define NT_STATUS_EVENTLOG_FILE_CHANGED NT_STATUS(0xC0000000 | 0x0197) -#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT NT_STATUS(0xC0000000 | 0x0198) -#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT NT_STATUS(0xC0000000 | 0x0199) -#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT NT_STATUS(0xC0000000 | 0x019a) -#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT NT_STATUS(0xC0000000 | 0x019b) -#define NT_STATUS_FS_DRIVER_REQUIRED NT_STATUS(0xC0000000 | 0x019c) -#define NT_STATUS_NO_USER_SESSION_KEY NT_STATUS(0xC0000000 | 0x0202) -#define NT_STATUS_USER_SESSION_DELETED NT_STATUS(0xC0000000 | 0x0203) -#define NT_STATUS_RESOURCE_LANG_NOT_FOUND NT_STATUS(0xC0000000 | 0x0204) -#define NT_STATUS_INSUFF_SERVER_RESOURCES NT_STATUS(0xC0000000 | 0x0205) -#define NT_STATUS_INVALID_BUFFER_SIZE NT_STATUS(0xC0000000 | 0x0206) -#define NT_STATUS_INVALID_ADDRESS_COMPONENT NT_STATUS(0xC0000000 | 0x0207) -#define NT_STATUS_INVALID_ADDRESS_WILDCARD NT_STATUS(0xC0000000 | 0x0208) -#define NT_STATUS_TOO_MANY_ADDRESSES NT_STATUS(0xC0000000 | 0x0209) -#define NT_STATUS_ADDRESS_ALREADY_EXISTS NT_STATUS(0xC0000000 | 0x020a) -#define NT_STATUS_ADDRESS_CLOSED NT_STATUS(0xC0000000 | 0x020b) -#define NT_STATUS_CONNECTION_DISCONNECTED NT_STATUS(0xC0000000 | 0x020c) -#define NT_STATUS_CONNECTION_RESET NT_STATUS(0xC0000000 | 0x020d) -#define NT_STATUS_TOO_MANY_NODES NT_STATUS(0xC0000000 | 0x020e) -#define NT_STATUS_TRANSACTION_ABORTED NT_STATUS(0xC0000000 | 0x020f) -#define NT_STATUS_TRANSACTION_TIMED_OUT NT_STATUS(0xC0000000 | 0x0210) -#define NT_STATUS_TRANSACTION_NO_RELEASE NT_STATUS(0xC0000000 | 0x0211) -#define NT_STATUS_TRANSACTION_NO_MATCH NT_STATUS(0xC0000000 | 0x0212) -#define NT_STATUS_TRANSACTION_RESPONDED NT_STATUS(0xC0000000 | 0x0213) -#define NT_STATUS_TRANSACTION_INVALID_ID NT_STATUS(0xC0000000 | 0x0214) -#define NT_STATUS_TRANSACTION_INVALID_TYPE NT_STATUS(0xC0000000 | 0x0215) -#define NT_STATUS_NOT_SERVER_SESSION NT_STATUS(0xC0000000 | 0x0216) -#define NT_STATUS_NOT_CLIENT_SESSION NT_STATUS(0xC0000000 | 0x0217) -#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE NT_STATUS(0xC0000000 | 0x0218) -#define NT_STATUS_DEBUG_ATTACH_FAILED NT_STATUS(0xC0000000 | 0x0219) -#define NT_STATUS_SYSTEM_PROCESS_TERMINATED NT_STATUS(0xC0000000 | 0x021a) -#define NT_STATUS_DATA_NOT_ACCEPTED NT_STATUS(0xC0000000 | 0x021b) -#define NT_STATUS_NO_BROWSER_SERVERS_FOUND NT_STATUS(0xC0000000 | 0x021c) -#define NT_STATUS_VDM_HARD_ERROR NT_STATUS(0xC0000000 | 0x021d) -#define NT_STATUS_DRIVER_CANCEL_TIMEOUT NT_STATUS(0xC0000000 | 0x021e) -#define NT_STATUS_REPLY_MESSAGE_MISMATCH NT_STATUS(0xC0000000 | 0x021f) -#define NT_STATUS_MAPPED_ALIGNMENT NT_STATUS(0xC0000000 | 0x0220) -#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH NT_STATUS(0xC0000000 | 0x0221) -#define NT_STATUS_LOST_WRITEBEHIND_DATA NT_STATUS(0xC0000000 | 0x0222) -#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID NT_STATUS(0xC0000000 | 0x0223) -#define NT_STATUS_PASSWORD_MUST_CHANGE NT_STATUS(0xC0000000 | 0x0224) -#define NT_STATUS_NOT_FOUND NT_STATUS(0xC0000000 | 0x0225) -#define NT_STATUS_NOT_TINY_STREAM NT_STATUS(0xC0000000 | 0x0226) -#define NT_STATUS_RECOVERY_FAILURE NT_STATUS(0xC0000000 | 0x0227) -#define NT_STATUS_STACK_OVERFLOW_READ NT_STATUS(0xC0000000 | 0x0228) -#define NT_STATUS_FAIL_CHECK NT_STATUS(0xC0000000 | 0x0229) -#define NT_STATUS_DUPLICATE_OBJECTID NT_STATUS(0xC0000000 | 0x022a) -#define NT_STATUS_OBJECTID_EXISTS NT_STATUS(0xC0000000 | 0x022b) -#define NT_STATUS_CONVERT_TO_LARGE NT_STATUS(0xC0000000 | 0x022c) -#define NT_STATUS_RETRY NT_STATUS(0xC0000000 | 0x022d) -#define NT_STATUS_FOUND_OUT_OF_SCOPE NT_STATUS(0xC0000000 | 0x022e) -#define NT_STATUS_ALLOCATE_BUCKET NT_STATUS(0xC0000000 | 0x022f) -#define NT_STATUS_PROPSET_NOT_FOUND NT_STATUS(0xC0000000 | 0x0230) -#define NT_STATUS_MARSHALL_OVERFLOW NT_STATUS(0xC0000000 | 0x0231) -#define NT_STATUS_INVALID_VARIANT NT_STATUS(0xC0000000 | 0x0232) -#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND NT_STATUS(0xC0000000 | 0x0233) -#define NT_STATUS_ACCOUNT_LOCKED_OUT NT_STATUS(0xC0000000 | 0x0234) -#define NT_STATUS_HANDLE_NOT_CLOSABLE NT_STATUS(0xC0000000 | 0x0235) -#define NT_STATUS_CONNECTION_REFUSED NT_STATUS(0xC0000000 | 0x0236) -#define NT_STATUS_GRACEFUL_DISCONNECT NT_STATUS(0xC0000000 | 0x0237) -#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED NT_STATUS(0xC0000000 | 0x0238) -#define NT_STATUS_ADDRESS_NOT_ASSOCIATED NT_STATUS(0xC0000000 | 0x0239) -#define NT_STATUS_CONNECTION_INVALID NT_STATUS(0xC0000000 | 0x023a) -#define NT_STATUS_CONNECTION_ACTIVE NT_STATUS(0xC0000000 | 0x023b) -#define NT_STATUS_NETWORK_UNREACHABLE NT_STATUS(0xC0000000 | 0x023c) -#define NT_STATUS_HOST_UNREACHABLE NT_STATUS(0xC0000000 | 0x023d) -#define NT_STATUS_PROTOCOL_UNREACHABLE NT_STATUS(0xC0000000 | 0x023e) -#define NT_STATUS_PORT_UNREACHABLE NT_STATUS(0xC0000000 | 0x023f) -#define NT_STATUS_REQUEST_ABORTED NT_STATUS(0xC0000000 | 0x0240) -#define NT_STATUS_CONNECTION_ABORTED NT_STATUS(0xC0000000 | 0x0241) -#define NT_STATUS_BAD_COMPRESSION_BUFFER NT_STATUS(0xC0000000 | 0x0242) -#define NT_STATUS_USER_MAPPED_FILE NT_STATUS(0xC0000000 | 0x0243) -#define NT_STATUS_AUDIT_FAILED NT_STATUS(0xC0000000 | 0x0244) -#define NT_STATUS_TIMER_RESOLUTION_NOT_SET NT_STATUS(0xC0000000 | 0x0245) -#define NT_STATUS_CONNECTION_COUNT_LIMIT NT_STATUS(0xC0000000 | 0x0246) -#define NT_STATUS_LOGIN_TIME_RESTRICTION NT_STATUS(0xC0000000 | 0x0247) -#define NT_STATUS_LOGIN_WKSTA_RESTRICTION NT_STATUS(0xC0000000 | 0x0248) -#define NT_STATUS_IMAGE_MP_UP_MISMATCH NT_STATUS(0xC0000000 | 0x0249) -#define NT_STATUS_INSUFFICIENT_LOGON_INFO NT_STATUS(0xC0000000 | 0x0250) -#define NT_STATUS_BAD_DLL_ENTRYPOINT NT_STATUS(0xC0000000 | 0x0251) -#define NT_STATUS_BAD_SERVICE_ENTRYPOINT NT_STATUS(0xC0000000 | 0x0252) -#define NT_STATUS_LPC_REPLY_LOST NT_STATUS(0xC0000000 | 0x0253) -#define NT_STATUS_IP_ADDRESS_CONFLICT1 NT_STATUS(0xC0000000 | 0x0254) -#define NT_STATUS_IP_ADDRESS_CONFLICT2 NT_STATUS(0xC0000000 | 0x0255) -#define NT_STATUS_REGISTRY_QUOTA_LIMIT NT_STATUS(0xC0000000 | 0x0256) -#define NT_STATUS_PATH_NOT_COVERED NT_STATUS(0xC0000000 | 0x0257) -#define NT_STATUS_NO_CALLBACK_ACTIVE NT_STATUS(0xC0000000 | 0x0258) -#define NT_STATUS_LICENSE_QUOTA_EXCEEDED NT_STATUS(0xC0000000 | 0x0259) -#define NT_STATUS_PWD_TOO_SHORT NT_STATUS(0xC0000000 | 0x025a) -#define NT_STATUS_PWD_TOO_RECENT NT_STATUS(0xC0000000 | 0x025b) -#define NT_STATUS_PWD_HISTORY_CONFLICT NT_STATUS(0xC0000000 | 0x025c) -#define NT_STATUS_PLUGPLAY_NO_DEVICE NT_STATUS(0xC0000000 | 0x025e) -#define NT_STATUS_UNSUPPORTED_COMPRESSION NT_STATUS(0xC0000000 | 0x025f) -#define NT_STATUS_INVALID_HW_PROFILE NT_STATUS(0xC0000000 | 0x0260) -#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH NT_STATUS(0xC0000000 | 0x0261) -#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND NT_STATUS(0xC0000000 | 0x0262) -#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND NT_STATUS(0xC0000000 | 0x0263) -#define NT_STATUS_RESOURCE_NOT_OWNED NT_STATUS(0xC0000000 | 0x0264) -#define NT_STATUS_TOO_MANY_LINKS NT_STATUS(0xC0000000 | 0x0265) -#define NT_STATUS_QUOTA_LIST_INCONSISTENT NT_STATUS(0xC0000000 | 0x0266) -#define NT_STATUS_FILE_IS_OFFLINE NT_STATUS(0xC0000000 | 0x0267) -#define NT_STATUS_NOT_A_REPARSE_POINT NT_STATUS(0xC0000000 | 0x0275) -#define NT_STATUS_OBJECTID_NOT_FOUND NT_STATUS(0xC0000000 | 0x02F0) -#define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE) /* scheduler */ -#define NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x20004) -#define NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX NT_STATUS(0xC0000000 | 0x20026) - - -/* I use NT_STATUS_FOOBAR when I have no idea what error code to use - - * this means we need a torture test */ -#define NT_STATUS_FOOBAR NT_STATUS_UNSUCCESSFUL - -#endif /* _NTERR_H */ diff --git a/source4/libcli/util/ntstatus.h b/source4/libcli/util/ntstatus.h new file mode 100644 index 0000000000..026b5162db --- /dev/null +++ b/source4/libcli/util/ntstatus.h @@ -0,0 +1,675 @@ +/* + Unix SMB/CIFS implementation. + NT error code constants + Copyright (C) Andrew Tridgell 1992-2000 + Copyright (C) John H Terpstra 1996-2000 + Copyright (C) Luke Kenneth Casson Leighton 1996-2000 + Copyright (C) Paul Ashton 1998-2000 + + 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 3 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, see . +*/ + +#ifndef _NTSTATUS_H +#define _NTSTATUS_H + +/* the following rather strange looking definitions of NTSTATUS + are there in order to catch common coding errors where different error types + are mixed up. This is especially important as we slowly convert Samba + from using bool for internal functions +*/ + +#if defined(HAVE_IMMEDIATE_STRUCTURES) +typedef struct {uint32_t v;} NTSTATUS; +#define NT_STATUS(x) ((NTSTATUS) { x }) +#define NT_STATUS_V(x) ((x).v) +#else +typedef uint32_t NTSTATUS; +#define NT_STATUS(x) (x) +#define NT_STATUS_V(x) (x) +#endif + +/* Win32 Status codes. */ + +#define STATUS_BUFFER_OVERFLOW NT_STATUS(0x80000005) +#define STATUS_NO_MORE_FILES NT_STATUS(0x80000006) +#define STATUS_NO_MORE_EAS NT_STATUS(0x80000012) +#define STATUS_INVALID_EA_NAME NT_STATUS(0x80000013) +#define STATUS_EA_LIST_INCONSISTENT NT_STATUS(0x80000014) +#define STATUS_INVALID_EA_FLAG NT_STATUS(0x80000015) +#define NT_STATUS_NO_MORE_ENTRIES NT_STATUS(0x8000001a) + +#define STATUS_PENDING NT_STATUS(0x0103) +#define STATUS_MORE_ENTRIES NT_STATUS(0x0105) +#define STATUS_SOME_UNMAPPED NT_STATUS(0x0107) +#define STATUS_NOTIFY_CLEANUP NT_STATUS(0x010b) +#define STATUS_NOTIFY_ENUM_DIR NT_STATUS(0x010c) +#define ERROR_INVALID_PARAMETER NT_STATUS(0x0057) +#define ERROR_INSUFFICIENT_BUFFER NT_STATUS(0x007a) +#define ERROR_INVALID_DATATYPE NT_STATUS(0x070c) + +/* Win32 Error codes extracted using a loop in smbclient then printing a + netmon sniff to a file. */ + +/* + -------------- + / \ + / REST \ + / IN \ + / PEACE \ + / \ + | NT_STATUS_NOPROBLEMO | + | | + | | + | 4 September | + | | + | 2001 | + *| * * * | * + _________)/\\_//(\/(/\)/\//\/\///|_)_______ +*/ + +#define NT_STATUS_OK NT_STATUS(0x0000) +#define NT_STATUS_UNSUCCESSFUL NT_STATUS(0xC0000000 | 0x0001) +#define NT_STATUS_NOT_IMPLEMENTED NT_STATUS(0xC0000000 | 0x0002) +#define NT_STATUS_INVALID_INFO_CLASS NT_STATUS(0xC0000000 | 0x0003) +#define NT_STATUS_INFO_LENGTH_MISMATCH NT_STATUS(0xC0000000 | 0x0004) +#define NT_STATUS_ACCESS_VIOLATION NT_STATUS(0xC0000000 | 0x0005) +#define NT_STATUS_IN_PAGE_ERROR NT_STATUS(0xC0000000 | 0x0006) +#define NT_STATUS_PAGEFILE_QUOTA NT_STATUS(0xC0000000 | 0x0007) +#define NT_STATUS_INVALID_HANDLE NT_STATUS(0xC0000000 | 0x0008) +#define NT_STATUS_BAD_INITIAL_STACK NT_STATUS(0xC0000000 | 0x0009) +#define NT_STATUS_BAD_INITIAL_PC NT_STATUS(0xC0000000 | 0x000a) +#define NT_STATUS_INVALID_CID NT_STATUS(0xC0000000 | 0x000b) +#define NT_STATUS_TIMER_NOT_CANCELED NT_STATUS(0xC0000000 | 0x000c) +#define NT_STATUS_INVALID_PARAMETER NT_STATUS(0xC0000000 | 0x000d) +#define NT_STATUS_NO_SUCH_DEVICE NT_STATUS(0xC0000000 | 0x000e) +#define NT_STATUS_NO_SUCH_FILE NT_STATUS(0xC0000000 | 0x000f) +#define NT_STATUS_INVALID_DEVICE_REQUEST NT_STATUS(0xC0000000 | 0x0010) +#define NT_STATUS_END_OF_FILE NT_STATUS(0xC0000000 | 0x0011) +#define NT_STATUS_WRONG_VOLUME NT_STATUS(0xC0000000 | 0x0012) +#define NT_STATUS_NO_MEDIA_IN_DEVICE NT_STATUS(0xC0000000 | 0x0013) +#define NT_STATUS_UNRECOGNIZED_MEDIA NT_STATUS(0xC0000000 | 0x0014) +#define NT_STATUS_NONEXISTENT_SECTOR NT_STATUS(0xC0000000 | 0x0015) +#define NT_STATUS_MORE_PROCESSING_REQUIRED NT_STATUS(0xC0000000 | 0x0016) +#if 0 +/* this demonstrates a little trick when tracking down error codes */ +#define NT_STATUS_NO_MEMORY (printf("no memory at %s\n", __location__), NT_STATUS(0xC0000000 | 0x0017)) +#else +#define NT_STATUS_NO_MEMORY NT_STATUS(0xC0000000 | 0x0017) +#endif +#define NT_STATUS_CONFLICTING_ADDRESSES NT_STATUS(0xC0000000 | 0x0018) +#define NT_STATUS_NOT_MAPPED_VIEW NT_STATUS(0xC0000000 | 0x0019) +#define NT_STATUS_UNABLE_TO_FREE_VM NT_STATUS(0xC0000000 | 0x001a) +#define NT_STATUS_UNABLE_TO_DELETE_SECTION NT_STATUS(0xC0000000 | 0x001b) +#define NT_STATUS_INVALID_SYSTEM_SERVICE NT_STATUS(0xC0000000 | 0x001c) +#define NT_STATUS_ILLEGAL_INSTRUCTION NT_STATUS(0xC0000000 | 0x001d) +#define NT_STATUS_INVALID_LOCK_SEQUENCE NT_STATUS(0xC0000000 | 0x001e) +#define NT_STATUS_INVALID_VIEW_SIZE NT_STATUS(0xC0000000 | 0x001f) +#define NT_STATUS_INVALID_FILE_FOR_SECTION NT_STATUS(0xC0000000 | 0x0020) +#define NT_STATUS_ALREADY_COMMITTED NT_STATUS(0xC0000000 | 0x0021) +#if 0 +/* this demonstrates a little trick when tracking down error codes */ +#define NT_STATUS_ACCESS_DENIED (printf("access denied at %s\n", __location__), NT_STATUS(0xC0000000 | 0x0022)) +#else +#define NT_STATUS_ACCESS_DENIED NT_STATUS(0xC0000000 | 0x0022) +#endif +#define NT_STATUS_BUFFER_TOO_SMALL NT_STATUS(0xC0000000 | 0x0023) +#define NT_STATUS_OBJECT_TYPE_MISMATCH NT_STATUS(0xC0000000 | 0x0024) +#define NT_STATUS_NONCONTINUABLE_EXCEPTION NT_STATUS(0xC0000000 | 0x0025) +#define NT_STATUS_INVALID_DISPOSITION NT_STATUS(0xC0000000 | 0x0026) +#define NT_STATUS_UNWIND NT_STATUS(0xC0000000 | 0x0027) +#define NT_STATUS_BAD_STACK NT_STATUS(0xC0000000 | 0x0028) +#define NT_STATUS_INVALID_UNWIND_TARGET NT_STATUS(0xC0000000 | 0x0029) +#define NT_STATUS_NOT_LOCKED NT_STATUS(0xC0000000 | 0x002a) +#define NT_STATUS_PARITY_ERROR NT_STATUS(0xC0000000 | 0x002b) +#define NT_STATUS_UNABLE_TO_DECOMMIT_VM NT_STATUS(0xC0000000 | 0x002c) +#define NT_STATUS_NOT_COMMITTED NT_STATUS(0xC0000000 | 0x002d) +#define NT_STATUS_INVALID_PORT_ATTRIBUTES NT_STATUS(0xC0000000 | 0x002e) +#define NT_STATUS_PORT_MESSAGE_TOO_LONG NT_STATUS(0xC0000000 | 0x002f) +#define NT_STATUS_INVALID_PARAMETER_MIX NT_STATUS(0xC0000000 | 0x0030) +#define NT_STATUS_INVALID_QUOTA_LOWER NT_STATUS(0xC0000000 | 0x0031) +#define NT_STATUS_DISK_CORRUPT_ERROR NT_STATUS(0xC0000000 | 0x0032) +#define NT_STATUS_OBJECT_NAME_INVALID NT_STATUS(0xC0000000 | 0x0033) +#define NT_STATUS_OBJECT_NAME_NOT_FOUND NT_STATUS(0xC0000000 | 0x0034) +#define NT_STATUS_OBJECT_NAME_COLLISION NT_STATUS(0xC0000000 | 0x0035) +#define NT_STATUS_HANDLE_NOT_WAITABLE NT_STATUS(0xC0000000 | 0x0036) +#define NT_STATUS_PORT_DISCONNECTED NT_STATUS(0xC0000000 | 0x0037) +#define NT_STATUS_DEVICE_ALREADY_ATTACHED NT_STATUS(0xC0000000 | 0x0038) +#define NT_STATUS_OBJECT_PATH_INVALID NT_STATUS(0xC0000000 | 0x0039) +#define NT_STATUS_OBJECT_PATH_NOT_FOUND NT_STATUS(0xC0000000 | 0x003a) +#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD NT_STATUS(0xC0000000 | 0x003b) +#define NT_STATUS_DATA_OVERRUN NT_STATUS(0xC0000000 | 0x003c) +#define NT_STATUS_DATA_LATE_ERROR NT_STATUS(0xC0000000 | 0x003d) +#define NT_STATUS_DATA_ERROR NT_STATUS(0xC0000000 | 0x003e) +#define NT_STATUS_CRC_ERROR NT_STATUS(0xC0000000 | 0x003f) +#define NT_STATUS_SECTION_TOO_BIG NT_STATUS(0xC0000000 | 0x0040) +#define NT_STATUS_PORT_CONNECTION_REFUSED NT_STATUS(0xC0000000 | 0x0041) +#define NT_STATUS_INVALID_PORT_HANDLE NT_STATUS(0xC0000000 | 0x0042) +#define NT_STATUS_SHARING_VIOLATION NT_STATUS(0xC0000000 | 0x0043) +#define NT_STATUS_QUOTA_EXCEEDED NT_STATUS(0xC0000000 | 0x0044) +#define NT_STATUS_INVALID_PAGE_PROTECTION NT_STATUS(0xC0000000 | 0x0045) +#define NT_STATUS_MUTANT_NOT_OWNED NT_STATUS(0xC0000000 | 0x0046) +#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED NT_STATUS(0xC0000000 | 0x0047) +#define NT_STATUS_PORT_ALREADY_SET NT_STATUS(0xC0000000 | 0x0048) +#define NT_STATUS_SECTION_NOT_IMAGE NT_STATUS(0xC0000000 | 0x0049) +#define NT_STATUS_SUSPEND_COUNT_EXCEEDED NT_STATUS(0xC0000000 | 0x004a) +#define NT_STATUS_THREAD_IS_TERMINATING NT_STATUS(0xC0000000 | 0x004b) +#define NT_STATUS_BAD_WORKING_SET_LIMIT NT_STATUS(0xC0000000 | 0x004c) +#define NT_STATUS_INCOMPATIBLE_FILE_MAP NT_STATUS(0xC0000000 | 0x004d) +#define NT_STATUS_SECTION_PROTECTION NT_STATUS(0xC0000000 | 0x004e) +#define NT_STATUS_EAS_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x004f) +#define NT_STATUS_EA_TOO_LARGE NT_STATUS(0xC0000000 | 0x0050) +#define NT_STATUS_NONEXISTENT_EA_ENTRY NT_STATUS(0xC0000000 | 0x0051) +#define NT_STATUS_NO_EAS_ON_FILE NT_STATUS(0xC0000000 | 0x0052) +#define NT_STATUS_EA_CORRUPT_ERROR NT_STATUS(0xC0000000 | 0x0053) +#define NT_STATUS_FILE_LOCK_CONFLICT NT_STATUS(0xC0000000 | 0x0054) +#define NT_STATUS_LOCK_NOT_GRANTED NT_STATUS(0xC0000000 | 0x0055) +#define NT_STATUS_DELETE_PENDING NT_STATUS(0xC0000000 | 0x0056) +#define NT_STATUS_CTL_FILE_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x0057) +#define NT_STATUS_UNKNOWN_REVISION NT_STATUS(0xC0000000 | 0x0058) +#define NT_STATUS_REVISION_MISMATCH NT_STATUS(0xC0000000 | 0x0059) +#define NT_STATUS_INVALID_OWNER NT_STATUS(0xC0000000 | 0x005a) +#define NT_STATUS_INVALID_PRIMARY_GROUP NT_STATUS(0xC0000000 | 0x005b) +#define NT_STATUS_NO_IMPERSONATION_TOKEN NT_STATUS(0xC0000000 | 0x005c) +#define NT_STATUS_CANT_DISABLE_MANDATORY NT_STATUS(0xC0000000 | 0x005d) +#define NT_STATUS_NO_LOGON_SERVERS NT_STATUS(0xC0000000 | 0x005e) +#define NT_STATUS_NO_SUCH_LOGON_SESSION NT_STATUS(0xC0000000 | 0x005f) +#define NT_STATUS_NO_SUCH_PRIVILEGE NT_STATUS(0xC0000000 | 0x0060) +#define NT_STATUS_PRIVILEGE_NOT_HELD NT_STATUS(0xC0000000 | 0x0061) +#define NT_STATUS_INVALID_ACCOUNT_NAME NT_STATUS(0xC0000000 | 0x0062) +#define NT_STATUS_USER_EXISTS NT_STATUS(0xC0000000 | 0x0063) +#define NT_STATUS_NO_SUCH_USER NT_STATUS(0xC0000000 | 0x0064) +#define NT_STATUS_GROUP_EXISTS NT_STATUS(0xC0000000 | 0x0065) +#define NT_STATUS_NO_SUCH_GROUP NT_STATUS(0xC0000000 | 0x0066) +#define NT_STATUS_MEMBER_IN_GROUP NT_STATUS(0xC0000000 | 0x0067) +#define NT_STATUS_MEMBER_NOT_IN_GROUP NT_STATUS(0xC0000000 | 0x0068) +#define NT_STATUS_LAST_ADMIN NT_STATUS(0xC0000000 | 0x0069) +#define NT_STATUS_WRONG_PASSWORD NT_STATUS(0xC0000000 | 0x006a) +#define NT_STATUS_ILL_FORMED_PASSWORD NT_STATUS(0xC0000000 | 0x006b) +#define NT_STATUS_PASSWORD_RESTRICTION NT_STATUS(0xC0000000 | 0x006c) +#define NT_STATUS_LOGON_FAILURE NT_STATUS(0xC0000000 | 0x006d) +#define NT_STATUS_ACCOUNT_RESTRICTION NT_STATUS(0xC0000000 | 0x006e) +#define NT_STATUS_INVALID_LOGON_HOURS NT_STATUS(0xC0000000 | 0x006f) +#define NT_STATUS_INVALID_WORKSTATION NT_STATUS(0xC0000000 | 0x0070) +#define NT_STATUS_PASSWORD_EXPIRED NT_STATUS(0xC0000000 | 0x0071) +#define NT_STATUS_ACCOUNT_DISABLED NT_STATUS(0xC0000000 | 0x0072) +#define NT_STATUS_NONE_MAPPED NT_STATUS(0xC0000000 | 0x0073) +#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED NT_STATUS(0xC0000000 | 0x0074) +#define NT_STATUS_LUIDS_EXHAUSTED NT_STATUS(0xC0000000 | 0x0075) +#define NT_STATUS_INVALID_SUB_AUTHORITY NT_STATUS(0xC0000000 | 0x0076) +#define NT_STATUS_INVALID_ACL NT_STATUS(0xC0000000 | 0x0077) +#define NT_STATUS_INVALID_SID NT_STATUS(0xC0000000 | 0x0078) +#define NT_STATUS_INVALID_SECURITY_DESCR NT_STATUS(0xC0000000 | 0x0079) +#define NT_STATUS_PROCEDURE_NOT_FOUND NT_STATUS(0xC0000000 | 0x007a) +#define NT_STATUS_INVALID_IMAGE_FORMAT NT_STATUS(0xC0000000 | 0x007b) +#define NT_STATUS_NO_TOKEN NT_STATUS(0xC0000000 | 0x007c) +#define NT_STATUS_BAD_INHERITANCE_ACL NT_STATUS(0xC0000000 | 0x007d) +#define NT_STATUS_RANGE_NOT_LOCKED NT_STATUS(0xC0000000 | 0x007e) +#define NT_STATUS_DISK_FULL NT_STATUS(0xC0000000 | 0x007f) +#define NT_STATUS_SERVER_DISABLED NT_STATUS(0xC0000000 | 0x0080) +#define NT_STATUS_SERVER_NOT_DISABLED NT_STATUS(0xC0000000 | 0x0081) +#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED NT_STATUS(0xC0000000 | 0x0082) +#define NT_STATUS_GUIDS_EXHAUSTED NT_STATUS(0xC0000000 | 0x0083) +#define NT_STATUS_INVALID_ID_AUTHORITY NT_STATUS(0xC0000000 | 0x0084) +#define NT_STATUS_AGENTS_EXHAUSTED NT_STATUS(0xC0000000 | 0x0085) +#define NT_STATUS_INVALID_VOLUME_LABEL NT_STATUS(0xC0000000 | 0x0086) +#define NT_STATUS_SECTION_NOT_EXTENDED NT_STATUS(0xC0000000 | 0x0087) +#define NT_STATUS_NOT_MAPPED_DATA NT_STATUS(0xC0000000 | 0x0088) +#define NT_STATUS_RESOURCE_DATA_NOT_FOUND NT_STATUS(0xC0000000 | 0x0089) +#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND NT_STATUS(0xC0000000 | 0x008a) +#define NT_STATUS_RESOURCE_NAME_NOT_FOUND NT_STATUS(0xC0000000 | 0x008b) +#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED NT_STATUS(0xC0000000 | 0x008c) +#define NT_STATUS_FLOAT_DENORMAL_OPERAND NT_STATUS(0xC0000000 | 0x008d) +#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO NT_STATUS(0xC0000000 | 0x008e) +#define NT_STATUS_FLOAT_INEXACT_RESULT NT_STATUS(0xC0000000 | 0x008f) +#define NT_STATUS_FLOAT_INVALID_OPERATION NT_STATUS(0xC0000000 | 0x0090) +#define NT_STATUS_FLOAT_OVERFLOW NT_STATUS(0xC0000000 | 0x0091) +#define NT_STATUS_FLOAT_STACK_CHECK NT_STATUS(0xC0000000 | 0x0092) +#define NT_STATUS_FLOAT_UNDERFLOW NT_STATUS(0xC0000000 | 0x0093) +#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO NT_STATUS(0xC0000000 | 0x0094) +#define NT_STATUS_INTEGER_OVERFLOW NT_STATUS(0xC0000000 | 0x0095) +#define NT_STATUS_PRIVILEGED_INSTRUCTION NT_STATUS(0xC0000000 | 0x0096) +#define NT_STATUS_TOO_MANY_PAGING_FILES NT_STATUS(0xC0000000 | 0x0097) +#define NT_STATUS_FILE_INVALID NT_STATUS(0xC0000000 | 0x0098) +#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED NT_STATUS(0xC0000000 | 0x0099) +#define NT_STATUS_INSUFFICIENT_RESOURCES NT_STATUS(0xC0000000 | 0x009a) +#define NT_STATUS_DFS_EXIT_PATH_FOUND NT_STATUS(0xC0000000 | 0x009b) +#define NT_STATUS_DEVICE_DATA_ERROR NT_STATUS(0xC0000000 | 0x009c) +#define NT_STATUS_DEVICE_NOT_CONNECTED NT_STATUS(0xC0000000 | 0x009d) +#define NT_STATUS_DEVICE_POWER_FAILURE NT_STATUS(0xC0000000 | 0x009e) +#define NT_STATUS_FREE_VM_NOT_AT_BASE NT_STATUS(0xC0000000 | 0x009f) +#define NT_STATUS_MEMORY_NOT_ALLOCATED NT_STATUS(0xC0000000 | 0x00a0) +#define NT_STATUS_WORKING_SET_QUOTA NT_STATUS(0xC0000000 | 0x00a1) +#define NT_STATUS_MEDIA_WRITE_PROTECTED NT_STATUS(0xC0000000 | 0x00a2) +#define NT_STATUS_DEVICE_NOT_READY NT_STATUS(0xC0000000 | 0x00a3) +#define NT_STATUS_INVALID_GROUP_ATTRIBUTES NT_STATUS(0xC0000000 | 0x00a4) +#define NT_STATUS_BAD_IMPERSONATION_LEVEL NT_STATUS(0xC0000000 | 0x00a5) +#define NT_STATUS_CANT_OPEN_ANONYMOUS NT_STATUS(0xC0000000 | 0x00a6) +#define NT_STATUS_BAD_VALIDATION_CLASS NT_STATUS(0xC0000000 | 0x00a7) +#define NT_STATUS_BAD_TOKEN_TYPE NT_STATUS(0xC0000000 | 0x00a8) +#define NT_STATUS_BAD_MASTER_BOOT_RECORD NT_STATUS(0xC0000000 | 0x00a9) +#define NT_STATUS_INSTRUCTION_MISALIGNMENT NT_STATUS(0xC0000000 | 0x00aa) +#define NT_STATUS_INSTANCE_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x00ab) +#define NT_STATUS_PIPE_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x00ac) +#define NT_STATUS_INVALID_PIPE_STATE NT_STATUS(0xC0000000 | 0x00ad) +#define NT_STATUS_PIPE_BUSY NT_STATUS(0xC0000000 | 0x00ae) +#define NT_STATUS_ILLEGAL_FUNCTION NT_STATUS(0xC0000000 | 0x00af) +#define NT_STATUS_PIPE_DISCONNECTED NT_STATUS(0xC0000000 | 0x00b0) +#define NT_STATUS_PIPE_CLOSING NT_STATUS(0xC0000000 | 0x00b1) +#define NT_STATUS_PIPE_CONNECTED NT_STATUS(0xC0000000 | 0x00b2) +#define NT_STATUS_PIPE_LISTENING NT_STATUS(0xC0000000 | 0x00b3) +#define NT_STATUS_INVALID_READ_MODE NT_STATUS(0xC0000000 | 0x00b4) +#define NT_STATUS_IO_TIMEOUT NT_STATUS(0xC0000000 | 0x00b5) +#define NT_STATUS_FILE_FORCED_CLOSED NT_STATUS(0xC0000000 | 0x00b6) +#define NT_STATUS_PROFILING_NOT_STARTED NT_STATUS(0xC0000000 | 0x00b7) +#define NT_STATUS_PROFILING_NOT_STOPPED NT_STATUS(0xC0000000 | 0x00b8) +#define NT_STATUS_COULD_NOT_INTERPRET NT_STATUS(0xC0000000 | 0x00b9) +#define NT_STATUS_FILE_IS_A_DIRECTORY NT_STATUS(0xC0000000 | 0x00ba) +#define NT_STATUS_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x00bb) +#define NT_STATUS_REMOTE_NOT_LISTENING NT_STATUS(0xC0000000 | 0x00bc) +#define NT_STATUS_DUPLICATE_NAME NT_STATUS(0xC0000000 | 0x00bd) +#define NT_STATUS_BAD_NETWORK_PATH NT_STATUS(0xC0000000 | 0x00be) +#define NT_STATUS_NETWORK_BUSY NT_STATUS(0xC0000000 | 0x00bf) +#define NT_STATUS_DEVICE_DOES_NOT_EXIST NT_STATUS(0xC0000000 | 0x00c0) +#define NT_STATUS_TOO_MANY_COMMANDS NT_STATUS(0xC0000000 | 0x00c1) +#define NT_STATUS_ADAPTER_HARDWARE_ERROR NT_STATUS(0xC0000000 | 0x00c2) +#define NT_STATUS_INVALID_NETWORK_RESPONSE NT_STATUS(0xC0000000 | 0x00c3) +#define NT_STATUS_UNEXPECTED_NETWORK_ERROR NT_STATUS(0xC0000000 | 0x00c4) +#define NT_STATUS_BAD_REMOTE_ADAPTER NT_STATUS(0xC0000000 | 0x00c5) +#define NT_STATUS_PRINT_QUEUE_FULL NT_STATUS(0xC0000000 | 0x00c6) +#define NT_STATUS_NO_SPOOL_SPACE NT_STATUS(0xC0000000 | 0x00c7) +#define NT_STATUS_PRINT_CANCELLED NT_STATUS(0xC0000000 | 0x00c8) +#define NT_STATUS_NETWORK_NAME_DELETED NT_STATUS(0xC0000000 | 0x00c9) +#define NT_STATUS_NETWORK_ACCESS_DENIED NT_STATUS(0xC0000000 | 0x00ca) +#define NT_STATUS_BAD_DEVICE_TYPE NT_STATUS(0xC0000000 | 0x00cb) +#define NT_STATUS_BAD_NETWORK_NAME NT_STATUS(0xC0000000 | 0x00cc) +#define NT_STATUS_TOO_MANY_NAMES NT_STATUS(0xC0000000 | 0x00cd) +#define NT_STATUS_TOO_MANY_SESSIONS NT_STATUS(0xC0000000 | 0x00ce) +#define NT_STATUS_SHARING_PAUSED NT_STATUS(0xC0000000 | 0x00cf) +#define NT_STATUS_REQUEST_NOT_ACCEPTED NT_STATUS(0xC0000000 | 0x00d0) +#define NT_STATUS_REDIRECTOR_PAUSED NT_STATUS(0xC0000000 | 0x00d1) +#define NT_STATUS_NET_WRITE_FAULT NT_STATUS(0xC0000000 | 0x00d2) +#define NT_STATUS_PROFILING_AT_LIMIT NT_STATUS(0xC0000000 | 0x00d3) +#define NT_STATUS_NOT_SAME_DEVICE NT_STATUS(0xC0000000 | 0x00d4) +#define NT_STATUS_FILE_RENAMED NT_STATUS(0xC0000000 | 0x00d5) +#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED NT_STATUS(0xC0000000 | 0x00d6) +#define NT_STATUS_NO_SECURITY_ON_OBJECT NT_STATUS(0xC0000000 | 0x00d7) +#define NT_STATUS_CANT_WAIT NT_STATUS(0xC0000000 | 0x00d8) +#define NT_STATUS_PIPE_EMPTY NT_STATUS(0xC0000000 | 0x00d9) +#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO NT_STATUS(0xC0000000 | 0x00da) +#define NT_STATUS_CANT_TERMINATE_SELF NT_STATUS(0xC0000000 | 0x00db) +#define NT_STATUS_INVALID_SERVER_STATE NT_STATUS(0xC0000000 | 0x00dc) +#define NT_STATUS_INVALID_DOMAIN_STATE NT_STATUS(0xC0000000 | 0x00dd) +#define NT_STATUS_INVALID_DOMAIN_ROLE NT_STATUS(0xC0000000 | 0x00de) +#define NT_STATUS_NO_SUCH_DOMAIN NT_STATUS(0xC0000000 | 0x00df) +#define NT_STATUS_DOMAIN_EXISTS NT_STATUS(0xC0000000 | 0x00e0) +#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED NT_STATUS(0xC0000000 | 0x00e1) +#define NT_STATUS_OPLOCK_NOT_GRANTED NT_STATUS(0xC0000000 | 0x00e2) +#define NT_STATUS_INVALID_OPLOCK_PROTOCOL NT_STATUS(0xC0000000 | 0x00e3) +#define NT_STATUS_INTERNAL_DB_CORRUPTION NT_STATUS(0xC0000000 | 0x00e4) +#define NT_STATUS_INTERNAL_ERROR NT_STATUS(0xC0000000 | 0x00e5) +#define NT_STATUS_GENERIC_NOT_MAPPED NT_STATUS(0xC0000000 | 0x00e6) +#define NT_STATUS_BAD_DESCRIPTOR_FORMAT NT_STATUS(0xC0000000 | 0x00e7) +#define NT_STATUS_INVALID_USER_BUFFER NT_STATUS(0xC0000000 | 0x00e8) +#define NT_STATUS_UNEXPECTED_IO_ERROR NT_STATUS(0xC0000000 | 0x00e9) +#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR NT_STATUS(0xC0000000 | 0x00ea) +#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR NT_STATUS(0xC0000000 | 0x00eb) +#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR NT_STATUS(0xC0000000 | 0x00ec) +#define NT_STATUS_NOT_LOGON_PROCESS NT_STATUS(0xC0000000 | 0x00ed) +#define NT_STATUS_LOGON_SESSION_EXISTS NT_STATUS(0xC0000000 | 0x00ee) +#define NT_STATUS_INVALID_PARAMETER_1 NT_STATUS(0xC0000000 | 0x00ef) +#define NT_STATUS_INVALID_PARAMETER_2 NT_STATUS(0xC0000000 | 0x00f0) +#define NT_STATUS_INVALID_PARAMETER_3 NT_STATUS(0xC0000000 | 0x00f1) +#define NT_STATUS_INVALID_PARAMETER_4 NT_STATUS(0xC0000000 | 0x00f2) +#define NT_STATUS_INVALID_PARAMETER_5 NT_STATUS(0xC0000000 | 0x00f3) +#define NT_STATUS_INVALID_PARAMETER_6 NT_STATUS(0xC0000000 | 0x00f4) +#define NT_STATUS_INVALID_PARAMETER_7 NT_STATUS(0xC0000000 | 0x00f5) +#define NT_STATUS_INVALID_PARAMETER_8 NT_STATUS(0xC0000000 | 0x00f6) +#define NT_STATUS_INVALID_PARAMETER_9 NT_STATUS(0xC0000000 | 0x00f7) +#define NT_STATUS_INVALID_PARAMETER_10 NT_STATUS(0xC0000000 | 0x00f8) +#define NT_STATUS_INVALID_PARAMETER_11 NT_STATUS(0xC0000000 | 0x00f9) +#define NT_STATUS_INVALID_PARAMETER_12 NT_STATUS(0xC0000000 | 0x00fa) +#define NT_STATUS_REDIRECTOR_NOT_STARTED NT_STATUS(0xC0000000 | 0x00fb) +#define NT_STATUS_REDIRECTOR_STARTED NT_STATUS(0xC0000000 | 0x00fc) +#define NT_STATUS_STACK_OVERFLOW NT_STATUS(0xC0000000 | 0x00fd) +#define NT_STATUS_NO_SUCH_PACKAGE NT_STATUS(0xC0000000 | 0x00fe) +#define NT_STATUS_BAD_FUNCTION_TABLE NT_STATUS(0xC0000000 | 0x00ff) +#define NT_STATUS_DIRECTORY_NOT_EMPTY NT_STATUS(0xC0000000 | 0x0101) +#define NT_STATUS_FILE_CORRUPT_ERROR NT_STATUS(0xC0000000 | 0x0102) +#define NT_STATUS_NOT_A_DIRECTORY NT_STATUS(0xC0000000 | 0x0103) +#define NT_STATUS_BAD_LOGON_SESSION_STATE NT_STATUS(0xC0000000 | 0x0104) +#define NT_STATUS_LOGON_SESSION_COLLISION NT_STATUS(0xC0000000 | 0x0105) +#define NT_STATUS_NAME_TOO_LONG NT_STATUS(0xC0000000 | 0x0106) +#define NT_STATUS_FILES_OPEN NT_STATUS(0xC0000000 | 0x0107) +#define NT_STATUS_CONNECTION_IN_USE NT_STATUS(0xC0000000 | 0x0108) +#define NT_STATUS_MESSAGE_NOT_FOUND NT_STATUS(0xC0000000 | 0x0109) +#define NT_STATUS_PROCESS_IS_TERMINATING NT_STATUS(0xC0000000 | 0x010a) +#define NT_STATUS_INVALID_LOGON_TYPE NT_STATUS(0xC0000000 | 0x010b) +#define NT_STATUS_NO_GUID_TRANSLATION NT_STATUS(0xC0000000 | 0x010c) +#define NT_STATUS_CANNOT_IMPERSONATE NT_STATUS(0xC0000000 | 0x010d) +#define NT_STATUS_IMAGE_ALREADY_LOADED NT_STATUS(0xC0000000 | 0x010e) +#define NT_STATUS_ABIOS_NOT_PRESENT NT_STATUS(0xC0000000 | 0x010f) +#define NT_STATUS_ABIOS_LID_NOT_EXIST NT_STATUS(0xC0000000 | 0x0110) +#define NT_STATUS_ABIOS_LID_ALREADY_OWNED NT_STATUS(0xC0000000 | 0x0111) +#define NT_STATUS_ABIOS_NOT_LID_OWNER NT_STATUS(0xC0000000 | 0x0112) +#define NT_STATUS_ABIOS_INVALID_COMMAND NT_STATUS(0xC0000000 | 0x0113) +#define NT_STATUS_ABIOS_INVALID_LID NT_STATUS(0xC0000000 | 0x0114) +#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x0115) +#define NT_STATUS_ABIOS_INVALID_SELECTOR NT_STATUS(0xC0000000 | 0x0116) +#define NT_STATUS_NO_LDT NT_STATUS(0xC0000000 | 0x0117) +#define NT_STATUS_INVALID_LDT_SIZE NT_STATUS(0xC0000000 | 0x0118) +#define NT_STATUS_INVALID_LDT_OFFSET NT_STATUS(0xC0000000 | 0x0119) +#define NT_STATUS_INVALID_LDT_DESCRIPTOR NT_STATUS(0xC0000000 | 0x011a) +#define NT_STATUS_INVALID_IMAGE_NE_FORMAT NT_STATUS(0xC0000000 | 0x011b) +#define NT_STATUS_RXACT_INVALID_STATE NT_STATUS(0xC0000000 | 0x011c) +#define NT_STATUS_RXACT_COMMIT_FAILURE NT_STATUS(0xC0000000 | 0x011d) +#define NT_STATUS_MAPPED_FILE_SIZE_ZERO NT_STATUS(0xC0000000 | 0x011e) +#define NT_STATUS_TOO_MANY_OPENED_FILES NT_STATUS(0xC0000000 | 0x011f) +#define NT_STATUS_CANCELLED NT_STATUS(0xC0000000 | 0x0120) +#define NT_STATUS_CANNOT_DELETE NT_STATUS(0xC0000000 | 0x0121) +#define NT_STATUS_INVALID_COMPUTER_NAME NT_STATUS(0xC0000000 | 0x0122) +#define NT_STATUS_FILE_DELETED NT_STATUS(0xC0000000 | 0x0123) +#define NT_STATUS_SPECIAL_ACCOUNT NT_STATUS(0xC0000000 | 0x0124) +#define NT_STATUS_SPECIAL_GROUP NT_STATUS(0xC0000000 | 0x0125) +#define NT_STATUS_SPECIAL_USER NT_STATUS(0xC0000000 | 0x0126) +#define NT_STATUS_MEMBERS_PRIMARY_GROUP NT_STATUS(0xC0000000 | 0x0127) +#define NT_STATUS_FILE_CLOSED NT_STATUS(0xC0000000 | 0x0128) +#define NT_STATUS_TOO_MANY_THREADS NT_STATUS(0xC0000000 | 0x0129) +#define NT_STATUS_THREAD_NOT_IN_PROCESS NT_STATUS(0xC0000000 | 0x012a) +#define NT_STATUS_TOKEN_ALREADY_IN_USE NT_STATUS(0xC0000000 | 0x012b) +#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED NT_STATUS(0xC0000000 | 0x012c) +#define NT_STATUS_COMMITMENT_LIMIT NT_STATUS(0xC0000000 | 0x012d) +#define NT_STATUS_INVALID_IMAGE_LE_FORMAT NT_STATUS(0xC0000000 | 0x012e) +#define NT_STATUS_INVALID_IMAGE_NOT_MZ NT_STATUS(0xC0000000 | 0x012f) +#define NT_STATUS_INVALID_IMAGE_PROTECT NT_STATUS(0xC0000000 | 0x0130) +#define NT_STATUS_INVALID_IMAGE_WIN_16 NT_STATUS(0xC0000000 | 0x0131) +#define NT_STATUS_LOGON_SERVER_CONFLICT NT_STATUS(0xC0000000 | 0x0132) +#define NT_STATUS_TIME_DIFFERENCE_AT_DC NT_STATUS(0xC0000000 | 0x0133) +#define NT_STATUS_SYNCHRONIZATION_REQUIRED NT_STATUS(0xC0000000 | 0x0134) +#define NT_STATUS_DLL_NOT_FOUND NT_STATUS(0xC0000000 | 0x0135) +#define NT_STATUS_OPEN_FAILED NT_STATUS(0xC0000000 | 0x0136) +#define NT_STATUS_IO_PRIVILEGE_FAILED NT_STATUS(0xC0000000 | 0x0137) +#define NT_STATUS_ORDINAL_NOT_FOUND NT_STATUS(0xC0000000 | 0x0138) +#define NT_STATUS_ENTRYPOINT_NOT_FOUND NT_STATUS(0xC0000000 | 0x0139) +#define NT_STATUS_CONTROL_C_EXIT NT_STATUS(0xC0000000 | 0x013a) +#define NT_STATUS_LOCAL_DISCONNECT NT_STATUS(0xC0000000 | 0x013b) +#define NT_STATUS_REMOTE_DISCONNECT NT_STATUS(0xC0000000 | 0x013c) +#define NT_STATUS_REMOTE_RESOURCES NT_STATUS(0xC0000000 | 0x013d) +#define NT_STATUS_LINK_FAILED NT_STATUS(0xC0000000 | 0x013e) +#define NT_STATUS_LINK_TIMEOUT NT_STATUS(0xC0000000 | 0x013f) +#define NT_STATUS_INVALID_CONNECTION NT_STATUS(0xC0000000 | 0x0140) +#define NT_STATUS_INVALID_ADDRESS NT_STATUS(0xC0000000 | 0x0141) +#define NT_STATUS_DLL_INIT_FAILED NT_STATUS(0xC0000000 | 0x0142) +#define NT_STATUS_MISSING_SYSTEMFILE NT_STATUS(0xC0000000 | 0x0143) +#define NT_STATUS_UNHANDLED_EXCEPTION NT_STATUS(0xC0000000 | 0x0144) +#define NT_STATUS_APP_INIT_FAILURE NT_STATUS(0xC0000000 | 0x0145) +#define NT_STATUS_PAGEFILE_CREATE_FAILED NT_STATUS(0xC0000000 | 0x0146) +#define NT_STATUS_NO_PAGEFILE NT_STATUS(0xC0000000 | 0x0147) +#define NT_STATUS_INVALID_LEVEL NT_STATUS(0xC0000000 | 0x0148) +#define NT_STATUS_WRONG_PASSWORD_CORE NT_STATUS(0xC0000000 | 0x0149) +#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT NT_STATUS(0xC0000000 | 0x014a) +#define NT_STATUS_PIPE_BROKEN NT_STATUS(0xC0000000 | 0x014b) +#define NT_STATUS_REGISTRY_CORRUPT NT_STATUS(0xC0000000 | 0x014c) +#define NT_STATUS_REGISTRY_IO_FAILED NT_STATUS(0xC0000000 | 0x014d) +#define NT_STATUS_NO_EVENT_PAIR NT_STATUS(0xC0000000 | 0x014e) +#define NT_STATUS_UNRECOGNIZED_VOLUME NT_STATUS(0xC0000000 | 0x014f) +#define NT_STATUS_SERIAL_NO_DEVICE_INITED NT_STATUS(0xC0000000 | 0x0150) +#define NT_STATUS_NO_SUCH_ALIAS NT_STATUS(0xC0000000 | 0x0151) +#define NT_STATUS_MEMBER_NOT_IN_ALIAS NT_STATUS(0xC0000000 | 0x0152) +#define NT_STATUS_MEMBER_IN_ALIAS NT_STATUS(0xC0000000 | 0x0153) +#define NT_STATUS_ALIAS_EXISTS NT_STATUS(0xC0000000 | 0x0154) +#define NT_STATUS_LOGON_NOT_GRANTED NT_STATUS(0xC0000000 | 0x0155) +#define NT_STATUS_TOO_MANY_SECRETS NT_STATUS(0xC0000000 | 0x0156) +#define NT_STATUS_SECRET_TOO_LONG NT_STATUS(0xC0000000 | 0x0157) +#define NT_STATUS_INTERNAL_DB_ERROR NT_STATUS(0xC0000000 | 0x0158) +#define NT_STATUS_FULLSCREEN_MODE NT_STATUS(0xC0000000 | 0x0159) +#define NT_STATUS_TOO_MANY_CONTEXT_IDS NT_STATUS(0xC0000000 | 0x015a) +#define NT_STATUS_LOGON_TYPE_NOT_GRANTED NT_STATUS(0xC0000000 | 0x015b) +#define NT_STATUS_NOT_REGISTRY_FILE NT_STATUS(0xC0000000 | 0x015c) +#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED NT_STATUS(0xC0000000 | 0x015d) +#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR NT_STATUS(0xC0000000 | 0x015e) +#define NT_STATUS_FT_MISSING_MEMBER NT_STATUS(0xC0000000 | 0x015f) +#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY NT_STATUS(0xC0000000 | 0x0160) +#define NT_STATUS_ILLEGAL_CHARACTER NT_STATUS(0xC0000000 | 0x0161) +#define NT_STATUS_UNMAPPABLE_CHARACTER NT_STATUS(0xC0000000 | 0x0162) +#define NT_STATUS_UNDEFINED_CHARACTER NT_STATUS(0xC0000000 | 0x0163) +#define NT_STATUS_FLOPPY_VOLUME NT_STATUS(0xC0000000 | 0x0164) +#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND NT_STATUS(0xC0000000 | 0x0165) +#define NT_STATUS_FLOPPY_WRONG_CYLINDER NT_STATUS(0xC0000000 | 0x0166) +#define NT_STATUS_FLOPPY_UNKNOWN_ERROR NT_STATUS(0xC0000000 | 0x0167) +#define NT_STATUS_FLOPPY_BAD_REGISTERS NT_STATUS(0xC0000000 | 0x0168) +#define NT_STATUS_DISK_RECALIBRATE_FAILED NT_STATUS(0xC0000000 | 0x0169) +#define NT_STATUS_DISK_OPERATION_FAILED NT_STATUS(0xC0000000 | 0x016a) +#define NT_STATUS_DISK_RESET_FAILED NT_STATUS(0xC0000000 | 0x016b) +#define NT_STATUS_SHARED_IRQ_BUSY NT_STATUS(0xC0000000 | 0x016c) +#define NT_STATUS_FT_ORPHANING NT_STATUS(0xC0000000 | 0x016d) +#define NT_STATUS_PARTITION_FAILURE NT_STATUS(0xC0000000 | 0x0172) +#define NT_STATUS_INVALID_BLOCK_LENGTH NT_STATUS(0xC0000000 | 0x0173) +#define NT_STATUS_DEVICE_NOT_PARTITIONED NT_STATUS(0xC0000000 | 0x0174) +#define NT_STATUS_UNABLE_TO_LOCK_MEDIA NT_STATUS(0xC0000000 | 0x0175) +#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA NT_STATUS(0xC0000000 | 0x0176) +#define NT_STATUS_EOM_OVERFLOW NT_STATUS(0xC0000000 | 0x0177) +#define NT_STATUS_NO_MEDIA NT_STATUS(0xC0000000 | 0x0178) +#define NT_STATUS_NO_SUCH_MEMBER NT_STATUS(0xC0000000 | 0x017a) +#define NT_STATUS_INVALID_MEMBER NT_STATUS(0xC0000000 | 0x017b) +#define NT_STATUS_KEY_DELETED NT_STATUS(0xC0000000 | 0x017c) +#define NT_STATUS_NO_LOG_SPACE NT_STATUS(0xC0000000 | 0x017d) +#define NT_STATUS_TOO_MANY_SIDS NT_STATUS(0xC0000000 | 0x017e) +#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED NT_STATUS(0xC0000000 | 0x017f) +#define NT_STATUS_KEY_HAS_CHILDREN NT_STATUS(0xC0000000 | 0x0180) +#define NT_STATUS_CHILD_MUST_BE_VOLATILE NT_STATUS(0xC0000000 | 0x0181) +#define NT_STATUS_DEVICE_CONFIGURATION_ERROR NT_STATUS(0xC0000000 | 0x0182) +#define NT_STATUS_DRIVER_INTERNAL_ERROR NT_STATUS(0xC0000000 | 0x0183) +#define NT_STATUS_INVALID_DEVICE_STATE NT_STATUS(0xC0000000 | 0x0184) +#define NT_STATUS_IO_DEVICE_ERROR NT_STATUS(0xC0000000 | 0x0185) +#define NT_STATUS_DEVICE_PROTOCOL_ERROR NT_STATUS(0xC0000000 | 0x0186) +#define NT_STATUS_BACKUP_CONTROLLER NT_STATUS(0xC0000000 | 0x0187) +#define NT_STATUS_LOG_FILE_FULL NT_STATUS(0xC0000000 | 0x0188) +#define NT_STATUS_TOO_LATE NT_STATUS(0xC0000000 | 0x0189) +#define NT_STATUS_NO_TRUST_LSA_SECRET NT_STATUS(0xC0000000 | 0x018a) +#define NT_STATUS_NO_TRUST_SAM_ACCOUNT NT_STATUS(0xC0000000 | 0x018b) +#define NT_STATUS_TRUSTED_DOMAIN_FAILURE NT_STATUS(0xC0000000 | 0x018c) +#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE NT_STATUS(0xC0000000 | 0x018d) +#define NT_STATUS_EVENTLOG_FILE_CORRUPT NT_STATUS(0xC0000000 | 0x018e) +#define NT_STATUS_EVENTLOG_CANT_START NT_STATUS(0xC0000000 | 0x018f) +#define NT_STATUS_TRUST_FAILURE NT_STATUS(0xC0000000 | 0x0190) +#define NT_STATUS_MUTANT_LIMIT_EXCEEDED NT_STATUS(0xC0000000 | 0x0191) +#define NT_STATUS_NETLOGON_NOT_STARTED NT_STATUS(0xC0000000 | 0x0192) +#define NT_STATUS_ACCOUNT_EXPIRED NT_STATUS(0xC0000000 | 0x0193) +#define NT_STATUS_POSSIBLE_DEADLOCK NT_STATUS(0xC0000000 | 0x0194) +#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT NT_STATUS(0xC0000000 | 0x0195) +#define NT_STATUS_REMOTE_SESSION_LIMIT NT_STATUS(0xC0000000 | 0x0196) +#define NT_STATUS_EVENTLOG_FILE_CHANGED NT_STATUS(0xC0000000 | 0x0197) +#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT NT_STATUS(0xC0000000 | 0x0198) +#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT NT_STATUS(0xC0000000 | 0x0199) +#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT NT_STATUS(0xC0000000 | 0x019a) +#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT NT_STATUS(0xC0000000 | 0x019b) +#define NT_STATUS_FS_DRIVER_REQUIRED NT_STATUS(0xC0000000 | 0x019c) +#define NT_STATUS_NO_USER_SESSION_KEY NT_STATUS(0xC0000000 | 0x0202) +#define NT_STATUS_USER_SESSION_DELETED NT_STATUS(0xC0000000 | 0x0203) +#define NT_STATUS_RESOURCE_LANG_NOT_FOUND NT_STATUS(0xC0000000 | 0x0204) +#define NT_STATUS_INSUFF_SERVER_RESOURCES NT_STATUS(0xC0000000 | 0x0205) +#define NT_STATUS_INVALID_BUFFER_SIZE NT_STATUS(0xC0000000 | 0x0206) +#define NT_STATUS_INVALID_ADDRESS_COMPONENT NT_STATUS(0xC0000000 | 0x0207) +#define NT_STATUS_INVALID_ADDRESS_WILDCARD NT_STATUS(0xC0000000 | 0x0208) +#define NT_STATUS_TOO_MANY_ADDRESSES NT_STATUS(0xC0000000 | 0x0209) +#define NT_STATUS_ADDRESS_ALREADY_EXISTS NT_STATUS(0xC0000000 | 0x020a) +#define NT_STATUS_ADDRESS_CLOSED NT_STATUS(0xC0000000 | 0x020b) +#define NT_STATUS_CONNECTION_DISCONNECTED NT_STATUS(0xC0000000 | 0x020c) +#define NT_STATUS_CONNECTION_RESET NT_STATUS(0xC0000000 | 0x020d) +#define NT_STATUS_TOO_MANY_NODES NT_STATUS(0xC0000000 | 0x020e) +#define NT_STATUS_TRANSACTION_ABORTED NT_STATUS(0xC0000000 | 0x020f) +#define NT_STATUS_TRANSACTION_TIMED_OUT NT_STATUS(0xC0000000 | 0x0210) +#define NT_STATUS_TRANSACTION_NO_RELEASE NT_STATUS(0xC0000000 | 0x0211) +#define NT_STATUS_TRANSACTION_NO_MATCH NT_STATUS(0xC0000000 | 0x0212) +#define NT_STATUS_TRANSACTION_RESPONDED NT_STATUS(0xC0000000 | 0x0213) +#define NT_STATUS_TRANSACTION_INVALID_ID NT_STATUS(0xC0000000 | 0x0214) +#define NT_STATUS_TRANSACTION_INVALID_TYPE NT_STATUS(0xC0000000 | 0x0215) +#define NT_STATUS_NOT_SERVER_SESSION NT_STATUS(0xC0000000 | 0x0216) +#define NT_STATUS_NOT_CLIENT_SESSION NT_STATUS(0xC0000000 | 0x0217) +#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE NT_STATUS(0xC0000000 | 0x0218) +#define NT_STATUS_DEBUG_ATTACH_FAILED NT_STATUS(0xC0000000 | 0x0219) +#define NT_STATUS_SYSTEM_PROCESS_TERMINATED NT_STATUS(0xC0000000 | 0x021a) +#define NT_STATUS_DATA_NOT_ACCEPTED NT_STATUS(0xC0000000 | 0x021b) +#define NT_STATUS_NO_BROWSER_SERVERS_FOUND NT_STATUS(0xC0000000 | 0x021c) +#define NT_STATUS_VDM_HARD_ERROR NT_STATUS(0xC0000000 | 0x021d) +#define NT_STATUS_DRIVER_CANCEL_TIMEOUT NT_STATUS(0xC0000000 | 0x021e) +#define NT_STATUS_REPLY_MESSAGE_MISMATCH NT_STATUS(0xC0000000 | 0x021f) +#define NT_STATUS_MAPPED_ALIGNMENT NT_STATUS(0xC0000000 | 0x0220) +#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH NT_STATUS(0xC0000000 | 0x0221) +#define NT_STATUS_LOST_WRITEBEHIND_DATA NT_STATUS(0xC0000000 | 0x0222) +#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID NT_STATUS(0xC0000000 | 0x0223) +#define NT_STATUS_PASSWORD_MUST_CHANGE NT_STATUS(0xC0000000 | 0x0224) +#define NT_STATUS_NOT_FOUND NT_STATUS(0xC0000000 | 0x0225) +#define NT_STATUS_NOT_TINY_STREAM NT_STATUS(0xC0000000 | 0x0226) +#define NT_STATUS_RECOVERY_FAILURE NT_STATUS(0xC0000000 | 0x0227) +#define NT_STATUS_STACK_OVERFLOW_READ NT_STATUS(0xC0000000 | 0x0228) +#define NT_STATUS_FAIL_CHECK NT_STATUS(0xC0000000 | 0x0229) +#define NT_STATUS_DUPLICATE_OBJECTID NT_STATUS(0xC0000000 | 0x022a) +#define NT_STATUS_OBJECTID_EXISTS NT_STATUS(0xC0000000 | 0x022b) +#define NT_STATUS_CONVERT_TO_LARGE NT_STATUS(0xC0000000 | 0x022c) +#define NT_STATUS_RETRY NT_STATUS(0xC0000000 | 0x022d) +#define NT_STATUS_FOUND_OUT_OF_SCOPE NT_STATUS(0xC0000000 | 0x022e) +#define NT_STATUS_ALLOCATE_BUCKET NT_STATUS(0xC0000000 | 0x022f) +#define NT_STATUS_PROPSET_NOT_FOUND NT_STATUS(0xC0000000 | 0x0230) +#define NT_STATUS_MARSHALL_OVERFLOW NT_STATUS(0xC0000000 | 0x0231) +#define NT_STATUS_INVALID_VARIANT NT_STATUS(0xC0000000 | 0x0232) +#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND NT_STATUS(0xC0000000 | 0x0233) +#define NT_STATUS_ACCOUNT_LOCKED_OUT NT_STATUS(0xC0000000 | 0x0234) +#define NT_STATUS_HANDLE_NOT_CLOSABLE NT_STATUS(0xC0000000 | 0x0235) +#define NT_STATUS_CONNECTION_REFUSED NT_STATUS(0xC0000000 | 0x0236) +#define NT_STATUS_GRACEFUL_DISCONNECT NT_STATUS(0xC0000000 | 0x0237) +#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED NT_STATUS(0xC0000000 | 0x0238) +#define NT_STATUS_ADDRESS_NOT_ASSOCIATED NT_STATUS(0xC0000000 | 0x0239) +#define NT_STATUS_CONNECTION_INVALID NT_STATUS(0xC0000000 | 0x023a) +#define NT_STATUS_CONNECTION_ACTIVE NT_STATUS(0xC0000000 | 0x023b) +#define NT_STATUS_NETWORK_UNREACHABLE NT_STATUS(0xC0000000 | 0x023c) +#define NT_STATUS_HOST_UNREACHABLE NT_STATUS(0xC0000000 | 0x023d) +#define NT_STATUS_PROTOCOL_UNREACHABLE NT_STATUS(0xC0000000 | 0x023e) +#define NT_STATUS_PORT_UNREACHABLE NT_STATUS(0xC0000000 | 0x023f) +#define NT_STATUS_REQUEST_ABORTED NT_STATUS(0xC0000000 | 0x0240) +#define NT_STATUS_CONNECTION_ABORTED NT_STATUS(0xC0000000 | 0x0241) +#define NT_STATUS_BAD_COMPRESSION_BUFFER NT_STATUS(0xC0000000 | 0x0242) +#define NT_STATUS_USER_MAPPED_FILE NT_STATUS(0xC0000000 | 0x0243) +#define NT_STATUS_AUDIT_FAILED NT_STATUS(0xC0000000 | 0x0244) +#define NT_STATUS_TIMER_RESOLUTION_NOT_SET NT_STATUS(0xC0000000 | 0x0245) +#define NT_STATUS_CONNECTION_COUNT_LIMIT NT_STATUS(0xC0000000 | 0x0246) +#define NT_STATUS_LOGIN_TIME_RESTRICTION NT_STATUS(0xC0000000 | 0x0247) +#define NT_STATUS_LOGIN_WKSTA_RESTRICTION NT_STATUS(0xC0000000 | 0x0248) +#define NT_STATUS_IMAGE_MP_UP_MISMATCH NT_STATUS(0xC0000000 | 0x0249) +#define NT_STATUS_INSUFFICIENT_LOGON_INFO NT_STATUS(0xC0000000 | 0x0250) +#define NT_STATUS_BAD_DLL_ENTRYPOINT NT_STATUS(0xC0000000 | 0x0251) +#define NT_STATUS_BAD_SERVICE_ENTRYPOINT NT_STATUS(0xC0000000 | 0x0252) +#define NT_STATUS_LPC_REPLY_LOST NT_STATUS(0xC0000000 | 0x0253) +#define NT_STATUS_IP_ADDRESS_CONFLICT1 NT_STATUS(0xC0000000 | 0x0254) +#define NT_STATUS_IP_ADDRESS_CONFLICT2 NT_STATUS(0xC0000000 | 0x0255) +#define NT_STATUS_REGISTRY_QUOTA_LIMIT NT_STATUS(0xC0000000 | 0x0256) +#define NT_STATUS_PATH_NOT_COVERED NT_STATUS(0xC0000000 | 0x0257) +#define NT_STATUS_NO_CALLBACK_ACTIVE NT_STATUS(0xC0000000 | 0x0258) +#define NT_STATUS_LICENSE_QUOTA_EXCEEDED NT_STATUS(0xC0000000 | 0x0259) +#define NT_STATUS_PWD_TOO_SHORT NT_STATUS(0xC0000000 | 0x025a) +#define NT_STATUS_PWD_TOO_RECENT NT_STATUS(0xC0000000 | 0x025b) +#define NT_STATUS_PWD_HISTORY_CONFLICT NT_STATUS(0xC0000000 | 0x025c) +#define NT_STATUS_PLUGPLAY_NO_DEVICE NT_STATUS(0xC0000000 | 0x025e) +#define NT_STATUS_UNSUPPORTED_COMPRESSION NT_STATUS(0xC0000000 | 0x025f) +#define NT_STATUS_INVALID_HW_PROFILE NT_STATUS(0xC0000000 | 0x0260) +#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH NT_STATUS(0xC0000000 | 0x0261) +#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND NT_STATUS(0xC0000000 | 0x0262) +#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND NT_STATUS(0xC0000000 | 0x0263) +#define NT_STATUS_RESOURCE_NOT_OWNED NT_STATUS(0xC0000000 | 0x0264) +#define NT_STATUS_TOO_MANY_LINKS NT_STATUS(0xC0000000 | 0x0265) +#define NT_STATUS_QUOTA_LIST_INCONSISTENT NT_STATUS(0xC0000000 | 0x0266) +#define NT_STATUS_FILE_IS_OFFLINE NT_STATUS(0xC0000000 | 0x0267) +#define NT_STATUS_NOT_A_REPARSE_POINT NT_STATUS(0xC0000000 | 0x0275) +#define NT_STATUS_OBJECTID_NOT_FOUND NT_STATUS(0xC0000000 | 0x02F0) +#define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE) /* scheduler */ +#define NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x20004) +#define NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX NT_STATUS(0xC0000000 | 0x20026) + + +/* I use NT_STATUS_FOOBAR when I have no idea what error code to use - + * this means we need a torture test */ +#define NT_STATUS_FOOBAR NT_STATUS_UNSUCCESSFUL + +/***************************************************************************** + returns an NT error message. not amazingly helpful, but better than a number. + *****************************************************************************/ +const char *nt_errstr(NTSTATUS nt_code); + +/************************************************************************ + Print friendler version fo NT error code + ***********************************************************************/ +const char *get_friendly_nt_error_msg(NTSTATUS nt_code); + +/***************************************************************************** + returns an NT_STATUS constant as a string for inclusion in autogen C code + *****************************************************************************/ +const char *get_nt_error_c_code(NTSTATUS nt_code); + +/***************************************************************************** + returns the NT_STATUS constant matching the string supplied (as an NTSTATUS) + *****************************************************************************/ +NTSTATUS nt_status_string_to_code(const char *nt_status_str); + +#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0) +#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000) +/* checking for DOS error mapping here is ugly, but unfortunately the + alternative is a very intrusive rewrite of the torture code */ +#define NT_STATUS_EQUAL(x,y) (NT_STATUS_IS_DOS(x)||NT_STATUS_IS_DOS(y)?ntstatus_dos_equal(x,y):NT_STATUS_V(x) == NT_STATUS_V(y)) + +#define NT_STATUS_HAVE_NO_MEMORY(x) do { \ + if (!(x)) {\ + return NT_STATUS_NO_MEMORY;\ + }\ +} while (0) + +#define NT_STATUS_IS_OK_RETURN(x) do { \ + if (NT_STATUS_IS_OK(x)) {\ + return x;\ + }\ +} while (0) + +#define NT_STATUS_NOT_OK_RETURN(x) do { \ + if (!NT_STATUS_IS_OK(x)) {\ + return x;\ + }\ +} while (0) + +#define NT_STATUS_IS_ERR_RETURN(x) do { \ + if (NT_STATUS_IS_ERR(x)) {\ + return x;\ + }\ +} while (0) + +#define NT_STATUS_NOT_ERR_RETURN(x) do { \ + if (!NT_STATUS_IS_ERR(x)) {\ + return x;\ + }\ +} while (0) + +/* this defines special NTSTATUS codes to represent DOS errors. I + have chosen this macro to produce status codes in the invalid + NTSTATUS range */ +#define NT_STATUS_DOS(class, code) NT_STATUS(0xF1000000 | ((class)<<16) | code) +#define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF1000000) +#define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF) +#define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF) + +/* define ldap error codes as NTSTATUS codes */ +#define NT_STATUS_LDAP(code) NT_STATUS(0xF2000000 | code) +#define NT_STATUS_IS_LDAP(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF2000000) +#define NT_STATUS_LDAP_CODE(status) (NT_STATUS_V(status) & ~0xFF000000) + + + +#endif /* _NTSTATUS_H */ diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h new file mode 100644 index 0000000000..0f49514b9f --- /dev/null +++ b/source4/libcli/util/werror.h @@ -0,0 +1,193 @@ +/* + Unix SMB/CIFS implementation. + SMB parameters and setup, plus a whole lot more. + + Copyright (C) Andrew Tridgell 2001 + + 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 3 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, see . +*/ + +#ifndef _WERROR_H_ +#define _WERROR_H + +#include + +/* the following rather strange looking definitions of NTSTATUS and WERROR + and there in order to catch common coding errors where different error types + are mixed up. This is especially important as we slowly convert Samba + from using bool for internal functions +*/ + +#if defined(HAVE_IMMEDIATE_STRUCTURES) +typedef struct {uint32_t v;} WERROR; +#define W_ERROR(x) ((WERROR) { x }) +#define W_ERROR_V(x) ((x).v) +#else +typedef uint32_t WERROR; +#define W_ERROR(x) (x) +#define W_ERROR_V(x) (x) +#endif + +#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0) +#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y)) + +#define W_ERROR_HAVE_NO_MEMORY(x) do { \ + if (!(x)) {\ + return WERR_NOMEM;\ + }\ +} while (0) + +#define W_ERROR_IS_OK_RETURN(x) do { \ + if (W_ERROR_IS_OK(x)) {\ + return x;\ + }\ +} while (0) + +#define W_ERROR_NOT_OK_RETURN(x) do { \ + if (!W_ERROR_IS_OK(x)) {\ + return x;\ + }\ +} while (0) + +/* these are win32 error codes. There are only a few places where + these matter for Samba, primarily in the NT printing code */ +#define WERR_OK W_ERROR(0) +#define WERR_BADFUNC W_ERROR(1) +#define WERR_BADFILE W_ERROR(2) +#define WERR_ACCESS_DENIED W_ERROR(5) +#define WERR_BADFID W_ERROR(6) +#define WERR_NOMEM W_ERROR(8) +#define WERR_GENERAL_FAILURE W_ERROR(31) +#define WERR_NOT_SUPPORTED W_ERROR(50) +#define WERR_BAD_NETPATH W_ERROR(53) +#define WERR_BAD_NET_RESP W_ERROR(58) +#define WERR_UNEXP_NET_ERR W_ERROR(59) +#define WERR_PRINTQ_FULL W_ERROR(61) +#define WERR_NO_SPOOL_SPACE W_ERROR(62) +#define WERR_NO_SUCH_SHARE W_ERROR(67) +#define WERR_FILE_EXISTS W_ERROR(80) +#define WERR_BAD_PASSWORD W_ERROR(86) +#define WERR_INVALID_PARAM W_ERROR(87) +#define WERR_INSUFFICIENT_BUFFER W_ERROR(122) +#define WERR_INVALID_NAME W_ERROR(123) +#define WERR_UNKNOWN_LEVEL W_ERROR(124) +#define WERR_OBJECT_PATH_INVALID W_ERROR(161) +#define WERR_ALREADY_EXISTS W_ERROR(183) +#define WERR_NO_MORE_ITEMS W_ERROR(259) +#define WERR_MORE_DATA W_ERROR(234) +#define WERR_CAN_NOT_COMPLETE W_ERROR(1003) +#define WERR_NOT_FOUND W_ERROR(1168) +#define WERR_INVALID_COMPUTERNAME W_ERROR(1210) +#define WERR_INVALID_DOMAINNAME W_ERROR(1212) +#define WERR_UNKNOWN_REVISION W_ERROR(1305) +#define WERR_REVISION_MISMATCH W_ERROR(1306) +#define WERR_INVALID_OWNER W_ERROR(1307) +#define WERR_NO_LOGON_SERVERS W_ERROR(1311) +#define WERR_NO_SUCH_PRIVILEGE W_ERROR(1313) +#define WERR_PRIVILEGE_NOT_HELD W_ERROR(1314) +#define WERR_NO_SUCH_USER W_ERROR(1317) +#define WERR_LOGON_FAILURE W_ERROR(1326) +#define WERR_INVALID_SECURITY_DESCRIPTOR W_ERROR(1338) +#define WERR_INVALID_DOMAIN_ROLE W_ERROR(1354) +#define WERR_NO_SUCH_DOMAIN W_ERROR(1355) +#define WERR_NO_SYSTEM_RESOURCES W_ERROR(1450) +#define WERR_SERVER_UNAVAILABLE W_ERROR(1722) +#define WERR_INVALID_FORM_NAME W_ERROR(1902) +#define WERR_INVALID_FORM_SIZE W_ERROR(1903) +#define WERR_ALREADY_SHARED W_ERROR(2118) +#define WERR_BUF_TOO_SMALL W_ERROR(2123) +#define WERR_JOB_NOT_FOUND W_ERROR(2151) +#define WERR_DEST_NOT_FOUND W_ERROR(2152) +#define WERR_SESSION_NOT_FOUND W_ERROR(2312) +#define WERR_FID_NOT_FOUND W_ERROR(2314) +#define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320) +#define WERR_DOMAIN_CONTROLLER_NOT_FOUND W_ERROR(2453) +#define WERR_DEVICE_NOT_AVAILABLE W_ERROR(4319) +#define WERR_STATUS_MORE_ENTRIES W_ERROR(0x0105) + +#define WERR_PRINTER_DRIVER_ALREADY_INSTALLED W_ERROR(ERRdriveralreadyinstalled) +#define WERR_UNKNOWN_PORT W_ERROR(ERRunknownprinterport) +#define WERR_UNKNOWN_PRINTER_DRIVER W_ERROR(ERRunknownprinterdriver) +#define WERR_UNKNOWN_PRINTPROCESSOR W_ERROR(ERRunknownprintprocessor) +#define WERR_INVALID_SEPARATOR_FILE W_ERROR(ERRinvalidseparatorfile) +#define WERR_INVALID_PRIORITY W_ERROR(ERRinvalidjobpriority) +#define WERR_INVALID_PRINTER_NAME W_ERROR(ERRinvalidprintername) +#define WERR_PRINTER_ALREADY_EXISTS W_ERROR(ERRprinteralreadyexists) +#define WERR_INVALID_PRINTER_COMMAND W_ERROR(ERRinvalidprintercommand) +#define WERR_INVALID_DATATYPE W_ERROR(ERRinvaliddatatype) +#define WERR_INVALID_ENVIRONMENT W_ERROR(ERRinvalidenvironment) + +#define WERR_UNKNOWN_PRINT_MONITOR W_ERROR(ERRunknownprintmonitor) +#define WERR_PRINTER_DRIVER_IN_USE W_ERROR(ERRprinterdriverinuse) +#define WERR_SPOOL_FILE_NOT_FOUND W_ERROR(ERRspoolfilenotfound) +#define WERR_SPL_NO_STARTDOC W_ERROR(ERRnostartdoc) +#define WERR_SPL_NO_ADDJOB W_ERROR(ERRnoaddjob) +#define WERR_PRINT_PROCESSOR_ALREADY_INSTALLED W_ERROR(ERRprintprocessoralreadyinstalled) +#define WERR_PRINT_MONITOR_ALREADY_INSTALLED W_ERROR(ERRprintmonitoralreadyinstalled) +#define WERR_INVALID_PRINT_MONITOR W_ERROR(ERRinvalidprintmonitor) +#define WERR_PRINT_MONITOR_IN_USE W_ERROR(ERRprintmonitorinuse) +#define WERR_PRINTER_HAS_JOBS_QUEUED W_ERROR(ERRprinterhasjobsqueued) + +#define WERR_CLASS_NOT_REGISTERED W_ERROR(0x40154) +#define WERR_NO_SHUTDOWN_IN_PROGRESS W_ERROR(0x45c) +#define WERR_SHUTDOWN_ALREADY_IN_PROGRESS W_ERROR(0x45b) + +#define WERR_NET_NAME_NOT_FOUND W_ERROR(NERR_BASE+210) +#define WERR_DEVICE_NOT_SHARED W_ERROR(NERR_BASE+211) + +/* DFS errors */ +#define WERR_DFS_NO_SUCH_VOL W_ERROR(NERR_BASE+562) +#define WERR_DFS_NO_SUCH_SHARE W_ERROR(NERR_BASE+565) +#define WERR_DFS_NO_SUCH_SERVER W_ERROR(NERR_BASE+573) +#define WERR_DFS_INTERNAL_ERROR W_ERROR(NERR_BASE+590) +#define WERR_DFS_CANT_CREATE_JUNCT W_ERROR(NERR_BASE+569) + +/* DS errors */ +#define WERR_DS_SERVICE_BUSY W_ERROR(0x0000200e) +#define WERR_DS_SERVICE_UNAVAILABLE W_ERROR(0x0000200f) +#define WERR_DS_NO_SUCH_OBJECT W_ERROR(0x00002030) +#define WERR_DS_OBJ_NOT_FOUND W_ERROR(0x0000208d) +#define WERR_DS_SCHEMA_NOT_LOADED W_ERROR(0x20de) +#define WERR_DS_SCHEMA_ALLOC_FAILED W_ERROR(0x20df) +#define WERR_DS_ATT_SCHEMA_REQ_SYNTAX W_ERROR(0x000020e0) +#define WERR_DS_DRA_SCHEMA_MISMATCH W_ERROR(0x000020e2) +#define WERR_DS_DRA_INVALID_PARAMETER W_ERROR(0x000020f5) +#define WERR_DS_DRA_BAD_DN W_ERROR(0x000020f7) +#define WERR_DS_DRA_BAD_NC W_ERROR(0x000020f8) +#define WERR_DS_DRA_INTERNAL_ERROR W_ERROR(0x000020fa) +#define WERR_DS_DRA_OUT_OF_MEM W_ERROR(0x000020fe) +#define WERR_DS_SINGLE_VALUE_CONSTRAINT W_ERROR(0x00002081) +#define WERR_DS_DRA_DB_ERROR W_ERROR(0x00002103) +#define WERR_DS_DRA_NO_REPLICA W_ERROR(0x00002104) +#define WERR_DS_DRA_ACCESS_DENIED W_ERROR(0x00002105) +#define WERR_DS_DNS_LOOKUP_FAILURE W_ERROR(0x0000214c) +#define WERR_DS_WRONG_LINKED_ATTRIBUTE_SYNTAX W_ERROR(0x00002150) +#define WERR_DS_NO_MSDS_INTID W_ERROR(0x00002194) +#define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195) + +/* SEC errors */ +#define WERR_SEC_E_ENCRYPT_FAILURE W_ERROR(0x80090329) +#define WERR_SEC_E_DECRYPT_FAILURE W_ERROR(0x80090330) +#define WERR_SEC_E_ALGORITHM_MISMATCH W_ERROR(0x80090331) + +#define WERR_FOOBAR WERR_GENERAL_FAILURE + +/***************************************************************************** + returns a windows error message. not amazingly helpful, but better than a number. + *****************************************************************************/ +const char *win_errstr(WERROR werror); + + + +#endif -- cgit From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Sep 2007 01:17:46 +0000 Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238) --- source4/libcli/util/errormap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 347d513e9c..49384817b6 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1168,7 +1168,7 @@ BOOL ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2) the mapping of dos codes, as we want to catch the cases where a forced dos code is needed */ - if (lp_nt_status_support()) { + if (lp_nt_status_support(global_loadparm)) { return NT_STATUS_V(status1) == NT_STATUS_V(status2); } -- cgit From a8f264eb2f5b3310d721e79f9ca7e8c47064267e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 Oct 2007 19:30:27 +0000 Subject: r25448: Remove IMMEDIATE_STRUCTURES define, which was used for splint. Newer versions of splint support immediate structures just fine. (This used to be commit d54a47ecdc418ee07c9479f519bd1a207e6ba3eb) --- source4/libcli/util/ntstatus.h | 6 ------ source4/libcli/util/werror.h | 8 +------- 2 files changed, 1 insertion(+), 13 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/ntstatus.h b/source4/libcli/util/ntstatus.h index 026b5162db..84d924c2ec 100644 --- a/source4/libcli/util/ntstatus.h +++ b/source4/libcli/util/ntstatus.h @@ -29,15 +29,9 @@ from using bool for internal functions */ -#if defined(HAVE_IMMEDIATE_STRUCTURES) typedef struct {uint32_t v;} NTSTATUS; #define NT_STATUS(x) ((NTSTATUS) { x }) #define NT_STATUS_V(x) ((x).v) -#else -typedef uint32_t NTSTATUS; -#define NT_STATUS(x) (x) -#define NT_STATUS_V(x) (x) -#endif /* Win32 Status codes. */ diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h index 0f49514b9f..3cd76816dc 100644 --- a/source4/libcli/util/werror.h +++ b/source4/libcli/util/werror.h @@ -19,7 +19,7 @@ */ #ifndef _WERROR_H_ -#define _WERROR_H +#define _WERROR_H_ #include @@ -29,15 +29,9 @@ from using bool for internal functions */ -#if defined(HAVE_IMMEDIATE_STRUCTURES) typedef struct {uint32_t v;} WERROR; #define W_ERROR(x) ((WERROR) { x }) #define W_ERROR_V(x) ((x).v) -#else -typedef uint32_t WERROR; -#define W_ERROR(x) (x) -#define W_ERROR_V(x) (x) -#endif #define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0) #define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y)) -- cgit From 3b07f6aeb1a060efcf8218e76b8b84fb8850f337 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 5 Oct 2007 12:05:40 +0000 Subject: r25515: Revert r25448: Immediate structures are *not* supportet by the native C compiler at least on Solaris, Tru64 and HP-UX. Michael (This used to be commit 6d07e29de2a7e535139622fa688b407da232c816) --- source4/libcli/util/ntstatus.h | 6 ++++++ source4/libcli/util/werror.h | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/ntstatus.h b/source4/libcli/util/ntstatus.h index 84d924c2ec..026b5162db 100644 --- a/source4/libcli/util/ntstatus.h +++ b/source4/libcli/util/ntstatus.h @@ -29,9 +29,15 @@ from using bool for internal functions */ +#if defined(HAVE_IMMEDIATE_STRUCTURES) typedef struct {uint32_t v;} NTSTATUS; #define NT_STATUS(x) ((NTSTATUS) { x }) #define NT_STATUS_V(x) ((x).v) +#else +typedef uint32_t NTSTATUS; +#define NT_STATUS(x) (x) +#define NT_STATUS_V(x) (x) +#endif /* Win32 Status codes. */ diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h index 3cd76816dc..0f49514b9f 100644 --- a/source4/libcli/util/werror.h +++ b/source4/libcli/util/werror.h @@ -19,7 +19,7 @@ */ #ifndef _WERROR_H_ -#define _WERROR_H_ +#define _WERROR_H #include @@ -29,9 +29,15 @@ from using bool for internal functions */ +#if defined(HAVE_IMMEDIATE_STRUCTURES) typedef struct {uint32_t v;} WERROR; #define W_ERROR(x) ((WERROR) { x }) #define W_ERROR_V(x) ((x).v) +#else +typedef uint32_t WERROR; +#define W_ERROR(x) (x) +#define W_ERROR_V(x) (x) +#endif #define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0) #define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y)) -- cgit From 20480a795306d1634db5c3cd5ce0ae6c8a13ba47 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 5 Oct 2007 12:41:22 +0000 Subject: r25516: Sorry, I reverted too much of r25448 in r25515. These two fixes should have remained! Thanks to Metze for pointing this out. Michael (This used to be commit 294b2bf593445a79c500f02569f10ff72e1d6933) --- source4/libcli/util/werror.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h index 0f49514b9f..55a4faa6a5 100644 --- a/source4/libcli/util/werror.h +++ b/source4/libcli/util/werror.h @@ -19,7 +19,7 @@ */ #ifndef _WERROR_H_ -#define _WERROR_H +#define _WERROR_H_ #include -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/libcli/util/asn1.c | 294 ++++++++++++++++++++--------------------- source4/libcli/util/clilsa.c | 2 +- source4/libcli/util/errormap.c | 2 +- 3 files changed, 149 insertions(+), 149 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index f2098de5c5..58cb5f07be 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -37,41 +37,41 @@ void asn1_free(struct asn1_data *data) } /* write to the ASN1 buffer, advancing the buffer pointer */ -BOOL asn1_write(struct asn1_data *data, const void *p, int len) +bool asn1_write(struct asn1_data *data, const void *p, int len) { - if (data->has_error) return False; + if (data->has_error) return false; if (data->length < data->ofs+len) { uint8_t *newp; newp = talloc_realloc(data, data->data, uint8_t, data->ofs+len); if (!newp) { asn1_free(data); - data->has_error = True; - return False; + data->has_error = true; + return false; } data->data = newp; data->length = data->ofs+len; } memcpy(data->data + data->ofs, p, len); data->ofs += len; - return True; + return true; } /* useful fn for writing a uint8_t */ -BOOL asn1_write_uint8(struct asn1_data *data, uint8_t v) +bool asn1_write_uint8(struct asn1_data *data, uint8_t v) { return asn1_write(data, &v, 1); } /* push a tag onto the asn1 data buffer. Used for nested structures */ -BOOL asn1_push_tag(struct asn1_data *data, uint8_t tag) +bool asn1_push_tag(struct asn1_data *data, uint8_t tag) { struct nesting *nesting; asn1_write_uint8(data, tag); nesting = talloc(data, struct nesting); if (!nesting) { - data->has_error = True; - return False; + data->has_error = true; + return false; } nesting->start = data->ofs; @@ -81,7 +81,7 @@ BOOL asn1_push_tag(struct asn1_data *data, uint8_t tag) } /* pop a tag */ -BOOL asn1_pop_tag(struct asn1_data *data) +bool asn1_pop_tag(struct asn1_data *data) { struct nesting *nesting; size_t len; @@ -89,8 +89,8 @@ BOOL asn1_pop_tag(struct asn1_data *data) nesting = data->nesting; if (!nesting) { - data->has_error = True; - return False; + data->has_error = true; + return false; } len = data->ofs - (nesting->start+1); /* yes, this is ugly. We don't know in advance how many bytes the length @@ -98,10 +98,10 @@ BOOL asn1_pop_tag(struct asn1_data *data) need to correct our mistake */ if (len > 0xFFFFFF) { data->data[nesting->start] = 0x84; - if (!asn1_write_uint8(data, 0)) return False; - if (!asn1_write_uint8(data, 0)) return False; - if (!asn1_write_uint8(data, 0)) return False; - if (!asn1_write_uint8(data, 0)) return False; + if (!asn1_write_uint8(data, 0)) return false; + if (!asn1_write_uint8(data, 0)) return false; + if (!asn1_write_uint8(data, 0)) return false; + if (!asn1_write_uint8(data, 0)) return false; memmove(data->data+nesting->start+5, data->data+nesting->start+1, len); data->data[nesting->start+1] = (len>>24) & 0xFF; data->data[nesting->start+2] = (len>>16) & 0xFF; @@ -109,23 +109,23 @@ BOOL asn1_pop_tag(struct asn1_data *data) data->data[nesting->start+4] = len&0xff; } else if (len > 0xFFFF) { data->data[nesting->start] = 0x83; - if (!asn1_write_uint8(data, 0)) return False; - if (!asn1_write_uint8(data, 0)) return False; - if (!asn1_write_uint8(data, 0)) return False; + if (!asn1_write_uint8(data, 0)) return false; + if (!asn1_write_uint8(data, 0)) return false; + if (!asn1_write_uint8(data, 0)) return false; memmove(data->data+nesting->start+4, data->data+nesting->start+1, len); data->data[nesting->start+1] = (len>>16) & 0xFF; data->data[nesting->start+2] = (len>>8) & 0xFF; data->data[nesting->start+3] = len&0xff; } else if (len > 255) { data->data[nesting->start] = 0x82; - if (!asn1_write_uint8(data, 0)) return False; - if (!asn1_write_uint8(data, 0)) return False; + if (!asn1_write_uint8(data, 0)) return false; + if (!asn1_write_uint8(data, 0)) return false; memmove(data->data+nesting->start+3, data->data+nesting->start+1, len); data->data[nesting->start+1] = len>>8; data->data[nesting->start+2] = len&0xff; } else if (len > 127) { data->data[nesting->start] = 0x81; - if (!asn1_write_uint8(data, 0)) return False; + if (!asn1_write_uint8(data, 0)) return false; memmove(data->data+nesting->start+2, data->data+nesting->start+1, len); data->data[nesting->start+1] = len; } else { @@ -134,20 +134,20 @@ BOOL asn1_pop_tag(struct asn1_data *data) data->nesting = nesting->next; talloc_free(nesting); - return True; + return true; } /* "i" is the one's complement representation, as is the normal result of an * implicit signed->unsigned conversion */ -static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL negative) +static bool push_int_bigendian(struct asn1_data *data, unsigned int i, bool negative) { uint8_t lowest = i & 0xFF; i = i >> 8; if (i != 0) if (!push_int_bigendian(data, i, negative)) - return False; + return false; if (data->nesting->start+1 == data->ofs) { @@ -157,14 +157,14 @@ static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL nega if (negative) { /* Don't write leading 0xff's */ if (lowest == 0xFF) - return True; + return true; if ((lowest & 0x80) == 0) { /* The only exception for a leading 0xff is if * the highest bit is 0, which would indicate * a positive value */ if (!asn1_write_uint8(data, 0xff)) - return False; + return false; } } else { if (lowest & 0x80) { @@ -172,7 +172,7 @@ static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL nega * this would indicate a negative number. Push * a 0 to indicate a positive one */ if (!asn1_write_uint8(data, 0)) - return False; + return false; } } } @@ -183,7 +183,7 @@ static BOOL push_int_bigendian(struct asn1_data *data, unsigned int i, BOOL nega /* write an Integer without the tag framing. Needed for example for the LDAP * Abandon Operation */ -BOOL asn1_write_implicit_Integer(struct asn1_data *data, int i) +bool asn1_write_implicit_Integer(struct asn1_data *data, int i) { if (i == -1) { /* -1 is special as it consists of all-0xff bytes. In @@ -198,14 +198,14 @@ BOOL asn1_write_implicit_Integer(struct asn1_data *data, int i) /* write an integer */ -BOOL asn1_write_Integer(struct asn1_data *data, int i) +bool asn1_write_Integer(struct asn1_data *data, int i) { - if (!asn1_push_tag(data, ASN1_INTEGER)) return False; - if (!asn1_write_implicit_Integer(data, i)) return False; + if (!asn1_push_tag(data, ASN1_INTEGER)) return false; + if (!asn1_write_implicit_Integer(data, i)) return false; return asn1_pop_tag(data); } -BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID) +bool ber_write_OID_String(DATA_BLOB *blob, const char *OID) { uint_t v, v2; const char *p = (const char *)OID; @@ -213,16 +213,16 @@ BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID) int i; v = strtoul(p, &newp, 10); - if (newp[0] != '.') return False; + if (newp[0] != '.') return false; p = newp + 1; v2 = strtoul(p, &newp, 10); - if (newp[0] != '.') return False; + if (newp[0] != '.') return false; p = newp + 1; /*the ber representation can't use more space then the string one */ *blob = data_blob(NULL, strlen(OID)); - if (!blob->data) return False; + if (!blob->data) return false; blob->data[0] = 40*v + v2; @@ -235,7 +235,7 @@ BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID) p = newp; } else { data_blob_free(blob); - return False; + return false; } if (v >= (1<<28)) blob->data[i++] = (0x80 | ((v>>28)&0x7f)); if (v >= (1<<21)) blob->data[i++] = (0x80 | ((v>>21)&0x7f)); @@ -246,31 +246,31 @@ BOOL ber_write_OID_String(DATA_BLOB *blob, const char *OID) blob->length = i; - return True; + return true; } /* write an object ID to a ASN1 buffer */ -BOOL asn1_write_OID(struct asn1_data *data, const char *OID) +bool asn1_write_OID(struct asn1_data *data, const char *OID) { DATA_BLOB blob; - if (!asn1_push_tag(data, ASN1_OID)) return False; + if (!asn1_push_tag(data, ASN1_OID)) return false; if (!ber_write_OID_String(&blob, OID)) { - data->has_error = True; - return False; + data->has_error = true; + return false; } if (!asn1_write(data, blob.data, blob.length)) { - data->has_error = True; - return False; + data->has_error = true; + return false; } data_blob_free(&blob); return asn1_pop_tag(data); } /* write an octet string */ -BOOL asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length) +bool asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length) { asn1_push_tag(data, ASN1_OCTET_STRING); asn1_write(data, p, length); @@ -279,14 +279,14 @@ BOOL asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length } /* write a LDAP string */ -BOOL asn1_write_LDAPString(struct asn1_data *data, const char *s) +bool asn1_write_LDAPString(struct asn1_data *data, const char *s) { asn1_write(data, s, strlen(s)); return !data->has_error; } /* write a general string */ -BOOL asn1_write_GeneralString(struct asn1_data *data, const char *s) +bool asn1_write_GeneralString(struct asn1_data *data, const char *s) { asn1_push_tag(data, ASN1_GENERAL_STRING); asn1_write_LDAPString(data, s); @@ -294,7 +294,7 @@ BOOL asn1_write_GeneralString(struct asn1_data *data, const char *s) return !data->has_error; } -BOOL asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob) +bool asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob) { asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(num)); asn1_write(data, blob->data, blob->length); @@ -303,7 +303,7 @@ BOOL asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *bl } /* write a BOOLEAN */ -BOOL asn1_write_BOOLEAN(struct asn1_data *data, BOOL v) +bool asn1_write_BOOLEAN(struct asn1_data *data, bool v) { asn1_push_tag(data, ASN1_BOOLEAN); asn1_write_uint8(data, v ? 0xFF : 0); @@ -311,140 +311,140 @@ BOOL asn1_write_BOOLEAN(struct asn1_data *data, BOOL v) return !data->has_error; } -BOOL asn1_read_BOOLEAN(struct asn1_data *data, BOOL *v) +bool asn1_read_BOOLEAN(struct asn1_data *data, bool *v) { uint8_t tmp = 0; asn1_start_tag(data, ASN1_BOOLEAN); asn1_read_uint8(data, &tmp); if (tmp == 0xFF) { - *v = True; + *v = true; } else { - *v = False; + *v = false; } asn1_end_tag(data); return !data->has_error; } /* check a BOOLEAN */ -BOOL asn1_check_BOOLEAN(struct asn1_data *data, BOOL v) +bool asn1_check_BOOLEAN(struct asn1_data *data, bool v) { uint8_t b = 0; asn1_read_uint8(data, &b); if (b != ASN1_BOOLEAN) { - data->has_error = True; - return False; + data->has_error = true; + return false; } asn1_read_uint8(data, &b); if (b != v) { - data->has_error = True; - return False; + data->has_error = true; + return false; } return !data->has_error; } /* load a struct asn1_data structure with a lump of data, ready to be parsed */ -BOOL asn1_load(struct asn1_data *data, DATA_BLOB blob) +bool asn1_load(struct asn1_data *data, DATA_BLOB blob) { ZERO_STRUCTP(data); data->data = talloc_memdup(data, blob.data, blob.length); if (!data->data) { - data->has_error = True; - return False; + data->has_error = true; + return false; } data->length = blob.length; - return True; + return true; } /* Peek into an ASN1 buffer, not advancing the pointer */ -BOOL asn1_peek(struct asn1_data *data, void *p, int len) +bool asn1_peek(struct asn1_data *data, void *p, int len) { if (data->has_error) - return False; + return false; if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len) - return False; + return false; if (data->ofs + len > data->length) { /* we need to mark the buffer as consumed, so the caller knows this was an out of data error, and not a decode error */ data->ofs = data->length; - return False; + return false; } memcpy(p, data->data + data->ofs, len); - return True; + return true; } /* read from a ASN1 buffer, advancing the buffer pointer */ -BOOL asn1_read(struct asn1_data *data, void *p, int len) +bool asn1_read(struct asn1_data *data, void *p, int len) { if (!asn1_peek(data, p, len)) { - data->has_error = True; - return False; + data->has_error = true; + return false; } data->ofs += len; - return True; + return true; } /* read a uint8_t from a ASN1 buffer */ -BOOL asn1_read_uint8(struct asn1_data *data, uint8_t *v) +bool asn1_read_uint8(struct asn1_data *data, uint8_t *v) { return asn1_read(data, v, 1); } -BOOL asn1_peek_uint8(struct asn1_data *data, uint8_t *v) +bool asn1_peek_uint8(struct asn1_data *data, uint8_t *v) { return asn1_peek(data, v, 1); } -BOOL asn1_peek_tag(struct asn1_data *data, uint8_t tag) +bool asn1_peek_tag(struct asn1_data *data, uint8_t tag) { uint8_t b; if (asn1_tag_remaining(data) <= 0) { - return False; + return false; } if (!asn1_peek_uint8(data, &b)) - return False; + return false; return (b == tag); } /* start reading a nested asn1 structure */ -BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag) +bool asn1_start_tag(struct asn1_data *data, uint8_t tag) { uint8_t b; struct nesting *nesting; if (!asn1_read_uint8(data, &b)) - return False; + return false; if (b != tag) { - data->has_error = True; - return False; + data->has_error = true; + return false; } nesting = talloc(data, struct nesting); if (!nesting) { - data->has_error = True; - return False; + data->has_error = true; + return false; } if (!asn1_read_uint8(data, &b)) { - return False; + return false; } if (b & 0x80) { int n = b & 0x7f; if (!asn1_read_uint8(data, &b)) - return False; + return false; nesting->taglen = b; while (n > 1) { if (!asn1_read_uint8(data, &b)) - return False; + return false; nesting->taglen = (nesting->taglen << 8) | b; n--; } @@ -455,32 +455,32 @@ BOOL asn1_start_tag(struct asn1_data *data, uint8_t tag) nesting->next = data->nesting; data->nesting = nesting; if (asn1_tag_remaining(data) == -1) { - return False; + return false; } return !data->has_error; } /* stop reading a tag */ -BOOL asn1_end_tag(struct asn1_data *data) +bool asn1_end_tag(struct asn1_data *data) { struct nesting *nesting; /* make sure we read it all */ if (asn1_tag_remaining(data) != 0) { - data->has_error = True; - return False; + data->has_error = true; + return false; } nesting = data->nesting; if (!nesting) { - data->has_error = True; - return False; + data->has_error = true; + return false; } data->nesting = nesting->next; talloc_free(nesting); - return True; + return true; } /* work out how many bytes are left in this nested tag */ @@ -492,26 +492,26 @@ int asn1_tag_remaining(struct asn1_data *data) } if (!data->nesting) { - data->has_error = True; + data->has_error = true; return -1; } remaining = data->nesting->taglen - (data->ofs - data->nesting->start); if (remaining > (data->length - data->ofs)) { - data->has_error = True; + data->has_error = true; return -1; } return remaining; } /* read an object ID from a data blob */ -BOOL ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID) +bool ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID) { int i; uint8_t *b; uint_t v; char *tmp_oid = NULL; - if (blob.length < 2) return False; + if (blob.length < 2) return false; b = blob.data; @@ -531,82 +531,82 @@ BOOL ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID) if (v != 0) { talloc_free(tmp_oid); - return False; + return false; } *OID = tmp_oid; - return True; + return true; nomem: - return False; + return false; } /* read an object ID from a ASN1 buffer */ -BOOL asn1_read_OID(struct asn1_data *data, TALLOC_CTX *mem_ctx, const char **OID) +bool asn1_read_OID(struct asn1_data *data, TALLOC_CTX *mem_ctx, const char **OID) { DATA_BLOB blob; int len; - if (!asn1_start_tag(data, ASN1_OID)) return False; + if (!asn1_start_tag(data, ASN1_OID)) return false; len = asn1_tag_remaining(data); if (len < 0) { - data->has_error = True; - return False; + data->has_error = true; + return false; } blob = data_blob(NULL, len); if (!blob.data) { - data->has_error = True; - return False; + data->has_error = true; + return false; } asn1_read(data, blob.data, len); asn1_end_tag(data); if (data->has_error) { data_blob_free(&blob); - return False; + return false; } if (!ber_read_OID_String(mem_ctx, blob, OID)) { - data->has_error = True; + data->has_error = true; data_blob_free(&blob); - return False; + return false; } data_blob_free(&blob); - return True; + return true; } /* check that the next object ID is correct */ -BOOL asn1_check_OID(struct asn1_data *data, const char *OID) +bool asn1_check_OID(struct asn1_data *data, const char *OID) { const char *id; - if (!asn1_read_OID(data, data, &id)) return False; + if (!asn1_read_OID(data, data, &id)) return false; if (strcmp(id, OID) != 0) { talloc_free(discard_const(id)); - data->has_error = True; - return False; + data->has_error = true; + return false; } talloc_free(discard_const(id)); - return True; + return true; } /* read a LDAPString from a ASN1 buffer */ -BOOL asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s) +bool asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s) { int len; len = asn1_tag_remaining(data); if (len < 0) { - data->has_error = True; - return False; + data->has_error = true; + return false; } *s = talloc_array(mem_ctx, char, len+1); if (! *s) { - data->has_error = True; - return False; + data->has_error = true; + return false; } asn1_read(data, *s, len); (*s)[len] = 0; @@ -615,29 +615,29 @@ BOOL asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s) /* read a GeneralString from a ASN1 buffer */ -BOOL asn1_read_GeneralString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s) +bool asn1_read_GeneralString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s) { - if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False; - if (!asn1_read_LDAPString(data, mem_ctx, s)) return False; + if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return false; + if (!asn1_read_LDAPString(data, mem_ctx, s)) return false; return asn1_end_tag(data); } /* read a octet string blob */ -BOOL asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLOB *blob) +bool asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLOB *blob) { int len; ZERO_STRUCTP(blob); - if (!asn1_start_tag(data, ASN1_OCTET_STRING)) return False; + if (!asn1_start_tag(data, ASN1_OCTET_STRING)) return false; len = asn1_tag_remaining(data); if (len < 0) { - data->has_error = True; - return False; + data->has_error = true; + return false; } *blob = data_blob_talloc(mem_ctx, NULL, len+1); if (!blob->data) { - data->has_error = True; - return False; + data->has_error = true; + return false; } asn1_read(data, blob->data, len); asn1_end_tag(data); @@ -647,25 +647,25 @@ BOOL asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLO if (data->has_error) { data_blob_free(blob); *blob = data_blob(NULL, 0); - return False; + return false; } - return True; + return true; } -BOOL asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob) +bool asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob) { int len; ZERO_STRUCTP(blob); - if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(num))) return False; + if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(num))) return false; len = asn1_tag_remaining(data); if (len < 0) { - data->has_error = True; - return False; + data->has_error = true; + return false; } *blob = data_blob(NULL, len); if ((len != 0) && (!blob->data)) { - data->has_error = True; - return False; + data->has_error = true; + return false; } asn1_read(data, blob->data, len); asn1_end_tag(data); @@ -673,13 +673,13 @@ BOOL asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blo } /* read an interger without tag*/ -BOOL asn1_read_implicit_Integer(struct asn1_data *data, int *i) +bool asn1_read_implicit_Integer(struct asn1_data *data, int *i) { uint8_t b; *i = 0; while (!data->has_error && asn1_tag_remaining(data)>0) { - if (!asn1_read_uint8(data, &b)) return False; + if (!asn1_read_uint8(data, &b)) return false; *i = (*i << 8) + b; } return !data->has_error; @@ -687,21 +687,21 @@ BOOL asn1_read_implicit_Integer(struct asn1_data *data, int *i) } /* read an interger */ -BOOL asn1_read_Integer(struct asn1_data *data, int *i) +bool asn1_read_Integer(struct asn1_data *data, int *i) { *i = 0; - if (!asn1_start_tag(data, ASN1_INTEGER)) return False; - if (!asn1_read_implicit_Integer(data, i)) return False; + if (!asn1_start_tag(data, ASN1_INTEGER)) return false; + if (!asn1_read_implicit_Integer(data, i)) return false; return asn1_end_tag(data); } /* read an interger */ -BOOL asn1_read_enumerated(struct asn1_data *data, int *v) +bool asn1_read_enumerated(struct asn1_data *data, int *v) { *v = 0; - if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False; + if (!asn1_start_tag(data, ASN1_ENUMERATED)) return false; while (!data->has_error && asn1_tag_remaining(data)>0) { uint8_t b; asn1_read_uint8(data, &b); @@ -711,23 +711,23 @@ BOOL asn1_read_enumerated(struct asn1_data *data, int *v) } /* check a enumarted value is correct */ -BOOL asn1_check_enumerated(struct asn1_data *data, int v) +bool asn1_check_enumerated(struct asn1_data *data, int v) { uint8_t b; - if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False; + if (!asn1_start_tag(data, ASN1_ENUMERATED)) return false; asn1_read_uint8(data, &b); asn1_end_tag(data); if (v != b) - data->has_error = False; + data->has_error = false; return !data->has_error; } /* write an enumarted value to the stream */ -BOOL asn1_write_enumerated(struct asn1_data *data, uint8_t v) +bool asn1_write_enumerated(struct asn1_data *data, uint8_t v) { - if (!asn1_push_tag(data, ASN1_ENUMERATED)) return False; + if (!asn1_push_tag(data, ASN1_ENUMERATED)) return false; asn1_write_uint8(data, v); asn1_pop_tag(data); return !data->has_error; diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 0fdf8a8e3a..7c32294648 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -61,7 +61,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) return NT_STATUS_NO_MEMORY; } - lsa->ipc_tree = smbcli_tree_init(cli->session, lsa, False); + lsa->ipc_tree = smbcli_tree_init(cli->session, lsa, false); if (lsa->ipc_tree == NULL) { return NT_STATUS_NO_MEMORY; } diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 49384817b6..8d088e1e4b 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1162,7 +1162,7 @@ static const struct { /* check if a DOS encoded NTSTATUS code maps to the given NTSTATUS code */ -BOOL ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2) +bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2) { /* when we negotiate nt status support, we don't want to consider the mapping of dos codes, as we want to catch the cases where -- cgit From 4860557842a8b5e2c5ceba03c64f42996f0bf60c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 16 Oct 2007 11:39:40 +0200 Subject: r25665: Add some more WERR codes. Guenther (This used to be commit 846d81c0ade7a1b56366feb4338312c24dc4351b) --- source4/libcli/util/doserr.c | 3 +++ source4/libcli/util/werror.h | 8 ++++++++ 2 files changed, 11 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 49818e573a..28618dbf2b 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -119,6 +119,9 @@ static const struct werror_code_struct dos_errs[] = { "WERR_SEC_E_ENCRYPT_FAILURE", WERR_SEC_E_ENCRYPT_FAILURE }, { "WERR_SEC_E_DECRYPT_FAILURE", WERR_SEC_E_DECRYPT_FAILURE }, { "WERR_SEC_E_ALGORITHM_MISMATCH", WERR_SEC_E_ALGORITHM_MISMATCH }, + { "WERR_NOT_AUTHENTICATED", WERR_NOT_AUTHENTICATED }, + { "WERR_CALL_NOT_IMPLEMENTED", WERR_CALL_NOT_IMPLEMENTED }, + { "WERR_FRS_INVALID_SERVICE_PARAMETER", WERR_FRS_INVALID_SERVICE_PARAMETER }, { NULL, W_ERROR(0) } }; diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h index 55a4faa6a5..bde58265d4 100644 --- a/source4/libcli/util/werror.h +++ b/source4/libcli/util/werror.h @@ -79,6 +79,7 @@ typedef uint32_t WERROR; #define WERR_FILE_EXISTS W_ERROR(80) #define WERR_BAD_PASSWORD W_ERROR(86) #define WERR_INVALID_PARAM W_ERROR(87) +#define WERR_CALL_NOT_IMPLEMENTED W_ERROR(120) #define WERR_INSUFFICIENT_BUFFER W_ERROR(122) #define WERR_INVALID_NAME W_ERROR(123) #define WERR_UNKNOWN_LEVEL W_ERROR(124) @@ -90,6 +91,7 @@ typedef uint32_t WERROR; #define WERR_NOT_FOUND W_ERROR(1168) #define WERR_INVALID_COMPUTERNAME W_ERROR(1210) #define WERR_INVALID_DOMAINNAME W_ERROR(1212) +#define WERR_NOT_AUTHENTICATED W_ERROR(1244) #define WERR_UNKNOWN_REVISION W_ERROR(1305) #define WERR_REVISION_MISMATCH W_ERROR(1306) #define WERR_INVALID_OWNER W_ERROR(1307) @@ -176,6 +178,12 @@ typedef uint32_t WERROR; #define WERR_DS_NO_MSDS_INTID W_ERROR(0x00002194) #define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195) +/* FRS errors */ +#ifndef FRS_ERR_BASE +#define FRS_ERR_BASE (8000) +#endif +#define WERR_FRS_INVALID_SERVICE_PARAMETER W_ERROR(FRS_ERROR_BASE+17) + /* SEC errors */ #define WERR_SEC_E_ENCRYPT_FAILURE W_ERROR(0x80090329) #define WERR_SEC_E_DECRYPT_FAILURE W_ERROR(0x80090330) -- cgit From 6282194fe5288f0118135ea492d8ec68d093491d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 16 Oct 2007 13:50:40 +0200 Subject: r25668: Hopefully fix the build, sorry... Guenther (This used to be commit df94fbfe96200ed521fd377a01b6b7b7a7ef88d8) --- source4/libcli/util/doserr.h | 4 ++++ source4/libcli/util/werror.h | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.h b/source4/libcli/util/doserr.h index bec268a565..6c757a3fc2 100644 --- a/source4/libcli/util/doserr.h +++ b/source4/libcli/util/doserr.h @@ -165,4 +165,8 @@ #define NERR_BASE (2100) #endif +#ifndef FRS_ERR_BASE +#define FRS_ERR_BASE (8000) +#endif + #endif /* _DOSERR_H */ diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h index bde58265d4..48f5b40091 100644 --- a/source4/libcli/util/werror.h +++ b/source4/libcli/util/werror.h @@ -179,9 +179,6 @@ typedef uint32_t WERROR; #define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195) /* FRS errors */ -#ifndef FRS_ERR_BASE -#define FRS_ERR_BASE (8000) -#endif #define WERR_FRS_INVALID_SERVICE_PARAMETER W_ERROR(FRS_ERROR_BASE+17) /* SEC errors */ -- cgit From 47f67ef366bca56ad9b4a561d183a35aa464b4ba Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 16 Oct 2007 14:09:49 +0200 Subject: r25669: Real build fix. Guenther (This used to be commit 1b9e526bf60372e5b3731e98dbfcc029b04e4b01) --- source4/libcli/util/werror.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h index 48f5b40091..e058120dce 100644 --- a/source4/libcli/util/werror.h +++ b/source4/libcli/util/werror.h @@ -179,7 +179,7 @@ typedef uint32_t WERROR; #define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195) /* FRS errors */ -#define WERR_FRS_INVALID_SERVICE_PARAMETER W_ERROR(FRS_ERROR_BASE+17) +#define WERR_FRS_INVALID_SERVICE_PARAMETER W_ERROR(FRS_ERR_BASE+17) /* SEC errors */ #define WERR_SEC_E_ENCRYPT_FAILURE W_ERROR(0x80090329) -- cgit From 177faf940f79398303c5566ff2771a4b742bd862 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 16 Oct 2007 17:22:03 +0200 Subject: r25672: Some more FRS werrors. Guenther (This used to be commit 8fa3de8dca9e9d0d9f7fc79e4fc78b85313f870b) --- source4/libcli/util/doserr.c | 2 ++ source4/libcli/util/werror.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 28618dbf2b..e94b50a6de 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -122,6 +122,8 @@ static const struct werror_code_struct dos_errs[] = { "WERR_NOT_AUTHENTICATED", WERR_NOT_AUTHENTICATED }, { "WERR_CALL_NOT_IMPLEMENTED", WERR_CALL_NOT_IMPLEMENTED }, { "WERR_FRS_INVALID_SERVICE_PARAMETER", WERR_FRS_INVALID_SERVICE_PARAMETER }, + { "WERR_FRS_SYSVOL_IS_BUSY", WERR_FRS_SYSVOL_IS_BUSY }, + { "WERR_FRS_INSUFFICIENT_PRIV", WERR_FRS_INSUFFICIENT_PRIV }, { NULL, W_ERROR(0) } }; diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h index e058120dce..d356b160d8 100644 --- a/source4/libcli/util/werror.h +++ b/source4/libcli/util/werror.h @@ -179,6 +179,8 @@ typedef uint32_t WERROR; #define WERR_DS_DUP_MSDS_INTID W_ERROR(0x00002195) /* FRS errors */ +#define WERR_FRS_INSUFFICIENT_PRIV W_ERROR(FRS_ERR_BASE+7) +#define WERR_FRS_SYSVOL_IS_BUSY W_ERROR(FRS_ERR_BASE+15) #define WERR_FRS_INVALID_SERVICE_PARAMETER W_ERROR(FRS_ERR_BASE+17) /* SEC errors */ -- cgit From b4ddef5942990c266e8cf8497da15aef7a357c33 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 7 Nov 2007 20:45:04 +0100 Subject: r25897: Add WERR_INVALID_FLAGS. Guenther (This used to be commit c3023eaeb389f44b64becc383552df0debfc232d) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/werror.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index e94b50a6de..19984cf2e9 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -111,6 +111,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_PRINTQ_FULL", WERR_PRINTQ_FULL }, { "WERR_NO_SPOOL_SPACE", WERR_NO_SPOOL_SPACE }, { "WERR_CAN_NOT_COMPLETE", WERR_CAN_NOT_COMPLETE }, + { "WERR_INVALID_FLAGS", WERR_INVALID_FLAGS }, { "WERR_NOT_FOUND", WERR_NOT_FOUND }, { "WERR_SERVER_UNAVAILABLE", WERR_SERVER_UNAVAILABLE }, { "WERR_CLASS_NOT_REGISTERED", WERR_CLASS_NOT_REGISTERED }, diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h index d356b160d8..532dc2ed8c 100644 --- a/source4/libcli/util/werror.h +++ b/source4/libcli/util/werror.h @@ -88,6 +88,7 @@ typedef uint32_t WERROR; #define WERR_NO_MORE_ITEMS W_ERROR(259) #define WERR_MORE_DATA W_ERROR(234) #define WERR_CAN_NOT_COMPLETE W_ERROR(1003) +#define WERR_INVALID_FLAGS W_ERROR(1004) #define WERR_NOT_FOUND W_ERROR(1168) #define WERR_INVALID_COMPUTERNAME W_ERROR(1210) #define WERR_INVALID_DOMAINNAME W_ERROR(1212) -- cgit From 0ce646d49a70b19d7ca54e0b83422f048dd39c1a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 19:23:57 +0100 Subject: r25917: ndr: move ndr_map_error2ntstatus to errormap.c metze (This used to be commit 8fc2e7737fc15f7265816f077e2a48a7a98f75b8) --- source4/libcli/util/error.h | 6 +++++- source4/libcli/util/errormap.c | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/error.h b/source4/libcli/util/error.h index dd2de3da75..e054948fbe 100644 --- a/source4/libcli/util/error.h +++ b/source4/libcli/util/error.h @@ -22,6 +22,7 @@ #include "libcli/util/werror.h" #include "libcli/util/doserr.h" #include "libcli/util/ntstatus.h" +#include "librpc/ndr/libndr.h" /** NT error on DOS connection! (NT_STATUS_OK) */ bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2); @@ -46,6 +47,9 @@ WERROR ntstatus_to_werror(NTSTATUS error); *********************************************************************/ NTSTATUS map_nt_error_from_unix(int unix_error); - +/********************************************************************* + Map an NT error code from a NDR error code. +*********************************************************************/ +NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err); #endif /* _SAMBA_ERROR_H */ diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index 8d088e1e4b..b8458d4bf3 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -1375,3 +1375,28 @@ NTSTATUS map_nt_error_from_unix(int unix_error) /* Default return */ return NT_STATUS_UNSUCCESSFUL; } + +NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err) +{ + switch (ndr_err) { + case NDR_ERR_SUCCESS: + return NT_STATUS_OK; + case NDR_ERR_BUFSIZE: + return NT_STATUS_BUFFER_TOO_SMALL; + case NDR_ERR_TOKEN: + return NT_STATUS_INTERNAL_ERROR; + case NDR_ERR_ALLOC: + return NT_STATUS_NO_MEMORY; + case NDR_ERR_ARRAY_SIZE: + return NT_STATUS_ARRAY_BOUNDS_EXCEEDED; + case NDR_ERR_INVALID_POINTER: + return NT_STATUS_INVALID_PARAMETER_MIX; + case NDR_ERR_UNREAD_BYTES: + return NT_STATUS_PORT_MESSAGE_TOO_LONG; + default: + break; + } + + /* we should map all error codes to different status codes */ + return NT_STATUS_INVALID_PARAMETER; +} -- cgit From e66d7d8074f01536ad49ed1195d1503b2f162938 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 20 Nov 2007 12:43:11 +0100 Subject: r26060: Add some error codes from remote join api. Guenther (This used to be commit 73f231cba3fde4b2c5078b7c6dd52c3dac8cd1ce) --- source4/libcli/util/doserr.c | 3 +++ source4/libcli/util/werror.h | 5 +++++ 2 files changed, 8 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index 19984cf2e9..b480946401 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -62,6 +62,9 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DEST_NOT_FOUND", WERR_DEST_NOT_FOUND }, { "WERR_NOT_LOCAL_DOMAIN", WERR_NOT_LOCAL_DOMAIN }, { "WERR_DOMAIN_CONTROLLER_NOT_FOUND", WERR_DOMAIN_CONTROLLER_NOT_FOUND }, + { "WERR_SETUP_NOT_JOINED", WERR_SETUP_NOT_JOINED }, + { "WERR_SETUP_ALREADY_JOINED", WERR_SETUP_ALREADY_JOINED }, + { "WERR_SETUP_DOMAIN_CONTROLLER", WERR_SETUP_DOMAIN_CONTROLLER }, { "WERR_DEVICE_NOT_AVAILABLE", WERR_DEVICE_NOT_AVAILABLE }, { "WERR_PRINTER_DRIVER_IN_USE", WERR_PRINTER_DRIVER_IN_USE }, { "WERR_STATUS_MORE_ENTRIES", WERR_STATUS_MORE_ENTRIES }, diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h index 532dc2ed8c..4de3092d9f 100644 --- a/source4/libcli/util/werror.h +++ b/source4/libcli/util/werror.h @@ -116,6 +116,11 @@ typedef uint32_t WERROR; #define WERR_FID_NOT_FOUND W_ERROR(2314) #define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320) #define WERR_DOMAIN_CONTROLLER_NOT_FOUND W_ERROR(2453) + +#define WERR_SETUP_ALREADY_JOINED W_ERROR(2691) +#define WERR_SETUP_NOT_JOINED W_ERROR(2692) +#define WERR_SETUP_DOMAIN_CONTROLLER W_ERROR(2693) + #define WERR_DEVICE_NOT_AVAILABLE W_ERROR(4319) #define WERR_STATUS_MORE_ENTRIES W_ERROR(0x0105) -- cgit From 4cb790b768755b1eb1623296aa752e5d64b5137c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 Nov 2007 12:31:29 +0100 Subject: r26074: Add SWIG magic for NTSTATUS and WERROR return codes. (This used to be commit 0bee7cb92e8ae1b80a957dd8fe32c36db1c32032) --- source4/libcli/util/errors.i | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 source4/libcli/util/errors.i (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errors.i b/source4/libcli/util/errors.i new file mode 100644 index 0000000000..61cb7a090a --- /dev/null +++ b/source4/libcli/util/errors.i @@ -0,0 +1,39 @@ +/* + Unix SMB/CIFS implementation. + Copyright (C) Jelmer Vernooij 2007 + Copyright (C) Tim Potter 2004 + + 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 3 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, see . +*/ + +#ifdef SWIGPYTHON +%typemap(out) WERROR { + if (!W_ERROR_IS_OK($1)) { + PyObject *obj = Py_BuildValue("(i,s)", $1.v, win_errstr($1)); + PyErr_SetObject(PyExc_RuntimeError, obj); + } else if ($result == NULL) { + $result = Py_None; + } +}; + +%typemap(out) NTSTATUS { + if (NT_STATUS_IS_ERR($1)) { + PyObject *obj = Py_BuildValue("(i,s)", $1.v, nt_errstr($1)); + PyErr_SetObject(PyExc_RuntimeError, obj); + } else if ($result == NULL) { + $result = Py_None; + } +}; + +#endif -- cgit From 39adc2418a0586261c6c4aea36f72596c6cf8897 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 Nov 2007 13:07:16 +0100 Subject: r26088: Import some native-python python modules and move original python swig torture code to common python directory as well. (This used to be commit cbf656ff054ab2b0b5ca81e1d4f16ac54c8098f1) --- source4/libcli/util/errors.i | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errors.i b/source4/libcli/util/errors.i index 61cb7a090a..d51c9e0ded 100644 --- a/source4/libcli/util/errors.i +++ b/source4/libcli/util/errors.i @@ -36,4 +36,15 @@ } }; +%typemap(in) NTSTATUS { + if (PyLong_Check($input)) + $1 = NT_STATUS(PyLong_AsUnsignedLong($input)); + else if (PyInt_Check($input)) + $1 = NT_STATUS(PyInt_AsLong($input)); + else { + PyErr_SetString(PyExc_TypeError, "Expected a long or an int"); + return NULL; + } +} + #endif -- cgit From 017ee874858d13cb77738a885d9320c659f49e18 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 26 Nov 2007 23:58:39 +0100 Subject: r26133: Add some more error codes from wkssvc testing. Guenther (This used to be commit 0cf974ee33ba0dbd41c554db2fd1d0458e99e3d1) --- source4/libcli/util/doserr.c | 5 +++++ source4/libcli/util/werror.h | 8 ++++++++ 2 files changed, 13 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index b480946401..d36532dcf4 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -41,6 +41,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_FILE_EXISTS", WERR_FILE_EXISTS }, { "WERR_INVALID_PARAM", WERR_INVALID_PARAM }, { "WERR_NOT_SUPPORTED", WERR_NOT_SUPPORTED }, + { "WERR_DUP_NAME", WERR_DUP_NAME }, { "WERR_BAD_PASSWORD", WERR_BAD_PASSWORD }, { "WERR_NOMEM", WERR_NOMEM }, { "WERR_INVALID_NAME", WERR_INVALID_NAME }, @@ -62,6 +63,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_DEST_NOT_FOUND", WERR_DEST_NOT_FOUND }, { "WERR_NOT_LOCAL_DOMAIN", WERR_NOT_LOCAL_DOMAIN }, { "WERR_DOMAIN_CONTROLLER_NOT_FOUND", WERR_DOMAIN_CONTROLLER_NOT_FOUND }, + { "WERR_TIME_DIFF_AT_DC", WERR_TIME_DIFF_AT_DC }, { "WERR_SETUP_NOT_JOINED", WERR_SETUP_NOT_JOINED }, { "WERR_SETUP_ALREADY_JOINED", WERR_SETUP_ALREADY_JOINED }, { "WERR_SETUP_DOMAIN_CONTROLLER", WERR_SETUP_DOMAIN_CONTROLLER }, @@ -84,6 +86,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_INVALID_COMPUTERNAME", WERR_INVALID_COMPUTERNAME }, { "WERR_INVALID_DOMAINNAME", WERR_INVALID_DOMAINNAME }, { "WERR_NO_LOGON_SERVERS", WERR_NO_LOGON_SERVERS }, + { "WERR_NO_SUCH_LOGON_SESSION", WERR_NO_SUCH_LOGON_SESSION }, { "WERR_NO_SUCH_PRIVILEGE", WERR_NO_SUCH_PRIVILEGE }, { "WERR_PRIVILEGE_NOT_HELD", WERR_PRIVILEGE_NOT_HELD }, { "WERR_NO_SUCH_USER", WERR_NO_SUCH_USER }, @@ -128,6 +131,8 @@ static const struct werror_code_struct dos_errs[] = { "WERR_FRS_INVALID_SERVICE_PARAMETER", WERR_FRS_INVALID_SERVICE_PARAMETER }, { "WERR_FRS_SYSVOL_IS_BUSY", WERR_FRS_SYSVOL_IS_BUSY }, { "WERR_FRS_INSUFFICIENT_PRIV", WERR_FRS_INSUFFICIENT_PRIV }, + { "WERR_RPC_E_REMOTE_DISABLED", WERR_RPC_E_REMOTE_DISABLED }, + { "WERR_NOT_CONNECTED", WERR_NOT_CONNECTED }, { NULL, W_ERROR(0) } }; diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h index 4de3092d9f..83fa5469cf 100644 --- a/source4/libcli/util/werror.h +++ b/source4/libcli/util/werror.h @@ -70,6 +70,7 @@ typedef uint32_t WERROR; #define WERR_NOMEM W_ERROR(8) #define WERR_GENERAL_FAILURE W_ERROR(31) #define WERR_NOT_SUPPORTED W_ERROR(50) +#define WERR_DUP_NAME W_ERROR(52) #define WERR_BAD_NETPATH W_ERROR(53) #define WERR_BAD_NET_RESP W_ERROR(58) #define WERR_UNEXP_NET_ERR W_ERROR(59) @@ -97,6 +98,7 @@ typedef uint32_t WERROR; #define WERR_REVISION_MISMATCH W_ERROR(1306) #define WERR_INVALID_OWNER W_ERROR(1307) #define WERR_NO_LOGON_SERVERS W_ERROR(1311) +#define WERR_NO_SUCH_LOGON_SESSION W_ERROR(1312) #define WERR_NO_SUCH_PRIVILEGE W_ERROR(1313) #define WERR_PRIVILEGE_NOT_HELD W_ERROR(1314) #define WERR_NO_SUCH_USER W_ERROR(1317) @@ -112,10 +114,12 @@ typedef uint32_t WERROR; #define WERR_BUF_TOO_SMALL W_ERROR(2123) #define WERR_JOB_NOT_FOUND W_ERROR(2151) #define WERR_DEST_NOT_FOUND W_ERROR(2152) +#define WERR_NOT_CONNECTED W_ERROR(2250) #define WERR_SESSION_NOT_FOUND W_ERROR(2312) #define WERR_FID_NOT_FOUND W_ERROR(2314) #define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320) #define WERR_DOMAIN_CONTROLLER_NOT_FOUND W_ERROR(2453) +#define WERR_TIME_DIFF_AT_DC W_ERROR(2457) #define WERR_SETUP_ALREADY_JOINED W_ERROR(2691) #define WERR_SETUP_NOT_JOINED W_ERROR(2692) @@ -189,6 +193,10 @@ typedef uint32_t WERROR; #define WERR_FRS_SYSVOL_IS_BUSY W_ERROR(FRS_ERR_BASE+15) #define WERR_FRS_INVALID_SERVICE_PARAMETER W_ERROR(FRS_ERR_BASE+17) +/* RPC errors */ +#define WERR_RPC_E_INVALID_HEADER W_ERROR(0x80010111) +#define WERR_RPC_E_REMOTE_DISABLED W_ERROR(0x8001011c) + /* SEC errors */ #define WERR_SEC_E_ENCRYPT_FAILURE W_ERROR(0x80090329) #define WERR_SEC_E_DECRYPT_FAILURE W_ERROR(0x80090330) -- cgit From 018a61a71178ac162c0b0a1f169de12ee75927cc Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 27 Nov 2007 11:58:33 +0100 Subject: r26160: Add WERR_NAME_NOT_FOUND. Guenther (This used to be commit 66be960c67787ed7355775e619f3973543a4fef8) --- source4/libcli/util/doserr.c | 1 + source4/libcli/util/werror.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/doserr.c b/source4/libcli/util/doserr.c index d36532dcf4..be33ba47e2 100644 --- a/source4/libcli/util/doserr.c +++ b/source4/libcli/util/doserr.c @@ -133,6 +133,7 @@ static const struct werror_code_struct dos_errs[] = { "WERR_FRS_INSUFFICIENT_PRIV", WERR_FRS_INSUFFICIENT_PRIV }, { "WERR_RPC_E_REMOTE_DISABLED", WERR_RPC_E_REMOTE_DISABLED }, { "WERR_NOT_CONNECTED", WERR_NOT_CONNECTED }, + { "WERR_NAME_NOT_FOUND", WERR_NAME_NOT_FOUND}, { NULL, W_ERROR(0) } }; diff --git a/source4/libcli/util/werror.h b/source4/libcli/util/werror.h index 83fa5469cf..c5ec90d5dd 100644 --- a/source4/libcli/util/werror.h +++ b/source4/libcli/util/werror.h @@ -115,6 +115,7 @@ typedef uint32_t WERROR; #define WERR_JOB_NOT_FOUND W_ERROR(2151) #define WERR_DEST_NOT_FOUND W_ERROR(2152) #define WERR_NOT_CONNECTED W_ERROR(2250) +#define WERR_NAME_NOT_FOUND W_ERROR(2273) #define WERR_SESSION_NOT_FOUND W_ERROR(2312) #define WERR_FID_NOT_FOUND W_ERROR(2314) #define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320) -- cgit From 249cc734cebfef31320ec10b05dbfaaaa39682ca Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Dec 2007 05:03:02 -0600 Subject: r26565: Fix python registry bindings. 'PROVISION_PYTHON=yes make test' works now. (This used to be commit 485d1fa3d17fe6cc7a0ecd80e8bac42d173bbb19) --- source4/libcli/util/errors.i | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errors.i b/source4/libcli/util/errors.i index d51c9e0ded..8d97daf537 100644 --- a/source4/libcli/util/errors.i +++ b/source4/libcli/util/errors.i @@ -22,6 +22,7 @@ if (!W_ERROR_IS_OK($1)) { PyObject *obj = Py_BuildValue("(i,s)", $1.v, win_errstr($1)); PyErr_SetObject(PyExc_RuntimeError, obj); + SWIG_fail; } else if ($result == NULL) { $result = Py_None; } @@ -31,6 +32,7 @@ if (NT_STATUS_IS_ERR($1)) { PyObject *obj = Py_BuildValue("(i,s)", $1.v, nt_errstr($1)); PyErr_SetObject(PyExc_RuntimeError, obj); + SWIG_fail; } else if ($result == NULL) { $result = Py_None; } -- cgit From aa0a06f13c44e0eca0b3f2f0c34f0f7995b87159 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Dec 2007 19:19:41 -0600 Subject: r26570: - Trim size of the swig-generated Python bindings by removing a bunch of {}'s. - Start working on Python equivalents for various EJS tests. - Fix regression in argument order for reg_diff_apply() in EJS bindings. (This used to be commit c550c03372cb260b78f6a6c132e70571bc4cb852) --- source4/libcli/util/errors.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errors.i b/source4/libcli/util/errors.i index 8d97daf537..3f6efda468 100644 --- a/source4/libcli/util/errors.i +++ b/source4/libcli/util/errors.i @@ -18,7 +18,7 @@ */ #ifdef SWIGPYTHON -%typemap(out) WERROR { +%typemap(out,noblock=1) WERROR { if (!W_ERROR_IS_OK($1)) { PyObject *obj = Py_BuildValue("(i,s)", $1.v, win_errstr($1)); PyErr_SetObject(PyExc_RuntimeError, obj); @@ -28,7 +28,7 @@ } }; -%typemap(out) NTSTATUS { +%typemap(out,noblock=1) NTSTATUS { if (NT_STATUS_IS_ERR($1)) { PyObject *obj = Py_BuildValue("(i,s)", $1.v, nt_errstr($1)); PyErr_SetObject(PyExc_RuntimeError, obj); @@ -38,7 +38,7 @@ } }; -%typemap(in) NTSTATUS { +%typemap(in,noblock=1) NTSTATUS { if (PyLong_Check($input)) $1 = NT_STATUS(PyLong_AsUnsignedLong($input)); else if (PyInt_Check($input)) -- cgit From 3ee442c54f658e0dc9541a492e46fd8f6bf3a7f4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Dec 2007 20:22:46 -0600 Subject: r26571: Hide warnings about unused macros and casting qualifiers in autogenerated files. (This used to be commit cb76c60007ae1254181c09ba1ab09c419f500bc5) --- source4/libcli/util/errors.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errors.i b/source4/libcli/util/errors.i index 3f6efda468..ec230a9c18 100644 --- a/source4/libcli/util/errors.i +++ b/source4/libcli/util/errors.i @@ -20,7 +20,7 @@ #ifdef SWIGPYTHON %typemap(out,noblock=1) WERROR { if (!W_ERROR_IS_OK($1)) { - PyObject *obj = Py_BuildValue("(i,s)", $1.v, win_errstr($1)); + PyObject *obj = Py_BuildValue("(i,s)", $1.v, (char *)win_errstr($1)); PyErr_SetObject(PyExc_RuntimeError, obj); SWIG_fail; } else if ($result == NULL) { @@ -30,7 +30,7 @@ %typemap(out,noblock=1) NTSTATUS { if (NT_STATUS_IS_ERR($1)) { - PyObject *obj = Py_BuildValue("(i,s)", $1.v, nt_errstr($1)); + PyObject *obj = Py_BuildValue("(i,s)", $1.v, (char *)nt_errstr($1)); PyErr_SetObject(PyExc_RuntimeError, obj); SWIG_fail; } else if ($result == NULL) { -- cgit From d0ba9f001474bfee9b1e8fb516effab736cd4050 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Dec 2007 20:56:41 -0600 Subject: r26572: Fix warnings in the Python code. (This used to be commit 15038d9586d0b58f301ca8c39c21ef10c4283f28) --- source4/libcli/util/errors.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errors.i b/source4/libcli/util/errors.i index ec230a9c18..ede536a995 100644 --- a/source4/libcli/util/errors.i +++ b/source4/libcli/util/errors.i @@ -20,7 +20,7 @@ #ifdef SWIGPYTHON %typemap(out,noblock=1) WERROR { if (!W_ERROR_IS_OK($1)) { - PyObject *obj = Py_BuildValue("(i,s)", $1.v, (char *)win_errstr($1)); + PyObject *obj = Py_BuildValue((char *)"(i,s)", $1.v, win_errstr($1)); PyErr_SetObject(PyExc_RuntimeError, obj); SWIG_fail; } else if ($result == NULL) { @@ -30,7 +30,7 @@ %typemap(out,noblock=1) NTSTATUS { if (NT_STATUS_IS_ERR($1)) { - PyObject *obj = Py_BuildValue("(i,s)", $1.v, (char *)nt_errstr($1)); + PyObject *obj = Py_BuildValue((char *)"(i,s)", $1.v, nt_errstr($1)); PyErr_SetObject(PyExc_RuntimeError, obj); SWIG_fail; } else if ($result == NULL) { -- cgit From 70cb5ac03c476110c0348881f49ad0697037ca38 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 27 Dec 2007 07:47:11 -0600 Subject: r26613: Add a function to write a DATA_BLOB into an LDAPString. This respects the length set in the DATA_BLOB, rather than hoping to see NULL termination of the data pointer. (found testing the Ambigious Name Resolution code against OpenLDAP). Andrew Bartlett (This used to be commit bc0022e8c7357b126dc91a945f0e53e4e4108e7d) --- source4/libcli/util/asn1.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 58cb5f07be..ca6f0dc031 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -285,6 +285,13 @@ bool asn1_write_LDAPString(struct asn1_data *data, const char *s) return !data->has_error; } +/* write a LDAP string from a DATA_BLOB */ +bool asn1_write_DATA_BLOB_LDAPString(struct asn1_data *data, const DATA_BLOB *s) +{ + asn1_write(data, s->data, s->length); + return !data->has_error; +} + /* write a general string */ bool asn1_write_GeneralString(struct asn1_data *data, const char *s) { -- cgit From 7d5f0e0893d42b56145a3ffa34e3b4b9906cbd91 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Jan 2008 22:05:13 -0600 Subject: r26639: librpc: Pass iconv convenience on from RPC connection to NDR library, so it can be overridden by OpenChange. (This used to be commit 2f29f80e07adef1f020173f2cd6d947d0ef505ce) --- source4/libcli/util/clilsa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 7c32294648..1eb2de83d2 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -32,6 +32,7 @@ #include "librpc/gen_ndr/ndr_lsa.h" #include "librpc/gen_ndr/ndr_lsa_c.h" #include "libcli/util/clilsa.h" +#include "param/param.h" struct smblsa_state { struct dcerpc_pipe *pipe; @@ -79,7 +80,8 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) } lsa->ipc_tree->tid = tcon.tconx.out.tid; - lsa->pipe = dcerpc_pipe_init(lsa, cli->transport->socket->event.ctx); + lsa->pipe = dcerpc_pipe_init(lsa, cli->transport->socket->event.ctx, + lp_iconv_convenience(global_loadparm)); if (lsa->pipe == NULL) { talloc_free(lsa); return NT_STATUS_NO_MEMORY; -- cgit From cef40813fac9363b544b22b2fa277af37a800cdf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 8 Jan 2008 14:27:40 -0600 Subject: r26694: asn1: Fix header and some typo's. (This used to be commit f9988734bb8a1d823e14b6bff5c4d55d75471f18) --- source4/libcli/util/asn1.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index ca6f0dc031..aad55382d9 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -1,6 +1,6 @@ /* Unix SMB/CIFS implementation. - simple SPNEGO routines + simple ASN1 routines Copyright (C) Andrew Tridgell 2001 This program is free software; you can redistribute it and/or modify @@ -679,7 +679,7 @@ bool asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blo return !data->has_error; } -/* read an interger without tag*/ +/* read an integer without tag*/ bool asn1_read_implicit_Integer(struct asn1_data *data, int *i) { uint8_t b; @@ -693,7 +693,7 @@ bool asn1_read_implicit_Integer(struct asn1_data *data, int *i) } -/* read an interger */ +/* read an integer */ bool asn1_read_Integer(struct asn1_data *data, int *i) { *i = 0; @@ -703,7 +703,7 @@ bool asn1_read_Integer(struct asn1_data *data, int *i) return asn1_end_tag(data); } -/* read an interger */ +/* read an integer */ bool asn1_read_enumerated(struct asn1_data *data, int *v) { *v = 0; @@ -717,7 +717,7 @@ bool asn1_read_enumerated(struct asn1_data *data, int *v) return asn1_end_tag(data); } -/* check a enumarted value is correct */ +/* check a enumerated value is correct */ bool asn1_check_enumerated(struct asn1_data *data, int v) { uint8_t b; @@ -731,7 +731,7 @@ bool asn1_check_enumerated(struct asn1_data *data, int v) return !data->has_error; } -/* write an enumarted value to the stream */ +/* write an enumerated value to the stream */ bool asn1_write_enumerated(struct asn1_data *data, uint8_t v) { if (!asn1_push_tag(data, ASN1_ENUMERATED)) return false; -- cgit From 939edd0eb7c3952859afb802c8e542449a2c4031 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 15 Jan 2008 01:04:38 +0100 Subject: util: Move asn1 to lib/util to trim down the number of subsystems. (This used to be commit 44e1cfd2d0ef62e4ee541cec00581a7151d951b3) --- source4/libcli/util/asn1.c | 770 -------------------------------------------- source4/libcli/util/asn_1.h | 54 ---- 2 files changed, 824 deletions(-) delete mode 100644 source4/libcli/util/asn1.c delete mode 100644 source4/libcli/util/asn_1.h (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c deleted file mode 100644 index aad55382d9..0000000000 --- a/source4/libcli/util/asn1.c +++ /dev/null @@ -1,770 +0,0 @@ -/* - Unix SMB/CIFS implementation. - simple ASN1 routines - Copyright (C) Andrew Tridgell 2001 - - 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 3 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, see . -*/ - -#include "includes.h" -#include "libcli/util/asn_1.h" - -/* allocate an asn1 structure */ -struct asn1_data *asn1_init(TALLOC_CTX *mem_ctx) -{ - struct asn1_data *ret = talloc_zero(mem_ctx, struct asn1_data); - if (ret == NULL) { - DEBUG(0,("asn1_init failed! out of memory\n")); - } - return ret; -} - -/* free an asn1 structure */ -void asn1_free(struct asn1_data *data) -{ - talloc_free(data); -} - -/* write to the ASN1 buffer, advancing the buffer pointer */ -bool asn1_write(struct asn1_data *data, const void *p, int len) -{ - if (data->has_error) return false; - if (data->length < data->ofs+len) { - uint8_t *newp; - newp = talloc_realloc(data, data->data, uint8_t, data->ofs+len); - if (!newp) { - asn1_free(data); - data->has_error = true; - return false; - } - data->data = newp; - data->length = data->ofs+len; - } - memcpy(data->data + data->ofs, p, len); - data->ofs += len; - return true; -} - -/* useful fn for writing a uint8_t */ -bool asn1_write_uint8(struct asn1_data *data, uint8_t v) -{ - return asn1_write(data, &v, 1); -} - -/* push a tag onto the asn1 data buffer. Used for nested structures */ -bool asn1_push_tag(struct asn1_data *data, uint8_t tag) -{ - struct nesting *nesting; - - asn1_write_uint8(data, tag); - nesting = talloc(data, struct nesting); - if (!nesting) { - data->has_error = true; - return false; - } - - nesting->start = data->ofs; - nesting->next = data->nesting; - data->nesting = nesting; - return asn1_write_uint8(data, 0xff); -} - -/* pop a tag */ -bool asn1_pop_tag(struct asn1_data *data) -{ - struct nesting *nesting; - size_t len; - - nesting = data->nesting; - - if (!nesting) { - data->has_error = true; - return false; - } - len = data->ofs - (nesting->start+1); - /* yes, this is ugly. We don't know in advance how many bytes the length - of a tag will take, so we assumed 1 byte. If we were wrong then we - need to correct our mistake */ - if (len > 0xFFFFFF) { - data->data[nesting->start] = 0x84; - if (!asn1_write_uint8(data, 0)) return false; - if (!asn1_write_uint8(data, 0)) return false; - if (!asn1_write_uint8(data, 0)) return false; - if (!asn1_write_uint8(data, 0)) return false; - memmove(data->data+nesting->start+5, data->data+nesting->start+1, len); - data->data[nesting->start+1] = (len>>24) & 0xFF; - data->data[nesting->start+2] = (len>>16) & 0xFF; - data->data[nesting->start+3] = (len>>8) & 0xFF; - data->data[nesting->start+4] = len&0xff; - } else if (len > 0xFFFF) { - data->data[nesting->start] = 0x83; - if (!asn1_write_uint8(data, 0)) return false; - if (!asn1_write_uint8(data, 0)) return false; - if (!asn1_write_uint8(data, 0)) return false; - memmove(data->data+nesting->start+4, data->data+nesting->start+1, len); - data->data[nesting->start+1] = (len>>16) & 0xFF; - data->data[nesting->start+2] = (len>>8) & 0xFF; - data->data[nesting->start+3] = len&0xff; - } else if (len > 255) { - data->data[nesting->start] = 0x82; - if (!asn1_write_uint8(data, 0)) return false; - if (!asn1_write_uint8(data, 0)) return false; - memmove(data->data+nesting->start+3, data->data+nesting->start+1, len); - data->data[nesting->start+1] = len>>8; - data->data[nesting->start+2] = len&0xff; - } else if (len > 127) { - data->data[nesting->start] = 0x81; - if (!asn1_write_uint8(data, 0)) return false; - memmove(data->data+nesting->start+2, data->data+nesting->start+1, len); - data->data[nesting->start+1] = len; - } else { - data->data[nesting->start] = len; - } - - data->nesting = nesting->next; - talloc_free(nesting); - return true; -} - -/* "i" is the one's complement representation, as is the normal result of an - * implicit signed->unsigned conversion */ - -static bool push_int_bigendian(struct asn1_data *data, unsigned int i, bool negative) -{ - uint8_t lowest = i & 0xFF; - - i = i >> 8; - if (i != 0) - if (!push_int_bigendian(data, i, negative)) - return false; - - if (data->nesting->start+1 == data->ofs) { - - /* We did not write anything yet, looking at the highest - * valued byte */ - - if (negative) { - /* Don't write leading 0xff's */ - if (lowest == 0xFF) - return true; - - if ((lowest & 0x80) == 0) { - /* The only exception for a leading 0xff is if - * the highest bit is 0, which would indicate - * a positive value */ - if (!asn1_write_uint8(data, 0xff)) - return false; - } - } else { - if (lowest & 0x80) { - /* The highest bit of a positive integer is 1, - * this would indicate a negative number. Push - * a 0 to indicate a positive one */ - if (!asn1_write_uint8(data, 0)) - return false; - } - } - } - - return asn1_write_uint8(data, lowest); -} - -/* write an Integer without the tag framing. Needed for example for the LDAP - * Abandon Operation */ - -bool asn1_write_implicit_Integer(struct asn1_data *data, int i) -{ - if (i == -1) { - /* -1 is special as it consists of all-0xff bytes. In - push_int_bigendian this is the only case that is not - properly handled, as all 0xff bytes would be handled as - leading ones to be ignored. */ - return asn1_write_uint8(data, 0xff); - } else { - return push_int_bigendian(data, i, i<0); - } -} - - -/* write an integer */ -bool asn1_write_Integer(struct asn1_data *data, int i) -{ - if (!asn1_push_tag(data, ASN1_INTEGER)) return false; - if (!asn1_write_implicit_Integer(data, i)) return false; - return asn1_pop_tag(data); -} - -bool ber_write_OID_String(DATA_BLOB *blob, const char *OID) -{ - uint_t v, v2; - const char *p = (const char *)OID; - char *newp; - int i; - - v = strtoul(p, &newp, 10); - if (newp[0] != '.') return false; - p = newp + 1; - - v2 = strtoul(p, &newp, 10); - if (newp[0] != '.') return false; - p = newp + 1; - - /*the ber representation can't use more space then the string one */ - *blob = data_blob(NULL, strlen(OID)); - if (!blob->data) return false; - - blob->data[0] = 40*v + v2; - - i = 1; - while (*p) { - v = strtoul(p, &newp, 10); - if (newp[0] == '.') { - p = newp + 1; - } else if (newp[0] == '\0') { - p = newp; - } else { - data_blob_free(blob); - return false; - } - if (v >= (1<<28)) blob->data[i++] = (0x80 | ((v>>28)&0x7f)); - if (v >= (1<<21)) blob->data[i++] = (0x80 | ((v>>21)&0x7f)); - if (v >= (1<<14)) blob->data[i++] = (0x80 | ((v>>14)&0x7f)); - if (v >= (1<<7)) blob->data[i++] = (0x80 | ((v>>7)&0x7f)); - blob->data[i++] = (v&0x7f); - } - - blob->length = i; - - return true; -} - -/* write an object ID to a ASN1 buffer */ -bool asn1_write_OID(struct asn1_data *data, const char *OID) -{ - DATA_BLOB blob; - - if (!asn1_push_tag(data, ASN1_OID)) return false; - - if (!ber_write_OID_String(&blob, OID)) { - data->has_error = true; - return false; - } - - if (!asn1_write(data, blob.data, blob.length)) { - data->has_error = true; - return false; - } - data_blob_free(&blob); - return asn1_pop_tag(data); -} - -/* write an octet string */ -bool asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length) -{ - asn1_push_tag(data, ASN1_OCTET_STRING); - asn1_write(data, p, length); - asn1_pop_tag(data); - return !data->has_error; -} - -/* write a LDAP string */ -bool asn1_write_LDAPString(struct asn1_data *data, const char *s) -{ - asn1_write(data, s, strlen(s)); - return !data->has_error; -} - -/* write a LDAP string from a DATA_BLOB */ -bool asn1_write_DATA_BLOB_LDAPString(struct asn1_data *data, const DATA_BLOB *s) -{ - asn1_write(data, s->data, s->length); - return !data->has_error; -} - -/* write a general string */ -bool asn1_write_GeneralString(struct asn1_data *data, const char *s) -{ - asn1_push_tag(data, ASN1_GENERAL_STRING); - asn1_write_LDAPString(data, s); - asn1_pop_tag(data); - return !data->has_error; -} - -bool asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob) -{ - asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(num)); - asn1_write(data, blob->data, blob->length); - asn1_pop_tag(data); - return !data->has_error; -} - -/* write a BOOLEAN */ -bool asn1_write_BOOLEAN(struct asn1_data *data, bool v) -{ - asn1_push_tag(data, ASN1_BOOLEAN); - asn1_write_uint8(data, v ? 0xFF : 0); - asn1_pop_tag(data); - return !data->has_error; -} - -bool asn1_read_BOOLEAN(struct asn1_data *data, bool *v) -{ - uint8_t tmp = 0; - asn1_start_tag(data, ASN1_BOOLEAN); - asn1_read_uint8(data, &tmp); - if (tmp == 0xFF) { - *v = true; - } else { - *v = false; - } - asn1_end_tag(data); - return !data->has_error; -} - -/* check a BOOLEAN */ -bool asn1_check_BOOLEAN(struct asn1_data *data, bool v) -{ - uint8_t b = 0; - - asn1_read_uint8(data, &b); - if (b != ASN1_BOOLEAN) { - data->has_error = true; - return false; - } - asn1_read_uint8(data, &b); - if (b != v) { - data->has_error = true; - return false; - } - return !data->has_error; -} - - -/* load a struct asn1_data structure with a lump of data, ready to be parsed */ -bool asn1_load(struct asn1_data *data, DATA_BLOB blob) -{ - ZERO_STRUCTP(data); - data->data = talloc_memdup(data, blob.data, blob.length); - if (!data->data) { - data->has_error = true; - return false; - } - data->length = blob.length; - return true; -} - -/* Peek into an ASN1 buffer, not advancing the pointer */ -bool asn1_peek(struct asn1_data *data, void *p, int len) -{ - if (data->has_error) - return false; - - if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len) - return false; - - if (data->ofs + len > data->length) { - /* we need to mark the buffer as consumed, so the caller knows - this was an out of data error, and not a decode error */ - data->ofs = data->length; - return false; - } - - memcpy(p, data->data + data->ofs, len); - return true; -} - -/* read from a ASN1 buffer, advancing the buffer pointer */ -bool asn1_read(struct asn1_data *data, void *p, int len) -{ - if (!asn1_peek(data, p, len)) { - data->has_error = true; - return false; - } - - data->ofs += len; - return true; -} - -/* read a uint8_t from a ASN1 buffer */ -bool asn1_read_uint8(struct asn1_data *data, uint8_t *v) -{ - return asn1_read(data, v, 1); -} - -bool asn1_peek_uint8(struct asn1_data *data, uint8_t *v) -{ - return asn1_peek(data, v, 1); -} - -bool asn1_peek_tag(struct asn1_data *data, uint8_t tag) -{ - uint8_t b; - - if (asn1_tag_remaining(data) <= 0) { - return false; - } - - if (!asn1_peek_uint8(data, &b)) - return false; - - return (b == tag); -} - -/* start reading a nested asn1 structure */ -bool asn1_start_tag(struct asn1_data *data, uint8_t tag) -{ - uint8_t b; - struct nesting *nesting; - - if (!asn1_read_uint8(data, &b)) - return false; - - if (b != tag) { - data->has_error = true; - return false; - } - nesting = talloc(data, struct nesting); - if (!nesting) { - data->has_error = true; - return false; - } - - if (!asn1_read_uint8(data, &b)) { - return false; - } - - if (b & 0x80) { - int n = b & 0x7f; - if (!asn1_read_uint8(data, &b)) - return false; - nesting->taglen = b; - while (n > 1) { - if (!asn1_read_uint8(data, &b)) - return false; - nesting->taglen = (nesting->taglen << 8) | b; - n--; - } - } else { - nesting->taglen = b; - } - nesting->start = data->ofs; - nesting->next = data->nesting; - data->nesting = nesting; - if (asn1_tag_remaining(data) == -1) { - return false; - } - return !data->has_error; -} - -/* stop reading a tag */ -bool asn1_end_tag(struct asn1_data *data) -{ - struct nesting *nesting; - - /* make sure we read it all */ - if (asn1_tag_remaining(data) != 0) { - data->has_error = true; - return false; - } - - nesting = data->nesting; - - if (!nesting) { - data->has_error = true; - return false; - } - - data->nesting = nesting->next; - talloc_free(nesting); - return true; -} - -/* work out how many bytes are left in this nested tag */ -int asn1_tag_remaining(struct asn1_data *data) -{ - int remaining; - if (data->has_error) { - return -1; - } - - if (!data->nesting) { - data->has_error = true; - return -1; - } - remaining = data->nesting->taglen - (data->ofs - data->nesting->start); - if (remaining > (data->length - data->ofs)) { - data->has_error = true; - return -1; - } - return remaining; -} - -/* read an object ID from a data blob */ -bool ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID) -{ - int i; - uint8_t *b; - uint_t v; - char *tmp_oid = NULL; - - if (blob.length < 2) return false; - - b = blob.data; - - tmp_oid = talloc_asprintf(mem_ctx, "%u", b[0]/40); - if (!tmp_oid) goto nomem; - tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", b[0]%40); - if (!tmp_oid) goto nomem; - - for(i = 1, v = 0; i < blob.length; i++) { - v = (v<<7) | (b[i]&0x7f); - if ( ! (b[i] & 0x80)) { - tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", v); - v = 0; - } - if (!tmp_oid) goto nomem; - } - - if (v != 0) { - talloc_free(tmp_oid); - return false; - } - - *OID = tmp_oid; - return true; - -nomem: - return false; -} - -/* read an object ID from a ASN1 buffer */ -bool asn1_read_OID(struct asn1_data *data, TALLOC_CTX *mem_ctx, const char **OID) -{ - DATA_BLOB blob; - int len; - - if (!asn1_start_tag(data, ASN1_OID)) return false; - - len = asn1_tag_remaining(data); - if (len < 0) { - data->has_error = true; - return false; - } - - blob = data_blob(NULL, len); - if (!blob.data) { - data->has_error = true; - return false; - } - - asn1_read(data, blob.data, len); - asn1_end_tag(data); - if (data->has_error) { - data_blob_free(&blob); - return false; - } - - if (!ber_read_OID_String(mem_ctx, blob, OID)) { - data->has_error = true; - data_blob_free(&blob); - return false; - } - - data_blob_free(&blob); - return true; -} - -/* check that the next object ID is correct */ -bool asn1_check_OID(struct asn1_data *data, const char *OID) -{ - const char *id; - - if (!asn1_read_OID(data, data, &id)) return false; - - if (strcmp(id, OID) != 0) { - talloc_free(discard_const(id)); - data->has_error = true; - return false; - } - talloc_free(discard_const(id)); - return true; -} - -/* read a LDAPString from a ASN1 buffer */ -bool asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s) -{ - int len; - len = asn1_tag_remaining(data); - if (len < 0) { - data->has_error = true; - return false; - } - *s = talloc_array(mem_ctx, char, len+1); - if (! *s) { - data->has_error = true; - return false; - } - asn1_read(data, *s, len); - (*s)[len] = 0; - return !data->has_error; -} - - -/* read a GeneralString from a ASN1 buffer */ -bool asn1_read_GeneralString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s) -{ - if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return false; - if (!asn1_read_LDAPString(data, mem_ctx, s)) return false; - return asn1_end_tag(data); -} - - -/* read a octet string blob */ -bool asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLOB *blob) -{ - int len; - ZERO_STRUCTP(blob); - if (!asn1_start_tag(data, ASN1_OCTET_STRING)) return false; - len = asn1_tag_remaining(data); - if (len < 0) { - data->has_error = true; - return false; - } - *blob = data_blob_talloc(mem_ctx, NULL, len+1); - if (!blob->data) { - data->has_error = true; - return false; - } - asn1_read(data, blob->data, len); - asn1_end_tag(data); - blob->length--; - blob->data[len] = 0; - - if (data->has_error) { - data_blob_free(blob); - *blob = data_blob(NULL, 0); - return false; - } - return true; -} - -bool asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob) -{ - int len; - ZERO_STRUCTP(blob); - if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(num))) return false; - len = asn1_tag_remaining(data); - if (len < 0) { - data->has_error = true; - return false; - } - *blob = data_blob(NULL, len); - if ((len != 0) && (!blob->data)) { - data->has_error = true; - return false; - } - asn1_read(data, blob->data, len); - asn1_end_tag(data); - return !data->has_error; -} - -/* read an integer without tag*/ -bool asn1_read_implicit_Integer(struct asn1_data *data, int *i) -{ - uint8_t b; - *i = 0; - - while (!data->has_error && asn1_tag_remaining(data)>0) { - if (!asn1_read_uint8(data, &b)) return false; - *i = (*i << 8) + b; - } - return !data->has_error; - -} - -/* read an integer */ -bool asn1_read_Integer(struct asn1_data *data, int *i) -{ - *i = 0; - - if (!asn1_start_tag(data, ASN1_INTEGER)) return false; - if (!asn1_read_implicit_Integer(data, i)) return false; - return asn1_end_tag(data); -} - -/* read an integer */ -bool asn1_read_enumerated(struct asn1_data *data, int *v) -{ - *v = 0; - - if (!asn1_start_tag(data, ASN1_ENUMERATED)) return false; - while (!data->has_error && asn1_tag_remaining(data)>0) { - uint8_t b; - asn1_read_uint8(data, &b); - *v = (*v << 8) + b; - } - return asn1_end_tag(data); -} - -/* check a enumerated value is correct */ -bool asn1_check_enumerated(struct asn1_data *data, int v) -{ - uint8_t b; - if (!asn1_start_tag(data, ASN1_ENUMERATED)) return false; - asn1_read_uint8(data, &b); - asn1_end_tag(data); - - if (v != b) - data->has_error = false; - - return !data->has_error; -} - -/* write an enumerated value to the stream */ -bool asn1_write_enumerated(struct asn1_data *data, uint8_t v) -{ - if (!asn1_push_tag(data, ASN1_ENUMERATED)) return false; - asn1_write_uint8(data, v); - asn1_pop_tag(data); - return !data->has_error; -} - -/* - check if a ASN.1 blob is a full tag -*/ -NTSTATUS asn1_full_tag(DATA_BLOB blob, uint8_t tag, size_t *packet_size) -{ - struct asn1_data *asn1 = asn1_init(NULL); - int size; - - NT_STATUS_HAVE_NO_MEMORY(asn1); - - asn1->data = blob.data; - asn1->length = blob.length; - asn1_start_tag(asn1, tag); - if (asn1->has_error) { - talloc_free(asn1); - return STATUS_MORE_ENTRIES; - } - size = asn1_tag_remaining(asn1) + asn1->ofs; - - talloc_free(asn1); - - if (size > blob.length) { - return STATUS_MORE_ENTRIES; - } - - *packet_size = size; - return NT_STATUS_OK; -} diff --git a/source4/libcli/util/asn_1.h b/source4/libcli/util/asn_1.h deleted file mode 100644 index 612a8a932f..0000000000 --- a/source4/libcli/util/asn_1.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - Unix SMB/CIFS implementation. - simple ASN1 code - Copyright (C) Andrew Tridgell 2001 - - 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 3 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, see . -*/ - -#ifndef _ASN_1_H -#define _ASN_1_H - -struct nesting { - off_t start; - size_t taglen; /* for parsing */ - struct nesting *next; -}; - -struct asn1_data { - uint8_t *data; - size_t length; - off_t ofs; - struct nesting *nesting; - bool has_error; -}; - -#define ASN1_APPLICATION(x) ((x)+0x60) -#define ASN1_APPLICATION_SIMPLE(x) ((x)+0x40) -#define ASN1_SEQUENCE(x) ((x)+0x30) -#define ASN1_CONTEXT(x) ((x)+0xa0) -#define ASN1_CONTEXT_SIMPLE(x) ((x)+0x80) -#define ASN1_GENERAL_STRING 0x1b -#define ASN1_OCTET_STRING 0x4 -#define ASN1_OID 0x6 -#define ASN1_BOOLEAN 0x1 -#define ASN1_INTEGER 0x2 -#define ASN1_ENUMERATED 0xa -#define ASN1_SET 0x31 - -#define ASN1_MAX_OIDS 20 - -#include "libcli/util/asn1_proto.h" - -#endif /* _ASN_1_H */ -- cgit From 25a3eb0436ea7c060eedd6827e5fdc5efd6ab47b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 14 Mar 2008 14:32:26 +0100 Subject: swig: make the code more portable and use NT_STATUS_V() and W_ERROR_V() metze (This used to be commit d6fd98a307f83fd492ef73bf6ec281f9f11286f2) --- source4/libcli/util/errors.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errors.i b/source4/libcli/util/errors.i index ede536a995..17efcbf62a 100644 --- a/source4/libcli/util/errors.i +++ b/source4/libcli/util/errors.i @@ -20,7 +20,7 @@ #ifdef SWIGPYTHON %typemap(out,noblock=1) WERROR { if (!W_ERROR_IS_OK($1)) { - PyObject *obj = Py_BuildValue((char *)"(i,s)", $1.v, win_errstr($1)); + PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V($1), win_errstr($1)); PyErr_SetObject(PyExc_RuntimeError, obj); SWIG_fail; } else if ($result == NULL) { @@ -30,7 +30,7 @@ %typemap(out,noblock=1) NTSTATUS { if (NT_STATUS_IS_ERR($1)) { - PyObject *obj = Py_BuildValue((char *)"(i,s)", $1.v, nt_errstr($1)); + PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V($1), nt_errstr($1)); PyErr_SetObject(PyExc_RuntimeError, obj); SWIG_fail; } else if ($result == NULL) { -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/libcli/util/error.h | 3 ++- source4/libcli/util/errormap.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/error.h b/source4/libcli/util/error.h index e054948fbe..84255448a0 100644 --- a/source4/libcli/util/error.h +++ b/source4/libcli/util/error.h @@ -22,7 +22,6 @@ #include "libcli/util/werror.h" #include "libcli/util/doserr.h" #include "libcli/util/ntstatus.h" -#include "librpc/ndr/libndr.h" /** NT error on DOS connection! (NT_STATUS_OK) */ bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2); @@ -47,6 +46,8 @@ WERROR ntstatus_to_werror(NTSTATUS error); *********************************************************************/ NTSTATUS map_nt_error_from_unix(int unix_error); +enum ndr_err_code; + /********************************************************************* Map an NT error code from a NDR error code. *********************************************************************/ diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index b8458d4bf3..2257955c76 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -21,6 +21,7 @@ #include "includes.h" #include "param/param.h" +#include "librpc/ndr/libndr.h" /* This map was extracted by the ERRMAPEXTRACT smbtorture command. The setup was a Samba HEAD (2002-01-03) PDC and an Win2k member -- cgit From f9c36fae757d197ee4de06f0ecf94ae13faad0de Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 24 May 2008 21:38:33 +0200 Subject: Export functions for setting NTSTATUS and WERRORs in python. (This used to be commit 4bcb92d2d49d90863b1e64b15d055517fbfd263c) --- source4/libcli/util/errors.i | 10 ++++++---- source4/libcli/util/pyerrors.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 source4/libcli/util/pyerrors.h (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errors.i b/source4/libcli/util/errors.i index 17efcbf62a..1fcde04c85 100644 --- a/source4/libcli/util/errors.i +++ b/source4/libcli/util/errors.i @@ -18,10 +18,13 @@ */ #ifdef SWIGPYTHON +%{ +#include "libcli/util/pyerrors.h" +%} + %typemap(out,noblock=1) WERROR { if (!W_ERROR_IS_OK($1)) { - PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V($1), win_errstr($1)); - PyErr_SetObject(PyExc_RuntimeError, obj); + PyErr_SetWERROR($1); SWIG_fail; } else if ($result == NULL) { $result = Py_None; @@ -30,8 +33,7 @@ %typemap(out,noblock=1) NTSTATUS { if (NT_STATUS_IS_ERR($1)) { - PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V($1), nt_errstr($1)); - PyErr_SetObject(PyExc_RuntimeError, obj); + PyErr_SetNTSTATUS($1); SWIG_fail; } else if ($result == NULL) { $result = Py_None; diff --git a/source4/libcli/util/pyerrors.h b/source4/libcli/util/pyerrors.h new file mode 100644 index 0000000000..49d9923130 --- /dev/null +++ b/source4/libcli/util/pyerrors.h @@ -0,0 +1,29 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij 2008 + + 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 3 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, see . +*/ + +#ifndef __PYERRORS_H__ +#define __PYERRORS_H__ + +#define PyErr_SetWERROR(err) \ + PyErr_SetObject(PyExc_RuntimeError, Py_BuildValue((char *)"(i,s)", W_ERROR_V(err), discard_const_p(char, win_errstr(err)))) + +#define PyErr_SetNTSTATUS(status) \ + PyErr_SetObject(PyExc_RuntimeError, Py_BuildValue((char *)"(i,s)", NT_STATUS_V(status), discard_const_p(char, nt_errstr(status)))) + +#endif /* __PYERRORS_H__ */ -- cgit From 75e7962d2efb1aa6e45ca999b1a93829406de540 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 24 May 2008 22:13:32 +0200 Subject: Add convenience functions for setting Python objects from errors. (This used to be commit f1de723b89251cbc8140b838941f304a34871bf3) --- source4/libcli/util/pyerrors.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/pyerrors.h b/source4/libcli/util/pyerrors.h index 49d9923130..aaa35b4d26 100644 --- a/source4/libcli/util/pyerrors.h +++ b/source4/libcli/util/pyerrors.h @@ -20,10 +20,14 @@ #ifndef __PYERRORS_H__ #define __PYERRORS_H__ +#define PyErr_FromWERROR(err) Py_BuildValue("(i,s)", W_ERROR_V(err), discard_const_p(char, win_errstr(err))) + +#define PyErr_FromNTSTATUS(status) Py_BuildValue("(i,s)", NT_STATUS_V(status), discard_const_p(char, nt_errstr(status))) + #define PyErr_SetWERROR(err) \ - PyErr_SetObject(PyExc_RuntimeError, Py_BuildValue((char *)"(i,s)", W_ERROR_V(err), discard_const_p(char, win_errstr(err)))) + PyErr_SetObject(PyExc_RuntimeError, PyErr_FromWERROR(err)) #define PyErr_SetNTSTATUS(status) \ - PyErr_SetObject(PyExc_RuntimeError, Py_BuildValue((char *)"(i,s)", NT_STATUS_V(status), discard_const_p(char, nt_errstr(status)))) + PyErr_SetObject(PyExc_RuntimeError, PyErr_FromNTSTATUS(status)) #endif /* __PYERRORS_H__ */ -- cgit From 929adc9efa5cf985f0585214d30d18521aa1a821 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 14 Jun 2008 11:24:17 -0400 Subject: Make up the right dependencies now that ldb depends on libevents (This used to be commit 3b8eec7ca334528cad3cdcd5e3fc5ee555d8d0e0) --- source4/libcli/util/nterr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index b1f345016d..7629a14106 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -20,6 +20,7 @@ /* NT error codes. please read nterr.h */ #include "includes.h" +#include "lib/events/events.h" #include "libcli/ldap/ldap.h" typedef struct -- cgit From cceabcd2a4a4282aee8562852de32b29038e12a3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 17 Jun 2008 14:21:02 +0200 Subject: Use friendly NTSTATUS message in python code when possible. (This used to be commit 09cf8c7dd82bb95e2f8782782286869654d96375) --- source4/libcli/util/pyerrors.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/pyerrors.h b/source4/libcli/util/pyerrors.h index aaa35b4d26..47e6f58b5d 100644 --- a/source4/libcli/util/pyerrors.h +++ b/source4/libcli/util/pyerrors.h @@ -22,7 +22,7 @@ #define PyErr_FromWERROR(err) Py_BuildValue("(i,s)", W_ERROR_V(err), discard_const_p(char, win_errstr(err))) -#define PyErr_FromNTSTATUS(status) Py_BuildValue("(i,s)", NT_STATUS_V(status), discard_const_p(char, nt_errstr(status))) +#define PyErr_FromNTSTATUS(status) Py_BuildValue("(i,s)", NT_STATUS_V(status), discard_const_p(char, get_friendly_nt_error_msg(status))) #define PyErr_SetWERROR(err) \ PyErr_SetObject(PyExc_RuntimeError, PyErr_FromWERROR(err)) -- cgit From ca20c56b260e2799c40b0c7c0e3ef5f7308b586e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 27 Aug 2008 10:29:54 +1000 Subject: Add definition for NT_STATUS_DOWNGRADE_DETECTED (This used to be commit f6e227b72bb56d12cb270d76f7f458136c4ca160) --- source4/libcli/util/nterr.c | 1 + source4/libcli/util/ntstatus.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 7629a14106..ef4055adaa 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -546,6 +546,7 @@ static const nt_err_code_struct nt_errs[] = { "NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED", NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED }, { "NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX", NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX }, { "NT_STATUS_OBJECTID_NOT_FOUND", NT_STATUS_OBJECTID_NOT_FOUND }, + { "NT_STATUS_DOWNGRADE_DETECTED", NT_STATUS_DOWNGRADE_DETECTED }, { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES }, { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED }, { "STATUS_NOTIFY_CLEANUP", STATUS_NOTIFY_CLEANUP }, diff --git a/source4/libcli/util/ntstatus.h b/source4/libcli/util/ntstatus.h index 026b5162db..527a95bd09 100644 --- a/source4/libcli/util/ntstatus.h +++ b/source4/libcli/util/ntstatus.h @@ -593,6 +593,7 @@ typedef uint32_t NTSTATUS; #define NT_STATUS_NOT_A_REPARSE_POINT NT_STATUS(0xC0000000 | 0x0275) #define NT_STATUS_OBJECTID_NOT_FOUND NT_STATUS(0xC0000000 | 0x02F0) #define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE) /* scheduler */ +#define NT_STATUS_DOWNGRADE_DETECTED NT_STATUS(0xC0000000 | 0x0388) #define NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x20004) #define NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX NT_STATUS(0xC0000000 | 0x20026) -- cgit From b7326979e9d8366eee03d967483a6513342186c4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 5 Sep 2008 16:46:12 +1000 Subject: Add a new error code (This used to be commit b52fba5b2c63a24acbfc7e3e989c16b691d98162) --- source4/libcli/util/nterr.c | 1 + source4/libcli/util/ntstatus.h | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index ef4055adaa..4e046c78ca 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -545,6 +545,7 @@ static const nt_err_code_struct nt_errs[] = { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES }, { "NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED", NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED }, { "NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX", NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX }, + { "NT_STATUS_CURRENT_DOMAIN_NOT_ALLOWED", NT_STATUS_CURRENT_DOMAIN_NOT_ALLOWED }, { "NT_STATUS_OBJECTID_NOT_FOUND", NT_STATUS_OBJECTID_NOT_FOUND }, { "NT_STATUS_DOWNGRADE_DETECTED", NT_STATUS_DOWNGRADE_DETECTED }, { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES }, diff --git a/source4/libcli/util/ntstatus.h b/source4/libcli/util/ntstatus.h index 527a95bd09..9c7bee0dfe 100644 --- a/source4/libcli/util/ntstatus.h +++ b/source4/libcli/util/ntstatus.h @@ -591,6 +591,7 @@ typedef uint32_t NTSTATUS; #define NT_STATUS_QUOTA_LIST_INCONSISTENT NT_STATUS(0xC0000000 | 0x0266) #define NT_STATUS_FILE_IS_OFFLINE NT_STATUS(0xC0000000 | 0x0267) #define NT_STATUS_NOT_A_REPARSE_POINT NT_STATUS(0xC0000000 | 0x0275) +#define NT_STATUS_CURRENT_DOMAIN_NOT_ALLOWED NT_STATUS(0xC0000000 | 0x02E9) #define NT_STATUS_OBJECTID_NOT_FOUND NT_STATUS(0xC0000000 | 0x02F0) #define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE) /* scheduler */ #define NT_STATUS_DOWNGRADE_DETECTED NT_STATUS(0xC0000000 | 0x0388) -- cgit