2007-12-21 15:28:01 +01:00
/*
2002-03-17 06:04:15 +00:00
* Unix SMB / CIFS implementation .
* DOS error routines
* Copyright ( C ) Tim Potter 2002.
2007-12-21 15:28:01 +01:00
*
2002-03-17 06:04:15 +00:00
* 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
2007-07-09 19:25:36 +00:00
* the Free Software Foundation ; either version 3 of the License , or
2002-03-17 06:04:15 +00:00
* ( at your option ) any later version .
2007-12-21 15:28:01 +01:00
*
2002-03-17 06:04:15 +00:00
* 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 .
2007-12-21 15:28:01 +01:00
*
2002-03-17 06:04:15 +00:00
* You should have received a copy of the GNU General Public License
2007-07-10 05:23:25 +00:00
* along with this program ; if not , see < http : //www.gnu.org/licenses/>.
2002-03-17 06:04:15 +00:00
*/
/* DOS error codes. please read doserr.h */
# include "includes.h"
2007-12-21 15:28:01 +01:00
typedef const struct {
2003-01-03 08:28:12 +00:00
const char * dos_errstr ;
2002-03-17 06:04:15 +00:00
WERROR werror ;
} werror_code_struct ;
2007-12-21 15:28:01 +01:00
typedef const struct {
WERROR werror ;
const char * friendly_errstr ;
} werror_str_struct ;
2002-03-17 06:04:15 +00:00
werror_code_struct dos_errs [ ] =
{
{ " WERR_OK " , WERR_OK } ,
2005-03-24 16:11:23 +00:00
{ " WERR_GENERAL_FAILURE " , WERR_GENERAL_FAILURE } ,
2002-03-17 06:04:15 +00:00
{ " WERR_BADFILE " , WERR_BADFILE } ,
{ " WERR_ACCESS_DENIED " , WERR_ACCESS_DENIED } ,
{ " WERR_BADFID " , WERR_BADFID } ,
{ " WERR_BADFUNC " , WERR_BADFUNC } ,
{ " WERR_INSUFFICIENT_BUFFER " , WERR_INSUFFICIENT_BUFFER } ,
2007-05-24 23:11:11 +00:00
{ " WERR_SEM_TIMEOUT " , WERR_SEM_TIMEOUT } ,
2002-03-17 06:04:15 +00:00
{ " 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 } ,
2002-04-09 05:11:34 +00:00
{ " WERR_INVALID_FORM_NAME " , WERR_INVALID_FORM_NAME } ,
2002-03-17 06:04:15 +00:00
{ " 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 } ,
2008-01-03 16:40:04 +01:00
{ " WERR_USER_EXISTS " , WERR_USER_EXISTS } ,
2007-05-24 23:11:11 +00:00
{ " WERR_NO_LOGON_SERVERS " , WERR_NO_LOGON_SERVERS } ,
2007-12-18 13:38:14 +01:00
{ " WERR_NO_SUCH_LOGON_SESSION " , WERR_NO_SUCH_LOGON_SESSION } ,
2008-04-12 18:30:14 +02:00
{ " WERR_USER_ALREADY_EXISTS " , WERR_USER_ALREADY_EXISTS } ,
2008-04-16 02:37:27 +02:00
{ " WERR_NO_SUCH_USER " , WERR_NO_SUCH_USER } ,
2002-03-17 06:04:15 +00:00
{ " 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 } ,
2008-01-24 23:39:38 +01:00
{ " WERR_INVALID_COMPUTER_NAME " , WERR_INVALID_COMPUTER_NAME } ,
2005-10-11 18:42:25 +00:00
{ " WERR_MACHINE_LOCKED " , WERR_MACHINE_LOCKED } ,
2008-01-18 01:04:40 +01:00
{ " WERR_DC_NOT_FOUND " , WERR_DC_NOT_FOUND } ,
2007-11-30 19:46:25 +01:00
{ " WERR_SETUP_NOT_JOINED " , WERR_SETUP_NOT_JOINED } ,
{ " WERR_SETUP_ALREADY_JOINED " , WERR_SETUP_ALREADY_JOINED } ,
{ " WERR_SETUP_DOMAIN_CONTROLLER " , WERR_SETUP_DOMAIN_CONTROLLER } ,
2008-01-03 16:40:04 +01:00
{ " WERR_DEFAULT_JOIN_REQUIRED " , WERR_DEFAULT_JOIN_REQUIRED } ,
2007-06-27 09:36:00 +00:00
{ " WERR_DEVICE_NOT_AVAILABLE " , WERR_DEVICE_NOT_AVAILABLE } ,
2007-03-01 02:43:33 +00:00
{ " WERR_LOGON_FAILURE " , WERR_LOGON_FAILURE } ,
2008-04-12 18:30:14 +02:00
{ " WERR_PASSWORD_RESTRICTION " , WERR_PASSWORD_RESTRICTION } ,
2006-10-07 05:23:56 +00:00
{ " WERR_NO_SUCH_DOMAIN " , WERR_NO_SUCH_DOMAIN } ,
2008-04-16 02:23:20 +02:00
{ " WERR_NONE_MAPPED " , WERR_NONE_MAPPED } ,
2002-04-24 05:45:04 +00:00
{ " WERR_INVALID_SECURITY_DESCRIPTOR " , WERR_INVALID_SECURITY_DESCRIPTOR } ,
2008-04-14 15:48:23 +02:00
{ " WERR_INVALID_DOMAIN_STATE " , WERR_INVALID_DOMAIN_STATE } ,
{ " WERR_INVALID_DOMAIN_ROLE " , WERR_INVALID_DOMAIN_ROLE } ,
2008-02-28 13:58:34 +01:00
{ " WERR_TIME_SKEW " , WERR_TIME_SKEW } ,
2002-05-07 06:18:50 +00:00
{ " WERR_INVALID_OWNER " , WERR_INVALID_OWNER } ,
2003-04-15 06:55:42 +00:00
{ " WERR_SERVER_UNAVAILABLE " , WERR_SERVER_UNAVAILABLE } ,
2004-10-13 01:40:35 +00:00
{ " WERR_IO_PENDING " , WERR_IO_PENDING } ,
2005-03-25 00:38:30 +00:00
{ " WERR_INVALID_SERVICE_CONTROL " , WERR_INVALID_SERVICE_CONTROL } ,
2007-10-15 19:10:19 +02:00
{ " WERR_SERVICE_ALREADY_RUNNING " , WERR_SERVICE_ALREADY_RUNNING } ,
2005-06-15 12:43:36 +00:00
{ " WERR_NET_NAME_NOT_FOUND " , WERR_NET_NAME_NOT_FOUND } ,
2005-07-01 22:24:00 +00:00
{ " WERR_REG_CORRUPT " , WERR_REG_CORRUPT } ,
{ " WERR_REG_IO_FAILURE " , WERR_REG_IO_FAILURE } ,
{ " WERR_REG_FILE_INVALID " , WERR_REG_FILE_INVALID } ,
2008-01-04 19:58:19 +01:00
{ " WERR_NO_SUCH_SERVICE " , WERR_NO_SUCH_SERVICE } ,
2005-12-11 04:21:34 +00:00
{ " WERR_SERVICE_DISABLED " , WERR_SERVICE_DISABLED } ,
2008-03-20 00:31:26 +01:00
{ " WERR_SERVICE_NEVER_STARTED " , WERR_SERVICE_NEVER_STARTED } ,
2007-05-24 23:11:11 +00:00
{ " WERR_CAN_NOT_COMPLETE " , WERR_CAN_NOT_COMPLETE } ,
{ " WERR_INVALID_FLAGS " , WERR_INVALID_FLAGS } ,
2008-01-18 01:04:40 +01:00
{ " WERR_PASSWORD_MUST_CHANGE " , WERR_PASSWORD_MUST_CHANGE } ,
{ " WERR_DOMAIN_CONTROLLER_NOT_FOUND " , WERR_DOMAIN_CONTROLLER_NOT_FOUND } ,
{ " WERR_ACCOUNT_LOCKED_OUT " , WERR_ACCOUNT_LOCKED_OUT } ,
2002-03-17 06:04:15 +00:00
{ NULL , W_ERROR ( 0 ) }
} ;
2007-12-21 15:28:01 +01:00
werror_str_struct dos_err_strs [ ] = {
{ WERR_OK , " Success " } ,
{ WERR_ACCESS_DENIED , " Access is denied " } ,
{ WERR_INVALID_PARAM , " Invalid parameter " } ,
{ WERR_NOT_SUPPORTED , " Not supported " } ,
{ WERR_BAD_PASSWORD , " A bad password was supplied " } ,
{ WERR_NOMEM , " Out of memory " } ,
{ WERR_NO_LOGON_SERVERS , " No logon servers found " } ,
{ WERR_NO_SUCH_LOGON_SESSION , " No such logon session " } ,
{ WERR_DOMAIN_CONTROLLER_NOT_FOUND , " A domain controller could not be found " } ,
2008-01-18 01:04:40 +01:00
{ WERR_DC_NOT_FOUND , " A domain controller could not be found " } ,
2007-12-21 15:28:01 +01:00
{ WERR_SETUP_NOT_JOINED , " Join failed " } ,
{ WERR_SETUP_ALREADY_JOINED , " Machine is already joined " } ,
{ WERR_SETUP_DOMAIN_CONTROLLER , " Machine is a Domain Controller " } ,
{ WERR_LOGON_FAILURE , " Invalid logon credentials " } ,
2008-01-03 16:40:04 +01:00
{ WERR_USER_EXISTS , " User account already exists " } ,
2008-01-18 01:04:40 +01:00
{ WERR_PASSWORD_MUST_CHANGE , " The password must be changed " } ,
{ WERR_ACCOUNT_LOCKED_OUT , " Account locked out " } ,
2008-02-28 13:58:34 +01:00
{ WERR_TIME_SKEW , " Time difference between client and server " } ,
2008-04-12 18:30:14 +02:00
{ WERR_USER_ALREADY_EXISTS , " User already exists " } ,
{ WERR_PASSWORD_RESTRICTION , " Password does not meet restrictions " } ,
2008-04-16 02:23:20 +02:00
{ WERR_NONE_MAPPED , " Could not map names to SIDs " } ,
2008-04-16 02:37:27 +02:00
{ WERR_NO_SUCH_USER , " No such User " } ,
2007-12-21 15:28:01 +01:00
} ;
2002-03-17 06:04:15 +00:00
/*****************************************************************************
2007-03-01 02:43:33 +00:00
Returns a DOS error message . not amazingly helpful , but better than a number .
2002-03-17 06:04:15 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-03-01 02:43:33 +00:00
2003-01-03 08:28:12 +00:00
const char * dos_errstr ( WERROR werror )
2002-03-17 06:04:15 +00:00
{
2007-11-07 18:47:32 +01:00
char * result ;
2002-03-17 06:04:15 +00:00
int idx = 0 ;
while ( dos_errs [ idx ] . dos_errstr ! = NULL ) {
2007-12-21 15:28:01 +01:00
if ( W_ERROR_V ( dos_errs [ idx ] . werror ) = =
2002-03-17 06:04:15 +00:00
W_ERROR_V ( werror ) )
return dos_errs [ idx ] . dos_errstr ;
idx + + ;
}
2007-11-07 18:47:32 +01:00
result = talloc_asprintf ( talloc_tos ( ) , " DOS code 0x%08x " ,
W_ERROR_V ( werror ) ) ;
SMB_ASSERT ( result ! = NULL ) ;
return result ;
2002-03-17 06:04:15 +00:00
}
2007-11-08 14:33:04 +01:00
2007-12-21 15:28:01 +01:00
/*****************************************************************************
Get friendly error string for WERRORs
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
const char * get_friendly_werror_msg ( WERROR werror )
{
int i = 0 ;
for ( i = 0 ; i < ARRAY_SIZE ( dos_err_strs ) ; i + + ) {
if ( W_ERROR_V ( dos_err_strs [ i ] . werror ) = =
W_ERROR_V ( werror ) ) {
return dos_err_strs [ i ] . friendly_errstr ;
}
}
return dos_errstr ( werror ) ;
}
2007-11-08 14:33:04 +01:00
/* compat function for samba4 */
const char * win_errstr ( WERROR werror )
{
return dos_errstr ( werror ) ;
}