[224] | 1 | /*
|
---|
| 2 | * Unix SMB/CIFS implementation.
|
---|
| 3 | * DOS error routines
|
---|
| 4 | * Copyright (C) Tim Potter 2002.
|
---|
| 5 | *
|
---|
| 6 | * This program is free software; you can redistribute it and/or modify
|
---|
| 7 | * it under the terms of the GNU General Public License as published by
|
---|
| 8 | * the Free Software Foundation; either version 3 of the License, or
|
---|
| 9 | * (at your option) any later version.
|
---|
| 10 | *
|
---|
| 11 | * This program is distributed in the hope that it will be useful,
|
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | * GNU General Public License for more details.
|
---|
| 15 | *
|
---|
| 16 | * You should have received a copy of the GNU General Public License
|
---|
| 17 | * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
---|
| 18 | */
|
---|
| 19 |
|
---|
| 20 | /* DOS error codes. please read doserr.h */
|
---|
| 21 |
|
---|
| 22 | #include "includes.h"
|
---|
| 23 |
|
---|
| 24 | typedef const struct {
|
---|
| 25 | const char *dos_errstr;
|
---|
| 26 | WERROR werror;
|
---|
| 27 | } werror_code_struct;
|
---|
| 28 |
|
---|
| 29 | typedef const struct {
|
---|
| 30 | WERROR werror;
|
---|
| 31 | const char *friendly_errstr;
|
---|
| 32 | } werror_str_struct;
|
---|
| 33 |
|
---|
| 34 | werror_code_struct dos_errs[] =
|
---|
| 35 | {
|
---|
| 36 | { "WERR_OK", WERR_OK },
|
---|
| 37 | { "WERR_GENERAL_FAILURE", WERR_GENERAL_FAILURE },
|
---|
| 38 | { "WERR_BADFILE", WERR_BADFILE },
|
---|
| 39 | { "WERR_ACCESS_DENIED", WERR_ACCESS_DENIED },
|
---|
| 40 | { "WERR_BADFID", WERR_BADFID },
|
---|
| 41 | { "WERR_BADFUNC", WERR_BADFUNC },
|
---|
| 42 | { "WERR_INSUFFICIENT_BUFFER", WERR_INSUFFICIENT_BUFFER },
|
---|
| 43 | { "WERR_SEM_TIMEOUT", WERR_SEM_TIMEOUT },
|
---|
| 44 | { "WERR_NO_SUCH_SHARE", WERR_NO_SUCH_SHARE },
|
---|
| 45 | { "WERR_ALREADY_EXISTS", WERR_ALREADY_EXISTS },
|
---|
| 46 | { "WERR_INVALID_PARAM", WERR_INVALID_PARAM },
|
---|
| 47 | { "WERR_NOT_SUPPORTED", WERR_NOT_SUPPORTED },
|
---|
| 48 | { "WERR_BAD_PASSWORD", WERR_BAD_PASSWORD },
|
---|
| 49 | { "WERR_NOMEM", WERR_NOMEM },
|
---|
| 50 | { "WERR_INVALID_NAME", WERR_INVALID_NAME },
|
---|
| 51 | { "WERR_UNKNOWN_LEVEL", WERR_UNKNOWN_LEVEL },
|
---|
| 52 | { "WERR_OBJECT_PATH_INVALID", WERR_OBJECT_PATH_INVALID },
|
---|
| 53 | { "WERR_NO_MORE_ITEMS", WERR_NO_MORE_ITEMS },
|
---|
| 54 | { "WERR_MORE_DATA", WERR_MORE_DATA },
|
---|
| 55 | { "WERR_UNKNOWN_PRINTER_DRIVER", WERR_UNKNOWN_PRINTER_DRIVER },
|
---|
| 56 | { "WERR_INVALID_PRINTER_NAME", WERR_INVALID_PRINTER_NAME },
|
---|
| 57 | { "WERR_PRINTER_ALREADY_EXISTS", WERR_PRINTER_ALREADY_EXISTS },
|
---|
| 58 | { "WERR_INVALID_DATATYPE", WERR_INVALID_DATATYPE },
|
---|
| 59 | { "WERR_INVALID_ENVIRONMENT", WERR_INVALID_ENVIRONMENT },
|
---|
| 60 | { "WERR_INVALID_FORM_NAME", WERR_INVALID_FORM_NAME },
|
---|
| 61 | { "WERR_INVALID_FORM_SIZE", WERR_INVALID_FORM_SIZE },
|
---|
| 62 | { "WERR_BUF_TOO_SMALL", WERR_BUF_TOO_SMALL },
|
---|
| 63 | { "WERR_JOB_NOT_FOUND", WERR_JOB_NOT_FOUND },
|
---|
| 64 | { "WERR_DEST_NOT_FOUND", WERR_DEST_NOT_FOUND },
|
---|
| 65 | { "WERR_GROUP_NOT_FOUND", WERR_GROUP_NOT_FOUND },
|
---|
| 66 | { "WERR_USER_NOT_FOUND", WERR_USER_NOT_FOUND },
|
---|
| 67 | { "WERR_NOT_LOCAL_DOMAIN", WERR_NOT_LOCAL_DOMAIN },
|
---|
| 68 | { "WERR_USER_EXISTS", WERR_USER_EXISTS },
|
---|
| 69 | { "WERR_REVISION_MISMATCH", WERR_REVISION_MISMATCH },
|
---|
| 70 | { "WERR_NO_LOGON_SERVERS", WERR_NO_LOGON_SERVERS },
|
---|
| 71 | { "WERR_NO_SUCH_LOGON_SESSION", WERR_NO_SUCH_LOGON_SESSION },
|
---|
| 72 | { "WERR_USER_ALREADY_EXISTS", WERR_USER_ALREADY_EXISTS },
|
---|
| 73 | { "WERR_NO_SUCH_USER", WERR_NO_SUCH_USER },
|
---|
| 74 | { "WERR_GROUP_EXISTS", WERR_GROUP_EXISTS },
|
---|
| 75 | { "WERR_MEMBER_IN_GROUP", WERR_MEMBER_IN_GROUP },
|
---|
| 76 | { "WERR_USER_NOT_IN_GROUP", WERR_USER_NOT_IN_GROUP },
|
---|
| 77 | { "WERR_PRINTER_DRIVER_IN_USE", WERR_PRINTER_DRIVER_IN_USE },
|
---|
| 78 | { "WERR_STATUS_MORE_ENTRIES ", WERR_STATUS_MORE_ENTRIES },
|
---|
| 79 | { "WERR_DFS_NO_SUCH_VOL", WERR_DFS_NO_SUCH_VOL },
|
---|
| 80 | { "WERR_DFS_NO_SUCH_SHARE", WERR_DFS_NO_SUCH_SHARE },
|
---|
| 81 | { "WERR_DFS_NO_SUCH_SERVER", WERR_DFS_NO_SUCH_SERVER },
|
---|
| 82 | { "WERR_DFS_INTERNAL_ERROR", WERR_DFS_INTERNAL_ERROR },
|
---|
| 83 | { "WERR_DFS_CANT_CREATE_JUNCT", WERR_DFS_CANT_CREATE_JUNCT },
|
---|
| 84 | { "WERR_INVALID_COMPUTER_NAME", WERR_INVALID_COMPUTER_NAME },
|
---|
| 85 | { "WERR_INVALID_DOMAINNAME", WERR_INVALID_DOMAINNAME },
|
---|
| 86 | { "WERR_MACHINE_LOCKED", WERR_MACHINE_LOCKED },
|
---|
| 87 | { "WERR_DC_NOT_FOUND", WERR_DC_NOT_FOUND },
|
---|
| 88 | { "WERR_SETUP_NOT_JOINED", WERR_SETUP_NOT_JOINED },
|
---|
| 89 | { "WERR_SETUP_ALREADY_JOINED", WERR_SETUP_ALREADY_JOINED },
|
---|
| 90 | { "WERR_SETUP_DOMAIN_CONTROLLER", WERR_SETUP_DOMAIN_CONTROLLER },
|
---|
| 91 | { "WERR_DEFAULT_JOIN_REQUIRED", WERR_DEFAULT_JOIN_REQUIRED },
|
---|
| 92 | { "WERR_DEVICE_NOT_AVAILABLE", WERR_DEVICE_NOT_AVAILABLE },
|
---|
| 93 | { "WERR_LOGON_FAILURE", WERR_LOGON_FAILURE },
|
---|
| 94 | { "WERR_WRONG_PASSWORD", WERR_WRONG_PASSWORD },
|
---|
| 95 | { "WERR_PASSWORD_RESTRICTION", WERR_PASSWORD_RESTRICTION },
|
---|
| 96 | { "WERR_NO_SUCH_DOMAIN", WERR_NO_SUCH_DOMAIN },
|
---|
| 97 | { "WERR_NONE_MAPPED", WERR_NONE_MAPPED },
|
---|
| 98 | { "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR },
|
---|
| 99 | { "WERR_INVALID_DOMAIN_STATE", WERR_INVALID_DOMAIN_STATE },
|
---|
| 100 | { "WERR_INVALID_DOMAIN_ROLE", WERR_INVALID_DOMAIN_ROLE },
|
---|
| 101 | { "WERR_SPECIAL_ACCOUNT", WERR_SPECIAL_ACCOUNT },
|
---|
| 102 | { "WERR_ALIAS_EXISTS", WERR_ALIAS_EXISTS },
|
---|
| 103 | { "WERR_NO_SUCH_ALIAS", WERR_NO_SUCH_ALIAS },
|
---|
| 104 | { "WERR_MEMBER_IN_ALIAS", WERR_MEMBER_IN_ALIAS },
|
---|
| 105 | { "WERR_TIME_SKEW", WERR_TIME_SKEW },
|
---|
| 106 | { "WERR_INVALID_OWNER", WERR_INVALID_OWNER },
|
---|
| 107 | { "WERR_SERVER_UNAVAILABLE", WERR_SERVER_UNAVAILABLE },
|
---|
| 108 | { "WERR_IO_PENDING", WERR_IO_PENDING },
|
---|
| 109 | { "WERR_INVALID_SERVICE_CONTROL", WERR_INVALID_SERVICE_CONTROL },
|
---|
| 110 | { "WERR_SERVICE_ALREADY_RUNNING", WERR_SERVICE_ALREADY_RUNNING },
|
---|
| 111 | { "WERR_NET_NAME_NOT_FOUND", WERR_NET_NAME_NOT_FOUND },
|
---|
| 112 | { "WERR_REG_CORRUPT", WERR_REG_CORRUPT },
|
---|
| 113 | { "WERR_REG_IO_FAILURE", WERR_REG_IO_FAILURE },
|
---|
| 114 | { "WERR_REG_FILE_INVALID", WERR_REG_FILE_INVALID },
|
---|
| 115 | { "WERR_NO_SUCH_SERVICE", WERR_NO_SUCH_SERVICE },
|
---|
| 116 | { "WERR_SERVICE_DISABLED", WERR_SERVICE_DISABLED },
|
---|
| 117 | { "WERR_SERVICE_MARKED_FOR_DELETE", WERR_SERVICE_MARKED_FOR_DELETE },
|
---|
| 118 | { "WERR_SERVICE_EXISTS", WERR_SERVICE_EXISTS },
|
---|
| 119 | { "WERR_SERVICE_NEVER_STARTED", WERR_SERVICE_NEVER_STARTED },
|
---|
| 120 | { "WERR_DUPLICATE_SERVICE_NAME", WERR_DUPLICATE_SERVICE_NAME },
|
---|
| 121 | { "WERR_NOT_FOUND", WERR_NOT_FOUND },
|
---|
| 122 | { "WERR_CAN_NOT_COMPLETE", WERR_CAN_NOT_COMPLETE},
|
---|
| 123 | { "WERR_INVALID_FLAGS", WERR_INVALID_FLAGS},
|
---|
| 124 | { "WERR_PASSWORD_MUST_CHANGE", WERR_PASSWORD_MUST_CHANGE },
|
---|
| 125 | { "WERR_DOMAIN_CONTROLLER_NOT_FOUND", WERR_DOMAIN_CONTROLLER_NOT_FOUND },
|
---|
| 126 | { "WERR_ACCOUNT_LOCKED_OUT", WERR_ACCOUNT_LOCKED_OUT },
|
---|
| 127 | { "WERR_DS_DRA_BAD_DN", WERR_DS_DRA_BAD_DN },
|
---|
| 128 | { "WERR_DS_DRA_BAD_NC", WERR_DS_DRA_BAD_NC },
|
---|
| 129 | { NULL, W_ERROR(0) }
|
---|
| 130 | };
|
---|
| 131 |
|
---|
| 132 | werror_str_struct dos_err_strs[] = {
|
---|
| 133 | { WERR_OK, "Success" },
|
---|
| 134 | { WERR_ACCESS_DENIED, "Access is denied" },
|
---|
| 135 | { WERR_INVALID_PARAM, "Invalid parameter" },
|
---|
| 136 | { WERR_NOT_SUPPORTED, "Not supported" },
|
---|
| 137 | { WERR_BAD_PASSWORD, "A bad password was supplied" },
|
---|
| 138 | { WERR_NOMEM, "Out of memory" },
|
---|
| 139 | { WERR_NO_LOGON_SERVERS, "No logon servers found" },
|
---|
| 140 | { WERR_NO_SUCH_LOGON_SESSION, "No such logon session" },
|
---|
| 141 | { WERR_DOMAIN_CONTROLLER_NOT_FOUND, "A domain controller could not be found" },
|
---|
| 142 | { WERR_DC_NOT_FOUND, "A domain controller could not be found" },
|
---|
| 143 | { WERR_SETUP_NOT_JOINED, "Join failed" },
|
---|
| 144 | { WERR_SETUP_ALREADY_JOINED, "Machine is already joined" },
|
---|
| 145 | { WERR_SETUP_DOMAIN_CONTROLLER, "Machine is a Domain Controller" },
|
---|
| 146 | { WERR_LOGON_FAILURE, "Invalid logon credentials" },
|
---|
| 147 | { WERR_USER_EXISTS, "User account already exists" },
|
---|
| 148 | { WERR_PASSWORD_MUST_CHANGE, "The password must be changed" },
|
---|
| 149 | { WERR_ACCOUNT_LOCKED_OUT, "Account locked out" },
|
---|
| 150 | { WERR_TIME_SKEW, "Time difference between client and server" },
|
---|
| 151 | { WERR_USER_ALREADY_EXISTS, "User already exists" },
|
---|
| 152 | { WERR_PASSWORD_RESTRICTION, "Password does not meet restrictions" },
|
---|
| 153 | { WERR_NONE_MAPPED, "Could not map names to SIDs" },
|
---|
| 154 | { WERR_NO_SUCH_USER, "No such User" },
|
---|
| 155 | { WERR_GROUP_EXISTS, "Group already exists" },
|
---|
| 156 | { WERR_DS_DRA_BAD_DN, "An invalid distinguished name was specified for this replication" },
|
---|
| 157 | { WERR_DS_DRA_BAD_NC, "An invalid naming context was specified for this replication operation" },
|
---|
| 158 | { WERR_WRONG_PASSWORD, "The current password is incorrect" }
|
---|
| 159 | };
|
---|
| 160 |
|
---|
| 161 | /*****************************************************************************
|
---|
| 162 | Returns a DOS error message. not amazingly helpful, but better than a number.
|
---|
| 163 | *****************************************************************************/
|
---|
| 164 |
|
---|
| 165 | const char *dos_errstr(WERROR werror)
|
---|
| 166 | {
|
---|
| 167 | char *result;
|
---|
| 168 | int idx = 0;
|
---|
| 169 |
|
---|
| 170 | while (dos_errs[idx].dos_errstr != NULL) {
|
---|
| 171 | if (W_ERROR_V(dos_errs[idx].werror) ==
|
---|
| 172 | W_ERROR_V(werror))
|
---|
| 173 | return dos_errs[idx].dos_errstr;
|
---|
| 174 | idx++;
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | result = talloc_asprintf(talloc_tos(), "DOS code 0x%08x",
|
---|
| 178 | W_ERROR_V(werror));
|
---|
| 179 | SMB_ASSERT(result != NULL);
|
---|
| 180 | return result;
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | /*****************************************************************************
|
---|
| 184 | Get friendly error string for WERRORs
|
---|
| 185 | *****************************************************************************/
|
---|
| 186 |
|
---|
| 187 | const char *get_friendly_werror_msg(WERROR werror)
|
---|
| 188 | {
|
---|
| 189 | int i = 0;
|
---|
| 190 |
|
---|
| 191 | for (i = 0; i < ARRAY_SIZE(dos_err_strs); i++) {
|
---|
| 192 | if (W_ERROR_V(dos_err_strs[i].werror) ==
|
---|
| 193 | W_ERROR_V(werror)) {
|
---|
| 194 | return dos_err_strs[i].friendly_errstr;
|
---|
| 195 | }
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | return dos_errstr(werror);
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | /* compat function for samba4 */
|
---|
| 202 | const char *win_errstr(WERROR werror)
|
---|
| 203 | {
|
---|
| 204 | return dos_errstr(werror);
|
---|
| 205 | }
|
---|