s3-lib Remove unused dos error codes from errmap_unix
[abartlet/samba.git/.git] / source4 / libcli / util / errormap.c
index 2257955c76cbc431639b028e711211d1d7b7adc5..962dc24a45c85d819b673b852facbbf978811c96 100644 (file)
@@ -20,8 +20,6 @@
  */
 
 #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 
@@ -180,6 +178,7 @@ static const struct {
         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},
@@ -1157,8 +1156,10 @@ static const struct {
        {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
@@ -1169,7 +1170,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(global_loadparm)) {
+       if (ntstatus_check_dos_mapping) {
                return NT_STATUS_V(status1) == NT_STATUS_V(status2);
        }
 
@@ -1258,14 +1259,12 @@ WERROR ntstatus_to_werror(NTSTATUS error)
        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 },
@@ -1320,7 +1319,7 @@ const struct unix_error_map unix_nt_errmap[] = {
        { 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 },
@@ -1355,6 +1354,10 @@ const struct unix_error_map unix_nt_errmap[] = {
 #ifdef ENOSYS
        { ENOSYS,       NT_STATUS_INVALID_SYSTEM_SERVICE },
 #endif
+#ifdef ECANCELED
+       { ECANCELED,    NT_STATUS_CANCELLED },
+#endif
+
        { 0, NT_STATUS_UNSUCCESSFUL }
 };
 
@@ -1377,27 +1380,8 @@ NTSTATUS map_nt_error_from_unix(int unix_error)
        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));
 }