*/
#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
during the session setup }
*/
{ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD},
+ {ERRSRV, ERRbaduid, NT_STATUS_USER_SESSION_DELETED},
{ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD},
{ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION},
{ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE},
{NT_STATUS(0x80000025), W_ERROR(0x962)},
{NT_STATUS(0x80000288), W_ERROR(0x48d)},
{NT_STATUS(0x80000289), W_ERROR(0x48e)},
- {NT_STATUS_OK, WERR_OK}};
+ {NT_STATUS_OK, WERR_OK}
+};
+bool ntstatus_check_dos_mapping = true;
/*
check if a DOS encoded NTSTATUS code maps to the given NTSTATUS code
the mapping of dos codes, as we want to catch the cases where
a forced dos code is needed
*/
- if (lp_nt_status_support(global_loadparm)) {
+ if (ntstatus_check_dos_mapping) {
return NT_STATUS_V(status1) == NT_STATUS_V(status2);
}
return W_ERROR(NT_STATUS_V(error) & 0xffff);
}
-/* Mapping between Unix, DOS and NT error numbers */
+/* Mapping between Unix, and NT error numbers */
-struct unix_error_map {
+static const struct {
int unix_error;
NTSTATUS nt_error;
-};
-
-const struct unix_error_map unix_nt_errmap[] = {
+} unix_nt_errmap[] = {
{ EAGAIN, STATUS_MORE_ENTRIES },
{ EINTR, STATUS_MORE_ENTRIES },
{ ENOBUFS, STATUS_MORE_ENTRIES },
{ ENODATA, NT_STATUS_NOT_FOUND },
#endif
#ifdef EDQUOT
- { EDQUOT, NT_STATUS_QUOTA_EXCEEDED },
+ { EDQUOT, NT_STATUS_DISK_FULL }, /* Windows does NOT return NT_STATUS_QUOTA_EXCEEDED */
#endif
#ifdef ENOTEMPTY
{ ENOTEMPTY, NT_STATUS_DIRECTORY_NOT_EMPTY },
#ifdef ENOSYS
{ ENOSYS, NT_STATUS_INVALID_SYSTEM_SERVICE },
#endif
+#ifdef ECANCELED
+ { ECANCELED, NT_STATUS_CANCELLED },
+#endif
+
{ 0, NT_STATUS_UNSUCCESSFUL }
};
return NT_STATUS_UNSUCCESSFUL;
}
-NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err)
+/* Convert a Unix error code to WERROR */
+WERROR unix_to_werror(int unix_error)
{
- 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;
+ return ntstatus_to_werror(map_nt_error_from_unix(unix_error));
}