Ensure we map our own Samba return of ERRSRV, ERRunknownsmb
[Samba/id10ts.git] / source3 / libsmb / errormap.c
blobb80065dde0fd8da6c6bcbbcab9f4ff4de9ffa3cc
1 /*
2 * Unix SMB/CIFS implementation.
3 * error mapping functions
4 * Copyright (C) Andrew Tridgell 2001
5 * Copyright (C) Andrew Bartlett 2001
6 * Copyright (C) Tim Potter 2000
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
24 #if HAVE_GSSAPI_GSSAPI_H
25 #include <gssapi/gssapi.h>
26 #elif HAVE_GSSAPI_GSSAPI_GENERIC_H
27 #include <gssapi/gssapi_generic.h>
28 #elif HAVE_GSSAPI_H
29 #include <gssapi.h>
30 #endif
32 /* dos -> nt status error map */
33 static const struct {
34 uint8 dos_class;
35 uint32 dos_code;
36 NTSTATUS ntstatus;
37 } dos_to_ntstatus_map[] = {
38 {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED},
39 {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE},
40 {ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND},
41 {ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES},
42 {ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED},
43 {ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE},
44 {ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES},
45 {ERRDOS, ERRbadaccess, NT_STATUS_ACCESS_DENIED},
46 {ERRDOS, ERRbaddata, NT_STATUS_DATA_ERROR},
47 {ERRDOS, 14, NT_STATUS_SECTION_NOT_EXTENDED},
48 {ERRDOS, ERRremcd, NT_STATUS_DIRECTORY_NOT_EMPTY},
49 {ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE},
50 {ERRDOS, ERRnofiles, STATUS_NO_MORE_FILES},
51 {ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED},
52 {ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE},
53 {ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE},
54 {ERRDOS, 23, NT_STATUS_DATA_ERROR},
55 {ERRDOS, 24, NT_STATUS_DATA_ERROR},
56 {ERRDOS, 26, NT_STATUS_DISK_CORRUPT_ERROR},
57 {ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR},
58 {ERRDOS, 28, NT_STATUS(0x8000000e)},
59 {ERRDOS, 31, NT_STATUS_UNSUCCESSFUL},
60 {ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION},
61 {ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT},
62 {ERRDOS, 34, NT_STATUS_WRONG_VOLUME},
63 {ERRDOS, 38, NT_STATUS_END_OF_FILE},
64 {ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED},
65 {ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING},
66 {ERRDOS, 52, NT_STATUS_DUPLICATE_NAME},
67 {ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH},
68 {ERRDOS, 54, NT_STATUS_NETWORK_BUSY},
69 {ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST},
70 {ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS},
71 {ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR},
72 {ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE},
73 {ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR},
74 {ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER},
75 {ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL},
76 {ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE},
77 {ERRDOS, 63, NT_STATUS_PRINT_CANCELLED},
78 {ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED},
79 {ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED},
80 {ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE},
81 {ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME},
82 {ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED},
83 {ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS},
84 {ERRDOS, 70, NT_STATUS_SHARING_PAUSED},
85 {ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED},
86 {ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED},
87 {ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION},
88 {ERRDOS, 86, NT_STATUS_WRONG_PASSWORD},
89 {ERRDOS, 87, NT_STATUS_INVALID_INFO_CLASS},
90 {ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT},
91 {ERRDOS, 109, NT_STATUS_PIPE_BROKEN},
92 {ERRDOS, 111, STATUS_MORE_ENTRIES},
93 {ERRDOS, 112, NT_STATUS_DISK_FULL},
94 {ERRDOS, 121, NT_STATUS_IO_TIMEOUT},
95 {ERRDOS, 122, NT_STATUS_BUFFER_TOO_SMALL},
96 {ERRDOS, ERRinvalidname, NT_STATUS_OBJECT_NAME_INVALID},
97 {ERRDOS, ERRunknownlevel, NT_STATUS_INVALID_LEVEL},
98 {ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND},
99 {ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND},
100 {ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY},
101 {ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL},
102 {ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED},
103 {ERRDOS, 158, NT_STATUS_NOT_LOCKED},
104 {ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID},
105 {ERRDOS, 170, NT_STATUS(0x80000011)},
106 {ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND},
107 {ERRDOS, 183, NT_STATUS_OBJECT_NAME_COLLISION},
108 {ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC},
109 {ERRDOS, 203, NT_STATUS(0xc0000100)},
110 {ERRDOS, 206, NT_STATUS_NAME_TOO_LONG},
111 {ERRDOS, ERRbadpipe, NT_STATUS_INVALID_INFO_CLASS},
112 {ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE},
113 {ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING},
114 {ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED},
115 {ERRDOS, ERRmoredata, NT_STATUS_MORE_PROCESSING_REQUIRED},
116 {ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED},
117 {ERRDOS, 254, NT_STATUS(0x80000013)},
118 {ERRDOS, 255, NT_STATUS_EA_TOO_LARGE},
119 {ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED},
120 {ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY},
121 {ERRDOS, 275, NT_STATUS_EA_TOO_LARGE},
122 {ERRDOS, 276, NT_STATUS_NONEXISTENT_EA_ENTRY},
123 {ERRDOS, 277, NT_STATUS_NONEXISTENT_EA_ENTRY},
124 {ERRDOS, 278, NT_STATUS_NONEXISTENT_EA_ENTRY},
125 {ERRDOS, ERReasnotsupported, NT_STATUS_EAS_NOT_SUPPORTED},
126 {ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED},
127 {ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED},
128 {ERRDOS, 299, NT_STATUS(0x8000000d)},
129 {ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED},
130 {ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL},
131 {ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES},
132 {ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW},
133 {ERRDOS, 535, NT_STATUS_PIPE_CONNECTED},
134 {ERRDOS, 536, NT_STATUS_PIPE_LISTENING},
135 {ERRDOS, 995, NT_STATUS_CANCELLED},
136 {ERRDOS, 997, NT_STATUS(0x00000103)},
137 {ERRDOS, 998, NT_STATUS_ACCESS_VIOLATION},
138 {ERRDOS, 999, NT_STATUS_IN_PAGE_ERROR},
139 {ERRDOS, 1001, NT_STATUS_BAD_INITIAL_STACK},
140 {ERRDOS, 1005, NT_STATUS_UNRECOGNIZED_VOLUME},
141 {ERRDOS, 1006, NT_STATUS_FILE_INVALID},
142 {ERRDOS, 1007, NT_STATUS_FULLSCREEN_MODE},
143 {ERRDOS, 1008, NT_STATUS_NO_TOKEN},
144 {ERRDOS, 1009, NT_STATUS_REGISTRY_CORRUPT},
145 {ERRDOS, 1016, NT_STATUS_REGISTRY_IO_FAILED},
146 {ERRDOS, 1017, NT_STATUS_NOT_REGISTRY_FILE},
147 {ERRDOS, 1018, NT_STATUS_KEY_DELETED},
148 {ERRDOS, 1019, NT_STATUS_NO_LOG_SPACE},
149 {ERRDOS, 1020, NT_STATUS_KEY_HAS_CHILDREN},
150 {ERRDOS, 1021, NT_STATUS_CHILD_MUST_BE_VOLATILE},
151 {ERRDOS, 1022, NT_STATUS(0x0000010c)},
152 {ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD},
153 {ERRSRV, ERRbaduid, NT_STATUS_USER_SESSION_DELETED},
154 {ERRSRV, ERRbadtype, NT_STATUS_BAD_DEVICE_TYPE},
155 {ERRSRV, ERRaccess, NT_STATUS_NETWORK_ACCESS_DENIED},
156 {ERRSRV, ERRinvnid, NT_STATUS_NETWORK_NAME_DELETED},
157 {ERRSRV, ERRinvnetname, NT_STATUS_BAD_NETWORK_NAME},
158 {ERRSRV, ERRinvdevice, NT_STATUS_BAD_DEVICE_TYPE},
159 {ERRSRV, ERRqfull, NT_STATUS_PRINT_QUEUE_FULL},
160 {ERRSRV, ERRqtoobig, NT_STATUS_NO_SPOOL_SPACE},
161 {ERRSRV, ERRinvpfid, NT_STATUS_PRINT_CANCELLED},
162 {ERRSRV, ERRsmbcmd, NT_STATUS_NOT_IMPLEMENTED},
163 {ERRSRV, ERRbadpermits, NT_STATUS_NETWORK_ACCESS_DENIED},
164 {ERRSRV, ERRpaused, NT_STATUS_SHARING_PAUSED},
165 {ERRSRV, ERRmsgoff, NT_STATUS_REQUEST_NOT_ACCEPTED},
166 {ERRSRV, ERRnoroom, NT_STATUS_DISK_FULL},
167 {ERRSRV, ERRnoresource, NT_STATUS_REQUEST_NOT_ACCEPTED},
168 {ERRSRV, ERRtoomanyuids, NT_STATUS_TOO_MANY_SESSIONS},
169 {ERRSRV, ERRunknownsmb, NT_STATUS_NOT_IMPLEMENTED},
170 {ERRSRV, 123, NT_STATUS_OBJECT_NAME_INVALID},
171 {ERRSRV, 206, NT_STATUS_OBJECT_NAME_INVALID},
172 {ERRHRD, 1, NT_STATUS_NOT_IMPLEMENTED},
173 {ERRHRD, 2, NT_STATUS_NO_SUCH_DEVICE},
174 {ERRHRD, 3, NT_STATUS_OBJECT_PATH_NOT_FOUND},
175 {ERRHRD, 4, NT_STATUS_TOO_MANY_OPENED_FILES},
176 {ERRHRD, 5, NT_STATUS_INVALID_LOCK_SEQUENCE},
177 {ERRHRD, 6, NT_STATUS_INVALID_HANDLE},
178 {ERRHRD, 8, NT_STATUS_INSUFFICIENT_RESOURCES},
179 {ERRHRD, 12, NT_STATUS_INVALID_LOCK_SEQUENCE},
180 {ERRHRD, 13, NT_STATUS_DATA_ERROR},
181 {ERRHRD, 14, NT_STATUS_SECTION_NOT_EXTENDED},
182 {ERRHRD, 16, NT_STATUS_DIRECTORY_NOT_EMPTY},
183 {ERRHRD, 17, NT_STATUS_NOT_SAME_DEVICE},
184 {ERRHRD, 18, NT_STATUS(0x80000006)},
185 {ERRHRD, ERRnowrite, NT_STATUS_MEDIA_WRITE_PROTECTED},
186 {ERRHRD, ERRnotready, NT_STATUS_NO_MEDIA_IN_DEVICE},
187 {ERRHRD, ERRbadcmd, NT_STATUS_INVALID_DEVICE_STATE},
188 {ERRHRD, ERRdata, NT_STATUS_DATA_ERROR},
189 {ERRHRD, ERRbadreq, NT_STATUS_DATA_ERROR},
190 {ERRHRD, ERRbadmedia, NT_STATUS_DISK_CORRUPT_ERROR},
191 {ERRHRD, ERRbadsector, NT_STATUS_NONEXISTENT_SECTOR},
192 {ERRHRD, ERRnopaper, NT_STATUS(0x8000000e)},
193 {ERRHRD, ERRgeneral, NT_STATUS_UNSUCCESSFUL},
194 {ERRHRD, ERRbadshare, NT_STATUS_SHARING_VIOLATION},
195 {ERRHRD, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT},
196 {ERRHRD, ERRwrongdisk, NT_STATUS_WRONG_VOLUME},
197 {ERRHRD, 38, NT_STATUS_END_OF_FILE},
198 {ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL},
199 {ERRHRD, 50, NT_STATUS_CTL_FILE_NOT_SUPPORTED},
200 {ERRHRD, 51, NT_STATUS_REMOTE_NOT_LISTENING},
201 {ERRHRD, 52, NT_STATUS_DUPLICATE_NAME},
202 {ERRHRD, 53, NT_STATUS_BAD_NETWORK_PATH},
203 {ERRHRD, 54, NT_STATUS_NETWORK_BUSY},
204 {ERRHRD, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST},
205 {ERRHRD, 56, NT_STATUS_TOO_MANY_COMMANDS},
206 {ERRHRD, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR},
207 {ERRHRD, 58, NT_STATUS_INVALID_NETWORK_RESPONSE},
208 {ERRHRD, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR},
209 {ERRHRD, 60, NT_STATUS_BAD_REMOTE_ADAPTER},
210 {ERRHRD, 61, NT_STATUS_PRINT_QUEUE_FULL},
211 {ERRHRD, 62, NT_STATUS_NO_SPOOL_SPACE},
212 {ERRHRD, 63, NT_STATUS_PRINT_CANCELLED},
213 {ERRHRD, 64, NT_STATUS_NETWORK_NAME_DELETED},
214 {ERRHRD, 65, NT_STATUS_NETWORK_ACCESS_DENIED},
215 {ERRHRD, 66, NT_STATUS_BAD_DEVICE_TYPE},
216 {ERRHRD, 67, NT_STATUS_BAD_NETWORK_NAME},
217 {ERRHRD, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED},
218 {ERRHRD, 69, NT_STATUS_TOO_MANY_SESSIONS},
219 {ERRHRD, 70, NT_STATUS_SHARING_PAUSED},
220 {ERRHRD, 71, NT_STATUS_REQUEST_NOT_ACCEPTED},
221 {ERRHRD, 72, NT_STATUS_REDIRECTOR_PAUSED},
222 {ERRHRD, 80, NT_STATUS_OBJECT_NAME_COLLISION},
223 {ERRHRD, 86, NT_STATUS_WRONG_PASSWORD},
224 {ERRHRD, 87, NT_STATUS_INVALID_INFO_CLASS},
225 {ERRHRD, 88, NT_STATUS_NET_WRITE_FAULT},
226 {ERRHRD, 109, NT_STATUS_PIPE_BROKEN},
227 {ERRHRD, 111, STATUS_MORE_ENTRIES},
228 {ERRHRD, 112, NT_STATUS_DISK_FULL},
229 {ERRHRD, 121, NT_STATUS_IO_TIMEOUT},
230 {ERRHRD, 122, NT_STATUS_BUFFER_TOO_SMALL},
231 {ERRHRD, 123, NT_STATUS_OBJECT_NAME_INVALID},
232 {ERRHRD, 124, NT_STATUS_INVALID_LEVEL},
233 {ERRHRD, 126, NT_STATUS_DLL_NOT_FOUND},
234 {ERRHRD, 127, NT_STATUS_PROCEDURE_NOT_FOUND},
235 {ERRHRD, 145, NT_STATUS_DIRECTORY_NOT_EMPTY},
236 {ERRHRD, 154, NT_STATUS_INVALID_VOLUME_LABEL},
237 {ERRHRD, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED},
238 {ERRHRD, 158, NT_STATUS_NOT_LOCKED},
239 {ERRHRD, 161, NT_STATUS_OBJECT_PATH_INVALID},
240 {ERRHRD, 170, NT_STATUS(0x80000011)},
241 {ERRHRD, 182, NT_STATUS_ORDINAL_NOT_FOUND},
242 {ERRHRD, 183, NT_STATUS_OBJECT_NAME_COLLISION},
243 {ERRHRD, 193, NT_STATUS_BAD_INITIAL_PC},
244 {ERRHRD, 203, NT_STATUS(0xc0000100)},
245 {ERRHRD, 206, NT_STATUS_NAME_TOO_LONG},
246 {ERRHRD, 230, NT_STATUS_INVALID_INFO_CLASS},
247 {ERRHRD, 231, NT_STATUS_INSTANCE_NOT_AVAILABLE},
248 {ERRHRD, 232, NT_STATUS_PIPE_CLOSING},
249 {ERRHRD, 233, NT_STATUS_PIPE_DISCONNECTED},
250 {ERRHRD, 234, STATUS_MORE_ENTRIES},
251 {ERRHRD, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED},
252 {ERRHRD, 254, NT_STATUS(0x80000013)},
253 {ERRHRD, 255, NT_STATUS_EA_TOO_LARGE},
254 {ERRHRD, 259, NT_STATUS_GUIDS_EXHAUSTED},
255 {ERRHRD, 267, NT_STATUS_NOT_A_DIRECTORY},
256 {ERRHRD, 275, NT_STATUS_EA_TOO_LARGE},
257 {ERRHRD, 276, NT_STATUS_NONEXISTENT_EA_ENTRY},
258 {ERRHRD, 277, NT_STATUS_NONEXISTENT_EA_ENTRY},
259 {ERRHRD, 278, NT_STATUS_NONEXISTENT_EA_ENTRY},
260 {ERRHRD, ERReasnotsupported, NT_STATUS_EAS_NOT_SUPPORTED},
261 {ERRHRD, 288, NT_STATUS_MUTANT_NOT_OWNED},
262 {ERRHRD, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED},
263 {ERRHRD, 299, NT_STATUS(0x8000000d)},
264 {ERRHRD, 300, NT_STATUS_OPLOCK_NOT_GRANTED},
265 {ERRHRD, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL},
266 {ERRHRD, 487, NT_STATUS_CONFLICTING_ADDRESSES},
267 {ERRHRD, 534, NT_STATUS_INTEGER_OVERFLOW},
268 {ERRHRD, 535, NT_STATUS_PIPE_CONNECTED},
269 {ERRHRD, 536, NT_STATUS_PIPE_LISTENING},
270 {ERRHRD, 995, NT_STATUS_CANCELLED},
271 {ERRHRD, 997, NT_STATUS(0x00000103)},
272 {ERRHRD, 998, NT_STATUS_ACCESS_VIOLATION},
273 {ERRHRD, 999, NT_STATUS_IN_PAGE_ERROR},
274 {ERRHRD, 1001, NT_STATUS_BAD_INITIAL_STACK},
275 {ERRHRD, 1005, NT_STATUS_UNRECOGNIZED_VOLUME},
276 {ERRHRD, 1006, NT_STATUS_FILE_INVALID},
277 {ERRHRD, 1007, NT_STATUS_FULLSCREEN_MODE},
278 {ERRHRD, 1008, NT_STATUS_NO_TOKEN},
279 {ERRHRD, 1009, NT_STATUS_REGISTRY_CORRUPT},
280 {ERRHRD, 1016, NT_STATUS_REGISTRY_IO_FAILED},
281 {ERRHRD, 1017, NT_STATUS_NOT_REGISTRY_FILE},
282 {ERRHRD, 1018, NT_STATUS_KEY_DELETED},
283 {ERRHRD, 1019, NT_STATUS_NO_LOG_SPACE},
284 {ERRHRD, 1020, NT_STATUS_KEY_HAS_CHILDREN},
285 {ERRHRD, 1021, NT_STATUS_CHILD_MUST_BE_VOLATILE},
286 {ERRHRD, 1022, NT_STATUS(0x0000010c)},
289 /*****************************************************************************
290 convert a dos eclas/ecode to a NT status32 code
291 *****************************************************************************/
292 NTSTATUS dos_to_ntstatus(uint8 eclass, uint32 ecode)
294 int i;
295 if (eclass == 0) return NT_STATUS_OK;
296 for (i=0; NT_STATUS_V(dos_to_ntstatus_map[i].ntstatus); i++) {
297 if (eclass == dos_to_ntstatus_map[i].dos_class &&
298 ecode == dos_to_ntstatus_map[i].dos_code) {
299 return dos_to_ntstatus_map[i].ntstatus;
302 return NT_STATUS_UNSUCCESSFUL;
305 #if defined(HAVE_GSSAPI)
306 /*******************************************************************************
307 Map between gssapi errors and NT status. I made these up :-(. JRA.
308 *******************************************************************************/
310 static const struct {
311 unsigned long gss_err;
312 NTSTATUS ntstatus;
313 } gss_to_ntstatus_errormap[] = {
314 #if defined(GSS_S_CALL_INACCESSIBLE_READ)
315 {GSS_S_CALL_INACCESSIBLE_READ, NT_STATUS_INVALID_PARAMETER},
316 #endif
317 #if defined(GSS_S_CALL_INACCESSIBLE_WRITE)
318 {GSS_S_CALL_INACCESSIBLE_WRITE, NT_STATUS_INVALID_PARAMETER},
319 #endif
320 #if defined(GSS_S_CALL_BAD_STRUCTURE)
321 {GSS_S_CALL_BAD_STRUCTURE, NT_STATUS_INVALID_PARAMETER},
322 #endif
323 #if defined(GSS_S_BAD_MECH)
324 {GSS_S_BAD_MECH, NT_STATUS_INVALID_PARAMETER},
325 #endif
326 #if defined(GSS_S_BAD_NAME)
327 {GSS_S_BAD_NAME, NT_STATUS_INVALID_ACCOUNT_NAME},
328 #endif
329 #if defined(GSS_S_BAD_NAMETYPE)
330 {GSS_S_BAD_NAMETYPE, NT_STATUS_INVALID_PARAMETER},
331 #endif
332 #if defined(GSS_S_BAD_BINDINGS)
333 {GSS_S_BAD_BINDINGS, NT_STATUS_INVALID_PARAMETER},
334 #endif
335 #if defined(GSS_S_BAD_STATUS)
336 {GSS_S_BAD_STATUS, NT_STATUS_UNSUCCESSFUL},
337 #endif
338 #if defined(GSS_S_BAD_SIG)
339 {GSS_S_BAD_SIG, NT_STATUS_ACCESS_DENIED},
340 #endif
341 #if defined(GSS_S_NO_CRED)
342 {GSS_S_NO_CRED, NT_STATUS_ACCESS_DENIED},
343 #endif
344 #if defined(GSS_S_NO_CONTEXT)
345 {GSS_S_NO_CONTEXT, NT_STATUS_ACCESS_DENIED},
346 #endif
347 #if defined(GSS_S_DEFECTIVE_TOKEN)
348 {GSS_S_DEFECTIVE_TOKEN, NT_STATUS_ACCESS_DENIED},
349 #endif
350 #if defined(GSS_S_DEFECTIVE_CREDENTIAL)
351 {GSS_S_DEFECTIVE_CREDENTIAL, NT_STATUS_ACCESS_DENIED},
352 #endif
353 #if defined(GSS_S_CREDENTIALS_EXPIRED)
354 {GSS_S_CREDENTIALS_EXPIRED, NT_STATUS_PASSWORD_EXPIRED},
355 #endif
356 #if defined(GSS_S_CONTEXT_EXPIRED)
357 {GSS_S_CONTEXT_EXPIRED, NT_STATUS_PASSWORD_EXPIRED},
358 #endif
359 #if defined(GSS_S_BAD_QOP)
360 {GSS_S_BAD_QOP, NT_STATUS_ACCESS_DENIED},
361 #endif
362 #if defined(GSS_S_UNAUTHORIZED)
363 {GSS_S_UNAUTHORIZED, NT_STATUS_ACCESS_DENIED},
364 #endif
365 #if defined(GSS_S_UNAVAILABLE)
366 {GSS_S_UNAVAILABLE, NT_STATUS_UNSUCCESSFUL},
367 #endif
368 #if defined(GSS_S_DUPLICATE_ELEMENT)
369 {GSS_S_DUPLICATE_ELEMENT, NT_STATUS_INVALID_PARAMETER},
370 #endif
371 #if defined(GSS_S_NAME_NOT_MN)
372 {GSS_S_NAME_NOT_MN, NT_STATUS_INVALID_PARAMETER},
373 #endif
374 { 0, NT_STATUS_OK }
377 /*********************************************************************
378 Map an NT error code from a gssapi error code.
379 *********************************************************************/
381 NTSTATUS map_nt_error_from_gss(uint32 gss_maj, uint32 minor)
383 int i = 0;
385 if (gss_maj == GSS_S_COMPLETE) {
386 return NT_STATUS_OK;
389 if (gss_maj == GSS_S_CONTINUE_NEEDED) {
390 return NT_STATUS_MORE_PROCESSING_REQUIRED;
393 if (gss_maj == GSS_S_FAILURE) {
394 return map_nt_error_from_unix((int)minor);
397 /* Look through list */
398 while(gss_to_ntstatus_errormap[i].gss_err != 0) {
399 if (gss_to_ntstatus_errormap[i].gss_err == gss_maj) {
400 return gss_to_ntstatus_errormap[i].ntstatus;
402 i++;
405 /* Default return */
406 return NT_STATUS_ACCESS_DENIED;
408 #endif